[MPlayer-dev-eng] [PATCH 3/9] ad_libmad: Use BE sample format on big endian architectures

Hans-Christian Egtvedt hans-christian.egtvedt at atmel.com
Tue Feb 17 11:12:17 CET 2009


On Mon, 16 Feb 2009 17:39:15 +0100
Reimar Döffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de> wrote:

> On Mon, Feb 16, 2009 at 05:16:52PM +0100, Hans-Christian Egtvedt
> wrote:
> > Signed-off-by: Hans-Christian Egtvedt
> > <hans-christian.egtvedt at atmel.com> ---
> >  libmpcodecs/ad_libmad.c |    5 +++++
> >  1 files changed, 5 insertions(+), 0 deletions(-)
> > 
> > diff --git a/libmpcodecs/ad_libmad.c b/libmpcodecs/ad_libmad.c
> > index 076359a..51b77fe 100644
> > --- a/libmpcodecs/ad_libmad.c
> > +++ b/libmpcodecs/ad_libmad.c
> > @@ -86,6 +86,11 @@ static int init(sh_audio_t *sh){
> >    sh->channels=(this->frame.header.mode ==
> > MAD_MODE_SINGLE_CHANNEL) ? 1 : 2;
> > sh->samplerate=this->frame.header.samplerate;
> > sh->i_bps=this->frame.header.bitrate/8; +#ifdef WORDS_BIGENDIAN
> > +  sh->sample_format = AF_FORMAT_S16_BE;
> > +#else
> > +  sh->sample_format = AF_FORMAT_S16_LE;
> > +#endif
> >    sh->samplesize=2;
> 
> Weird, why has that worked so far (I am not aware of any complaints)?
> Also, for avoiding such ugly ifdefs is what AF_FORMAT_S16_NE is there
> for.
>

It works without, but IMHO it is more optimized for the architecture
to match the memory model. So perhaps changing it to AF_FORMAT_S16_NE is
the most appropriate.

Although some sound devices support byte swapping in hardware, so the
gain may not be relative for all. Comments?

-- 
Best regards,
Hans-Christian Egtvedt



More information about the MPlayer-dev-eng mailing list