The branch, release/8.0 has been updated
via 24205bc65792ae51c8a7ac453a15807c23df1838 (commit)
from 7cbc26267b6968eb2b8cc5f70e3603b6ee9b2101 (commit)
- Log -----------------------------------------------------------------
commit 24205bc65792ae51c8a7ac453a15807c23df1838
Author: James Almer <[email protected]>
AuthorDate: Mon Oct 27 16:18:17 2025 -0300
Commit: James Almer <[email protected]>
CommitDate: Tue Oct 28 11:45:10 2025 -0300
avformat/demux: pass new extradata to the parser
The parser API doesn't work with packets, only raw data, so in order for it
to
be made aware of new extradata propagated through packet side data we need
to
pass it in some other form, namely, replacing the main extradata and
ensuring
it will be parsed by restarting the parser.
Signed-off-by: James Almer <[email protected]>
diff --git a/libavformat/demux.c b/libavformat/demux.c
index 3749ab67a3..0527265328 100644
--- a/libavformat/demux.c
+++ b/libavformat/demux.c
@@ -1167,7 +1167,10 @@ static int parse_packet(AVFormatContext *s, AVPacket
*pkt,
AVPacket *out_pkt = si->parse_pkt;
AVStream *st = s->streams[stream_index];
FFStream *const sti = ffstream(st);
+ const AVPacketSideData *sd = NULL;
const uint8_t *data = pkt->data;
+ uint8_t *extradata = sti->avctx->extradata;
+ int extradata_size = sti->avctx->extradata_size;
int size = pkt->size;
int ret = 0, got_output = flush;
@@ -1184,6 +1187,16 @@ static int parse_packet(AVFormatContext *s, AVPacket
*pkt,
}
}
+ if (pkt->side_data_elems)
+ sd = av_packet_side_data_get(pkt->side_data, pkt->side_data_elems,
+ AV_PKT_DATA_NEW_EXTRADATA);
+ if (sd) {
+ av_assert1(size && !flush);
+
+ sti->avctx->extradata = sd->data;
+ sti->avctx->extradata_size = sd->size;
+ }
+
while (size > 0 || (flush && got_output)) {
int64_t next_pts = pkt->pts;
int64_t next_dts = pkt->dts;
@@ -1277,6 +1290,11 @@ static int parse_packet(AVFormatContext *s, AVPacket
*pkt,
}
fail:
+ if (sd) {
+ sti->avctx->extradata = extradata;
+ sti->avctx->extradata_size = extradata_size;
+ }
+
if (ret < 0)
av_packet_unref(out_pkt);
av_packet_unref(pkt);
@@ -1370,6 +1388,11 @@ static int read_frame_internal(AVFormatContext *s,
AVPacket *pkt)
st->event_flags |= AVSTREAM_EVENT_FLAG_NEW_PACKETS;
+ int new_extradata = !!av_packet_side_data_get(pkt->side_data,
pkt->side_data_elems,
+
AV_PKT_DATA_NEW_EXTRADATA);
+ if (new_extradata)
+ sti->need_context_update = 1;
+
/* update context if required */
if (sti->need_context_update) {
if (avcodec_is_open(sti->avctx)) {
@@ -1380,8 +1403,9 @@ static int read_frame_internal(AVFormatContext *s,
AVPacket *pkt)
return ret;
}
- /* close parser, because it depends on the codec */
- if (sti->parser && sti->avctx->codec_id != st->codecpar->codec_id)
{
+ /* close parser, because it depends on the codec and extradata */
+ if (sti->parser &&
+ (sti->avctx->codec_id != st->codecpar->codec_id ||
new_extradata)) {
av_parser_close(sti->parser);
sti->parser = NULL;
}
-----------------------------------------------------------------------
Summary of changes:
libavformat/demux.c | 28 ++++++++++++++++++++++++++--
1 file changed, 26 insertions(+), 2 deletions(-)
hooks/post-receive
--
_______________________________________________
ffmpeg-cvslog mailing list -- [email protected]
To unsubscribe send an email to [email protected]