annotate libmpcodecs/ad_msgsm.c @ 25813:ba7bd4f7e322

Add global ass_force_reload flag. If it is set, renderer is reconfigured before the next frame.
author eugeni
date Wed, 23 Jan 2008 21:18:30 +0000
parents e0a6fb06f058
children 0f1b5b68af32
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
5345
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
1 #include <stdio.h>
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
2 #include <stdlib.h>
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
3 #include <unistd.h>
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
4
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
5 #include "config.h"
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
6 #include "ad_internal.h"
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
7
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
8 static ad_info_t info =
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
9 {
7410
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
10 "native GSM/MSGSM audio decoder",
5345
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
11 "msgsm",
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
12 "A'rpi",
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
13 "XAnim",
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
14 ""
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
15 };
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
16
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
17 LIBAD_EXTERN(msgsm)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
18
22587
e0a6fb06f058 Use explicit header location, don't use CFLAGS for simple subdirectories.
diego
parents: 13427
diff changeset
19 #include "native/xa_gsm.h"
5345
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
20
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
21 static int init(sh_audio_t *sh_audio)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
22 {
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
23 if(!sh_audio->wf) return 0;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
24 // MS-GSM audio codec:
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
25 GSM_Init();
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
26 sh_audio->channels=sh_audio->wf->nChannels;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
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
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
29 // decodes 65 byte -> 320 short
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
30 // 1 sec: sh_audio->channels*sh_audio->samplerate samples
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
31 // 1 frame: 320 samples
7410
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
32 if(sh_audio->format==0x31 || sh_audio->format==0x32){
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
33 sh_audio->ds->ss_mul=65; sh_audio->ds->ss_div=320;
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
34 } else {
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
35 sh_audio->ds->ss_mul=33; sh_audio->ds->ss_div=160;
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
36 }
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
37 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
38 return 1;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
39 }
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
40
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
41 static int preinit(sh_audio_t *sh_audio)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
42 {
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
43 sh_audio->audio_out_minsize=4*320;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
44 return 1;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
45 }
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
46
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
47 static void uninit(sh_audio_t *sh)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
48 {
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
49 }
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
50
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
51 static int control(sh_audio_t *sh,int cmd,void* arg, ...)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
52 {
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
53 return CONTROL_UNKNOWN;
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
54 }
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
55
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
56 static int decode_audio(sh_audio_t *sh_audio,unsigned char *buf,int minlen,int maxlen)
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
57 {
7410
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
58 if(sh_audio->format==0x31 || sh_audio->format==0x32){
5345
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
59 unsigned char ibuf[65]; // 65 bytes / frame
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
60 if(demux_read_data(sh_audio->ds,ibuf,65)!=65) return -1; // EOF
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
61 XA_MSGSM_Decoder(ibuf,(unsigned short *) buf); // decodes 65 byte -> 320 short
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
62 return 2*320;
7410
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
63 } else {
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
64 unsigned char ibuf[33]; // 33 bytes / frame
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
65 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
66 XA_GSM_Decoder(ibuf,(unsigned short *) buf); // decodes 33 byte -> 160 short
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
67 return 2*160;
1578dc56a9ad standard GSM support for .mov files
arpi
parents: 7180
diff changeset
68 }
5345
81071ffb7b22 ad_msgsm added
arpi
parents:
diff changeset
69 }