6 #include "ad_internal.h"
8 static const ad_info_t info
=
10 "aLaw/uLaw audio decoder",
19 #include "native/alaw.h"
21 static int init(sh_audio_t
*sh_audio
)
23 /* aLaw audio codec:*/
24 if(!sh_audio
->wf
) return 0;
25 sh_audio
->channels
=sh_audio
->wf
->nChannels
;
26 sh_audio
->samplerate
=sh_audio
->wf
->nSamplesPerSec
;
27 sh_audio
->i_bps
=sh_audio
->channels
*sh_audio
->samplerate
;
28 sh_audio
->samplesize
=2;
32 static int preinit(sh_audio_t
*sh
)
34 sh
->audio_out_minsize
=2048;
35 sh
->ds
->ss_div
= 1; // 1 samples/packet
36 sh
->ds
->ss_mul
= sh
->wf
->nChannels
; // bytes/packet
40 static void uninit(sh_audio_t
*sh
)
44 static int control(sh_audio_t
*sh
,int cmd
,void* arg
, ...)
49 case ADCTRL_SKIP_FRAME
:
52 demux_read_data(sh
->ds
,NULL
,skip
);
55 return CONTROL_UNKNOWN
;
57 return CONTROL_UNKNOWN
;
60 static int decode_audio(sh_audio_t
*sh_audio
,unsigned char *buf
,int minlen
,int maxlen
)
63 int l
=demux_read_data(sh_audio
->ds
,buf
,minlen
/2);
64 unsigned short *d
=(unsigned short *) buf
;
67 if(sh_audio
->format
==6 || sh_audio
->format
==0x77616C61){
69 while(l
>0){ --l
; d
[l
]=alaw2short
[s
[l
]]; }
72 while(l
>0){ --l
; d
[l
]=ulaw2short
[s
[l
]]; }