[FFmpeg-cvslog] lavc/hevcdec: move the check for multiple frames in a packet
Anton Khirnov
git at videolan.org
Tue Jun 11 18:51:33 EEST 2024
ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Mon Jun 3 11:31:24 2024 +0200| [3cd6492fb5e7bb4b6e0fdada2d2277b405b1236a] | committer: Anton Khirnov
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.
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3cd6492fb5e7bb4b6e0fdada2d2277b405b1236a
---
libavcodec/hevc/hevcdec.c | 14 ++++++--------
1 file 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)
More information about the ffmpeg-cvslog
mailing list