changeset 36163:d13733fdf789

Avoid using swab() This is the only place where it is used and it is not available universally (missing e.g. on Android).
author reimar
date Thu, 09 May 2013 10:53:20 +0000
parents cb10031f4ead
children 17c68386c303
files libmpcodecs/ad_hwac3.c
diffstat 1 files changed, 9 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/libmpcodecs/ad_hwac3.c	Thu May 09 10:53:18 2013 +0000
+++ b/libmpcodecs/ad_hwac3.c	Thu May 09 10:53:20 2013 +0000
@@ -20,11 +20,9 @@
  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
  */
 
-#define _XOPEN_SOURCE 600
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <unistd.h>
 
 #include "config.h"
 #include "mp_msg.h"
@@ -556,10 +554,16 @@
       memcpy(&buf[8], indata_ptr, fsize);
     else
     {
-      swab(indata_ptr, &buf[8], fsize);
+      int i = fsize >> 1;
+      uint16_t *d = buf16 + 4;
+      uint8_t *s = indata_ptr;
+      while (i--) {
+        *d++ = HAVE_BIGENDIAN ? AV_RL16(s) : AV_RB16(s);
+        s += 2;
+      }
       if (fsize & 1) {
-        buf[8+fsize-1] = 0;
-        buf[8+fsize] = indata_ptr[fsize-1];
+        // treat as if there was an additional 0
+        *d++ = HAVE_BIGENDIAN ? *s : *s << 8;
         fsize++;
       }
     }