From: Xiaolei Yu <dreifachstein@gmail.com>
To: ffmpeg-devel@ffmpeg.org
Subject: [FFmpeg-devel] [PATCH v2 1/2] avcodec/hevcdec: skip generating missing refs in foll lists
Date: Sat, 16 Apr 2022 16:31:21 +0800
Message-ID: <9c14fe0c-ba79-9136-227a-26bfdcdf562e@gmail.com> (raw)
In-Reply-To: <2237ca87-c339-b00c-1562-5c49faee0987@gmail.com>
[-- Attachment #1.1.1.1: Type: text/plain, Size: 2734 bytes --]
Missing refs shall be generated only when they are actually used.
Without this change a sequence of a BLA picture and an associated RASL picture
would still be decoded without complaints if the RASL picture is mislabeled
as RADL.
---
libavcodec/hevc_refs.c | 19 +++++++++++++------
1 file changed, 13 insertions(+), 6 deletions(-)
diff --git a/libavcodec/hevc_refs.c b/libavcodec/hevc_refs.c
index fe18ca2b1d..84a21991c7 100644
--- a/libavcodec/hevc_refs.c
+++ b/libavcodec/hevc_refs.c
@@ -378,9 +378,6 @@ static HEVCFrame *find_ref_idx(HEVCContext *s, int poc, uint8_t use_msb)
}
}
- if (s->nal_unit_type != HEVC_NAL_CRA_NUT && !IS_BLA(s))
- av_log(s->avctx, AV_LOG_ERROR,
- "Could not find ref with POC %d\n", poc);
return NULL;
}
@@ -426,7 +423,7 @@ static HEVCFrame *generate_missing_ref(HEVCContext *s, int poc)
/* add a reference with the given poc to the list and mark it as used in DPB */
static int add_candidate_ref(HEVCContext *s, RefPicList *list,
- int poc, int ref_flag, uint8_t use_msb)
+ int poc, int ref_flag, uint8_t use_msb, enum RPSType rps_type)
{
HEVCFrame *ref = find_ref_idx(s, poc, use_msb);
@@ -434,6 +431,15 @@ static int add_candidate_ref(HEVCContext *s, RefPicList *list,
return AVERROR_INVALIDDATA;
if (!ref) {
+ int allow_missing = !(rps_type == ST_CURR_BEF || rps_type == ST_CURR_AFT ||
+ rps_type == LT_CURR);
+
+ /* skip generating missing refs in foll lists as they are not used by current frame */
+ if (allow_missing)
+ return 0;
+
+ av_log(s->avctx, AV_LOG_ERROR, "Could not find ref with POC %d\n", poc);
+
ref = generate_missing_ref(s, poc);
if (!ref)
return AVERROR(ENOMEM);
@@ -484,7 +490,7 @@ int ff_hevc_frame_rps(HEVCContext *s)
else
list = ST_CURR_AFT;
- ret = add_candidate_ref(s, &rps[list], poc, HEVC_FRAME_FLAG_SHORT_REF, 1);
+ ret = add_candidate_ref(s, &rps[list], poc, HEVC_FRAME_FLAG_SHORT_REF, 1, list);
if (ret < 0)
goto fail;
}
@@ -494,7 +500,8 @@ int ff_hevc_frame_rps(HEVCContext *s)
int poc = long_rps->poc[i];
int list = long_rps->used[i] ? LT_CURR : LT_FOLL;
- ret = add_candidate_ref(s, &rps[list], poc, HEVC_FRAME_FLAG_LONG_REF, long_rps->poc_msb_present[i]);
+ ret = add_candidate_ref(s, &rps[list], poc, HEVC_FRAME_FLAG_LONG_REF, long_rps->poc_msb_present[i],
+ list);
if (ret < 0)
goto fail;
}
--
2.35.1
[-- Attachment #1.1.1.2: OpenPGP public key --]
[-- Type: application/pgp-keys, Size: 669 bytes --]
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 236 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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".
next prev parent reply other threads:[~2022-04-16 8:31 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-05 6:49 [FFmpeg-devel] [PATCH] libavcodec/hevcdec: detect non-conformant missing refs Xiaolei Yu
2022-04-05 9:10 ` Anton Khirnov
2022-04-16 8:30 ` Xiaolei Yu
[not found] ` <2237ca87-c339-b00c-1562-5c49faee0987@gmail.com>
2022-04-16 8:31 ` Xiaolei Yu [this message]
2022-04-16 8:31 ` [FFmpeg-devel] [PATCH v2 2/2] avcodec/hevcdec: " Xiaolei Yu
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=9c14fe0c-ba79-9136-227a-26bfdcdf562e@gmail.com \
--to=dreifachstein@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