mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2024-12-28 10:22:10 +00:00
avcodec/pcm: Allow user-supplied buffers
Trivial for encoders that know the size of the output packet in advance. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
parent
3e6dcf0b1a
commit
0788069cb1
@ -30,6 +30,7 @@
|
||||
#include "libavutil/thread.h"
|
||||
#include "avcodec.h"
|
||||
#include "bytestream.h"
|
||||
#include "encode.h"
|
||||
#include "internal.h"
|
||||
#include "mathops.h"
|
||||
#include "pcm_tablegen.h"
|
||||
@ -106,7 +107,7 @@ static int pcm_encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
||||
n = frame->nb_samples * avctx->channels;
|
||||
samples = (const short *)frame->data[0];
|
||||
|
||||
if ((ret = ff_alloc_packet2(avctx, avpkt, n * sample_size, n * sample_size)) < 0)
|
||||
if ((ret = ff_get_encode_buffer(avctx, avpkt, n * sample_size, 0)) < 0)
|
||||
return ret;
|
||||
dst = avpkt->data;
|
||||
|
||||
@ -555,9 +556,9 @@ const AVCodec ff_ ## name_ ## _encoder = { \
|
||||
.long_name = NULL_IF_CONFIG_SMALL(long_name_), \
|
||||
.type = AVMEDIA_TYPE_AUDIO, \
|
||||
.id = AV_CODEC_ID_ ## id_, \
|
||||
.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_VARIABLE_FRAME_SIZE, \
|
||||
.init = pcm_encode_init, \
|
||||
.encode2 = pcm_encode_frame, \
|
||||
.capabilities = AV_CODEC_CAP_VARIABLE_FRAME_SIZE, \
|
||||
.sample_fmts = (const enum AVSampleFormat[]){ sample_fmt_, \
|
||||
AV_SAMPLE_FMT_NONE }, \
|
||||
.caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, \
|
||||
|
Loading…
Reference in New Issue
Block a user