aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2024-06-03 11:31:24 +0200
committerAnton Khirnov <anton@khirnov.net>2024-06-11 17:39:35 +0200
commit3cd6492fb5e7bb4b6e0fdada2d2277b405b1236a (patch)
treec4962424d50c64ce0dd73c4208f4d3b25fa9a0a5
parenta8f9d52c227841929959cd414398cfa426b6024e (diff)
downloadffmpeg-3cd6492fb5e7bb4b6e0fdada2d2277b405b1236a.tar.gz
lavc/hevcdec: move the check for multiple frames in a packet
Do not do it in hls_slice_header(), which is the wrong place for it. Avoids special magic return value of 1 in that function. The comment mentioning potential corrupted state is no longer relevant, as hls_slice_header() modifies no state beyond SliceHeader, which will only get used for a valid frame.
-rw-r--r--libavcodec/hevc/hevcdec.c14
1 files changed, 6 insertions, 8 deletions
diff --git a/libavcodec/hevc/hevcdec.c b/libavcodec/hevc/hevcdec.c
index 2809e1e61d..a241e25196 100644
--- a/libavcodec/hevc/hevcdec.c
+++ b/libavcodec/hevc/hevcdec.c
@@ -598,10 +598,6 @@ static int hls_slice_header(SliceHeader *sh, const HEVCContext *s, GetBitContext
// Coded parameters
sh->first_slice_in_pic_flag = get_bits1(gb);
- if (s->cur_frame && sh->first_slice_in_pic_flag) {
- av_log(s->avctx, AV_LOG_ERROR, "Two slices reporting being the first in the same frame.\n");
- return 1; // This slice will be skipped later, do not corrupt state
- }
sh->no_output_of_prior_pics_flag = 0;
if (IS_IRAP(s))
@@ -3131,10 +3127,6 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
ret = hls_slice_header(&s->sh, s, &gb);
if (ret < 0)
return ret;
- if (ret == 1) {
- ret = AVERROR_INVALIDDATA;
- goto fail;
- }
if ((s->avctx->skip_frame >= AVDISCARD_BIDIR && s->sh.slice_type == HEVC_SLICE_B) ||
(s->avctx->skip_frame >= AVDISCARD_NONINTRA && s->sh.slice_type != HEVC_SLICE_I) ||
@@ -3145,6 +3137,12 @@ static int decode_nal_unit(HEVCContext *s, const H2645NAL *nal)
}
if (s->sh.first_slice_in_pic_flag) {
+ if (s->cur_frame) {
+ av_log(s->avctx, AV_LOG_ERROR, "Two slices reporting being the first in the same frame.\n");
+ ret = AVERROR_INVALIDDATA;
+ goto fail;
+ }
+
s->overlap ++;
ret = hevc_frame_start(s);
if (ret < 0)