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

Reimar Döffinger Reimar.Doeffinger at stud.uni-karlsruhe.de
Thu Sep 13 13:22:46 CEST 2007


Hello,
On Thu, Sep 13, 2007 at 01:14:40PM +0200, Reimar Döffinger wrote:
> > 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.
> 
> Please just try it with swab, if it works we should use it IMO. If there
> are some weird systems where it does not work for src==dst we can write
> a replacement function for those.
> 
> Otherwise the patch looks good to me.

On second thought, could you test attached patch?

Greetings,
Reimar Döffinger
-------------- next part --------------
Index: libmpcodecs/ad_hwac3.c
===================================================================
--- libmpcodecs/ad_hwac3.c	(revision 24434)
+++ libmpcodecs/ad_hwac3.c	(working copy)
@@ -159,14 +159,11 @@
   }
   else if(isdts == 0)
   {
-    buf[0] = 0x72;
-    buf[1] = 0xF8;
-    buf[2] = 0x1F;
-    buf[3] = 0x4E;
-    buf[4] = 0x01; //(length) ? data_type : 0; /* & 0x1F; */
-    buf[5] = 0x00;
-    buf[6] = (len << 3) & 0xFF;
-    buf[7] = (len >> 5) & 0xFF;
+    uint16_t *buf16 = buf;
+    buf16[0] = 0xF872;
+    buf16[1] = 0x4E1F;
+    buf16[2] = 0x0001; //(length) ? data_type : 0; /* & 0x1F; */
+    buf16[3] = len << 3;
 #ifdef WORDS_BIGENDIAN
     memcpy(buf + 8, sh_audio->a_in_buffer, len);  // untested
 #else
@@ -327,6 +324,7 @@
   int sfreq;
   int burst_len;
   int nr_samples;
+  uint16_t *buf16 = buf;
 
   fsize = dts_decode_header(indata_ptr, &rate, &nblks, &sfreq);
   if(fsize < 0)
@@ -335,27 +333,25 @@
   burst_len = fsize * 8;
   nr_samples = nblks * 32;
 
-  buf[0] = 0x72; buf[1] = 0xf8; /* iec 61937     */
-  buf[2] = 0x1f; buf[3] = 0x4e; /*  syncword     */
+  buf16[0] = 0xf872; /* iec 61937     */
+  buf16[1] = 0x431f; /*  syncword     */
   switch(nr_samples) 
   {
   case 512:
-    buf[4] = 0x0b;      /* DTS-1 (512-sample bursts) */
+    buf16[2] = 0x000b;      /* DTS-1 (512-sample bursts) */
     break;
   case 1024:
-    buf[4] = 0x0c;      /* DTS-2 (1024-sample bursts) */
+    buf16[2] = 0x000c;      /* DTS-2 (1024-sample bursts) */
     break;
   case 2048:
-    buf[4] = 0x0d;      /* DTS-3 (2048-sample bursts) */
+    buf16[2] = 0x000d;      /* DTS-3 (2048-sample bursts) */
     break;
   default:
     mp_msg(MSGT_DECAUDIO, MSGL_ERR, "DTS: %d-sample bursts not supported\n", nr_samples);
-    buf[4] = 0x00;
+    buf16[2] = 0x0000;
     break;
   }
-  buf[5] = 0;                      /* ?? */    
-  buf[6] = (burst_len) & 0xff;   
-  buf[7] = (burst_len >> 8) & 0xff;
+  buf16[3] = burst_len;   
  
   if(fsize + 8 > nr_samples * 2 * 2)
   {


More information about the MPlayer-dev-eng mailing list