[FFmpeg-devel] [PATCH] lavc/hevc_ps: fix crop info

Zhao Zhili quinkblack at foxmail.com
Thu Aug 16 06:29:09 EEST 2018


---
 libavcodec/hevc_ps.c | 26 ++++++++++++++++++++++----
 1 file changed, 22 insertions(+), 4 deletions(-)

diff --git a/libavcodec/hevc_ps.c b/libavcodec/hevc_ps.c
index fbd9fbf..4161ab6 100644
--- a/libavcodec/hevc_ps.c
+++ b/libavcodec/hevc_ps.c
@@ -628,8 +628,17 @@ static void decode_vui(GetBitContext *gb, AVCodecContext *avctx,
         vui->default_display_window_flag = get_bits1(gb);
 
     if (vui->default_display_window_flag) {
-        int vert_mult  = 1 + (sps->chroma_format_idc < 2);
-        int horiz_mult = 1 + (sps->chroma_format_idc < 3);
+        unsigned horiz_mult, vert_mult;
+        if (sps->chroma_format_idc == 1) {
+            horiz_mult = 2;
+            vert_mult = 2;
+        } else if (sps->chroma_format_idc == 2) {
+            horiz_mult = 2;
+            vert_mult = 1;
+        } else {
+            horiz_mult = 1;
+            vert_mult = 1;
+        }
         vui->def_disp_win.left_offset   = get_ue_golomb_long(gb) * horiz_mult;
         vui->def_disp_win.right_offset  = get_ue_golomb_long(gb) * horiz_mult;
         vui->def_disp_win.top_offset    = get_ue_golomb_long(gb) *  vert_mult;
@@ -923,8 +932,17 @@ int ff_hevc_parse_sps(HEVCSPS *sps, GetBitContext *gb, unsigned int *sps_id,
         return ret;
 
     if (get_bits1(gb)) { // pic_conformance_flag
-        int vert_mult  = 1 + (sps->chroma_format_idc < 2);
-        int horiz_mult = 1 + (sps->chroma_format_idc < 3);
+        unsigned horiz_mult, vert_mult;
+        if (sps->chroma_format_idc == 1) {
+            horiz_mult = 2;
+            vert_mult = 2;
+        } else if (sps->chroma_format_idc == 2) {
+            horiz_mult = 2;
+            vert_mult = 1;
+        } else {
+            horiz_mult = 1;
+            vert_mult = 1;
+        }
         sps->pic_conf_win.left_offset   = get_ue_golomb_long(gb) * horiz_mult;
         sps->pic_conf_win.right_offset  = get_ue_golomb_long(gb) * horiz_mult;
         sps->pic_conf_win.top_offset    = get_ue_golomb_long(gb) *  vert_mult;
-- 
2.9.5





More information about the ffmpeg-devel mailing list