AVC & HEVC packetizers: use rationals for calculation of display dimensions

This commit is contained in:
Moritz Bunkus 2021-07-06 09:37:21 +02:00
parent 4b74b43fdb
commit 188436f981
No known key found for this signature in database
GPG Key ID: 74AF00ADF2E32C85
4 changed files with 8 additions and 8 deletions

View File

@ -91,10 +91,10 @@ avc_video_packetizer_c::extract_aspect_ratio() {
if (!result.is_valid() || display_dimensions_or_aspect_ratio_set())
return;
auto par = static_cast<double>(result.numerator) / static_cast<double>(result.denominator);
auto par = mtx::rational(result.numerator, result.denominator);
set_video_display_dimensions(1 <= par ? std::llround(m_width * par) : m_width,
1 <= par ? m_height : std::llround(m_height / par),
set_video_display_dimensions(1 <= par ? mtx::to_int_rounded(m_width * par) : m_width,
1 <= par ? m_height : mtx::to_int_rounded(m_height / par),
generic_packetizer_c::ddu_pixels,
OPTION_SOURCE_BITSTREAM);

View File

@ -141,7 +141,7 @@ avc_es_video_packetizer_c::handle_aspect_ratio() {
mxdebug_if(m_debug_aspect_ratio,
fmt::format("PAR {0} pixel_width/hgith {1}/{2} display_width/height {3}/{4}\n",
static_cast<double>(m_parser.get_par()), m_hvideo_pixel_width, m_hvideo_pixel_height, m_ti.m_display_width, m_ti.m_display_height));
m_parser.get_par(), m_hvideo_pixel_width, m_hvideo_pixel_height, m_ti.m_display_width, m_ti.m_display_height));
}
void

View File

@ -99,10 +99,10 @@ hevc_video_packetizer_c::extract_aspect_ratio() {
if (!result.is_valid() || display_dimensions_or_aspect_ratio_set())
return;
auto par = static_cast<double>(result.numerator) / static_cast<double>(result.denominator);
auto par = mtx::rational(result.numerator, result.denominator);
set_video_display_dimensions(1 <= par ? std::llround(m_width * par) : m_width,
1 <= par ? m_height : std::llround(m_height / par),
set_video_display_dimensions(1 <= par ? mtx::to_int_rounded(m_width * par) : m_width,
1 <= par ? m_height : mtx::to_int_rounded(m_height / par),
generic_packetizer_c::ddu_pixels,
OPTION_SOURCE_BITSTREAM);

View File

@ -128,7 +128,7 @@ hevc_es_video_packetizer_c::handle_aspect_ratio() {
mxdebug_if(m_debug_aspect_ratio,
fmt::format("PAR {0} pixel_width/hgith {1}/{2} display_width/height {3}/{4}\n",
static_cast<double>(m_parser.get_par()), m_hvideo_pixel_width, m_hvideo_pixel_height, m_ti.m_display_width, m_ti.m_display_height));
m_parser.get_par(), m_hvideo_pixel_width, m_hvideo_pixel_height, m_ti.m_display_width, m_ti.m_display_height));
}
void