diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2011-12-03 05:08:55 +0400 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2011-12-03 06:00:30 +0400 |
commit | e4de71677f3adeac0f74b89ac8df5d417364df2c (patch) | |
tree | 4792dd8d85d24f0f4eaddabb65f6044727907daa /libavcodec/cook.c | |
parent | 12804348f5babf56a315fa01751eea1ffdddf98a (diff) | |
parent | d268b79e3436107c11ee8bcdf9f3645368bb3fcd (diff) |
Merge remote-tracking branch 'qatar/master'
* qatar/master:
aac_latm: reconfigure decoder on audio specific config changes
latmdec: fix audio specific config parsing
Add avcodec_decode_audio4().
avcodec: change number of plane pointers from 4 to 8 at next major bump.
Update developers documentation with coding conventions.
svq1dec: avoid undefined get_bits(0) call
ARM: h264dsp_neon cosmetics
ARM: make some NEON macros reusable
Do not memcpy raw video frames when using null muxer
fate: update asf seektest
vp8: flush buffers on size changes.
doc: improve general documentation for MacOSX
asf: use packet dts as approximation of pts
asf: do not call av_read_frame
rtsp: Initialize the media_type_mask in the rtp guessing demuxer
Cleaned up alacenc.c
Conflicts:
doc/APIchanges
doc/developer.texi
libavcodec/8svx.c
libavcodec/aacdec.c
libavcodec/ac3dec.c
libavcodec/avcodec.h
libavcodec/nellymoserdec.c
libavcodec/tta.c
libavcodec/utils.c
libavcodec/version.h
libavcodec/wmadec.c
libavformat/asfdec.c
tests/ref/seek/lavf_asf
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/cook.c')
-rw-r--r-- | libavcodec/cook.c | 43 |
1 files changed, 30 insertions, 13 deletions
diff --git a/libavcodec/cook.c b/libavcodec/cook.c index 6a076d9310..b285f88a15 100644 --- a/libavcodec/cook.c +++ b/libavcodec/cook.c @@ -122,6 +122,7 @@ typedef struct cook { void (* saturate_output) (struct cook *q, int chan, float *out); AVCodecContext* avctx; + AVFrame frame; GetBitContext gb; /* stream data */ int nb_channels; @@ -131,6 +132,7 @@ typedef struct cook { int samples_per_channel; /* states */ AVLFG random_state; + int discarded_packets; /* transform data */ FFTContext mdct_ctx; @@ -896,7 +898,8 @@ mlt_compensate_output(COOKContext *q, float *decode_buffer, float *out, int chan) { imlt_gain(q, decode_buffer, gains_ptr, previous_buffer); - q->saturate_output (q, chan, out); + if (out) + q->saturate_output(q, chan, out); } @@ -953,24 +956,28 @@ static void decode_subpacket(COOKContext *q, COOKSubpacket *p, * @param avctx pointer to the AVCodecContext */ -static int cook_decode_frame(AVCodecContext *avctx, - void *data, int *data_size, - AVPacket *avpkt) { +static int cook_decode_frame(AVCodecContext *avctx, void *data, + int *got_frame_ptr, AVPacket *avpkt) +{ const uint8_t *buf = avpkt->data; int buf_size = avpkt->size; COOKContext *q = avctx->priv_data; - int i, out_size; + float *samples = NULL; + int i, ret; int offset = 0; int chidx = 0; if (buf_size < avctx->block_align) return buf_size; - out_size = q->nb_channels * q->samples_per_channel * - av_get_bytes_per_sample(avctx->sample_fmt); - if (*data_size < out_size) { - av_log(avctx, AV_LOG_ERROR, "Output buffer is too small\n"); - return AVERROR(EINVAL); + /* get output buffer */ + if (q->discarded_packets >= 2) { + q->frame.nb_samples = q->samples_per_channel; + if ((ret = avctx->get_buffer(avctx, &q->frame)) < 0) { + av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n"); + return ret; + } + samples = (float *)q->frame.data[0]; } /* estimate subpacket sizes */ @@ -990,15 +997,21 @@ static int cook_decode_frame(AVCodecContext *avctx, q->subpacket[i].bits_per_subpacket = (q->subpacket[i].size*8)>>q->subpacket[i].bits_per_subpdiv; q->subpacket[i].ch_idx = chidx; av_log(avctx,AV_LOG_DEBUG,"subpacket[%i] size %i js %i %i block_align %i\n",i,q->subpacket[i].size,q->subpacket[i].joint_stereo,offset,avctx->block_align); - decode_subpacket(q, &q->subpacket[i], buf + offset, data); + decode_subpacket(q, &q->subpacket[i], buf + offset, samples); offset += q->subpacket[i].size; chidx += q->subpacket[i].num_channels; av_log(avctx,AV_LOG_DEBUG,"subpacket[%i] %i %i\n",i,q->subpacket[i].size * 8,get_bits_count(&q->gb)); } - *data_size = out_size; /* Discard the first two frames: no valid audio. */ - if (avctx->frame_number < 2) *data_size = 0; + if (q->discarded_packets < 2) { + q->discarded_packets++; + *got_frame_ptr = 0; + return avctx->block_align; + } + + *got_frame_ptr = 1; + *(AVFrame *)data = q->frame; return avctx->block_align; } @@ -1246,6 +1259,9 @@ static av_cold int cook_decode_init(AVCodecContext *avctx) else avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO; + avcodec_get_frame_defaults(&q->frame); + avctx->coded_frame = &q->frame; + #ifdef DEBUG dump_cook_context(q); #endif @@ -1262,5 +1278,6 @@ AVCodec ff_cook_decoder = .init = cook_decode_init, .close = cook_decode_close, .decode = cook_decode_frame, + .capabilities = CODEC_CAP_DR1, .long_name = NULL_IF_CONFIG_SMALL("COOK"), }; |