Commit 6442d8ba authored by James Almer's avatar James Almer Committed by Luca Barbato

avcodec/extract_extradata: Move the reference in the bsf internal buffer

There is no need to allocate a new packet for it.
Reviewed-by: 's avatarMark Thompson <sw@jkqxz.net>
Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
Signed-off-by: 's avatarLuca Barbato <lu_zero@gentoo.org>
parent 70f11ee9
...@@ -252,24 +252,23 @@ static int extract_extradata_init(AVBSFContext *ctx) ...@@ -252,24 +252,23 @@ static int extract_extradata_init(AVBSFContext *ctx)
return 0; return 0;
} }
static int extract_extradata_filter(AVBSFContext *ctx, AVPacket *out) static int extract_extradata_filter(AVBSFContext *ctx, AVPacket *pkt)
{ {
ExtractExtradataContext *s = ctx->priv_data; ExtractExtradataContext *s = ctx->priv_data;
AVPacket *in;
uint8_t *extradata = NULL; uint8_t *extradata = NULL;
int extradata_size; int extradata_size;
int ret = 0; int ret = 0;
ret = ff_bsf_get_packet(ctx, &in); ret = ff_bsf_get_packet_ref(ctx, pkt);
if (ret < 0) if (ret < 0)
return ret; return ret;
ret = s->extract(ctx, in, &extradata, &extradata_size); ret = s->extract(ctx, pkt, &extradata, &extradata_size);
if (ret < 0) if (ret < 0)
goto fail; goto fail;
if (extradata) { if (extradata) {
ret = av_packet_add_side_data(in, AV_PKT_DATA_NEW_EXTRADATA, ret = av_packet_add_side_data(pkt, AV_PKT_DATA_NEW_EXTRADATA,
extradata, extradata_size); extradata, extradata_size);
if (ret < 0) { if (ret < 0) {
av_freep(&extradata); av_freep(&extradata);
...@@ -277,10 +276,10 @@ static int extract_extradata_filter(AVBSFContext *ctx, AVPacket *out) ...@@ -277,10 +276,10 @@ static int extract_extradata_filter(AVBSFContext *ctx, AVPacket *out)
} }
} }
av_packet_move_ref(out, in); return 0;
fail: fail:
av_packet_free(&in); av_packet_unref(pkt);
return ret; return ret;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment