You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
avcodec/ra144enc: 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:
@@ -30,6 +30,7 @@
|
|||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
#include "audio_frame_queue.h"
|
#include "audio_frame_queue.h"
|
||||||
#include "celp_filters.h"
|
#include "celp_filters.h"
|
||||||
|
#include "encode.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
#include "mathops.h"
|
#include "mathops.h"
|
||||||
#include "put_bits.h"
|
#include "put_bits.h"
|
||||||
@@ -444,7 +445,7 @@ static int ra144_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
|||||||
if (ractx->last_frame)
|
if (ractx->last_frame)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if ((ret = ff_alloc_packet2(avctx, avpkt, FRAME_SIZE, 0)) < 0)
|
if ((ret = ff_get_encode_buffer(avctx, avpkt, FRAME_SIZE, 0)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -533,7 +534,6 @@ static int ra144_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
|||||||
ff_af_queue_remove(&ractx->afq, avctx->frame_size, &avpkt->pts,
|
ff_af_queue_remove(&ractx->afq, avctx->frame_size, &avpkt->pts,
|
||||||
&avpkt->duration);
|
&avpkt->duration);
|
||||||
|
|
||||||
avpkt->size = FRAME_SIZE;
|
|
||||||
*got_packet_ptr = 1;
|
*got_packet_ptr = 1;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
@@ -544,11 +544,12 @@ const AVCodec ff_ra_144_encoder = {
|
|||||||
.long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K)"),
|
.long_name = NULL_IF_CONFIG_SMALL("RealAudio 1.0 (14.4K)"),
|
||||||
.type = AVMEDIA_TYPE_AUDIO,
|
.type = AVMEDIA_TYPE_AUDIO,
|
||||||
.id = AV_CODEC_ID_RA_144,
|
.id = AV_CODEC_ID_RA_144,
|
||||||
|
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY |
|
||||||
|
AV_CODEC_CAP_SMALL_LAST_FRAME,
|
||||||
.priv_data_size = sizeof(RA144Context),
|
.priv_data_size = sizeof(RA144Context),
|
||||||
.init = ra144_encode_init,
|
.init = ra144_encode_init,
|
||||||
.encode2 = ra144_encode_frame,
|
.encode2 = ra144_encode_frame,
|
||||||
.close = ra144_encode_close,
|
.close = ra144_encode_close,
|
||||||
.capabilities = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_SMALL_LAST_FRAME,
|
|
||||||
.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16,
|
.sample_fmts = (const enum AVSampleFormat[]){ AV_SAMPLE_FMT_S16,
|
||||||
AV_SAMPLE_FMT_NONE },
|
AV_SAMPLE_FMT_NONE },
|
||||||
.supported_samplerates = (const int[]){ 8000, 0 },
|
.supported_samplerates = (const int[]){ 8000, 0 },
|
||||||
|
Reference in New Issue
Block a user