[FFmpeg-devel] [PATCH 1/2] avcodec/cbs_h266: fix use of uninitialized value

James Almer jamrial at gmail.com
Thu Jul 6 18:06:07 EEST 2023


And fix the allowed range for ph_log2_diff_max_bt_min_qt_intra_slice_luma while at it.

Signed-off-by: James Almer <jamrial at gmail.com>
---
 libavcodec/cbs_h266_syntax_template.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/libavcodec/cbs_h266_syntax_template.c b/libavcodec/cbs_h266_syntax_template.c
index b984a12d8f..f6aae3ac51 100644
--- a/libavcodec/cbs_h266_syntax_template.c
+++ b/libavcodec/cbs_h266_syntax_template.c
@@ -2730,9 +2730,14 @@ static int FUNC(picture_header) (CodedBitstreamContext *ctx, RWContext *rw,
                0, FFMIN(6, ctb_log2_size_y) - min_cb_log2_size_y);
             ue(ph_max_mtt_hierarchy_depth_intra_slice_luma,
                0, 2 * (ctb_log2_size_y - min_cb_log2_size_y));
+            min_qt_log2_size_intra_y =
+                current->ph_log2_diff_min_qt_min_cb_intra_slice_luma +
+                min_cb_log2_size_y;
             if (current->ph_max_mtt_hierarchy_depth_intra_slice_luma != 0) {
                 ue(ph_log2_diff_max_bt_min_qt_intra_slice_luma,
-                   0, ctb_log2_size_y - min_qt_log2_size_intra_y);
+                   0, (sps->sps_qtbtt_dual_tree_intra_flag ?
+                       FFMIN(6, ctb_log2_size_y) :
+                       ctb_log2_size_y) - min_qt_log2_size_intra_y);
                 ue(ph_log2_diff_max_tt_min_qt_intra_slice_luma,
                    0, FFMIN(6, ctb_log2_size_y) - min_qt_log2_size_intra_y);
             } else {
@@ -2780,9 +2785,6 @@ static int FUNC(picture_header) (CodedBitstreamContext *ctx, RWContext *rw,
                   sps->sps_log2_diff_max_tt_min_qt_intra_slice_chroma);
         }
 
-        min_qt_log2_size_intra_y =
-            current->ph_log2_diff_min_qt_min_cb_intra_slice_luma +
-            min_cb_log2_size_y;
         if (pps->pps_cu_qp_delta_enabled_flag)
             ue(ph_cu_qp_delta_subdiv_intra_slice, 0,
                2 * (ctb_log2_size_y - min_qt_log2_size_intra_y +
-- 
2.41.0



More information about the ffmpeg-devel mailing list