mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-12-12 18:10:13 +01:00
avformat/utils: Don't allocate separate packet for extract_extradata
One can simply reuse AVFormatInternal.parse_pkt instead. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
This commit is contained in:
@@ -90,9 +90,18 @@ struct AVFormatInternal {
|
|||||||
/**
|
/**
|
||||||
* Packets split by the parser get queued here.
|
* Packets split by the parser get queued here.
|
||||||
*/
|
*/
|
||||||
AVPacket *parse_pkt;
|
|
||||||
struct PacketList *parse_queue;
|
struct PacketList *parse_queue;
|
||||||
struct PacketList *parse_queue_end;
|
struct PacketList *parse_queue_end;
|
||||||
|
/**
|
||||||
|
* The generic code uses this as a temporary packet
|
||||||
|
* to parse packets; it may also be used for other means
|
||||||
|
* for short periods that are guaranteed not to overlap
|
||||||
|
* with calls to av_read_frame() (or ff_read_packet())
|
||||||
|
* or with each other.
|
||||||
|
* Every user has to ensure that this packet is blank
|
||||||
|
* after using it.
|
||||||
|
*/
|
||||||
|
AVPacket *parse_pkt;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used to hold temporary packets.
|
* Used to hold temporary packets.
|
||||||
@@ -190,7 +199,6 @@ struct AVStreamInternal {
|
|||||||
* supported) */
|
* supported) */
|
||||||
struct {
|
struct {
|
||||||
AVBSFContext *bsf;
|
AVBSFContext *bsf;
|
||||||
AVPacket *pkt;
|
|
||||||
int inited;
|
int inited;
|
||||||
} extract_extradata;
|
} extract_extradata;
|
||||||
|
|
||||||
|
|||||||
@@ -3496,13 +3496,9 @@ static int extract_extradata_init(AVStream *st)
|
|||||||
if (!ret)
|
if (!ret)
|
||||||
goto finish;
|
goto finish;
|
||||||
|
|
||||||
sti->extract_extradata.pkt = av_packet_alloc();
|
|
||||||
if (!sti->extract_extradata.pkt)
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
|
|
||||||
ret = av_bsf_alloc(f, &sti->extract_extradata.bsf);
|
ret = av_bsf_alloc(f, &sti->extract_extradata.bsf);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto fail;
|
return ret;
|
||||||
|
|
||||||
ret = avcodec_parameters_copy(sti->extract_extradata.bsf->par_in,
|
ret = avcodec_parameters_copy(sti->extract_extradata.bsf->par_in,
|
||||||
st->codecpar);
|
st->codecpar);
|
||||||
@@ -3521,14 +3517,13 @@ finish:
|
|||||||
return 0;
|
return 0;
|
||||||
fail:
|
fail:
|
||||||
av_bsf_free(&sti->extract_extradata.bsf);
|
av_bsf_free(&sti->extract_extradata.bsf);
|
||||||
av_packet_free(&sti->extract_extradata.pkt);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int extract_extradata(AVStream *st, const AVPacket *pkt)
|
static int extract_extradata(AVFormatContext *s, AVStream *st, const AVPacket *pkt)
|
||||||
{
|
{
|
||||||
AVStreamInternal *sti = st->internal;
|
AVStreamInternal *sti = st->internal;
|
||||||
AVPacket *pkt_ref;
|
AVPacket *pkt_ref = s->internal->parse_pkt;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
if (!sti->extract_extradata.inited) {
|
if (!sti->extract_extradata.inited) {
|
||||||
@@ -3540,7 +3535,6 @@ static int extract_extradata(AVStream *st, const AVPacket *pkt)
|
|||||||
if (sti->extract_extradata.inited && !sti->extract_extradata.bsf)
|
if (sti->extract_extradata.inited && !sti->extract_extradata.bsf)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
pkt_ref = sti->extract_extradata.pkt;
|
|
||||||
ret = av_packet_ref(pkt_ref, pkt);
|
ret = av_packet_ref(pkt_ref, pkt);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
@@ -3921,7 +3915,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
|
|||||||
st->internal->info->frame_delay_evidence = 1;
|
st->internal->info->frame_delay_evidence = 1;
|
||||||
}
|
}
|
||||||
if (!st->internal->avctx->extradata) {
|
if (!st->internal->avctx->extradata) {
|
||||||
ret = extract_extradata(st, pkt);
|
ret = extract_extradata(ic, st, pkt);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
goto unref_then_goto_end;
|
goto unref_then_goto_end;
|
||||||
}
|
}
|
||||||
@@ -4187,7 +4181,6 @@ find_stream_info_err:
|
|||||||
avcodec_close(ic->streams[i]->internal->avctx);
|
avcodec_close(ic->streams[i]->internal->avctx);
|
||||||
av_freep(&ic->streams[i]->internal->info);
|
av_freep(&ic->streams[i]->internal->info);
|
||||||
av_bsf_free(&ic->streams[i]->internal->extract_extradata.bsf);
|
av_bsf_free(&ic->streams[i]->internal->extract_extradata.bsf);
|
||||||
av_packet_free(&ic->streams[i]->internal->extract_extradata.pkt);
|
|
||||||
}
|
}
|
||||||
if (ic->pb)
|
if (ic->pb)
|
||||||
av_log(ic, AV_LOG_DEBUG, "After avformat_find_stream_info() pos: %"PRId64" bytes read:%"PRId64" seeks:%d frames:%d\n",
|
av_log(ic, AV_LOG_DEBUG, "After avformat_find_stream_info() pos: %"PRId64" bytes read:%"PRId64" seeks:%d frames:%d\n",
|
||||||
@@ -4389,7 +4382,6 @@ static void free_stream(AVStream **pst)
|
|||||||
av_freep(&st->internal->probe_data.buf);
|
av_freep(&st->internal->probe_data.buf);
|
||||||
|
|
||||||
av_bsf_free(&st->internal->extract_extradata.bsf);
|
av_bsf_free(&st->internal->extract_extradata.bsf);
|
||||||
av_packet_free(&st->internal->extract_extradata.pkt);
|
|
||||||
|
|
||||||
if (st->internal->info)
|
if (st->internal->info)
|
||||||
av_freep(&st->internal->info->duration_error);
|
av_freep(&st->internal->info->duration_error);
|
||||||
|
|||||||
Reference in New Issue
Block a user