Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-06-20 02:45:05 +0300
committerMark Thompson <sw@jkqxz.net>2019-07-08 00:59:20 +0300
commitddd53ef66d6a714f02ca553b9300db4dd4c16ae1 (patch)
tree0b14ee2bd64e05e483c540ceba4421277a850a8e /libavcodec/h265_metadata_bsf.c
parent9362f1a982682ebddfd477f8562c4065bb531333 (diff)
h265_metadata: Avoid allocations and copies of packet structures
This commit changes h265_metadata to (a) use ff_bsf_get_packet_ref instead of ff_bsf_get_packet (thereby avoiding one malloc and free per filtered packet) and (b) to use only one packet structure at all, thereby avoiding a call to av_packet_copy_props. (b) has been made possible by the recent changes to ff_cbs_write_packet. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/h265_metadata_bsf.c')
-rw-r--r--libavcodec/h265_metadata_bsf.c16
1 files changed, 5 insertions, 11 deletions
diff --git a/libavcodec/h265_metadata_bsf.c b/libavcodec/h265_metadata_bsf.c
index c7a635ebe2..042bc212a8 100644
--- a/libavcodec/h265_metadata_bsf.c
+++ b/libavcodec/h265_metadata_bsf.c
@@ -336,18 +336,17 @@ static int h265_metadata_update_sps(AVBSFContext *bsf,
return 0;
}
-static int h265_metadata_filter(AVBSFContext *bsf, AVPacket *out)
+static int h265_metadata_filter(AVBSFContext *bsf, AVPacket *pkt)
{
H265MetadataContext *ctx = bsf->priv_data;
- AVPacket *in = NULL;
CodedBitstreamFragment *au = &ctx->access_unit;
int err, i;
- err = ff_bsf_get_packet(bsf, &in);
+ err = ff_bsf_get_packet_ref(bsf, pkt);
if (err < 0)
return err;
- err = ff_cbs_read_packet(ctx->cbc, au, in);
+ err = ff_cbs_read_packet(ctx->cbc, au, pkt);
if (err < 0) {
av_log(bsf, AV_LOG_ERROR, "Failed to read packet.\n");
goto fail;
@@ -419,23 +418,18 @@ static int h265_metadata_filter(AVBSFContext *bsf, AVPacket *out)
}
}
- err = ff_cbs_write_packet(ctx->cbc, out, au);
+ err = ff_cbs_write_packet(ctx->cbc, pkt, au);
if (err < 0) {
av_log(bsf, AV_LOG_ERROR, "Failed to write packet.\n");
goto fail;
}
- err = av_packet_copy_props(out, in);
- if (err < 0)
- goto fail;
-
err = 0;
fail:
ff_cbs_fragment_reset(ctx->cbc, au);
if (err < 0)
- av_packet_unref(out);
- av_packet_free(&in);
+ av_packet_unref(pkt);
return err;
}