From 7c026066ea35886bddfda08a71c0cc8f170a5d86 Mon Sep 17 00:00:00 2001 From: arpi Date: Mon, 25 Mar 2002 21:06:01 +0000 Subject: imported from MPlayerXP, dlopen() hack removed, some bugs fixed, interface functions changed to static, info->author field added git-svn-id: svn://svn.mplayerhq.hu/mplayer/trunk@5341 b3059339-0415-0410-9bf9-f77b7e298cf2 --- libmpcodecs/ad_hwac3.c | 88 ++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) create mode 100644 libmpcodecs/ad_hwac3.c (limited to 'libmpcodecs/ad_hwac3.c') diff --git a/libmpcodecs/ad_hwac3.c b/libmpcodecs/ad_hwac3.c new file mode 100644 index 0000000000..fb92d5b593 --- /dev/null +++ b/libmpcodecs/ad_hwac3.c @@ -0,0 +1,88 @@ +#include +#include +#include + +#include "config.h" +#include "mp_msg.h" +#include "help_mp.h" + +#include "ad_internal.h" + +#include "../liba52/a52.h" +#include "../ac3-iec958.h" + +extern int a52_fillbuff(sh_audio_t *sh_audio); + +static ad_info_t info = +{ + "AC3 through SPDIF", + "hwac3", + AFM_HWAC3, + "Nick Kurshev", + "???", + "" +}; + +LIBAD_EXTERN(hwac3) + +static int preinit(sh_audio_t *sh) +{ + /* Dolby AC3 audio: */ + sh->audio_out_minsize=4*256*6; + sh->channels=2; + return 1; +} + +static int init(sh_audio_t *sh_audio) +{ + /* Dolby AC3 passthrough:*/ + sample_t *a52_samples=a52_init(0); + if (a52_samples == NULL) { + mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 init failed\n"); + return 0; + } + sh_audio->a_in_buffer_size=3840; + sh_audio->a_in_buffer=malloc(sh_audio->a_in_buffer_size); + sh_audio->a_in_buffer_len=0; + if(a52_fillbuff(sh_audio)<0) { + mp_msg(MSGT_DECAUDIO,MSGL_ERR,"A52 sync failed\n"); + return 0; + } + /* + sh_audio->samplerate=ai.samplerate; // SET by a52_fillbuff() + sh_audio->samplesize=ai.framesize; + sh_audio->i_bps=ai.bitrate*(1000/8); // SET by a52_fillbuff() + sh_audio->ac3_frame=malloc(6144); + sh_audio->o_bps=sh_audio->i_bps; // XXX FIXME!!! XXX + + o_bps is calculated from samplesize*channels*samplerate + a single ac3 frame is always translated to 6144 byte packet. (zero padding)*/ + sh_audio->channels=2; + sh_audio->samplesize=2; /* 2*2*(6*256) = 6144 (very TRICKY!)*/ + return 1; +} + +static void uninit(sh_audio_t *sh) +{ +} + +static int control(sh_audio_t *sh,int cmd,void* arg, ...) +{ + switch(cmd) + { + case ADCTRL_SKIP_FRAME: + a52_fillbuff(sh); break; // skip AC3 frame + return CONTROL_TRUE; + } + return CONTROL_UNKNOWN; +} + +static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen) +{ + int len=-1; + if(!sh_audio->a_in_buffer_len) + if((len=a52_fillbuff(sh_audio))<0) return len; /*EOF*/ + sh_audio->a_in_buffer_len=0; + len = ac3_iec958_build_burst(len, 0x01, 1, sh_audio->a_in_buffer, buf); + return len; +} -- cgit v1.2.3