annotate libao2/pl_format.c @ 14360:ed9c07a9915a

Cumulative sync with 1.840: 1.840: just typos. 1.839: alphabetical order 1.838: small fixes/improvements (by Sebastian Kraemer, except the hyphen stuff)
author gpoirier
date Tue, 04 Jan 2005 21:13:05 +0000
parents 137896e25c24
children
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>
6237
2eec40929570 warning fixes (string.h is required for memset)
pl
parents: 3309
diff changeset
12 #include <string.h>
3195
62d797a16f72 unistd.h required at least by FreeBSD
nexus
parents: 3194
diff changeset
13 #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
14 #include <inttypes.h>
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
15
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
16 #include "audio_out.h"
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
17 #include "audio_plugin.h"
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
18 #include "audio_plugin_internal.h"
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
19 #include "libaf/af_format.h"
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
20
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
21 static ao_info_t info =
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
22 {
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
23 "Sample format conversion audio plugin",
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
24 "format",
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
25 "Anders",
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
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
29 LIBAO_PLUGIN_EXTERN(format)
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
30
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
31 // local data
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
32 typedef struct pl_format_s
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
33 {
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
34 void* data; // local audio data block
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
35 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
36 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
37 int out; // output fomat
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
38 double sz_mult; // data size multiplier
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
39 } pl_format_t;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
40
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
41 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
42
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
43 // 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
44 #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
45 #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
46 #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
47 #define NBITS_MASK (3<<0)
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
48
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
49 // 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
50 #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
51 #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
52 #define END_MASK (1<<2)
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
53
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
54 // 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
55 #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
56 #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
57 #define SIGN_MASK (1<<3)
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
58
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
59 // to set/get/query special features/parameters
9633
12b1790038b0 64bit libao2 fix by Jens Axboe <mplayer-dev@kernel.dk>
alex
parents: 9217
diff changeset
60 static int control(int cmd,void *arg){
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
61 switch(cmd){
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
62 case AOCONTROL_PLUGIN_SET_LEN:
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
63 if(pl_format.data)
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
64 free(pl_format.data);
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
65 pl_format.len = ao_plugin_data.len;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
66 pl_format.data=(void*)malloc(ao_plugin_data.len);
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
67 if(!pl_format.data)
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
68 return CONTROL_ERROR;
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
69 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
70 return CONTROL_OK;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
71 }
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
72 return -1;
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
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
75 // open & setup audio device
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
76 // return: 1=success 0=fail
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
77 static int init(){
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
78 char buf1[128], buf2[128];
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
79 // Sheck input format
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
80 switch(ao_plugin_data.format){
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
81 case(AF_FORMAT_U8):
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
82 pl_format.in=LE|B08|US; break;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
83 case(AF_FORMAT_S8):
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
84 pl_format.in=LE|B08|SI; break;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
85 case(AF_FORMAT_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
86 pl_format.in=LE|B16|SI; break;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
87 case(AF_FORMAT_S16_BE):
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
88 pl_format.in=BE|B16|SI; break;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
89 case(AF_FORMAT_U16_LE):
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
90 pl_format.in=LE|B16|US; break;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
91 case(AF_FORMAT_U16_BE):
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
92 pl_format.in=BE|B16|US; break;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
93 case(AF_FORMAT_S32_LE):
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
94 pl_format.in=LE|B32|SI; break;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
95 case(AF_FORMAT_S32_BE):
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
96 pl_format.in=BE|B32|SI; break;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
97 case(AF_FORMAT_IMA_ADPCM):
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
98 case(AF_FORMAT_MU_LAW):
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
99 case(AF_FORMAT_A_LAW):
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
100 case(AF_FORMAT_MPEG2):
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
101 case(AF_FORMAT_AC3):
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
102 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
103 return 0;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
104 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
105 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
106 return 0;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
107 }
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
108 // Sheck output format
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
109 switch(ao_plugin_cfg.pl_format_type){
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
110 case(AF_FORMAT_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
111 pl_format.out=LE|B08|US; break;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
112 case(AF_FORMAT_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
113 pl_format.out=LE|B08|SI; break;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
114 case(AF_FORMAT_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
115 pl_format.out=LE|B16|SI; break;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
116 case(AF_FORMAT_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
117 pl_format.out=BE|B16|SI; break;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
118 case(AF_FORMAT_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
119 pl_format.out=LE|B16|US; break;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
120 case(AF_FORMAT_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
121 pl_format.out=BE|B16|US; break;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
122 case(AF_FORMAT_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
123 pl_format.out=LE|B32|SI; break;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
124 case(AF_FORMAT_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
125 pl_format.out=BE|B32|SI; break;
14245
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
126 case(AF_FORMAT_IMA_ADPCM):
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
127 case(AF_FORMAT_MU_LAW):
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
128 case(AF_FORMAT_A_LAW):
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
129 case(AF_FORMAT_MPEG2):
815f03b7cee5 removing AFMT_ dependancy
alex
parents: 9633
diff changeset
130 case(AF_FORMAT_AC3):
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
131 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
132 return 0;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
133 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
134 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
135 return 0;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
136 }
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
137
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 // 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
139 printf("[pl_format] Input format: %s, output format: %s \n",
14255
137896e25c24 100l, buf etc. in af_fmt2str call are already pointers...
reimar
parents: 14245
diff changeset
140 af_fmt2str(ao_plugin_data.format, buf1, 128),
137896e25c24 100l, buf etc. in af_fmt2str call are already pointers...
reimar
parents: 14245
diff changeset
141 af_fmt2str(ao_plugin_cfg.pl_format_type, buf2, 128));
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
142
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
143 // We are changing the format
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
144 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
145
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
146 // And perhaps the buffer size
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
147 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
148 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
149 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
150 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
151 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
152 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
153
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
154 return 1;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
155 }
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
156
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
157 // close plugin
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
158 static void uninit(){
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
159 if(pl_format.data)
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
160 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
161 pl_format.data=NULL;
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
162 }
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
163
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
164 // empty buffers
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
165 static void reset(){
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
166 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
167 }
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
168
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
169 // 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
170 // 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
171 // 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
172 static int play(){
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
173 register int i=0;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
174 void* in_data=ao_plugin_data.data;
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
175 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
176 int len=(ao_plugin_data.len)>>(pl_format.in&NBITS_MASK);
7075
b9f7aec2e07d Fixed *= bug in length calculation
anders
parents: 6237
diff changeset
177 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
178
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
179 // 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
180 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
181 switch(pl_format.in&NBITS_MASK){
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
182 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
183 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
184 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
185 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
186 ((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
187 }
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
188 }
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
189 break;
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
190 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
191 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
192 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
193 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
194 ((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
195 ((s&0x00FF0000)>>8) | ((s&0xFF000000)>>24));
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
196 }
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
197 }
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
198 break;
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
199 }
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
200 }
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
201 // 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
202 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
203 switch((pl_format.in&NBITS_MASK)){
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
204 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
205 switch(pl_format.in&SIGN_MASK){
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
206 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
207 for(i=0;i<len;i++)
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
208 ((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
209 break;
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
210 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
211 for(i=0;i<len;i++)
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
212 ((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
213 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
214 }
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 break;
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
216 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
217 switch(pl_format.in&SIGN_MASK){
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
218 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
219 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
220 ((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
221 break;
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
222 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
223 for(i=0;i<len;i++)
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
224 ((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
225 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
226 }
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 break;
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
228 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
229 switch(pl_format.in&SIGN_MASK){
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
230 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
231 for(i=0;i<len;i++)
9217
420e2b2f8e5a compiler warning fixes patch by Dominik Mierzejewski <dominik@rangers.eu.org>
arpi
parents: 7075
diff changeset
232 ((int32_t*)in_data)[i]=(int32_t)(((uint32_t*)in_data)[i]-0x80000000);
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 break;
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
234 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
235 for(i=0;i<len;i++)
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
236 ((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
237 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
238 }
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 break;
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
240 }
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
241 }
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 // 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
243 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
244 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
245 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
246 ((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
247 } 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
248 switch(pl_format.in&NBITS_MASK){
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
249 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
250 switch(pl_format.out&NBITS_MASK){
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
251 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
252 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
253 ((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
254 break;
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
255 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
256 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
257 ((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
258 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
259 }
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
260 break;
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
261 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
262 switch(pl_format.out&NBITS_MASK){
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
263 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
264 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
265 ((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
266 break;
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
267 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
268 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
269 ((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
270 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
271 }
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
272 break;
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
273 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
274 switch(pl_format.out&NBITS_MASK){
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
275 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
276 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
277 ((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
278 break;
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
279 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
280 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
281 ((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
282 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
283 }
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
284 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
285 }
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 }
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 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
288 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
289 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
290 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
291 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
292 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
293 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
294 ((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
295 }
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 }
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
297 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
298 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
299 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
300 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
301 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
302 ((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
303 ((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
304 }
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 }
3309
28f2ebcb5c95 Format plugin now with working switch statements
anders
parents: 3279
diff changeset
306 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
307 }
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
308 }
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
309 ao_plugin_data.data=out_data;
3194
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
310 return 1;
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
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
313
1648d11fc36c commandline configuration of audio plugins now through struct, format conversion plugin added
anders
parents:
diff changeset
314
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
315
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
316