mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-04-14 00:58:38 +02:00
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:
parent
ffa28da180
commit
b1a0d694ea
@ -26,6 +26,7 @@
|
|||||||
#include "libavutil/audioconvert.h"
|
#include "libavutil/audioconvert.h"
|
||||||
#include "avcodec.h"
|
#include "avcodec.h"
|
||||||
#include "get_bits.h"
|
#include "get_bits.h"
|
||||||
|
#include "internal.h"
|
||||||
#include "put_bits.h"
|
#include "put_bits.h"
|
||||||
#include "dcaenc.h"
|
#include "dcaenc.h"
|
||||||
#include "dcadata.h"
|
#include "dcadata.h"
|
||||||
@ -488,14 +489,18 @@ static void put_frame(DCAContext *c,
|
|||||||
flush_put_bits(&c->pb);
|
flush_put_bits(&c->pb);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int encode_frame(AVCodecContext *avctx, uint8_t *frame,
|
static int encode_frame(AVCodecContext *avctx, AVPacket *avpkt,
|
||||||
int buf_size, void *data)
|
const AVFrame *frame, int *got_packet_ptr)
|
||||||
{
|
{
|
||||||
int i, k, channel;
|
int i, k, channel;
|
||||||
DCAContext *c = avctx->priv_data;
|
DCAContext *c = avctx->priv_data;
|
||||||
int16_t *samples = data;
|
const int16_t *samples;
|
||||||
int real_channel = 0;
|
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 (i = 0; i < PCM_SAMPLES; i ++) { /* i is the decimated sample number */
|
||||||
for (channel = 0; channel < c->prim_channels + 1; channel++) {
|
for (channel = 0; channel < c->prim_channels + 1; channel++) {
|
||||||
/* Get 32 PCM samples */
|
/* 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)
|
static int encode_init(AVCodecContext *avctx)
|
||||||
@ -580,7 +587,7 @@ AVCodec ff_dca_encoder = {
|
|||||||
.id = CODEC_ID_DTS,
|
.id = CODEC_ID_DTS,
|
||||||
.priv_data_size = sizeof(DCAContext),
|
.priv_data_size = sizeof(DCAContext),
|
||||||
.init = encode_init,
|
.init = encode_init,
|
||||||
.encode = encode_frame,
|
.encode2 = encode_frame,
|
||||||
.capabilities = CODEC_CAP_EXPERIMENTAL,
|
.capabilities = CODEC_CAP_EXPERIMENTAL,
|
||||||
.sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
|
.sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
|
||||||
.long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"),
|
.long_name = NULL_IF_CONFIG_SMALL("DCA (DTS Coherent Acoustics)"),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user