[FFmpeg-devel] [PATCH] MLP/TrueHD decoder
Aurelien Jacobs
aurel
Sat Nov 3 01:02:51 CET 2007
On Sat, 3 Nov 2007 00:49:21 +0100
Michael Niedermayer <michaelni at gmx.at> wrote:
> > +/** Write the audio data into the output buffer.
> > + */
> > +
> > +static int output_data(MLPDecodeContext *m, unsigned int substr)
> > +{
> > + unsigned int i, ch;
> > + int32_t sample;
> > + int16_t *sample_buf16 = (int16_t*)(m->out_buf + m->bytes_output);
> > +
> > +#ifdef CONFIG_AUDIO_NONSHORT
> > + int32_t *sample_buf32 = (int32_t*)(m->out_buf + m->bytes_output);
> > +
> > + if (m->avctx->sample_fmt == SAMPLE_FMT_S32) {
> > + for (i = 0; i < m->blockpos[substr]; i++) {
> > + for (ch = 0; ch <= m->max_channel[substr]; ch++) {
> > + sample = m->sample_buffer[i][ch] << m->output_shift[substr][ch];
> > + m->lossless_check_data[substr] ^= (sample & 0xffffff) << ch;
> > + *sample_buf32++ = sample << 8;
> > + m->bytes_output += 4;
> > + }
> > + }
> > + } else
> > +#endif
> > + {
> > + for (i = 0; i < m->blockpos[substr]; i++) {
> > + for (ch = 0; ch <= m->max_channel[substr]; ch++) {
> > + sample = m->sample_buffer[i][ch] << m->output_shift[substr][ch];
> > + m->lossless_check_data[substr] ^= (sample & 0xffffff) << ch;
> > + *sample_buf16++ = (sample) >> 8;
> > + m->bytes_output += 2;
> > + }
> > + }
> > + }
> > +
> > + return 0;
> > +}
>
>
> static inline void output_data_internal(MLPDecodeContext *m, unsigned int substr, int is32)
> {
> unsigned int i, ch;
> for (i = 0; i < m->blockpos[substr]; i++) {
> for (ch = 0; ch <= m->max_channel[substr]; ch++) {
> int sample = m->sample_buffer[i][ch] << m->output_shift[substr][ch];
> m->lossless_check_data[substr] ^= (sample & 0xffffff) << ch;
> if(is32) *((int32_t*)m->out_ptr)++ = sample << 8;
> else *((int16_t*)m->out_ptr)++ = sample >> 8;
> }
> }
> }
>
> static void output_data_internal(MLPDecodeContext *m, unsigned int substr)
> {
> if(m->avctx->sample_fmt == SAMPLE_FMT_S32) output_data_internal(m, substr, 1);
> else output_data_internal(m, substr, 0);
> }
I'm astonished you didn't proposed directly this simpler form:
static void output_data(MLPDecodeContext *m, unsigned int substr)
{
output_data_internal(m, substr, m->avctx->sample_fmt == SAMPLE_FMT_S32);
}
Aurel
More information about the ffmpeg-devel
mailing list