diff mbox series

[FFmpeg-devel,17/20] avcodec/h264_ps: Don't output invalid chroma location

Message ID DB6PR0101MB221468BA5ECE51D3881E7F788FBC9@DB6PR0101MB2214.eurprd01.prod.exchangelabs.com
State Accepted
Commit 1e38e7fd14492a71665bc7084cd871c6fb5e8d28
Headers show
Series [FFmpeg-devel,01/20] avcodec/hevc_sei: Use proper type for NALU type | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Andreas Rheinhardt July 2, 2022, 10:21 p.m. UTC
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
 libavcodec/h264_ps.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/libavcodec/h264_ps.c b/libavcodec/h264_ps.c
index 1fd7375a13..874790a3a3 100644
--- a/libavcodec/h264_ps.c
+++ b/libavcodec/h264_ps.c
@@ -181,7 +181,11 @@  static inline int decode_vui_parameters(GetBitContext *gb, void *logctx,
     /* chroma_location_info_present_flag */
     if (get_bits1(gb)) {
         /* chroma_sample_location_type_top_field */
-        sps->chroma_location = get_ue_golomb_31(gb) + 1;
+        sps->chroma_location = get_ue_golomb_31(gb);
+        if (sps->chroma_location <= 5U)
+            sps->chroma_location++;
+        else
+            sps->chroma_location = AVCHROMA_LOC_UNSPECIFIED;
         get_ue_golomb_31(gb);  /* chroma_sample_location_type_bottom_field */
     } else
         sps->chroma_location = AVCHROMA_LOC_LEFT;