From: "Xiang, Haihao" <haihao.xiang-at-intel.com@ffmpeg.org>
To: ffmpeg-devel@ffmpeg.org
Cc: Haihao Xiang <haihao.xiang@intel.com>
Subject: [FFmpeg-devel] [PATCH] libavcodec/hevc_mp4toannexb_bsf: insert extradata before non-AUD unit
Date: Thu, 17 Mar 2022 14:35:46 +0800
Message-ID: <20220317063546.7429-1-haihao.xiang@intel.com> (raw)
From: Haihao Xiang <haihao.xiang@intel.com>
It is possible that an IRAP frame in input AVPacket contains VPS, SPS
and PPS, and these headers should take effect. However the prepended
extradata might override these headers. This patch inserts extradata
before non-AUD unit, hence VPS, SPS and PPS from the input AVPacket will
take effect if they are present.
This should fix #7799
Signed-off-by: Haihao Xiang <haihao.xiang@intel.com>
---
libavcodec/hevc_mp4toannexb_bsf.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/libavcodec/hevc_mp4toannexb_bsf.c b/libavcodec/hevc_mp4toannexb_bsf.c
index 790dfb0394..77551ba221 100644
--- a/libavcodec/hevc_mp4toannexb_bsf.c
+++ b/libavcodec/hevc_mp4toannexb_bsf.c
@@ -124,6 +124,7 @@ static int hevc_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out)
int got_irap = 0;
int i, ret = 0;
+ int prev_nalu_is_aud = 0, extradata_offset = 0;
ret = ff_bsf_get_packet(ctx, &in);
if (ret < 0)
@@ -169,14 +170,21 @@ static int hevc_mp4toannexb_filter(AVBSFContext *ctx, AVPacket *out)
prev_size = out->size;
+ if (prev_nalu_is_aud)
+ extradata_offset = prev_size;
+
ret = av_grow_packet(out, 4 + nalu_size + extra_size);
if (ret < 0)
goto fail;
- if (extra_size)
- memcpy(out->data + prev_size, ctx->par_out->extradata, extra_size);
+ if (extra_size) {
+ memmove(out->data + extradata_offset + extra_size, out->data + extradata_offset, prev_size - extradata_offset);
+ memcpy(out->data + extradata_offset, ctx->par_out->extradata, extra_size);
+ }
+
AV_WB32(out->data + prev_size + extra_size, 1);
bytestream2_get_buffer(&gb, out->data + prev_size + 4 + extra_size, nalu_size);
+ prev_nalu_is_aud = nalu_type == HEVC_NAL_AUD;
}
ret = av_packet_copy_props(out, in);
--
2.17.1
_______________________________________________
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 reply other threads:[~2022-03-17 6:36 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-17 6:35 Xiang, Haihao [this message]
2022-03-22 2:52 ` Xiang, Haihao
2022-03-22 9:29 ` Andreas Rheinhardt
2022-03-23 7:47 ` Xiang, Haihao
2022-06-27 21:09 ` Soft Works
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=20220317063546.7429-1-haihao.xiang@intel.com \
--to=haihao.xiang-at-intel.com@ffmpeg.org \
--cc=ffmpeg-devel@ffmpeg.org \
--cc=haihao.xiang@intel.com \
/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