mirror of
https://gitlab.com/mbunkus/mkvtoolnix.git
synced 2024-12-24 11:54:01 +00:00
AVC & HEVC packetizers: use rationals for calculation of display dimensions
This commit is contained in:
parent
4b74b43fdb
commit
188436f981
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user