[FFmpeg-devel] [PATCH 2/6] avcodec/vaapi_h264: Do not store our error code in VASliceParameterBufferH264

Michael Niedermayer michael at niedermayer.cc
Sun Jul 7 21:47:25 EEST 2024


I am not sure this is possible (thus this requires review)

Fixes: CID1604570 Overflowed constant

Sponsored-by: Sovereign Tech Fund
Signed-off-by: Michael Niedermayer <michael at niedermayer.cc>
---
 libavcodec/vaapi_h264.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/libavcodec/vaapi_h264.c b/libavcodec/vaapi_h264.c
index 398e92568c2..77819a64a4e 100644
--- a/libavcodec/vaapi_h264.c
+++ b/libavcodec/vaapi_h264.c
@@ -342,6 +342,10 @@ static int vaapi_h264_decode_slice(AVCodecContext *avctx,
     const H264SliceContext *sl  = &h->slice_ctx[0];
     VASliceParameterBufferH264 slice_param;
     int err;
+    int slice_type = ff_h264_get_slice_type(sl);
+
+    if (slice_type < 0)
+        return slice_type;
 
     slice_param = (VASliceParameterBufferH264) {
         .slice_data_size               = size,
@@ -349,7 +353,7 @@ static int vaapi_h264_decode_slice(AVCodecContext *avctx,
         .slice_data_flag               = VA_SLICE_DATA_FLAG_ALL,
         .slice_data_bit_offset         = get_bits_count(&sl->gb),
         .first_mb_in_slice             = (sl->mb_y >> FIELD_OR_MBAFF_PICTURE(h)) * h->mb_width + sl->mb_x,
-        .slice_type                    = ff_h264_get_slice_type(sl),
+        .slice_type                    = slice_type,
         .direct_spatial_mv_pred_flag   = sl->slice_type == AV_PICTURE_TYPE_B ? sl->direct_spatial_mv_pred : 0,
         .num_ref_idx_l0_active_minus1  = sl->list_count > 0 ? sl->ref_count[0] - 1 : 0,
         .num_ref_idx_l1_active_minus1  = sl->list_count > 1 ? sl->ref_count[1] - 1 : 0,
-- 
2.45.2



More information about the ffmpeg-devel mailing list