[MPlayer-dev-eng] [PATCH] bigendian fix for hwac3

Ulion ulion2002 at gmail.com
Thu Sep 13 19:16:01 CEST 2007


2007/9/13, Reimar Döffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de>:
> Hello,
> On Thu, Sep 13, 2007 at 09:01:43PM +0800, Ulion wrote:
> [...]
> > Although you are right, I think we should try to figure out a way to
> > swap by output stream's format flag. We should use machine byte-order
> > only if there's no way to get the output stream's format.
> >
> > Or we should always output little endian bytes from hwac3, and swap
> > bytes in ao modules if needed?
> >
> > Or introduce a hwac3_be afm or a parameter for hwac3 to decide output byteorder?
>
> The right way would be to combine AF_FORMAT_AC3 with either AF_FORMAT_LE
> or AF_FORMAT_BE as it is done for all other formats, but that is of
> course a solution with a bit more effort.
>

Yes, I also consider using AF_FORMAT_AC3 with AF_FORMAT_LE or AF_FORMAT_BE flag.

Current hwac3's behavior is always output LE stream on LE compile, and
BE stream on BE compile, but both marked as stream_format
AF_FORMAT_AC3. So all ao modules have to assume byte-order of
AF_FORMAT_AC3 input stream is same with the compiled byte-order.
We can continue use this assumption, just take good care of the
situation that compile byte-order not same with output stream format
(on LE machine has only BE output stream for AC3 or reversed). In that
case, ao module should fix the byte-order itself.

If we want to prevent byte-swap twice both in hwac3 and ao module and
place all byte-swap code in one place (hwac3), we have to make hwac3
known accurate byte-order of the output stream. That mean ao module
may set LE/BE format flag to the sh_audio_t so hwac3 can known the
accurate byte-order output needed. But this cause a bit more
modifications, because currently the stream_format always set as
AF_FORMAT_AC3 which is a BE format so most modules need to set an
AF_FORMAT_LE flag back to the stream_format since they are almost
using LE output stream.

So, shall we keep the original assumption, LE machine has default LE
AC3/DTS stream outputed into ao module, and BE machine has default BE
output? That's exactly what our patches posted did.

As your native word version, there's little problem:
> -    buf[6] = (len << 3) & 0xFF;
> -    buf[7] = (len >> 5) & 0xFF;
> +    buf16[3] = len << 3;
Which probably should be more complex such like:
    buf16[3] = ((len << 3) & 0xFF00) | (len & 0x3F);

I will test it further later. Or just using the bswap_16 or swab version.

-- 
Ulion



More information about the MPlayer-dev-eng mailing list