Commit ddb813b0 authored by James Almer's avatar James Almer

mlpdec: move rematrix_channels code to output_data()

Reviewed-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
Signed-off-by: 's avatarJames Almer <jamrial@gmail.com>
parent 5c378d6a
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment