[MPlayer-dev-eng] [PATCH] #define __BSD_VISIBLE to 1

Alexander Strasser eclipse7 at gmx.net
Tue Feb 18 08:10:44 CET 2014


On 2014-02-18 01:26 +0100, Alexander Strasser wrote:
> On 2014-02-16 20:09 +0100, Alexander Strasser wrote:
> > On 2014-02-16 18:38 +0100, Reimar Döffinger wrote:
[...]
> > > Also avoiding the cast and aliasing issues and using some AV_* macros
> > > might make sense.
> > 
> >   Will see what I can do.
> 
>   New patch attached. I hope it is better; can't really tell because
> I am tired :)
> 
>   I assume the read -> swap -> write could be nested. So I can squash
> it into one line if that is preferred.
> 
>   I also switched away from bswap_16 to using the FFmpeg version directly.
> 
>   Another style question is if I should use uint8_t * as type for the
> buffer pointer or rather char * which is more consistent according to
> the definition of the array.
> 
>   Alexander

> From 38724b44c3d9ad13e305be8804dc08be7b23187a Mon Sep 17 00:00:00 2001
> Message-Id: <38724b44c3d9ad13e305be8804dc08be7b23187a.1392683094.git.eclipse7 at gmx.net>
> From: Alexander Strasser <eclipse7 at gmx.net>
> Date: Sun, 16 Feb 2014 18:07:18 +0100
> Subject: [PATCH] ad_liba52: Use MPlayer bswap_16 instead of swab
> 
> Some OSs do not have it and OS/2 kLIBC does not activate it
> without _BSD_SOURCE defined (which should not be required).
> 
> Signed-off-by: Alexander Strasser <eclipse7 at gmx.net>
> ---
>  libmpcodecs/ad_liba52.c | 22 ++++++++++++++++++----
>  1 file changed, 18 insertions(+), 4 deletions(-)
> 
> diff --git a/libmpcodecs/ad_liba52.c b/libmpcodecs/ad_liba52.c
> index 89b3dc7..324e237 100644
> --- a/libmpcodecs/ad_liba52.c
> +++ b/libmpcodecs/ad_liba52.c
> @@ -22,12 +22,12 @@
>  #include <unistd.h>
>  #include <math.h>
>  #include <assert.h>
> +#include <stdint.h>
>  
>  #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,9 @@
>  
>  #include "libaf/af_format.h"
>  
> +#include <libavutil/bswap.h>
> +#include <libavutil/intreadwrite.h>
> +
>  #include <a52dec/a52.h>
>  #include <a52dec/mm_accel.h>
>  int (* a52_resample) (float * _f, int16_t * s16);
> @@ -68,6 +71,17 @@ static const ad_info_t info =
>  
>  LIBAD_EXTERN(liba52)
>  
> +static void swap_bytes(uint8_t * buf, int size)
> +{
> +   size -= size & 1;
> +   while (size > 0) {

> +     int16_t swapped = av_bswap16(AV_RN16(buf));
> +     AV_WN16(buf, swapped);

  Or would it be better to do:

     AV_WB16(buf, AV_RL16(buf));

  ?

> +     buf += 2;
> +     size -= 2;
> +   }
> +}
> +
>  static int a52_fillbuff(sh_audio_t *sh_audio)
>  {
>  int length=0;
> @@ -83,11 +97,11 @@ while(1){
>  	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 +111,7 @@ while(1){
>      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)
> -- 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <http://lists.mplayerhq.hu/pipermail/mplayer-dev-eng/attachments/20140218/35973e54/attachment.asc>


More information about the MPlayer-dev-eng mailing list