annotate libao2/pl_format.c @ 3755:b805040d6645

release todo
author arpi
date Wed, 26 Dec 2001 02:42:44 +0000
parents 28f2ebcb5c95
children 2eec40929570
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
1 /* This audio output plugin changes the format of a data block. Valid
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
2 output formats are: AFMT_U8, AFMT_S8, AFMT_S16_LE, AFMT_S16_BE
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
3 AFMT_U16_LE, AFMT_U16_BE, AFMT_S32_LE and AFMT_S32_BE. The output
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
4 format is spedified using the cfg switch 'format=NR' where NR is
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
5 the number as given in libao2/afmt.h
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
6 */
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
7
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
8 #define PLUGIN
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
9
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
10 #include <stdio.h>
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
11 #include <stdlib.h>
3195
62d797a16f72 unistd.h required at least by FreeBSD
nexus
parents: 3194
diff changeset
12 #include <unistd.h>
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
13 #include <inttypes.h>
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
14
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
15 #include "audio_out.h"
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
16 #include "audio_plugin.h"
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
17 #include "audio_plugin_internal.h"
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
18 #include "afmt.h"
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
19
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
20 static ao_info_t info =
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
21 {
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
22 "Sample format conversion audio plugin",
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
23 "format",
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
24 "Anders",
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
25 ""
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
26 };
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
27
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
28 LIBAO_PLUGIN_EXTERN(format)
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
29
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
30 // local data
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
31 typedef struct pl_format_s
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
32 {
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
33 void* data; // local audio data block
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
34 int len; // local buffer length
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
35 int in; // input fomat
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
36 int out; // output fomat
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
37 double sz_mult; // data size multiplier
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
38 } pl_format_t;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
39
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
40 static pl_format_t pl_format={NULL,0,0,0,1};
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
41
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
42 // Number of bits
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
43 #define B08 (0<<0)
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
44 #define B16 (1<<0)
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
45 #define B32 (2<<0)
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
46 #define NBITS_MASK (3<<0)
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
47
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
48 // Endianess
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
49 #define BE (0<<2) // Big Endian
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
50 #define LE (1<<2) // Little Endian
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
51 #define END_MASK (1<<2)
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
52
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
53 // Signed
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
54 #define US (0<<3) // Un Signed
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
55 #define SI (1<<3) // SIgned
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
56 #define SIGN_MASK (1<<3)
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
57
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
58 // to set/get/query special features/parameters
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
59 static int control(int cmd,int arg){
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
60 switch(cmd){
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
61 case AOCONTROL_PLUGIN_SET_LEN:
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
62 if(pl_format.data)
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
63 free(pl_format.data);
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
64 pl_format.len = ao_plugin_data.len;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
65 pl_format.data=(void*)malloc(ao_plugin_data.len);
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
66 if(!pl_format.data)
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
67 return CONTROL_ERROR;
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
68 ao_plugin_data.len=(int)(((double)ao_plugin_data.len)/pl_format.sz_mult);
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
69 return CONTROL_OK;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
70 }
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
71 return -1;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
72 }
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
73
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
74 // open & setup audio device
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
75 // return: 1=success 0=fail
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
76 static int init(){
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
77 // Sheck input format
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
78 switch(ao_plugin_data.format){
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
79 case(AFMT_U8):
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
80 pl_format.in=LE|B08|US; break;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
81 case(AFMT_S8):
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
82 pl_format.in=LE|B08|SI; break;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
83 case(AFMT_S16_LE):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
84 pl_format.in=LE|B16|SI; break;
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
85 case(AFMT_S16_BE):
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
86 pl_format.in=BE|B16|SI; break;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
87 case(AFMT_U16_LE):
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
88 pl_format.in=LE|B16|US; break;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
89 case(AFMT_U16_BE):
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
90 pl_format.in=BE|B16|US; break;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
91 case(AFMT_S32_LE):
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
92 pl_format.in=LE|B32|SI; break;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
93 case(AFMT_S32_BE):
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
94 pl_format.in=BE|B32|SI; break;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
95 case(AFMT_IMA_ADPCM):
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
96 case(AFMT_MU_LAW):
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
97 case(AFMT_A_LAW):
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
98 case(AFMT_MPEG):
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
99 case(AFMT_AC3):
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
100 printf("[pl_format] Input audio format not yet suported \n");
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
101 return 0;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
102 default:
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
103 printf("[pl_format] Unrecognised input audio format\n"); //This can not happen ....
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
104 return 0;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
105 }
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
106 // Sheck output format
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
107 switch(ao_plugin_cfg.pl_format_type){
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
108 case(AFMT_U8):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
109 pl_format.out=LE|B08|US; break;
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
110 case(AFMT_S8):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
111 pl_format.out=LE|B08|SI; break;
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
112 case(AFMT_S16_LE):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
113 pl_format.out=LE|B16|SI; break;
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
114 case(AFMT_S16_BE):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
115 pl_format.out=BE|B16|SI; break;
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
116 case(AFMT_U16_LE):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
117 pl_format.out=LE|B16|US; break;
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
118 case(AFMT_U16_BE):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
119 pl_format.out=BE|B16|US; break;
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
120 case(AFMT_S32_LE):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
121 pl_format.out=LE|B32|SI; break;
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
122 case(AFMT_S32_BE):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
123 pl_format.out=BE|B32|SI; break;
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
124 case(AFMT_IMA_ADPCM):
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
125 case(AFMT_MU_LAW):
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
126 case(AFMT_A_LAW):
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
127 case(AFMT_MPEG):
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
128 case(AFMT_AC3):
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
129 printf("[pl_format] Output audio format not yet suported \n");
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
130 return 0;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
131 default:
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
132 printf("[pl_format] Unrecognised audio output format\n");
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
133 return 0;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
134 }
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
135
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
136 // Tell the world what we are up to
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
137 printf("[pl_format] Input format: %s, output format: %s \n",
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
138 audio_out_format_name(ao_plugin_data.format),
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
139 audio_out_format_name(ao_plugin_cfg.pl_format_type));
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
140
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
141 // We are changing the format
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
142 ao_plugin_data.format=ao_plugin_cfg.pl_format_type;
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
143
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
144 // And perhaps the buffer size
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
145 pl_format.sz_mult=1;
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
146 if((pl_format.in&NBITS_MASK) > (pl_format.out&NBITS_MASK))
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
147 pl_format.sz_mult/=(double)(1<<((pl_format.in&NBITS_MASK)-(pl_format.out&NBITS_MASK)));
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
148 if((pl_format.in&NBITS_MASK) < (pl_format.out&NBITS_MASK))
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
149 pl_format.sz_mult*=(double)(1<<((pl_format.out&NBITS_MASK)-(pl_format.in&NBITS_MASK)));
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
150 ao_plugin_data.sz_mult/=pl_format.sz_mult;
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
151
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
152 return 1;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
153 }
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
154
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
155 // close plugin
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
156 static void uninit(){
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
157 if(pl_format.data)
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
158 free(pl_format.data);
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
159 pl_format.data=NULL;
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
160 }
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
161
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
162 // empty buffers
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
163 static void reset(){
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
164 memset(pl_format.data, 0, pl_format.len);
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
165 }
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
166
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
167 // processes 'ao_plugin_data.len' bytes of 'data'
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
168 // called for every block of data
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
169 // FIXME: this routine needs to be optimized (it is probably possible to do a lot here)
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
170 static int play(){
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
171 register int i=0;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
172 void* in_data=ao_plugin_data.data;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
173 void* out_data=pl_format.data;
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
174 int len=(ao_plugin_data.len)>>(pl_format.in&NBITS_MASK);
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
175 ao_plugin_data.len=(int)(((double)ao_plugin_data.len)*=pl_format.sz_mult);
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
176
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
177 // Change to little endian (Is this true for sun ?)
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
178 if((pl_format.in&END_MASK)!=LE){
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
179 switch(pl_format.in&NBITS_MASK){
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
180 case(B16):{
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
181 register uint16_t s;
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
182 for(i=1;i<len;i++){
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
183 s=((uint16_t*)in_data)[i];
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
184 ((uint16_t*)in_data)[i]=(uint16_t)(((s&0x00FF)<<8) | (s&0xFF00)>>8);
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
185 }
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
186 }
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
187 break;
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
188 case(B32):{
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
189 register uint32_t s;
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
190 for(i=1;i<len;i++){
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
191 s=((uint32_t*)in_data)[i];
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
192 ((uint32_t*)in_data)[i]=(uint32_t)(((s&0x000000FF)<<24) | ((s&0x0000FF00)<<8) |
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
193 ((s&0x00FF0000)>>8) | ((s&0xFF000000)>>24));
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
194 }
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
195 }
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
196 break;
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
197 }
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
198 }
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
199 // Change signed/unsigned
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
200 if((pl_format.in&SIGN_MASK) != (pl_format.out&SIGN_MASK)){
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
201 switch((pl_format.in&NBITS_MASK)){
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
202 case(B08):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
203 switch(pl_format.in&SIGN_MASK){
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
204 case(US):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
205 for(i=0;i<len;i++)
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
206 ((int8_t*)in_data)[i]=(int8_t)(-127+((int)((uint8_t*)in_data)[i]));
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
207 break;
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
208 case(SI):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
209 for(i=0;i<len;i++)
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
210 ((uint8_t*)in_data)[i]=(uint8_t)(+128+((int)((int8_t*)in_data)[i]));
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
211 break;
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
212 }
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
213 break;
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
214 case(B16):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
215 switch(pl_format.in&SIGN_MASK){
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
216 case(US):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
217 for(i=0;i<len;i++)
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
218 ((int16_t*)in_data)[i]=(int16_t)(-32767+((int)((uint16_t*)in_data)[i]));
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
219 break;
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
220 case(SI):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
221 for(i=0;i<len;i++)
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
222 ((uint16_t*)in_data)[i]=(uint16_t)(+32768+((int)((int16_t*)in_data)[i]));
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
223 break;
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
224 }
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
225 break;
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
226 case(B32):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
227 switch(pl_format.in&SIGN_MASK){
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
228 case(US):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
229 for(i=0;i<len;i++)
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
230 ((int32_t*)in_data)[i]=(int32_t)(-(1<<31-1)+((uint32_t*)in_data)[i]);
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
231 break;
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
232 case(SI):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
233 for(i=0;i<len;i++)
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
234 ((uint32_t*)in_data)[i]=(uint32_t)(+(1<<31)+((int32_t*)in_data)[i]);
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
235 break;
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
236 }
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
237 break;
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
238 }
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
239 }
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
240 // Change the number of bits
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
241 if((pl_format.in&NBITS_MASK) == (pl_format.out&NBITS_MASK)){
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
242 int sz=(int)((double)ao_plugin_data.len/pl_format.sz_mult);
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
243 for(i=0;i<sz;i++)
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
244 ((char*)out_data)[i]=((char*)in_data)[i];
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
245 } else {
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
246 switch(pl_format.in&NBITS_MASK){
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
247 case(B08):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
248 switch(pl_format.out&NBITS_MASK){
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
249 case(B16):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
250 for(i=1;i<len;i++)
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
251 ((uint16_t*)out_data)[i]=((uint16_t)((uint8_t*)in_data)[i])<<8;
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
252 break;
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
253 case(B32):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
254 for(i=1;i<len;i++)
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
255 ((uint32_t*)out_data)[i]=((uint32_t)((uint8_t*)in_data)[i])<<24;
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
256 break;
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
257 }
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
258 break;
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
259 case(B16):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
260 switch(pl_format.out&NBITS_MASK){
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
261 case(B08):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
262 for(i=0;i<len;i++)
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
263 ((uint8_t*)out_data)[i]=(uint8_t)((((uint16_t*)in_data)[i])>>8);
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
264 break;
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
265 case(B32):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
266 for(i=1;i<len;i++)
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
267 ((uint32_t*)out_data)[i]=((uint32_t)((uint16_t*)in_data)[i])<<16;
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
268 break;
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
269 }
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
270 break;
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
271 case(B32):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
272 switch(pl_format.out&NBITS_MASK){
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
273 case(B08):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
274 for(i=0;i<len;i++)
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
275 ((uint8_t*)out_data)[i]=(uint8_t)((((uint32_t*)in_data)[i])>>24);
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
276 break;
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
277 case(B16):
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
278 for(i=1;i<len;i++)
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
279 ((uint16_t*)out_data)[i]=(uint16_t)((((uint32_t*)in_data)[i])>>16);
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
280 break;
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
281 }
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
282 break;
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
283 }
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
284 }
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
285 // Switch to the correct endainess (agiain the problem with sun?)
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
286 if((pl_format.out&END_MASK)!=LE){
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
287 switch(pl_format.in&NBITS_MASK){
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
288 case(B16):{
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
289 register uint16_t s;
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
290 for(i=1;i<len;i++){
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
291 s=((uint16_t*)out_data)[i];
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
292 ((uint16_t*)out_data)[i]=(uint16_t)(((s&0x00FF)<<8) | (s&0xFF00)>>8);
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
293 }
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
294 }
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
295 break;
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
296 case(B32):{
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
297 register uint32_t s;
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
298 for(i=1;i<len;i++){
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
299 s=((uint32_t*)out_data)[i];
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
300 ((uint32_t*)out_data)[i]=(uint32_t)(((s&0x000000FF)<<24) | ((s&0x0000FF00)<<8) |
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
301 ((s&0x00FF0000)>>8) | ((s&0xFF000000)>>24));
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
302 }
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
303 }
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
304 break;
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
305 }
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
306 }
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
307 ao_plugin_data.data=out_data;
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
308 return 1;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
309 }
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
310
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
311
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
312
3279
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
313
d6ea11bed983 Commandline interface to ao_plugin updated according to mplayers complex parameter format and plugin pl_format finished (alpha code needs testing)
anders
parents: 3195
diff changeset
314