1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2025-08-15 14:13:16 +02:00

avcodec/dca_core: 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>
This commit is contained in:
James Almer
2018-03-11 13:29:19 -03:00
parent 27d4249fad
commit aba437a6d0

View File

@@ -24,18 +24,17 @@
#include "dca_syncwords.h" #include "dca_syncwords.h"
#include "libavutil/mem.h" #include "libavutil/mem.h"
static int dca_core_filter(AVBSFContext *ctx, AVPacket *out) static int dca_core_filter(AVBSFContext *ctx, AVPacket *pkt)
{ {
AVPacket *in;
GetByteContext gb; GetByteContext gb;
uint32_t syncword; uint32_t syncword;
int core_size = 0, ret; int core_size = 0, ret;
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;
bytestream2_init(&gb, in->data, in->size); bytestream2_init(&gb, pkt->data, pkt->size);
syncword = bytestream2_get_be32(&gb); syncword = bytestream2_get_be32(&gb);
bytestream2_skip(&gb, 1); bytestream2_skip(&gb, 1);
@@ -45,11 +44,8 @@ static int dca_core_filter(AVBSFContext *ctx, AVPacket *out)
break; break;
} }
av_packet_move_ref(out, in); if (core_size > 0 && core_size <= pkt->size) {
av_packet_free(&in); pkt->size = core_size;
if (core_size > 0 && core_size <= out->size) {
out->size = core_size;
} }
return 0; return 0;