[FFmpeg-devel] [PATCH] MLP/TrueHD decoder

Michael Niedermayer michaelni
Sat Nov 3 01:24:06 CET 2007


Hi

On Sat, Nov 03, 2007 at 01:02:51AM +0100, Aurelien Jacobs wrote:
> 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);
> }

thats because we live in a world without a well written free compiler

gcc can optimize the check out of the inner loop with my suggestion but
not with yours, at least not last time i looked at what gcc generats for
such code

[...]

-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Those who are too smart to engage in politics are punished by being
governed by those who are dumber. -- Plato 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
URL: <http://lists.mplayerhq.hu/pipermail/ffmpeg-devel/attachments/20071103/98688aaa/attachment.pgp>



More information about the ffmpeg-devel mailing list