diff options
author | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-04-25 01:43:26 +0200 |
---|---|---|
committer | Andreas Rheinhardt <andreas.rheinhardt@outlook.com> | 2021-05-05 12:28:51 +0200 |
commit | 9e9836424b63ee096fd715a2479066daff8dfa01 (patch) | |
tree | feca98f800e74384729c45623924595bc5b5ada6 | |
parent | ad232c6833d9f192324c9e99c19d1b4dd7852828 (diff) | |
download | ffmpeg-9e9836424b63ee096fd715a2479066daff8dfa01.tar.gz |
avcodec/aptxenc: Avoid copying packet data, allow user-supplied buffers
When the packet size is known in advance like here, one can avoid
an intermediate buffer for the packet data by using
ff_get_encode_buffer() and also set AV_CODEC_CAP_DR1 at the same time.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
-rw-r--r-- | libavcodec/aptxenc.c | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/libavcodec/aptxenc.c b/libavcodec/aptxenc.c index f432a123d0..733ebc42c3 100644 --- a/libavcodec/aptxenc.c +++ b/libavcodec/aptxenc.c @@ -21,6 +21,7 @@ */ #include "aptx.h" +#include "encode.h" /* * Half-band QMF analysis filter realized with a polyphase FIR filter. @@ -214,7 +215,7 @@ static int aptx_encode_frame(AVCodecContext *avctx, AVPacket *avpkt, return ret; output_size = s->block_size * frame->nb_samples/4; - if ((ret = ff_alloc_packet2(avctx, avpkt, output_size, 0)) < 0) + if ((ret = ff_get_encode_buffer(avctx, avpkt, output_size, 0)) < 0) return ret; for (pos = 0, ipos = 0; pos < output_size; pos += s->block_size, ipos += 4) { @@ -245,11 +246,11 @@ const AVCodec ff_aptx_encoder = { .long_name = NULL_IF_CONFIG_SMALL("aptX (Audio Processing Technology for Bluetooth)"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_APTX, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, .priv_data_size = sizeof(AptXContext), .init = ff_aptx_init, .encode2 = aptx_encode_frame, .close = aptx_close, - .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, .channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_STEREO, 0}, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S32P, @@ -264,11 +265,11 @@ const AVCodec ff_aptx_hd_encoder = { .long_name = NULL_IF_CONFIG_SMALL("aptX HD (Audio Processing Technology for Bluetooth)"), .type = AVMEDIA_TYPE_AUDIO, .id = AV_CODEC_ID_APTX_HD, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SMALL_LAST_FRAME, .priv_data_size = sizeof(AptXContext), .init = ff_aptx_init, .encode2 = aptx_encode_frame, .close = aptx_close, - .capabilities = AV_CODEC_CAP_SMALL_LAST_FRAME, .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, .channel_layouts = (const uint64_t[]) { AV_CH_LAYOUT_STEREO, 0}, .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_S32P, |