From bbcd3a5ea70054cef0950c2e0211ab700efce178 Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Tue, 31 Mar 2020 13:51:55 -0600 Subject: scan: Fix aspect ratio warning for DVD and BD DVD and BD do not have PAR specified at container level. Since the title is initialized with PAR 1:1, the warning was triggered. (cherry picked from commit d72cdd2b73984762bf39b302e6e7270533c093a6) --- libhb/common.c | 2 +- libhb/scan.c | 20 +++++++++++++++++++- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/libhb/common.c b/libhb/common.c index 7d80cc0b0..b78d5fabc 100644 --- a/libhb/common.c +++ b/libhb/common.c @@ -3690,7 +3690,7 @@ hb_title_t * hb_title_init( char * path, int index ) t->video_timebase.num = 1; t->video_timebase.den = 90000; t->angle_count = 1; - t->geometry.par.num = 1; + t->geometry.par.num = 0; t->geometry.par.den = 1; return t; diff --git a/libhb/scan.c b/libhb/scan.c index 7c8813a54..d9fdc5614 100644 --- a/libhb/scan.c +++ b/libhb/scan.c @@ -1002,8 +1002,21 @@ skip_preview: } title->video_bitrate = vid_info.bitrate; - if( vid_info.geometry.par.num && vid_info.geometry.par.den ) + if (data->dvd || data->bd) { + // DVD/BD doesn't have a container PAR, but it has container DAR + // which can be used to compute container PAR + hb_reduce(&title->geometry.par.num, &title->geometry.par.den, + title->geometry.height * title->container_dar.num, + title->geometry.width * title->container_dar.den); + } + if (vid_info.geometry.par.num && vid_info.geometry.par.den) + { + // title->geometry.par is initially container PAR, but + // the video stream almost always also supplies PAR and + // is generally more reliable, so use it. + // + // Check if container PAR and video stream PAR are in agreement if (title->geometry.par.num && title->geometry.par.den && title->geometry.par.num != vid_info.geometry.par.num && title->geometry.par.den != vid_info.geometry.par.den) @@ -1014,6 +1027,11 @@ skip_preview: } title->geometry.par = vid_info.geometry.par; } + else if (!title->geometry.par.num || !title->geometry.par.den) + { + // No video PAR found, assume 1:1 + title->geometry.par.num = title->geometry.par.den = 1; + } title->pix_fmt = vid_info.pix_fmt; title->color_prim = vid_info.color_prim; title->color_transfer = vid_info.color_transfer; -- cgit v1.2.3