Mercurial > mplayer.hg
annotate libmpcodecs/ad_msgsm.c @ 19585:5ba92e0ab9b7
fixe some typos and formatting of -radio entry
author | kraymer |
---|---|
date | Tue, 29 Aug 2006 14:19:20 +0000 |
parents | 9d0b052c4f74 |
children | e0a6fb06f058 |
rev | line source |
---|---|
5345 | 1 #include <stdio.h> |
2 #include <stdlib.h> | |
3 #include <unistd.h> | |
4 | |
5 #include "config.h" | |
6 #include "ad_internal.h" | |
7 | |
8 static ad_info_t info = | |
9 { | |
7410 | 10 "native GSM/MSGSM audio decoder", |
5345 | 11 "msgsm", |
12 "A'rpi", | |
13 "XAnim", | |
14 "" | |
15 }; | |
16 | |
17 LIBAD_EXTERN(msgsm) | |
18 | |
5603 | 19 #include "xa_gsm.h" |
5345 | 20 |
21 static int init(sh_audio_t *sh_audio) | |
22 { | |
23 if(!sh_audio->wf) return 0; | |
24 // MS-GSM audio codec: | |
25 GSM_Init(); | |
26 sh_audio->channels=sh_audio->wf->nChannels; | |
27 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; | |
13427
9d0b052c4f74
setting samplesize to 2 in decoders where neccessary.
reimar
parents:
7410
diff
changeset
|
28 sh_audio->samplesize=2; |
5345 | 29 // decodes 65 byte -> 320 short |
30 // 1 sec: sh_audio->channels*sh_audio->samplerate samples | |
31 // 1 frame: 320 samples | |
7410 | 32 if(sh_audio->format==0x31 || sh_audio->format==0x32){ |
33 sh_audio->ds->ss_mul=65; sh_audio->ds->ss_div=320; | |
34 } else { | |
35 sh_audio->ds->ss_mul=33; sh_audio->ds->ss_div=160; | |
36 } | |
37 sh_audio->i_bps=sh_audio->ds->ss_mul*(sh_audio->channels*sh_audio->samplerate)/sh_audio->ds->ss_div; // 1:10 | |
5345 | 38 return 1; |
39 } | |
40 | |
41 static int preinit(sh_audio_t *sh_audio) | |
42 { | |
43 sh_audio->audio_out_minsize=4*320; | |
44 return 1; | |
45 } | |
46 | |
47 static void uninit(sh_audio_t *sh) | |
48 { | |
49 } | |
50 | |
51 static int control(sh_audio_t *sh,int cmd,void* arg, ...) | |
52 { | |
53 return CONTROL_UNKNOWN; | |
54 } | |
55 | |
56 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen) | |
57 { | |
7410 | 58 if(sh_audio->format==0x31 || sh_audio->format==0x32){ |
5345 | 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 | |
62 return 2*320; | |
7410 | 63 } else { |
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 | |
67 return 2*160; | |
68 } | |
5345 | 69 } |