From 92b91439e01656b1e00dfe9c86d1f36ae5446abe Mon Sep 17 00:00:00 2001 From: reimar Date: Mon, 11 Jan 2010 19:43:19 +0000 Subject: 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. git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@30280 b3059339-0415-0410-9bf9-f77b7e298cf2 --- Makefile | 4 ++-- libmpcodecs/ad_hwac3.c | 56 +++++++++++++++++++++++++++++++++++--------------- 2 files changed, 42 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 00d615bfdb..a3971dda5c 100644 --- a/Makefile +++ b/Makefile @@ -106,8 +106,7 @@ SRCS_COMMON-$(HAVE_POSIX_SELECT) += libmpcodecs/vf_bmovl.c 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 \ diff --git a/libmpcodecs/ad_hwac3.c b/libmpcodecs/ad_hwac3.c index f59fa9c15b..1aa8de0cb6 100644 --- a/libmpcodecs/ad_hwac3.c +++ b/libmpcodecs/ad_hwac3.c @@ -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 -#endif - static int isdts = -1; @@ -43,6 +38,44 @@ static int dts_syncinfo(uint8_t *indata_ptr, int *flags, int *sample_rate, int * 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 *sh_audio) } 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, ...) -- cgit v1.2.3