---
libavcodec/cook.c | 40 ++++++++++++++++++++++------------------
1 files changed, 22 insertions(+), 18 deletions(-)
diff --git a/libavcodec/cook.c b/libavcodec/cook.c
index 0e7c497..2c4b3bf 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 */
@@ -878,18 +879,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,
@@ -900,15 +898,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);
}
@@ -921,7 +918,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;
@@ -947,15 +944,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;
}
@@ -972,7 +972,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;
@@ -987,7 +987,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 */
@@ -1104,6 +1104,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. */
@@ -1279,7 +1281,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
@@ -1304,4 +1306,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 },
};
--
1.7.1
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel