[FFmpeg-cvslog] avcodec/aptxenc: Avoid copying packet data, allow user-supplied buffers
Andreas Rheinhardt
git at videolan.org
Wed May 5 15:37:43 EEST 2021
ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at outlook.com> | Sun Apr 25 01:43:26 2021 +0200| [9e9836424b63ee096fd715a2479066daff8dfa01] | committer: Andreas Rheinhardt
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 at outlook.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=9e9836424b63ee096fd715a2479066daff8dfa01
---
libavcodec/aptxenc.c | 7 ++++---
1 file 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,
More information about the ffmpeg-cvslog
mailing list