[MPlayer-dev-eng] [PATCH] external liba52 support

Dominik 'Rathann' Mierzejewski dominik at rangers.eu.org
Fri Aug 22 02:14:23 CEST 2008


Hi.
Here are two patches which add external liba52-0.7.4 support.

Patch1: conditionalizes enabling of some acceleration because
liba52-0.7.4 doesn't support all that MPlayer's copy does.
Patch2: the main patch, depends on Patch1

Tested with --disable-liba52-internal and without, seems to be working fine.

Regards,
R.

-- 
MPlayer http://mplayerhq.hu | Livna http://rpm.livna.org
There should be a science of discontent. People need hard times and
oppression to develop psychic muscles.
	-- from "Collected Sayings of Muad'Dib" by the Princess Irulan
-------------- next part --------------
diff -up mplayer-export-2008-08-18/libmpcodecs/ad_liba52.c.accel mplayer-export-2008-08-18/libmpcodecs/ad_liba52.c
--- mplayer-export-2008-08-18/libmpcodecs/ad_liba52.c.accel	2008-08-22 01:26:25.000000000 +0200
+++ mplayer-export-2008-08-18/libmpcodecs/ad_liba52.c	2008-08-22 01:25:33.000000000 +0200
@@ -169,12 +169,18 @@ static int init(sh_audio_t *sh_audio)
   sample_t level=a52_level, bias=384;
   int flags=0;
   /* Dolby AC3 audio:*/
+#ifdef MM_ACCEL_X86_SSE
   if(gCpuCaps.hasSSE) a52_accel|=MM_ACCEL_X86_SSE;
+#endif
   if(gCpuCaps.hasMMX) a52_accel|=MM_ACCEL_X86_MMX;
   if(gCpuCaps.hasMMX2) a52_accel|=MM_ACCEL_X86_MMXEXT;
   if(gCpuCaps.has3DNow) a52_accel|=MM_ACCEL_X86_3DNOW;
+#ifdef MM_ACCEL_X86_3DNOWEXT
   if(gCpuCaps.has3DNowExt) a52_accel|=MM_ACCEL_X86_3DNOWEXT;
+#endif
+#ifdef MM_ACCEL_PPC_ALTIVEC
   if(gCpuCaps.hasAltiVec) a52_accel|=MM_ACCEL_PPC_ALTIVEC;
+#endif
   a52_state=a52_init (a52_accel);
   if (a52_state == NULL) {
 	mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 init failed\n");
-------------- next part --------------
diff -up mplayer-export-2008-08-18/configure.liba52 mplayer-export-2008-08-18/configure
--- mplayer-export-2008-08-18/configure.liba52	2008-08-19 00:52:31.000000000 +0200
+++ mplayer-export-2008-08-18/configure	2008-08-22 02:09:52.000000000 +0200
@@ -320,7 +320,8 @@ Codecs:
   --enable-xmms             enable XMMS input plugin support [disabled]
   --enable-libdca           enable libdca support [autodetect]
   --disable-mp3lib          disable builtin mp3lib [enabled]
-  --disable-liba52          disable builtin liba52 [enabled]
+  --enable-liba52-external  enable external liba52 [autodetect] 
+  --disable-liba52-internal disable builtin liba52 [autodetect] 
   --disable-libmpeg2        disable builtin libmpeg2 [autodetect]
   --disable-musepack        disable musepack support [autodetect]
   --disable-libamr_nb       disable libamr narrowband [autodetect]
@@ -574,7 +575,8 @@ _libvorbis=auto
 _speex=auto
 _theora=auto
 _mp3lib=yes
-_liba52=yes
+_liba52_internal=auto
+_liba52_external=auto
 _libdca=auto
 _libmpeg2=auto
 _faad_internal=auto
@@ -938,8 +940,10 @@ for ac_option do
   --disable-theora)	_theora=no	;;
   --enable-mp3lib)	_mp3lib=yes	;;
   --disable-mp3lib)	_mp3lib=no	;;
-  --enable-liba52)	_liba52=yes	;;
-  --disable-liba52)	_liba52=no	;;
+  --enable-liba52-internal)	_liba52_internal=yes	;;
+  --disable-liba52-internal)	_liba52_internal=no	;;
+  --enable-liba52-external)	_liba52_external=yes	;;
+  --disable-liba52-external)	_liba52_external=no	;;
   --enable-libdca)	_libdca=yes     ;;
   --disable-libdca)	_libdca=no      ;;
   --enable-libmpeg2)	_libmpeg2=yes	;;
@@ -6053,10 +6057,33 @@ else
 fi
 echores "$_mp3lib"
 
-echocheck "internal liba52 support"
+echocheck "liba52 support"
+if test "$_liba52_internal" = auto ; then
+  _liba52_internal=yes
+elif test "$_liba52_internal" = no && test "$_liba52_external" = auto ; then
+  _liba52_external=no
+  cat > $TMPC << EOF
+#include <inttypes.h>
+#include <a52dec/a52.h>
+int main(void) { a52_state_t *testHand; testHand=a52_init(0); return 0; }
+EOF
+  cc_check -la52 && _liba52_external=yes
+fi
+if test "$_liba52_internal" = yes ; then
+  _def_liba52_internal="#define CONFIG_LIBA52_INTERNAL 1"
+  _res_comment="internal"
+  _liba52=yes
+elif test "$_liba52_external" = yes ; then
+  _ld_extra="$_ld_extra -la52"
+  _res_comment="external"
+  _liba52=yes
+else
+  _def_liba52_internal="#undef CONFIG_LIBA52_INTERNAL"
+  _liba52=no
+fi
 if test "$_liba52" = yes ; then
   _def_liba52='#define CONFIG_LIBA52 1'
