Mercurial > mplayer.hg
comparison libmpcodecs/ad_hwac3.c @ 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 | 7ee92e6f4d61 |
comparison
equal
deleted
inserted
replaced
36162:cb10031f4ead | 36163:d13733fdf789 |
---|---|
18 * You should have received a copy of the GNU General Public License along | 18 * You should have received a copy of the GNU General Public License along |
19 * with MPlayer; if not, write to the Free Software Foundation, Inc., | 19 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. | 20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
21 */ | 21 */ |
22 | 22 |
23 #define _XOPEN_SOURCE 600 | |
24 #include <stdio.h> | 23 #include <stdio.h> |
25 #include <stdlib.h> | 24 #include <stdlib.h> |
26 #include <string.h> | 25 #include <string.h> |
27 #include <unistd.h> | |
28 | 26 |
29 #include "config.h" | 27 #include "config.h" |
30 #include "mp_msg.h" | 28 #include "mp_msg.h" |
31 #include "help_mp.h" | 29 #include "help_mp.h" |
32 #include "mpbswap.h" | 30 #include "mpbswap.h" |
554 int be_stream = indata_ptr[0] == 0x1f || indata_ptr[0] == 0x7f; | 552 int be_stream = indata_ptr[0] == 0x1f || indata_ptr[0] == 0x7f; |
555 if (be_stream == HAVE_BIGENDIAN) | 553 if (be_stream == HAVE_BIGENDIAN) |
556 memcpy(&buf[8], indata_ptr, fsize); | 554 memcpy(&buf[8], indata_ptr, fsize); |
557 else | 555 else |
558 { | 556 { |
559 swab(indata_ptr, &buf[8], fsize); | 557 int i = fsize >> 1; |
558 uint16_t *d = buf16 + 4; | |
559 uint8_t *s = indata_ptr; | |
560 while (i--) { | |
561 *d++ = HAVE_BIGENDIAN ? AV_RL16(s) : AV_RB16(s); | |
562 s += 2; | |
563 } | |
560 if (fsize & 1) { | 564 if (fsize & 1) { |
561 buf[8+fsize-1] = 0; | 565 // treat as if there was an additional 0 |
562 buf[8+fsize] = indata_ptr[fsize-1]; | 566 *d++ = HAVE_BIGENDIAN ? *s : *s << 8; |
563 fsize++; | 567 fsize++; |
564 } | 568 } |
565 } | 569 } |
566 } | 570 } |
567 memset(&buf[fsize + 8], 0, nr_samples * 2 * 2 - (fsize + 8)); | 571 memset(&buf[fsize + 8], 0, nr_samples * 2 * 2 - (fsize + 8)); |