6 #include "ad_internal.h"
8 static ad_info_t info
=
10 "native GSM/MSGSM audio decoder",
19 #include "native/xa_gsm.h"
21 static int init(sh_audio_t
*sh_audio
)
23 if(!sh_audio
->wf
) return 0;
24 // MS-GSM audio codec:
26 sh_audio
->channels
=sh_audio
->wf
->nChannels
;
27 sh_audio
->samplerate
=sh_audio
->wf
->nSamplesPerSec
;
28 sh_audio
->samplesize
=2;
29 // decodes 65 byte -> 320 short
30 // 1 sec: sh_audio->channels*sh_audio->samplerate samples
31 // 1 frame: 320 samples
32 if(sh_audio
->format
==0x31 || sh_audio
->format
==0x32){
33 sh_audio
->ds
->ss_mul
=65; sh_audio
->ds
->ss_div
=320;
35 sh_audio
->ds
->ss_mul
=33; sh_audio
->ds
->ss_div
=160;
37 sh_audio
->i_bps
=sh_audio
->ds
->ss_mul
*(sh_audio
->channels
*sh_audio
->samplerate
)/sh_audio
->ds
->ss_div
; // 1:10
41 static int preinit(sh_audio_t
*sh_audio
)
43 sh_audio
->audio_out_minsize
=4*320;
47 static void uninit(sh_audio_t
*sh
)
51 static int control(sh_audio_t
*sh
,int cmd
,void* arg
, ...)
53 return CONTROL_UNKNOWN
;
56 static int decode_audio(sh_audio_t
*sh_audio
,unsigned char *buf
,int minlen
,int maxlen
)
58 if(sh_audio
->format
==0x31 || sh_audio
->format
==0x32){
59 unsigned char ibuf
[65]; // 65 bytes / frame
60 if(demux_read_data(sh_audio
->ds
,ibuf
,65)!=65) return -1; // EOF
61 XA_MSGSM_Decoder(ibuf
,(unsigned short *) buf
); // decodes 65 byte -> 320 short
64 unsigned char ibuf
[33]; // 33 bytes / frame
65 if(demux_read_data(sh_audio
->ds
,ibuf
,33)!=33) return -1; // EOF
66 XA_GSM_Decoder(ibuf
,(unsigned short *) buf
); // decodes 33 byte -> 160 short