diff options
author | James Almer <jamrial@gmail.com> | 2018-03-11 13:50:28 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2018-03-11 15:42:01 -0300 |
commit | c266049191e5230e36e610874a57673e7af0515d (patch) | |
tree | 15ad23d7d1a5a3d9a40235d1406f9929bbbbbce9 /libavcodec | |
parent | a1a0859ad52e8f5161b1ba15cc951783e52b5ff8 (diff) | |
download | ffmpeg-streaming-c266049191e5230e36e610874a57673e7af0515d.zip ffmpeg-streaming-c266049191e5230e36e610874a57673e7af0515d.tar.gz |
avcodec/trace_headers: move the reference in the bsf internal buffer
There's no need to allocate a new packet for it.
Reviewed-by: Mark Thompson <sw@jkqxz.net>
Signed-off-by: James Almer <jamrial@gmail.com>
Diffstat (limited to 'libavcodec')
-rw-r--r-- | libavcodec/trace_headers_bsf.c | 32 |
1 files changed, 15 insertions, 17 deletions
diff --git a/libavcodec/trace_headers_bsf.c b/libavcodec/trace_headers_bsf.c index 93d04cb..0697e98 100644 --- a/libavcodec/trace_headers_bsf.c +++ b/libavcodec/trace_headers_bsf.c @@ -67,45 +67,43 @@ static void trace_headers_close(AVBSFContext *bsf) ff_cbs_close(&ctx->cbc); } -static int trace_headers(AVBSFContext *bsf, AVPacket *out) +static int trace_headers(AVBSFContext *bsf, AVPacket *pkt) { TraceHeadersContext *ctx = bsf->priv_data; CodedBitstreamFragment au; - AVPacket *in; char tmp[256] = { 0 }; int err; - err = ff_bsf_get_packet(bsf, &in); + err = ff_bsf_get_packet_ref(bsf, pkt); if (err < 0) return err; - if (in->flags & AV_PKT_FLAG_KEY) + if (pkt->flags & AV_PKT_FLAG_KEY) av_strlcat(tmp, ", key frame", sizeof(tmp)); - if (in->flags & AV_PKT_FLAG_CORRUPT) + if (pkt->flags & AV_PKT_FLAG_CORRUPT) av_strlcat(tmp, ", corrupt", sizeof(tmp)); - if (in->pts != AV_NOPTS_VALUE) - av_strlcatf(tmp, sizeof(tmp), ", pts %"PRId64, in->pts); + if (pkt->pts != AV_NOPTS_VALUE) + av_strlcatf(tmp, sizeof(tmp), ", pts %"PRId64, pkt->pts); else av_strlcat(tmp, ", no pts", sizeof(tmp)); - if (in->dts != AV_NOPTS_VALUE) - av_strlcatf(tmp, sizeof(tmp), ", dts %"PRId64, in->dts); + if (pkt->dts != AV_NOPTS_VALUE) + av_strlcatf(tmp, sizeof(tmp), ", dts %"PRId64, pkt->dts); else av_strlcat(tmp, ", no dts", sizeof(tmp)); - if (in->duration > 0) - av_strlcatf(tmp, sizeof(tmp), ", duration %"PRId64, in->duration); + if (pkt->duration > 0) + av_strlcatf(tmp, sizeof(tmp), ", duration %"PRId64, pkt->duration); - av_log(bsf, AV_LOG_INFO, "Packet: %d bytes%s.\n", in->size, tmp); + av_log(bsf, AV_LOG_INFO, "Packet: %d bytes%s.\n", pkt->size, tmp); - err = ff_cbs_read_packet(ctx->cbc, &au, in); - if (err < 0) + err = ff_cbs_read_packet(ctx->cbc, &au, pkt); + if (err < 0) { + av_packet_unref(pkt); return err; + } ff_cbs_fragment_uninit(ctx->cbc, &au); - av_packet_move_ref(out, in); - av_packet_free(&in); - return 0; } |