summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-07-02 17:25:10 +0200
committerAndreas Rheinhardt <andreas.rheinhardt@outlook.com>2022-12-01 11:00:41 +0100
commit1e38e7fd14492a71665bc7084cd871c6fb5e8d28 (patch)
tree7d828e1365e44fe052fe52d0085ccfc120cb1220
parent881e8bcc515ada587b18216da18a402ed88e6f63 (diff)
avcodec/h264_ps: Don't output invalid chroma location
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r--libavcodec/h264_ps.c6
1 files changed, 5 insertions, 1 deletions
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;