-  _codecmodules="liba52 $_codecmodules"
+  _codecmodules="liba52($_res_comment) $_codecmodules"
 else
   _def_liba52='#undef CONFIG_LIBA52'
   _nocodecmodules="liba52 $_nocodecmodules"
@@ -7810,6 +7837,7 @@ MPLAYER = $_mplayer
 
 #internal libraries
 LIBA52 = $_liba52
+LIBA52_INTERNAL = $_liba52_internal
 LIBMPEG2 = $_libmpeg2
 MP3LIB = $_mp3lib
 TREMOR_INTERNAL = $_tremor_internal
@@ -8353,6 +8381,9 @@ $_def_xvid_lavc
 
 /* Use codec libs included in mplayer CVS / source dist: */
 $_def_mp3lib
+
+/* enable liba52 support */
+$_def_liba52_internal
 $_def_liba52
 $_def_libmpeg2
 
diff -up mplayer-export-2008-08-18/libmpcodecs/ad_hwac3.c.liba52 mplayer-export-2008-08-18/libmpcodecs/ad_hwac3.c
--- mplayer-export-2008-08-18/libmpcodecs/ad_hwac3.c.liba52	2008-08-21 21:02:53.000000000 +0200
+++ mplayer-export-2008-08-18/libmpcodecs/ad_hwac3.c	2008-08-21 21:04:36.000000000 +0200
@@ -17,7 +17,11 @@
 
 #include "ad_internal.h"
 
+#ifdef CONFIG_LIBA52_INTERNAL
 #include "liba52/a52.h"
+#else
+#include <a52dec/a52.h>
+#endif
 
 
 static int isdts = -1;
diff -up mplayer-export-2008-08-18/libmpcodecs/ad_liba52.c.liba52 mplayer-export-2008-08-18/libmpcodecs/ad_liba52.c
--- mplayer-export-2008-08-18/libmpcodecs/ad_liba52.c.liba52	2008-08-22 01:28:36.000000000 +0200
+++ mplayer-export-2008-08-18/libmpcodecs/ad_liba52.c	2008-08-22 01:51:58.000000000 +0200
@@ -16,8 +16,14 @@
 
 #include "libaf/af_format.h"
 
+#ifdef CONFIG_LIBA52_INTERNAL
 #include "liba52/a52.h"
 #include "liba52/mm_accel.h"
+#else
+#include <a52dec/a52.h>
+#include <a52dec/mm_accel.h>
+int (* a52_resample) (float * _f, int16_t * s16);
+#endif
 
 static a52_state_t *a52_state;
 static uint32_t a52_flags=0;
@@ -79,8 +85,10 @@ while(1){
     if(sh_audio->format!=0x2000)
 	swab(sh_audio->a_in_buffer+8,sh_audio->a_in_buffer+8,length-8);
     
+#ifdef CONFIG_LIBA52_INTERNAL
     if(crc16_block(sh_audio->a_in_buffer+2,length-2)!=0)
 	mp_msg(MSGT_DECAUDIO,MSGL_STATUS,"a52: CRC check failed!  \n");
+#endif
     
     return length;
 }
@@ -121,7 +129,11 @@ static int preinit(sh_audio_t *sh)
 {
   /* Dolby AC3 audio: */
   /* however many channels, 2 bytes in a word, 256 samples in a block, 6 blocks in a frame */
+#ifndef CONFIG_LIBA52_INTERNAL
+  if (sh->samplesize < 4) sh->samplesize = 4;
+#else
   if (sh->samplesize < 2) sh->samplesize = 2;
+#endif
   sh->audio_out_minsize=audio_output_channels*sh->samplesize*256*6;
   sh->audio_in_minsize=3840;
   a52_level = 1.0;
@@ -175,6 +187,9 @@ static int init(sh_audio_t *sh_audio)
 	mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 init failed\n");
 	return 0;
   }
+#ifndef CONFIG_LIBA52_INTERNAL
+  sh_audio->sample_format = AF_FORMAT_FLOAT_NE;
+#endif
   if(a52_fillbuff(sh_audio)<0){
 	mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 sync failed\n");
 	return 0;
@@ -247,8 +262,12 @@ while(sh_audio->channels>0){
 	  break;
       }
   } else
+#ifdef CONFIG_LIBA52_INTERNAL
   if(a52_resample_init(a52_accel,flags,sh_audio->channels)) break;
   --sh_audio->channels; /* try to decrease no. of channels*/
+#else
+  break;
+#endif
 }
   if(sh_audio->channels<=0){
     mp_msg(MSGT_DECAUDIO,MSGL_ERR,"a52: no resampler. try different channel setup!\n");
diff -up mplayer-export-2008-08-18/Makefile.liba52 mplayer-export-2008-08-18/Makefile
--- mplayer-export-2008-08-18/Makefile.liba52	2008-08-21 21:03:43.000000000 +0200
+++ mplayer-export-2008-08-18/Makefile	2008-08-22 01:52:21.000000000 +0200
@@ -294,8 +294,8 @@ SRCS_COMMON-$(HAVE_SYS_MMAN_H)       += 
 SRCS_COMMON-$(JPEG)                  += libmpcodecs/vd_ijpg.c
 SRCS_COMMON-$(LADSPA)                += libaf/af_ladspa.c
 SRCS_COMMON-$(LIBA52)                += libmpcodecs/ad_hwac3.c \
-                                        libmpcodecs/ad_liba52.c \
-                                        liba52/crc.c \
+                                        libmpcodecs/ad_liba52.c
+SRCS_COMMON-$(LIBA52_INTERNAL)       += liba52/crc.c \
                                         liba52/resample.c \
                                         liba52/bit_allocate.c \
                                         liba52/bitstream.c \


More information about the MPlayer-dev-eng mailing list