Mercurial > mplayer.hg
annotate libmpcodecs/ad_msgsm.c @ 30738:25622198a15a
Make -slave also work with the normal console on Windows.
author | reimar |
---|---|
date | Sat, 27 Feb 2010 23:12:34 +0000 |
parents | cc27da5d7286 |
children |
rev | line source |
---|---|
30421
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
1 /* |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
2 * This file is part of MPlayer. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
3 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
4 * MPlayer is free software; you can redistribute it and/or modify |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
5 * it under the terms of the GNU General Public License as published by |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
6 * the Free Software Foundation; either version 2 of the License, or |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
7 * (at your option) any later version. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
8 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
9 * MPlayer is distributed in the hope that it will be useful, |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
12 * GNU General Public License for more details. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
13 * |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
14 * You should have received a copy of the GNU General Public License along |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
15 * with MPlayer; if not, write to the Free Software Foundation, Inc., |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
16 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
17 */ |
bbb6ebec87a0
Add missing license headers to all files in the libmpcodecs directory.
diego
parents:
29263
diff
changeset
|
18 |
5345 | 19 #include <stdio.h> |
20 #include <stdlib.h> | |
21 #include <unistd.h> | |
22 | |
23 #include "config.h" | |
24 #include "ad_internal.h" | |
25 | |
30504
cc27da5d7286
Mark all ad_info_t/vd_info_t structure declarations as const.
diego
parents:
30421
diff
changeset
|
26 static const ad_info_t info = |
5345 | 27 { |
7410 | 28 "native GSM/MSGSM audio decoder", |
5345 | 29 "msgsm", |
30 "A'rpi", | |
31 "XAnim", | |
32 "" | |
33 }; | |
34 | |
35 LIBAD_EXTERN(msgsm) | |
36 | |
22587
e0a6fb06f058
Use explicit header location, don't use CFLAGS for simple subdirectories.
diego
parents:
13427
diff
changeset
|
37 #include "native/xa_gsm.h" |
5345 | 38 |
39 static int init(sh_audio_t *sh_audio) | |
40 { | |
41 if(!sh_audio->wf) return 0; | |
42 // MS-GSM audio codec: | |
43 GSM_Init(); | |
44 sh_audio->channels=sh_audio->wf->nChannels; | |
45 sh_audio->samplerate=sh_audio->wf->nSamplesPerSec; | |
13427
9d0b052c4f74
setting samplesize to 2 in decoders where neccessary.
reimar
parents:
7410
diff
changeset
|
46 sh_audio->samplesize=2; |
5345 | 47 // decodes 65 byte -> 320 short |
48 // 1 sec: sh_audio->channels*sh_audio->samplerate samples | |
49 // 1 frame: 320 samples | |
7410 | 50 if(sh_audio->format==0x31 || sh_audio->format==0x32){ |
51 sh_audio->ds->ss_mul=65; sh_audio->ds->ss_div=320; | |
52 } else { | |
53 sh_audio->ds->ss_mul=33; sh_audio->ds->ss_div=160; | |
54 } | |
55 sh_audio->i_bps=sh_audio->ds->ss_mul*(sh_audio->channels*sh_audio->samplerate)/sh_audio->ds->ss_div; // 1:10 | |
5345 | 56 return 1; |
57 } | |
58 | |
59 static int preinit(sh_audio_t *sh_audio) | |
60 { | |
61 sh_audio->audio_out_minsize=4*320; | |
62 return 1; | |
63 } | |
64 | |
65 static void uninit(sh_audio_t *sh) | |
66 { | |
67 } | |
68 | |
69 static int control(sh_audio_t *sh,int cmd,void* arg, ...) | |
70 { | |
71 return CONTROL_UNKNOWN; | |
72 } | |
73 | |
74 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen) | |
75 { | |
7410 | 76 if(sh_audio->format==0x31 || sh_audio->format==0x32){ |
5345 | 77 unsigned char ibuf[65]; // 65 bytes / frame |
78 if(demux_read_data(sh_audio->ds,ibuf,65)!=65) return -1; // EOF | |
79 XA_MSGSM_Decoder(ibuf,(unsigned short *) buf); // decodes 65 byte -> 320 short | |
80 return 2*320; | |
7410 | 81 } else { |
82 unsigned char ibuf[33]; // 33 bytes / frame | |
83 if(demux_read_data(sh_audio->ds,ibuf,33)!=33) return -1; // EOF | |
84 XA_GSM_Decoder(ibuf,(unsigned short *) buf); // decodes 33 byte -> 160 short | |
85 return 2*160; | |
86 } | |
5345 | 87 } |