1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-11-21 10:55:51 +02:00

mlpdec: move rematrix_channels code to output_data()

Reviewed-by: Michael Niedermayer <michaelni@gmx.at>
Signed-off-by: James Almer <jamrial@gmail.com>
This commit is contained in:
James Almer 2014-09-30 15:12:10 -03:00
parent 5c378d6a6d
commit ddb813b0ef

View File

@ -1038,15 +1038,27 @@ static void fill_noise_buffer(MLPDecodeContext *m, unsigned int substr)
s->noisegen_seed = seed;
}
/** Write the audio data into the output buffer. */
/** Apply the channel matrices in turn to reconstruct the original audio
* samples. */
static void rematrix_channels(MLPDecodeContext *m, unsigned int substr)
static int output_data(MLPDecodeContext *m, unsigned int substr,
AVFrame *frame, int *got_frame_ptr)
{
AVCodecContext *avctx = m->avctx;
SubStream *s = &m->substream[substr];
unsigned int mat;
unsigned int maxchan;
int ret;
int is32 = (m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);
if (m->avctx->channels != s->max_matrix_channel + 1) {
av_log(m->avctx, AV_LOG_ERROR, "channel count mismatch\n");
return AVERROR_INVALIDDATA;
}
if (!s->blockpos) {
av_log(avctx, AV_LOG_ERROR, "No samples to output.\n");
return AVERROR_INVALIDDATA;
}
maxchan = s->max_matrix_channel;
if (!s->noise_type) {
@ -1056,6 +1068,8 @@ static void rematrix_channels(MLPDecodeContext *m, unsigned int substr)
fill_noise_buffer(m, substr);
}
/* Apply the channel matrices in turn to reconstruct the original audio
* samples. */
for (mat = 0; mat < s->num_primitive_matrices; mat++) {
unsigned int dest_ch = s->matrix_out_ch[mat];
m->dsp.mlp_rematrix_channel(&m->sample_buffer[0][0],
@ -1070,27 +1084,6 @@ static void rematrix_channels(MLPDecodeContext *m, unsigned int substr)
m->access_unit_size_pow2,
MSB_MASK(s->quant_step_size[dest_ch]));
}
}
/** Write the audio data into the output buffer. */
static int output_data(MLPDecodeContext *m, unsigned int substr,
AVFrame *frame, int *got_frame_ptr)
{
AVCodecContext *avctx = m->avctx;
SubStream *s = &m->substream[substr];
int ret;
int is32 = (m->avctx->sample_fmt == AV_SAMPLE_FMT_S32);
if (m->avctx->channels != s->max_matrix_channel + 1) {
av_log(m->avctx, AV_LOG_ERROR, "channel count mismatch\n");
return AVERROR_INVALIDDATA;
}
if (!s->blockpos) {
av_log(avctx, AV_LOG_ERROR, "No samples to output.\n");
return AVERROR_INVALIDDATA;
}
/* get output buffer */
frame->nb_samples = s->blockpos;
@ -1298,8 +1291,6 @@ next_substr:
buf += substream_data_len[substr];
}
rematrix_channels(m, m->max_decoded_substream);
if ((ret = output_data(m, m->max_decoded_substream, data, got_frame_ptr)) < 0)
return ret;