diff options
author | James Almer <jamrial@gmail.com> | 2018-03-16 18:58:04 -0300 |
---|---|---|
committer | James Almer <jamrial@gmail.com> | 2018-03-19 22:26:54 -0300 |
commit | e4eaaf7bf6930cd0c9a15631dfee0e235f327ba9 (patch) | |
tree | 7606886436b8882d2ece44100a80ca17f1625be3 | |
parent | cbbefc05b1b894fd858ba4da983cbf713f4f4421 (diff) | |
download | ffmpeg-streaming-e4eaaf7bf6930cd0c9a15631dfee0e235f327ba9.zip ffmpeg-streaming-e4eaaf7bf6930cd0c9a15631dfee0e235f327ba9.tar.gz |
avcodec/vp9_superframe_split: move the reference in the bsf internal buffer
There's no need to allocate a new packet for it.
Signed-off-by: James Almer <jamrial@gmail.com>
-rw-r--r-- | libavcodec/vp9_superframe_split_bsf.c | 21 |
1 files changed, 10 insertions, 11 deletions
diff --git a/libavcodec/vp9_superframe_split_bsf.c b/libavcodec/vp9_superframe_split_bsf.c index 0d2523e..7b6fa38 100644 --- a/libavcodec/vp9_superframe_split_bsf.c +++ b/libavcodec/vp9_superframe_split_bsf.c @@ -30,7 +30,7 @@ #include "get_bits.h" typedef struct VP9SFSplitContext { - AVPacket *buffer_pkt; + AVPacket buffer_pkt; int nb_frames; int next_frame; @@ -43,13 +43,13 @@ static int vp9_superframe_split_filter(AVBSFContext *ctx, AVPacket *out) VP9SFSplitContext *s = ctx->priv_data; AVPacket *in; int i, j, ret, marker; - int is_superframe = !!s->buffer_pkt; + int is_superframe = !!s->buffer_pkt.data; - if (!s->buffer_pkt) { - ret = ff_bsf_get_packet(ctx, &s->buffer_pkt); + if (!s->buffer_pkt.data) { + ret = ff_bsf_get_packet_ref(ctx, &s->buffer_pkt); if (ret < 0) return ret; - in = s->buffer_pkt; + in = &s->buffer_pkt; marker = in->data[in->size - 1]; if ((marker & 0xe0) == 0xc0) { @@ -90,7 +90,7 @@ static int vp9_superframe_split_filter(AVBSFContext *ctx, AVPacket *out) GetBitContext gb; int profile, invisible = 0; - ret = av_packet_ref(out, s->buffer_pkt); + ret = av_packet_ref(out, &s->buffer_pkt); if (ret < 0) goto fail; @@ -101,7 +101,7 @@ static int vp9_superframe_split_filter(AVBSFContext *ctx, AVPacket *out) s->next_frame++; if (s->next_frame >= s->nb_frames) - av_packet_free(&s->buffer_pkt); + av_packet_unref(&s->buffer_pkt); ret = init_get_bits8(&gb, out->data, out->size); if (ret < 0) @@ -121,20 +121,19 @@ static int vp9_superframe_split_filter(AVBSFContext *ctx, AVPacket *out) out->pts = AV_NOPTS_VALUE; } else { - av_packet_move_ref(out, s->buffer_pkt); - av_packet_free(&s->buffer_pkt); + av_packet_move_ref(out, &s->buffer_pkt); } return 0; fail: - av_packet_free(&s->buffer_pkt); + av_packet_unref(&s->buffer_pkt); return ret; } static void vp9_superframe_split_uninit(AVBSFContext *ctx) { VP9SFSplitContext *s = ctx->priv_data; - av_packet_free(&s->buffer_pkt); + av_packet_unref(&s->buffer_pkt); } const AVBitStreamFilter ff_vp9_superframe_split_bsf = { |