summaryrefslogtreecommitdiff
path: root/libavcodec/cook.c
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-10-02 16:25:58 +0200
committerMichael Niedermayer <michaelni@gmx.at>2012-10-02 17:27:52 +0200
commite88ca80dc325a0291c64e1dd3245c4943397cfa3 (patch)
treedf8abbc8d6defc5bf10932ed096ec18cd979d0eb /libavcodec/cook.c
parent82db8ee3211014a38db6b8cae03f1c3246938eee (diff)
parentbfcd4b6a1691d20aebc6d2308424c2a88334a9f0 (diff)
Merge commit 'bfcd4b6a1691d20aebc6d2308424c2a88334a9f0'
* commit 'bfcd4b6a1691d20aebc6d2308424c2a88334a9f0': adpcmdec: set AVCodec.sample_fmts twinvq: use planar sample format ralf: use planar sample format mpc7/8: use planar sample format iac/imc: use planar sample format dcadec: use float planar sample format cook: use planar sample format atrac3: use float planar sample format apedec: output in planar sample format 8svx: use planar sample format Conflicts: libavcodec/8svx.c libavcodec/dcadec.c libavcodec/mpc7.c libavcodec/mpc8.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/cook.c')
-rw-r--r--libavcodec/cook.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/libavcodec/cook.c b/libavcodec/cook.c
index cca97e3046..b4d1a37ca1 100644
--- a/libavcodec/cook.c
+++ b/libavcodec/cook.c
@@ -119,9 +119,10 @@ typedef struct cook {
void (*interpolate)(struct cook *q, float *buffer,
int gain_index, int gain_index_next);
- void (*saturate_output)(struct cook *q, int chan, float *out);
+ void (*saturate_output)(struct cook *q, float *out);
AVCodecContext* avctx;
+ DSPContext dsp;
AVFrame frame;
GetBitContext gb;
/* stream data */
@@ -887,18 +888,15 @@ static inline void decode_bytes_and_gain(COOKContext *q, COOKSubpacket *p,
* Saturate the output signal and interleave.
*
* @param q pointer to the COOKContext
- * @param chan channel to saturate
* @param out pointer to the output vector
*/
-static void saturate_output_float(COOKContext *q, int chan, float *out)
+static void saturate_output_float(COOKContext *q, float *out)
{
- int j;
- float *output = q->mono_mdct_output + q->samples_per_channel;
- for (j = 0; j < q->samples_per_channel; j++) {
- out[chan + q->nb_channels * j] = av_clipf(output[j], -1.0, 1.0);
- }
+ q->dsp.vector_clipf(out, q->mono_mdct_output + q->samples_per_channel,
+ -1.0f, 1.0f, FFALIGN(q->samples_per_channel, 8));
}
+
/**
* Final part of subpacket decoding:
* Apply modulated lapped transform, gain compensation,
@@ -909,15 +907,14 @@ static void saturate_output_float(COOKContext *q, int chan, float *out)
* @param gains_ptr array of current/prev gain pointers
* @param previous_buffer pointer to the previous buffer to be used for overlapping
* @param out pointer to the output buffer
- * @param chan 0: left or single channel, 1: right channel
*/
static inline void mlt_compensate_output(COOKContext *q, float *decode_buffer,
cook_gains *gains_ptr, float *previous_buffer,
- float *out, int chan)
+ float *out)
{
imlt_gain(q, decode_buffer, gains_ptr, previous_buffer);
if (out)
- q->saturate_output(q, chan, out);
+ q->saturate_output(q, out);
}
@@ -930,7 +927,7 @@ static inline void mlt_compensate_output(COOKContext *q, float *decode_buffer,
* @param outbuffer pointer to the outbuffer
*/
static int decode_subpacket(COOKContext *q, COOKSubpacket *p,
- const uint8_t *inbuffer, float *outbuffer)
+ const uint8_t *inbuffer, float **outbuffer)
{
int sub_packet_size = p->size;
int res;
@@ -953,15 +950,18 @@ static int decode_subpacket(COOKContext *q, COOKSubpacket *p,
}
mlt_compensate_output(q, q->decode_buffer_1, &p->gains1,
- p->mono_previous_buffer1, outbuffer, p->ch_idx);
+ p->mono_previous_buffer1,
+ outbuffer ? outbuffer[p->ch_idx] : NULL);
if (p->num_channels == 2)
if (p->joint_stereo)
mlt_compensate_output(q, q->decode_buffer_2, &p->gains1,
- p->mono_previous_buffer2, outbuffer, p->ch_idx + 1);
+ p->mono_previous_buffer2,
+ outbuffer ? outbuffer[p->ch_idx + 1] : NULL);
else
mlt_compensate_output(q, q->decode_buffer_2, &p->gains2,
- p->mono_previous_buffer2, outbuffer, p->ch_idx + 1);
+ p->mono_previous_buffer2,
+ outbuffer ? outbuffer[p->ch_idx + 1] : NULL);
return 0;
}
@@ -978,7 +978,7 @@ static int cook_decode_frame(AVCodecContext *avctx, void *data,
const uint8_t *buf = avpkt->data;
int buf_size = avpkt->size;
COOKContext *q = avctx->priv_data;
- float *samples = NULL;
+ float **samples = NULL;
int i, ret;
int offset = 0;
int chidx = 0;
@@ -993,7 +993,7 @@ static int cook_decode_frame(AVCodecContext *avctx, void *data,
av_log(avctx, AV_LOG_ERROR, "get_buffer() failed\n");
return ret;
}
- samples = (float *) q->frame.data[0];
+ samples = (float **)q->frame.extended_data;
}
/* estimate subpacket sizes */
@@ -1110,6 +1110,8 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
/* Initialize RNG. */
av_lfg_init(&q->random_state, 0);
+ ff_dsputil_init(&q->dsp, avctx);
+
while (edata_ptr < edata_ptr_end) {
/* 8 for mono, 16 for stereo, ? for multichannel
Swap to right endianness so we don't need to care later on. */
@@ -1290,7 +1292,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
return AVERROR_PATCHWELCOME;
}
- avctx->sample_fmt = AV_SAMPLE_FMT_FLT;
+ avctx->sample_fmt = AV_SAMPLE_FMT_FLTP;
if (channel_mask)
avctx->channel_layout = channel_mask;
else
@@ -1315,4 +1317,6 @@ AVCodec ff_cook_decoder = {
.decode = cook_decode_frame,
.capabilities = CODEC_CAP_DR1,
.long_name = NULL_IF_CONFIG_SMALL("Cook / Cooker / Gecko (RealAudio G2)"),
+ .sample_fmts = (const enum AVSampleFormat[]) { AV_SAMPLE_FMT_FLTP,
+ AV_SAMPLE_FMT_NONE },
};