mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2025-03-25 04:19:05 +00:00
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>
This commit is contained in:
parent
ad232c6833
commit
9e9836424b
@ -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,
|
||||
|
Loading…
Reference in New Issue
Block a user