1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Merge commit 'e57daa876bf0cf50782550e366e589441cd8c2bd'

* commit 'e57daa876bf0cf50782550e366e589441cd8c2bd':
  adpcm: decode directly to the user-provided AVFrame
  ac3: decode directly to the user-provided AVFrame
  aac: decode directly to the user-provided AVFrame
  8svx: decode directly to the user-provided AVFrame

Conflicts:
	libavcodec/8svx.c
	libavcodec/ac3dec.c
	libavcodec/adpcm.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:
Michael Niedermayer 2013-02-13 11:18:55 +01:00
commit 4789955ec4
6 changed files with 29 additions and 44 deletions

View File

@ -44,7 +44,6 @@
/** decoder context */
typedef struct EightSvxContext {
AVFrame frame;
uint8_t fib_acc[2];
const int8_t *table;
@ -88,6 +87,7 @@ static int eightsvx_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
EightSvxContext *esc = avctx->priv_data;
AVFrame *frame = data;
int buf_size;
int ch, ret;
int hdr_size = 2;
@ -135,21 +135,20 @@ static int eightsvx_decode_frame(AVCodecContext *avctx, void *data,
}
/* get output buffer */
esc->frame.nb_samples = buf_size * 2;
if ((ret = ff_get_buffer(avctx, &esc->frame)) < 0) {
frame->nb_samples = buf_size * 2;
if ((ret = ff_get_buffer(avctx, frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
for (ch = 0; ch < avctx->channels; ch++) {
delta_decode(esc->frame.data[ch], &esc->data[ch][esc->data_idx],
delta_decode(frame->data[ch], &esc->data[ch][esc->data_idx],
buf_size, &esc->fib_acc[ch], esc->table);
}
esc->data_idx += buf_size;
*got_frame_ptr = 1;
*(AVFrame *)data = esc->frame;
*got_frame_ptr = 1;
return ((avctx->frame_number == 0)*hdr_size + buf_size)*avctx->channels;
}
@ -172,9 +171,6 @@ static av_cold int eightsvx_decode_init(AVCodecContext *avctx)
}
avctx->sample_fmt = AV_SAMPLE_FMT_U8P;
avcodec_get_frame_defaults(&esc->frame);
avctx->coded_frame = &esc->frame;
return 0;
}

View File

@ -265,7 +265,7 @@ typedef struct AACContext AACContext;
struct AACContext {
AVClass *class;
AVCodecContext *avctx;
AVFrame frame;
AVFrame *frame;
int is_saved; ///< Set if elements have stored overlap from previous frame.
DynamicRangeControl che_drc;

View File

@ -187,8 +187,8 @@ static int frame_configure_elements(AVCodecContext *avctx)
}
/* get output buffer */
ac->frame.nb_samples = 2048;
if ((ret = ff_get_buffer(avctx, &ac->frame)) < 0) {
ac->frame->nb_samples = 2048;
if ((ret = ff_get_buffer(avctx, ac->frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
@ -196,7 +196,7 @@ static int frame_configure_elements(AVCodecContext *avctx)
/* map output channel pointers to AVFrame data */
for (ch = 0; ch < avctx->channels; ch++) {
if (ac->output_element[ch])
ac->output_element[ch]->ret = (float *)ac->frame.extended_data[ch];
ac->output_element[ch]->ret = (float *)ac->frame->extended_data[ch];
}
return 0;
@ -964,9 +964,6 @@ static av_cold int aac_decode_init(AVCodecContext *avctx)
cbrt_tableinit();
avcodec_get_frame_defaults(&ac->frame);
avctx->coded_frame = &ac->frame;
return 0;
}
@ -2484,6 +2481,8 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
int samples = 0, multiplier, audio_found = 0, pce_found = 0;
int is_dmono, sce_count = 0;
ac->frame = data;
if (show_bits(gb, 12) == 0xfff) {
if (parse_adts_frame_header(ac, gb) < 0) {
av_log(avctx, AV_LOG_ERROR, "Error decoding AAC frame header.\n");
@ -2604,10 +2603,8 @@ static int aac_decode_frame_int(AVCodecContext *avctx, void *data,
is_dmono = ac->dmono_mode && sce_count == 2 &&
ac->oc[1].channel_layout == (AV_CH_FRONT_LEFT | AV_CH_FRONT_RIGHT);
if (samples) {
ac->frame.nb_samples = samples;
*(AVFrame *)data = ac->frame;
}
if (samples)
ac->frame->nb_samples = samples;
*got_frame_ptr = !!samples;
if (is_dmono) {

View File

@ -185,9 +185,6 @@ static av_cold int ac3_decode_init(AVCodecContext *avctx)
}
s->downmixed = 1;
avcodec_get_frame_defaults(&s->frame);
avctx->coded_frame = &s->frame;
for (i = 0; i < AC3_MAX_CHANNELS; i++) {
s->xcfptr[i] = s->transform_coeffs[i];
s->dlyptr[i] = s->delay[i];
@ -1267,6 +1264,7 @@ static int decode_audio_block(AC3DecodeContext *s, int blk)
static int ac3_decode_frame(AVCodecContext * avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
AC3DecodeContext *s = avctx->priv_data;
@ -1378,8 +1376,8 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
/* get output buffer */
avctx->channels = s->out_channels;
s->frame.nb_samples = s->num_blocks * 256;
if ((ret = ff_get_buffer(avctx, &s->frame)) < 0) {
frame->nb_samples = s->num_blocks * 256;
if ((ret = ff_get_buffer(avctx, frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
@ -1392,7 +1390,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
}
for (ch = 0; ch < s->channels; ch++) {
if (ch < s->out_channels)
s->outptr[channel_map[ch]] = (float *)s->frame.data[ch];
s->outptr[channel_map[ch]] = (float *)frame->data[ch];
}
for (blk = 0; blk < s->num_blocks; blk++) {
if (!err && decode_audio_block(s, blk)) {
@ -1401,7 +1399,7 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
}
if (err)
for (ch = 0; ch < s->out_channels; ch++)
memcpy(((float*)s->frame.data[ch]) + AC3_BLOCK_SIZE*blk, output[ch], 1024);
memcpy(((float*)frame->data[ch]) + AC3_BLOCK_SIZE*blk, output[ch], 1024);
for (ch = 0; ch < s->out_channels; ch++)
output[ch] = s->outptr[channel_map[ch]];
for (ch = 0; ch < s->out_channels; ch++) {
@ -1410,14 +1408,13 @@ static int ac3_decode_frame(AVCodecContext * avctx, void *data,
}
}
s->frame.decode_error_flags = err ? FF_DECODE_ERROR_INVALID_BITSTREAM : 0;
frame->decode_error_flags = err ? FF_DECODE_ERROR_INVALID_BITSTREAM : 0;
/* keep last block for error concealment in next frame */
for (ch = 0; ch < s->out_channels; ch++)
memcpy(s->output[ch], output[ch], 1024);
*got_frame_ptr = 1;
*(AVFrame *)data = s->frame;
*got_frame_ptr = 1;
return FFMIN(buf_size, s->frame_size);
}

View File

@ -69,7 +69,6 @@
typedef struct AC3DecodeContext {
AVClass *class; ///< class for AVOptions
AVCodecContext *avctx; ///< parent context
AVFrame frame; ///< AVFrame for decoded output
GetBitContext gbc; ///< bitstream reader
///@name Bit stream information

View File

@ -85,7 +85,6 @@ static const int swf_index_tables[4][16] = {
/* end of tables */
typedef struct ADPCMDecodeContext {
AVFrame frame;
ADPCMChannelStatus status[6];
int vqa_version; /**< VQA version. Used for ADPCM_IMA_WS */
} ADPCMDecodeContext;
@ -159,9 +158,6 @@ static av_cold int adpcm_decode_init(AVCodecContext * avctx)
avctx->sample_fmt = AV_SAMPLE_FMT_S16;
}
avcodec_get_frame_defaults(&c->frame);
avctx->coded_frame = &c->frame;
return 0;
}
@ -619,6 +615,7 @@ static int get_nb_samples(AVCodecContext *avctx, GetByteContext *gb,
static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
int *got_frame_ptr, AVPacket *avpkt)
{
AVFrame *frame = data;
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
ADPCMDecodeContext *c = avctx->priv_data;
@ -639,20 +636,20 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
}
/* get output buffer */
c->frame.nb_samples = nb_samples;
if ((ret = ff_get_buffer(avctx, &c->frame)) < 0) {
frame->nb_samples = nb_samples;
if ((ret = ff_get_buffer(avctx, frame)) < 0) {
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
samples = (short *)c->frame.data[0];
samples_p = (int16_t **)c->frame.extended_data;
samples = (short *)frame->data[0];
samples_p = (int16_t **)frame->extended_data;
/* use coded_samples when applicable */
/* it is always <= nb_samples, so the output buffer will be large enough */
if (coded_samples) {
if (coded_samples != nb_samples)
av_log(avctx, AV_LOG_WARNING, "mismatch in coded sample count\n");
c->frame.nb_samples = nb_samples = coded_samples;
frame->nb_samples = nb_samples = coded_samples;
}
st = avctx->channels == 2 ? 1 : 0;
@ -738,7 +735,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
}
for (i = 0; i < avctx->channels; i++) {
samples = (int16_t *)c->frame.data[i];
samples = (int16_t *)frame->data[i];
cs = &c->status[i];
for (n = nb_samples >> 1; n > 0; n--) {
int v = bytestream2_get_byteu(&gb);
@ -1135,7 +1132,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
}
}
c->frame.nb_samples = count * 28;
frame->nb_samples = count * 28;
bytestream2_seek(&gb, 0, SEEK_END);
break;
}
@ -1378,8 +1375,7 @@ static int adpcm_decode_frame(AVCodecContext *avctx, void *data,
return AVERROR_INVALIDDATA;
}
*got_frame_ptr = 1;
*(AVFrame *)data = c->frame;
*got_frame_ptr = 1;
return bytestream2_tell(&gb);
}