X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=libavcodec%2Fvp9_superframe_bsf.c;h=57681e29e429c36ca26676766d007dce5d4ff7ce;hb=bc70684e74a185d7b80c8b80bdedda659cb581b8;hp=ea6750750b0a49bd5830fe3a9c91685880cc7778;hpb=1b98bfb932ad36667ea7f18e24c54978623f6654;p=ffmpeg diff --git a/libavcodec/vp9_superframe_bsf.c b/libavcodec/vp9_superframe_bsf.c index ea6750750b0..57681e29e42 100644 --- a/libavcodec/vp9_superframe_bsf.c +++ b/libavcodec/vp9_superframe_bsf.c @@ -20,8 +20,9 @@ */ #include "libavutil/avassert.h" -#include "avcodec.h" + #include "bsf.h" +#include "bsf_internal.h" #include "get_bits.h" #define MAX_CACHE 8 @@ -97,26 +98,25 @@ static int merge_superframe(AVPacket * const *in, int n_in, AVPacket *out) return 0; } -static int vp9_superframe_filter(AVBSFContext *ctx, AVPacket *out) +static int vp9_superframe_filter(AVBSFContext *ctx, AVPacket *pkt) { GetBitContext gb; VP9BSFContext *s = ctx->priv_data; - AVPacket *in; int res, invisible, profile, marker, uses_superframe_syntax = 0, n; - res = ff_bsf_get_packet(ctx, &in); + res = ff_bsf_get_packet_ref(ctx, pkt); if (res < 0) return res; - marker = in->data[in->size - 1]; + marker = pkt->data[pkt->size - 1]; if ((marker & 0xe0) == 0xc0) { int nbytes = 1 + ((marker >> 3) & 0x3); int n_frames = 1 + (marker & 0x7), idx_sz = 2 + n_frames * nbytes; - uses_superframe_syntax = in->size >= idx_sz && in->data[in->size - idx_sz] == marker; + uses_superframe_syntax = pkt->size >= idx_sz && pkt->data[pkt->size - idx_sz] == marker; } - if ((res = init_get_bits8(&gb, in->data, in->size)) < 0) + if ((res = init_get_bits8(&gb, pkt->data, pkt->size)) < 0) goto done; get_bits(&gb, 2); // frame marker @@ -133,33 +133,31 @@ static int vp9_superframe_filter(AVBSFContext *ctx, AVPacket *out) if (uses_superframe_syntax && s->n_cache > 0) { av_log(ctx, AV_LOG_ERROR, - "Mixing of superframe syntax and naked VP9 frames not supported"); + "Mixing of superframe syntax and naked VP9 frames not supported\n"); res = AVERROR(ENOSYS); goto done; } else if ((!invisible || uses_superframe_syntax) && !s->n_cache) { // passthrough - av_packet_move_ref(out, in); - goto done; + return 0; } else if (s->n_cache + 1 >= MAX_CACHE) { av_log(ctx, AV_LOG_ERROR, - "Too many invisible frames"); + "Too many invisible frames\n"); res = AVERROR_INVALIDDATA; goto done; } - av_packet_move_ref(s->cache[s->n_cache++], in); + av_packet_move_ref(s->cache[s->n_cache++], pkt); if (invisible) { - res = AVERROR(EAGAIN); - goto done; + return AVERROR(EAGAIN); } av_assert0(s->n_cache > 0); // build superframe - if ((res = merge_superframe(s->cache, s->n_cache, out)) < 0) + if ((res = merge_superframe(s->cache, s->n_cache, pkt)) < 0) goto done; - res = av_packet_copy_props(out, s->cache[s->n_cache - 1]); + res = av_packet_copy_props(pkt, s->cache[s->n_cache - 1]); if (res < 0) goto done; @@ -169,8 +167,7 @@ static int vp9_superframe_filter(AVBSFContext *ctx, AVPacket *out) done: if (res < 0) - av_packet_unref(out); - av_packet_free(&in); + av_packet_unref(pkt); return res; }