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

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Thu Sep 13 10:21:47 CEST 2007


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...

> @@ -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

> @@ -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



More information about the MPlayer-dev-eng mailing list