[MPlayer-cvslog] r30280 - in trunk: Makefile libmpcodecs/ad_hwac3.c

reimar subversion at mplayerhq.hu
Mon Jan 11 20:43:19 CET 2010


Author: reimar
Date: Mon Jan 11 20:43:19 2010
New Revision: 30280

Log:
Make ad_hwac3 independent of liba52. Needs a minor amount of code duplication,
though that is already done that way for dts support in hwac3.

Modified:
   trunk/Makefile
   trunk/libmpcodecs/ad_hwac3.c

Modified: trunk/Makefile
==============================================================================
--- trunk/Makefile	Mon Jan 11 20:40:58 2010	(r30279)
+++ trunk/Makefile	Mon Jan 11 20:43:19 2010	(r30280)
@@ -106,8 +106,7 @@ SRCS_COMMON-$(HAVE_POSIX_SELECT)     += 
 SRCS_COMMON-$(HAVE_SYS_MMAN_H)       += libaf/af_export.c osdep/mmap_anon.c
 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
+SRCS_COMMON-$(LIBA52)                += libmpcodecs/ad_liba52.c
 SRCS_COMMON-$(LIBA52_INTERNAL)       += liba52/crc.c \
                                         liba52/resample.c \
                                         liba52/bit_allocate.c \
@@ -380,6 +379,7 @@ SRCS_COMMON = asxparser.c \
               libmpcodecs/ad_alaw.c \
               libmpcodecs/ad_dk3adpcm.c \
               libmpcodecs/ad_dvdpcm.c \
+              libmpcodecs/ad_hwac3.c \
               libmpcodecs/ad_hwmpa.c \
               libmpcodecs/ad_imaadpcm.c \
               libmpcodecs/ad_msadpcm.c \

Modified: trunk/libmpcodecs/ad_hwac3.c
==============================================================================
--- trunk/libmpcodecs/ad_hwac3.c	Mon Jan 11 20:40:58 2010	(r30279)
+++ trunk/libmpcodecs/ad_hwac3.c	Mon Jan 11 20:43:19 2010	(r30280)
@@ -15,15 +15,10 @@
 #include "mp_msg.h"
 #include "help_mp.h"
 #include "mpbswap.h"
+#include "libavutil/common.h"
 
 #include "ad_internal.h"
 
-#ifdef CONFIG_LIBA52_INTERNAL
-#include "liba52/a52.h"
-#else
-#include <a52dec/a52.h>
-#endif
-
 
 static int isdts = -1;
 
@@ -43,6 +38,44 @@ static int dts_syncinfo(uint8_t *indata_
 static int decode_audio_dts(unsigned char *indata_ptr, int len, unsigned char *buf);
 
 
+static int a52_syncinfo (uint8_t *buf, int *sample_rate, int *bit_rate)
+{
+    static const uint16_t rate[] = { 32,  40,  48,  56,  64,  80,  96, 112,
+                                    128, 160, 192, 224, 256, 320, 384, 448,
+                                    512, 576, 640};
+    int frmsizecod;
+    int bitrate;
+    int half;
+
+    if (buf[0] != 0x0b || buf[1] != 0x77)    /* syncword */
+        return 0;
+
+    if (buf[5] >= 0x60)                      /* bsid >= 12 */
+        return 0;
+    half = buf[5] >> 3;
+    half = FFMAX(half - 8, 0);
+
+    frmsizecod = buf[4] & 63;
+    if (frmsizecod >= 38)
+        return 0;
+    bitrate = rate[frmsizecod >> 1];
+    *bit_rate = (bitrate * 1000) >> half;
+
+    switch (buf[4] & 0xc0) {
+    case 0:
+        *sample_rate = 48000 >> half;
+        return 4 * bitrate;
+    case 0x40:
+        *sample_rate = 44100 >> half;
+        return 2 * (320 * bitrate / 147 + (frmsizecod & 1));
+    case 0x80:
+        *sample_rate = 32000 >> half;
+        return 6 * bitrate;
+    default:
+        return 0;
+    }
+}
+
 static int ac3dts_fillbuff(sh_audio_t *sh_audio)
 {
   int length = 0;
@@ -79,7 +112,7 @@ static int ac3dts_fillbuff(sh_audio_t *s
     }
     else
     {
-      length = a52_syncinfo(sh_audio->a_in_buffer, &flags, &sample_rate, &bit_rate);
+      length = a52_syncinfo(sh_audio->a_in_buffer, &sample_rate, &bit_rate);
       if(length >= 7 && length <= 3840)
       {
         if(isdts != 0)
@@ -125,25 +158,16 @@ static int preinit(sh_audio_t *sh)
 static int init(sh_audio_t *sh_audio)
 {
   /* Dolby AC3 passthrough:*/
-  a52_state_t *a52_state = a52_init(0);
-  if(a52_state == NULL)
-  {
-    mp_msg(MSGT_DECAUDIO, MSGL_ERR, "A52 init failed\n");
-    return 0;
-  }
   if(ac3dts_fillbuff(sh_audio) < 0)
   {
-    a52_free(a52_state);
     mp_msg(MSGT_DECAUDIO, MSGL_ERR, "AC3/DTS sync failed\n");
     return 0;
   }
-  sh_audio->context = a52_state;
   return 1;
 }
 
 static void uninit(sh_audio_t *sh)
 {
-  a52_free(sh->context);
 }
 
 static int control(sh_audio_t *sh,int cmd,void* arg, ...)


More information about the MPlayer-cvslog mailing list