dcaenc: switch to encode2()

Signed-off-by: Paul B Mahol <onemda@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Paul B Mahol 2012-03-22 19:27:19 +00:00 committed by Michael Niedermayer
parent ffa28da180
commit b1a0d694ea
1 changed files with 14 additions and 7 deletions

View File

@ -26,6 +26,7 @@
#include "libavutil/audioconvert.h"
#include "avcodec.h"
#include "get_bits.h"
#include "internal.h"
#include "put_bits.h"
#include "dcaenc.h"
#include "dcadata.h"
@ -488,14 +489,18 @@ static void put_frame(DCAContext *c,
flush_put_bits(&c->pb);
}
static int encode_frame(AVCodecContext *avctx, uint8_t *frame,
int buf_size, void *data)
static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
const AVFrame *frame, int *got_packet_ptr)
{
int i, k, channel;
DCAContext *c = avctx->priv_data;
int16_t *samples = data;
int real_channel = 0;
const int16_t *samples;
int ret, real_channel = 0;
if ((ret = ff_alloc_packet2(avctx, avpkt, DCA_MAX_FRAME_SIZE + DCA_HEADER_SIZE)))
return ret;
samples = (const int16_t *)frame->data[0];
for (i = 0; i < PCM_SAMPLES; i ++) { /* i is the decimated sample number */
for (channel = 0; channel < c->prim_channels + 1; channel++) {
/* Get 32 PCM samples */
@ -518,9 +523,11 @@ static int encode_frame(AVCodecContext *avctx, uint8_t *frame,
}
}
put_frame(c, c->subband, frame);
put_frame(c, c->subband, avpkt->data);
return c->frame_size;
avpkt->size = c->frame_size;
*got_packet_ptr = 1;
return 0;
}
static int encode_init(AVCodecContext *avctx)
@ -580,7 +587,7 @@ AVCodec ff_dca_encoder = {
.id = CODEC_ID_DTS,
.priv_data_size = sizeof(DCAContext),
.init = encode_init,
.encode = encode_frame,
.encode2 = encode_frame,
.capabilities = CODEC_CAP_EXPERIMENTAL,
.sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"),