annotate libmpcodecs/ad_msgsm.c @ 31001:6215761e4d02

sync with en/mplayer.1 rev. 31028
author jrash
date Sat, 17 Apr 2010 02:14:55 +0000
parents cc27da5d7286
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
19 #include <stdio.h>
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
20 #include <stdlib.h>
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
21 #include <unistd.h>
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
22
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
23 #include "config.h"
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
24 #include "ad_internal.h"
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
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
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
27 {
7410
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
28 "native GSM/MSGSM audio decoder",
5345
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
29 "msgsm",
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
30 "A'rpi",
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
31 "XAnim",
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
32 ""
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
33 };
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
34
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
35 LIBAD_EXTERN(msgsm)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
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
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
38
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
39 static int init(sh_audio_t *sh_audio)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
40 {
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
41 if(!sh_audio->wf) return 0;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
42 // MS-GSM audio codec:
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
43 GSM_Init();
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
44 sh_audio->channels=sh_audio->wf->nChannels;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
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
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
47 // decodes 65 byte -> 320 short
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
48 // 1 sec: sh_audio->channels*sh_audio->samplerate samples
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
49 // 1 frame: 320 samples
7410
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
50 if(sh_audio->format==0x31 || sh_audio->format==0x32){
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
51 sh_audio->ds->ss_mul=65; sh_audio->ds->ss_div=320;
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
52 } else {
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
53 sh_audio->ds->ss_mul=33; sh_audio->ds->ss_div=160;
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
54 }
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
55 sh_audio->i_bps=sh_audio->ds->ss_mul*(sh_audio->channels*sh_audio->samplerate)/sh_audio->ds->ss_div; // 1:10
5345
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
56 return 1;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
57 }
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
58
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
59 static int preinit(sh_audio_t *sh_audio)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
60 {
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
61 sh_audio->audio_out_minsize=4*320;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
62 return 1;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
63 }
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
64
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
65 static void uninit(sh_audio_t *sh)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
66 {
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
67 }
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
68
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
69 static int control(sh_audio_t *sh,int cmd,void* arg, ...)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
70 {
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
71 return CONTROL_UNKNOWN;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
72 }
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
73
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
74 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
75 {
7410
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
76 if(sh_audio->format==0x31 || sh_audio->format==0x32){
5345
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
77 unsigned char ibuf[65]; // 65 bytes / frame
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
78 if(demux_read_data(sh_audio->ds,ibuf,65)!=65) return -1; // EOF
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
79 XA_MSGSM_Decoder(ibuf,(unsigned short *) buf); // decodes 65 byte -> 320 short
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
80 return 2*320;
7410
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
81 } else {
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
82 unsigned char ibuf[33]; // 33 bytes / frame
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
83 if(demux_read_data(sh_audio->ds,ibuf,33)!=33) return -1; // EOF
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
84 XA_GSM_Decoder(ibuf,(unsigned short *) buf); // decodes 33 byte -> 160 short
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
85 return 2*160;
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
86 }
5345
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
87 }