[MPlayer-dev-eng] [PATCH] bigendian fix for hwac3
Ulion
ulion2002 at gmail.com
Thu Sep 13 12:38:52 CEST 2007
2007/9/13, Reimar Döffinger <Reimar.Doeffinger at stud.uni-karlsruhe.de>:
> Hello,
> On Thu, Sep 13, 2007 at 09:53:15AM +0800, Ulion wrote:
> > Since my old patch last month mixed two features into one, I split it.
> >
> > Here's the patch to fix hwac3 to make it work on bigendian machines,
> > tested on PowerPC G5.
>
> I have some doubts about it, since I'd assume the right behaviour would depend
> on the endianness of the sound card and not that of the CPU...
Not sure, the old code in hwac3 use the macro WORDS_BIGENDIAN to
decide whether to swap bytes, so I continue using it. By now we can
only assume the audio device's byte-order is same with cpu's as the
old code did.
>
> > @@ -159,6 +159,17 @@
> > }
> > else if(isdts == 0)
> > {
> > +#ifdef WORDS_BIGENDIAN
> > + buf[0] = 0xF8;
> > + buf[1] = 0x72;
> > + buf[2] = 0x4E;
> > + buf[3] = 0x1F;
> > + buf[4] = 0x00;
> > + buf[5] = 0x01; //(length) ? data_type : 0; /* & 0x1F; */
> > + buf[6] = (len >> 5) & 0xFF;
> > + buf[7] = (len << 3) & 0xFF;
> > + memcpy(buf + 8, sh_audio->a_in_buffer, len);
> > +#else
> > buf[0] = 0x72;
> > buf[1] = 0xF8;
> > buf[2] = 0x1F;
> > @@ -167,9 +178,6 @@
> > buf[5] = 0x00;
> > buf[6] = (len << 3) & 0xFF;
> > buf[7] = (len >> 5) & 0xFF;
> > -#ifdef WORDS_BIGENDIAN
> > - memcpy(buf + 8, sh_audio->a_in_buffer, len); // untested
> > -#else
> > swab(sh_audio->a_in_buffer, buf + 8, len);
> > #endif
>
> ?? This does the same as just removing the WORDS_BIGENDIAN case
No, the swab here swap bytes from in_buffer into buf+8, first 8 bytes
in buf need be swapped manually.
>
> > @@ -335,8 +343,13 @@
> > burst_len = fsize * 8;
> > nr_samples = nblks * 32;
> >
> > +#ifdef WORDS_BIGENDIAN
> > + buf[0] = 0xf8; buf[1] = 0x72; /* iec 61937 */
> > + buf[2] = 0x4e; buf[3] = 0x1f; /* syncword */
> > +#else
> > buf[0] = 0x72; buf[1] = 0xf8; /* iec 61937 */
> > buf[2] = 0x1f; buf[3] = 0x4e; /* syncword */
> > +#endif
> > switch(nr_samples)
> > {
> > case 512:
> > @@ -353,16 +366,24 @@
> > buf[4] = 0x00;
> > break;
> > }
> > +
> > +#ifdef WORDS_BIGENDIAN
> > + buf[5] = buf[4];
> > + buf[4] = 0;
> > + buf[6] = (burst_len >> 8) & 0xff;
> > + buf[7] = (burst_len) & 0xff;
> > +#else
> > buf[5] = 0; /* ?? */
> > buf[6] = (burst_len) & 0xff;
> > buf[7] = (burst_len >> 8) & 0xff;
> > +#endif
>
> These changes do the same as just adding a swab(buf, buf, 8) of swab
> allows from == to (my man page "forgot" to mention that) or
> alternatively something like
> for (i = 0; i < 4; i++)
> ((uint16_t *)buf)[i] = le2me_16(((uint16_t *)buf)[i]);
>
> Greetings,
> Reimar Döffinger
Yes, I'd like to use swab for all these modifications but the swab man
page did not say whether it works fine when src==dst.
So, if you insist, I can give a bswap_16 version according to your
sample code. Here it is.
--
Ulion
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: hwac3_bigendian_shorten.txt
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20070913/f25ba40a/attachment.txt>
More information about the MPlayer-dev-eng
mailing list