Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Hendrik Leppkes <h.leppkes@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Hendrik Leppkes <h.leppkes@gmail.com>
Subject: [FFmpeg-devel] [PATCH v2] hevcdec: skip slices with missing PPS instead of skipping the entire packet
Date: Thu, 30 Dec 2021 16:08:16 +0100
Message-ID: <20211230150816.500-1-h.leppkes@gmail.com> (raw)
In-Reply-To: <20211228134929.1164-1-h.leppkes@gmail.com>

Aborting decoding of the entire packet on a missing PPS can result in
missing the actual PPS on streams with badly ordered NALs, where the
SPS/PPS/VPS are stitched to the back of the previous frame, instead of
the beginning of the next frame.

Instead, skip the undecodable slice, and let the decoder process further
NALs in the same packet.

If this happens on the first slice, the entire frame will be discarded
later, otherwise on other slices the decode error flag will be set to
indicate a missing/corrupt slice.
---
 libavcodec/hevcdec.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c
index 3aa70e2245..89381db240 100644
--- a/libavcodec/hevcdec.c
+++ b/libavcodec/hevcdec.c
@@ -575,7 +575,9 @@ static int hls_slice_header(HEVCContext *s)
     sh->pps_id = get_ue_golomb_long(gb);
     if (sh->pps_id >= HEVC_MAX_PPS_COUNT || !s->ps.pps_list[sh->pps_id]) {
         av_log(s->avctx, AV_LOG_ERROR, "PPS id out of range: %d\n", sh->pps_id);
-        return AVERROR_INVALIDDATA;
+        if (s->ref)
+            s->ref->frame->decode_error_flags |= FF_DECODE_ERROR_DECODE_SLICES;
+        return 1; // skip slice with missing PPS, allowing other NALs to be decoded
     }
     if (!sh->first_slice_in_pic_flag &&
         s->ps.pps != (HEVCPPS*)s->ps.pps_list[sh->pps_id]->data) {
-- 
2.33.0.windows.2

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

  parent reply	other threads:[~2021-12-30 15:08 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-28 13:49 [FFmpeg-devel] [PATCH] " Hendrik Leppkes
2021-12-28 14:26 ` James Almer
2021-12-28 22:01   ` Hendrik Leppkes
2021-12-28 23:08     ` James Almer
2021-12-30 15:08 ` Hendrik Leppkes [this message]
2021-12-30 15:13   ` [FFmpeg-devel] [PATCH v2] " James Almer
2021-12-30 15:26     ` Hendrik Leppkes
2021-12-30 15:31       ` James Almer
2021-12-31  9:22         ` Andreas Rheinhardt

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211230150816.500-1-h.leppkes@gmail.com \
    --to=h.leppkes@gmail.com \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git