# HG changeset patch # User al # Date 1393104954 0 # Node ID 630f03c82df3dc1b435dc145a6083cc89a2ada7a # Parent c8b6ad3e5732710eeecf790ac203202236543b86 ad_liba52: Avoid using the swab function Some OSs do not have it and OS/2 kLIBC does not activate it without _BSD_SOURCE defined (which should not be required). Reported-by: KO Myung-Hun Reviewed-by: Reimar diff -r c8b6ad3e5732 -r 630f03c82df3 libmpcodecs/ad_liba52.c --- a/libmpcodecs/ad_liba52.c Fri Feb 21 05:10:12 2014 +0000 +++ b/libmpcodecs/ad_liba52.c Sat Feb 22 21:35:54 2014 +0000 @@ -22,12 +22,12 @@ #include #include #include +#include #include "config.h" #include "mp_msg.h" #include "help_mp.h" -#include "mpbswap.h" #include "ad_internal.h" #include "dec_audio.h" @@ -36,6 +36,8 @@ #include "libaf/af_format.h" +#include + #include #include int (* a52_resample) (float * _f, int16_t * s16); @@ -68,6 +70,16 @@ LIBAD_EXTERN(liba52) +static void swap_bytes(uint8_t * buf, int size) +{ + size -= size & 1; + while (size > 0) { + FFSWAP(uint8_t, buf[0], buf[1]); + buf += 2; + size -= 2; + } +} + static int a52_fillbuff(sh_audio_t *sh_audio) { int length=0; @@ -83,11 +95,11 @@ if(c<0) return -1; /* EOF*/ sh_audio->a_in_buffer[sh_audio->a_in_buffer_len++]=c; } - if(sh_audio->format==MKTAG('d','n','e','t')) swab(sh_audio->a_in_buffer,sh_audio->a_in_buffer,8); + if(sh_audio->format==MKTAG('d','n','e','t')) swap_bytes(sh_audio->a_in_buffer,8); length = a52_syncinfo (sh_audio->a_in_buffer, &flags, &sample_rate, &bit_rate); if(length>=7 && length<=3840) break; /* we're done.*/ /* bad file => resync*/ - if(sh_audio->format==MKTAG('d','n','e','t')) swab(sh_audio->a_in_buffer,sh_audio->a_in_buffer,8); + if(sh_audio->format==MKTAG('d','n','e','t')) swap_bytes(sh_audio->a_in_buffer,8); memmove(sh_audio->a_in_buffer,sh_audio->a_in_buffer+1,7); --sh_audio->a_in_buffer_len; } @@ -97,7 +109,7 @@ sh_audio->samplesize=sh_audio->sample_format==AF_FORMAT_FLOAT_NE ? 4 : 2; demux_read_data(sh_audio->ds,sh_audio->a_in_buffer+8,length-8); if(sh_audio->format==MKTAG('d','n','e','t')) - swab(sh_audio->a_in_buffer+8,sh_audio->a_in_buffer+8,length-8); + swap_bytes(sh_audio->a_in_buffer+8,length-8); #ifdef CONFIG_LIBA52_INTERNAL if(crc16_block(sh_audio->a_in_buffer+2,length-2)!=0)