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:
@@ -1038,15 +1038,27 @@ static void fill_noise_buffer(MLPDecodeContext *m, unsigned int substr)
|
|||||||
s->noisegen_seed = seed;
|
s->noisegen_seed = seed;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** Write the audio data into the output buffer. */
|
||||||
|
|
||||||
/** Apply the channel matrices in turn to reconstruct the original audio
|
static int output_data(MLPDecodeContext *m, unsigned int substr,
|
||||||
* samples. */
|
AVFrame *frame, int *got_frame_ptr)
|
||||||
|
|
||||||
static void rematrix_channels(MLPDecodeContext *m, unsigned int substr)
|
|
||||||
{
|
{
|
||||||
|
AVCodecContext *avctx = m->avctx;
|
||||||
SubStream *s = &m->substream[substr];
|
SubStream *s = &m->substream[substr];
|
||||||
unsigned int mat;
|
unsigned int mat;
|
||||||
unsigned int maxchan;
|
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;
|
maxchan = s->max_matrix_channel;
|
||||||
if (!s->noise_type) {
|
if (!s->noise_type) {
|
||||||
@@ -1056,6 +1068,8 @@ static void rematrix_channels(MLPDecodeContext *m, unsigned int substr)
|
|||||||
fill_noise_buffer(m, 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++) {
|
for (mat = 0; mat < s->num_primitive_matrices; mat++) {
|
||||||
unsigned int dest_ch = s->matrix_out_ch[mat];
|
unsigned int dest_ch = s->matrix_out_ch[mat];
|
||||||
m->dsp.mlp_rematrix_channel(&m->sample_buffer[0][0],
|
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,
|
m->access_unit_size_pow2,
|
||||||
MSB_MASK(s->quant_step_size[dest_ch]));
|
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 */
|
/* get output buffer */
|
||||||
frame->nb_samples = s->blockpos;
|
frame->nb_samples = s->blockpos;
|
||||||
@@ -1298,8 +1291,6 @@ next_substr:
|
|||||||
buf += substream_data_len[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)
|
if ((ret = output_data(m, m->max_decoded_substream, data, got_frame_ptr)) < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user