annotate libaf/af_format.c @ 36673:1285e5ce2054

Prettify the skin browser. Use the same design as with the other similar lists (available audio and video drivers, playlist).
author ib
date Fri, 31 Jan 2014 17:08:39 +0000
parents 06cf8a9249f7
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
28229
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 26345
diff changeset
1 /*
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 26345
diff changeset
2 * This audio filter changes the format of a data block. Valid
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 26345
diff changeset
3 * formats are: AFMT_U8, AFMT_S8, AFMT_S16_LE, AFMT_S16_BE
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 26345
diff changeset
4 * AFMT_U16_LE, AFMT_U16_BE, AFMT_S32_LE and AFMT_S32_BE.
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 26345
diff changeset
5 *
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 26345
diff changeset
6 * This file is part of MPlayer.
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 26345
diff changeset
7 *
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 26345
diff changeset
8 * MPlayer is free software; you can redistribute it and/or modify
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 26345
diff changeset
9 * it under the terms of the GNU General Public License as published by
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 26345
diff changeset
10 * the Free Software Foundation; either version 2 of the License, or
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 26345
diff changeset
11 * (at your option) any later version.
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 26345
diff changeset
12 *
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 26345
diff changeset
13 * MPlayer is distributed in the hope that it will be useful,
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 26345
diff changeset
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 26345
diff changeset
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 26345
diff changeset
16 * GNU General Public License for more details.
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 26345
diff changeset
17 *
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 26345
diff changeset
18 * You should have received a copy of the GNU General Public License along
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 26345
diff changeset
19 * with MPlayer; if not, write to the Free Software Foundation, Inc.,
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 26345
diff changeset
20 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
72d0b1444141 Replace informal license notices by standard license header
diego
parents: 26345
diff changeset
21 */
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
22
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
23 #include <stdio.h>
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
24 #include <stdlib.h>
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
25 #include <string.h>
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
26 #include <inttypes.h>
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
27 #include <limits.h>
28337
34b7297904ac Drop HAVE_LRINTF check, lrintf is used without checking in other places.
diego
parents: 28333
diff changeset
28 #include <math.h>
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
29
28333
0ec2ac66f064 Fix build: Add required header and adjust preprocessor check.
diego
parents: 28238
diff changeset
30 #include "config.h"
21353
a965ca17debc reordering of #include to avoid clash with math.h and quicktime/*.h, patch by Crhis Roccati<roccati@pobox.com>
nplourde
parents: 16982
diff changeset
31 #include "af.h"
34174
a93891202051 Add missing mp_msg.h #includes, remove some unnecessary ones.
diego
parents: 33736
diff changeset
32 #include "mp_msg.h"
21507
fa99b3d31d13 Hack around libavutil/bswap.h compilation problems due to always_inline undefined.
reimar
parents: 21372
diff changeset
33 #include "mpbswap.h"
21353
a965ca17debc reordering of #include to avoid clash with math.h and quicktime/*.h, patch by Crhis Roccati<roccati@pobox.com>
nplourde
parents: 16982
diff changeset
34 #include "libvo/fastmemcpy.h"
a965ca17debc reordering of #include to avoid clash with math.h and quicktime/*.h, patch by Crhis Roccati<roccati@pobox.com>
nplourde
parents: 16982
diff changeset
35
33723
6c8743e5fa30 Audio format conversion from float to int is not checked for overflow.
iive
parents: 30241
diff changeset
36 #include "libavutil/avutil.h"
35712
d206960484fe Add a number of missing libavutil header #includes.
diego
parents: 35451
diff changeset
37 #include "libavutil/common.h"
33723
6c8743e5fa30 Audio format conversion from float to int is not checked for overflow.
iive
parents: 30241
diff changeset
38
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
39 /* Functions used by play to convert the input audio to the correct
e8832e66babd New features:
anders
parents: 7998
diff changeset
40 format */
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
41
24561
90b0691d9709 Fix loads of typos
reimar
parents: 24521
diff changeset
42 /* The below includes retrieves functions for converting to and from
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
43 ulaw and alaw */
28238
1bf9023840f9 Rename libaf/af_format_alaw.c --> libaf/af_format_alaw.h and
diego
parents: 28236
diff changeset
44 #include "af_format_ulaw.h"
1bf9023840f9 Rename libaf/af_format_alaw.c --> libaf/af_format_alaw.h and
diego
parents: 28236
diff changeset
45 #include "af_format_alaw.h"
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
46
24561
90b0691d9709 Fix loads of typos
reimar
parents: 24521
diff changeset
47 // Switch endianness
36391
3b1fb70800f4 Add some "const" to input-only pointers.
reimar
parents: 36384
diff changeset
48 static void endian(const void* in, void* out, int len, int bps);
24561
90b0691d9709 Fix loads of typos
reimar
parents: 24521
diff changeset
49 // From signed to unsigned and the other way
16664
9991e406a2a2 much simpler signed/unsigned conversion.
reimar
parents: 15311
diff changeset
50 static void si2us(void* data, int len, int bps);
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
51 // Change the number of bits per sample
36391
3b1fb70800f4 Add some "const" to input-only pointers.
reimar
parents: 36384
diff changeset
52 static void change_bps(const void* in, void* out, int len, int inbps, int outbps);
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
53 // From float to int signed
36391
3b1fb70800f4 Add some "const" to input-only pointers.
reimar
parents: 36384
diff changeset
54 static void float2int(const float* in, void* out, int len, int bps);
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
55 // From signed int to float
36391
3b1fb70800f4 Add some "const" to input-only pointers.
reimar
parents: 36384
diff changeset
56 static void int2float(const void* in, float* out, int len, int bps);
7719
41e8d0916c60 Fix for audio filters on big endian cpus. It's working now on Solaris SPARC &
jkeil
parents: 7711
diff changeset
57
14272
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
58 static af_data_t* play(struct af_instance_s* af, af_data_t* data);
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
59 static af_data_t* play_swapendian(struct af_instance_s* af, af_data_t* data);
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
60 static af_data_t* play_float_s16(struct af_instance_s* af, af_data_t* data);
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
61 static af_data_t* play_s16_float(struct af_instance_s* af, af_data_t* data);
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
62
8607
d6f40a06867b Changes includes:
anders
parents: 8185
diff changeset
63 // Helper functions to check sanity for input arguments
d6f40a06867b Changes includes:
anders
parents: 8185
diff changeset
64
d6f40a06867b Changes includes:
anders
parents: 8185
diff changeset
65 // Sanity check for bytes per sample
13989
dcb6b4a33aaa declare check_format and check_bps static, they are used nowhere else.
reimar
parents: 12486
diff changeset
66 static int check_bps(int bps)
8607
d6f40a06867b Changes includes:
anders
parents: 8185
diff changeset
67 {
12478
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
68 if(bps != 4 && bps != 3 && bps != 2 && bps != 1){
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
69 mp_msg(MSGT_AFILTER, MSGL_ERR, "[format] The number of bytes per sample"
12478
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
70 " must be 1, 2, 3 or 4. Current value is %i \n",bps);
8607
d6f40a06867b Changes includes:
anders
parents: 8185
diff changeset
71 return AF_ERROR;
d6f40a06867b Changes includes:
anders
parents: 8185
diff changeset
72 }
d6f40a06867b Changes includes:
anders
parents: 8185
diff changeset
73 return AF_OK;
d6f40a06867b Changes includes:
anders
parents: 8185
diff changeset
74 }
d6f40a06867b Changes includes:
anders
parents: 8185
diff changeset
75
d6f40a06867b Changes includes:
anders
parents: 8185
diff changeset
76 // Check for unsupported formats
13989
dcb6b4a33aaa declare check_format and check_bps static, they are used nowhere else.
reimar
parents: 12486
diff changeset
77 static int check_format(int format)
8180
4ba9aed295f2 Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents: 8167
diff changeset
78 {
4ba9aed295f2 Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents: 8167
diff changeset
79 char buf[256];
8607
d6f40a06867b Changes includes:
anders
parents: 8185
diff changeset
80 switch(format & AF_FORMAT_SPECIAL_MASK){
35451
29f66b254dd7 af_format: Fix check_format, non-special formats are of course supported.
reimar
parents: 35444
diff changeset
81 case 0:
35440
c2b5fda66143 Replace outdated list of unsupported formats by list of supported formats.
reimar
parents: 34174
diff changeset
82 case AF_FORMAT_MU_LAW:
c2b5fda66143 Replace outdated list of unsupported formats by list of supported formats.
reimar
parents: 34174
diff changeset
83 case AF_FORMAT_A_LAW:
c2b5fda66143 Replace outdated list of unsupported formats by list of supported formats.
reimar
parents: 34174
diff changeset
84 return AF_OK;
8180
4ba9aed295f2 Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents: 8167
diff changeset
85 }
35440
c2b5fda66143 Replace outdated list of unsupported formats by list of supported formats.
reimar
parents: 34174
diff changeset
86 mp_msg(MSGT_AFILTER, MSGL_ERR, "[format] Sample format %s not yet supported \n",
c2b5fda66143 Replace outdated list of unsupported formats by list of supported formats.
reimar
parents: 34174
diff changeset
87 af_fmt2str(format,buf,256));
c2b5fda66143 Replace outdated list of unsupported formats by list of supported formats.
reimar
parents: 34174
diff changeset
88 return AF_ERROR;
8607
d6f40a06867b Changes includes:
anders
parents: 8185
diff changeset
89 }
8180
4ba9aed295f2 Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents: 8167
diff changeset
90
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
91 // Initialization and runtime control
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
92 static int control(struct af_instance_s* af, int cmd, void* arg)
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
93 {
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
94 switch(cmd){
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
95 case AF_CONTROL_REINIT:{
e8832e66babd New features:
anders
parents: 7998
diff changeset
96 char buf1[256];
e8832e66babd New features:
anders
parents: 7998
diff changeset
97 char buf2[256];
14272
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
98 af_data_t *data = arg;
35444
4644c320daf4 af_format: support endianness conversion also for iec61937
reimar
parents: 35441
diff changeset
99 int supported_ac3 = 0;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
100
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
101 // Make sure this filter isn't redundant
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
102 if(af->data->format == data->format &&
14717
51a7560a92b7 confusing mixture of typecasts and casted variable, removed typecasts
reimar
parents: 14433
diff changeset
103 af->data->bps == data->bps)
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
104 return AF_DETACH;
8607
d6f40a06867b Changes includes:
anders
parents: 8185
diff changeset
105
35444
4644c320daf4 af_format: support endianness conversion also for iec61937
reimar
parents: 35441
diff changeset
106 // A bit complex because we can convert AC3
4644c320daf4 af_format: support endianness conversion also for iec61937
reimar
parents: 35441
diff changeset
107 // to generic iec61937 but not the other way
4644c320daf4 af_format: support endianness conversion also for iec61937
reimar
parents: 35441
diff changeset
108 // round.
4644c320daf4 af_format: support endianness conversion also for iec61937
reimar
parents: 35441
diff changeset
109 if (AF_FORMAT_IS_AC3(af->data->format))
4644c320daf4 af_format: support endianness conversion also for iec61937
reimar
parents: 35441
diff changeset
110 supported_ac3 = AF_FORMAT_IS_AC3(data->format);
4644c320daf4 af_format: support endianness conversion also for iec61937
reimar
parents: 35441
diff changeset
111 else if (AF_FORMAT_IS_IEC61937(af->data->format))
4644c320daf4 af_format: support endianness conversion also for iec61937
reimar
parents: 35441
diff changeset
112 supported_ac3 = AF_FORMAT_IS_IEC61937(data->format);
4644c320daf4 af_format: support endianness conversion also for iec61937
reimar
parents: 35441
diff changeset
113
30241
02b9c1a452e1 Add support for distinguishing between little- and big-endian SPDIF AC3
reimar
parents: 29401
diff changeset
114 // Allow trivial AC3-endianness conversion
35444
4644c320daf4 af_format: support endianness conversion also for iec61937
reimar
parents: 35441
diff changeset
115 if (!supported_ac3)
24521
186626edd969 Fix typo in comment
reimar
parents: 23457
diff changeset
116 // Check for errors in configuration
14717
51a7560a92b7 confusing mixture of typecasts and casted variable, removed typecasts
reimar
parents: 14433
diff changeset
117 if((AF_OK != check_bps(data->bps)) ||
51a7560a92b7 confusing mixture of typecasts and casted variable, removed typecasts
reimar
parents: 14433
diff changeset
118 (AF_OK != check_format(data->format)) ||
8607
d6f40a06867b Changes includes:
anders
parents: 8185
diff changeset
119 (AF_OK != check_bps(af->data->bps)) ||
d6f40a06867b Changes includes:
anders
parents: 8185
diff changeset
120 (AF_OK != check_format(af->data->format)))
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
121 return AF_ERROR;
e8832e66babd New features:
anders
parents: 7998
diff changeset
122
35441
6dc94af7016d Do not call af_fmt2str on the same data over and over.
reimar
parents: 35440
diff changeset
123 af_fmt2str(data->format,buf1,256);
6dc94af7016d Do not call af_fmt2str on the same data over and over.
reimar
parents: 35440
diff changeset
124 af_fmt2str(af->data->format,buf2,256);
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28339
diff changeset
125 mp_msg(MSGT_AFILTER, MSGL_V, "[format] Changing sample format from %s to %s\n",
35441
6dc94af7016d Do not call af_fmt2str on the same data over and over.
reimar
parents: 35440
diff changeset
126 buf1, buf2);
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
127
14717
51a7560a92b7 confusing mixture of typecasts and casted variable, removed typecasts
reimar
parents: 14433
diff changeset
128 af->data->rate = data->rate;
51a7560a92b7 confusing mixture of typecasts and casted variable, removed typecasts
reimar
parents: 14433
diff changeset
129 af->data->nch = data->nch;
24888
b2402b4f0afa libaf: change filter input/output ratio calculations
uau
parents: 24561
diff changeset
130 af->mul = (double)af->data->bps / data->bps;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
131
14272
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
132 af->play = play; // set default
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
133
24561
90b0691d9709 Fix loads of typos
reimar
parents: 24521
diff changeset
134 // look whether only endianness differences are there
14272
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
135 if ((af->data->format & ~AF_FORMAT_END_MASK) ==
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
136 (data->format & ~AF_FORMAT_END_MASK))
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
137 {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28339
diff changeset
138 mp_msg(MSGT_AFILTER, MSGL_V, "[format] Accelerated endianness conversion only\n");
14272
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
139 af->play = play_swapendian;
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
140 }
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
141 if ((data->format == AF_FORMAT_FLOAT_NE) &&
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
142 (af->data->format == AF_FORMAT_S16_NE))
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
143 {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28339
diff changeset
144 mp_msg(MSGT_AFILTER, MSGL_V, "[format] Accelerated %s to %s conversion\n",
35441
6dc94af7016d Do not call af_fmt2str on the same data over and over.
reimar
parents: 35440
diff changeset
145 buf1, buf2);
14272
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
146 af->play = play_float_s16;
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
147 }
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
148 if ((data->format == AF_FORMAT_S16_NE) &&
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
149 (af->data->format == AF_FORMAT_FLOAT_NE))
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
150 {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28339
diff changeset
151 mp_msg(MSGT_AFILTER, MSGL_V, "[format] Accelerated %s to %s conversion\n",
35441
6dc94af7016d Do not call af_fmt2str on the same data over and over.
reimar
parents: 35440
diff changeset
152 buf1, buf2);
14272
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
153 af->play = play_s16_float;
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
154 }
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
155 return AF_OK;
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
156 }
7998
d48a06d07afb Adding commandline options for filters and fixing stupid bug in cfg
anders
parents: 7719
diff changeset
157 case AF_CONTROL_COMMAND_LINE:{
14335
8380694ba14f af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents: 14272
diff changeset
158 int format = af_str2fmt_short(arg);
15311
b00b16a1ef05 Error out when invalid format is specified
reimar
parents: 14791
diff changeset
159 if (format == -1) {
29049
8c706ce21c6f Remove af_msg special-casing API in libaf.
bircoph
parents: 28339
diff changeset
160 mp_msg(MSGT_AFILTER, MSGL_ERR, "[format] %s is not a valid format\n", (char *)arg);
15311
b00b16a1ef05 Error out when invalid format is specified
reimar
parents: 14791
diff changeset
161 return AF_ERROR;
b00b16a1ef05 Error out when invalid format is specified
reimar
parents: 14791
diff changeset
162 }
14335
8380694ba14f af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents: 14272
diff changeset
163 if(AF_OK != af->control(af,AF_CONTROL_FORMAT_FMT | AF_CONTROL_SET,&format))
8607
d6f40a06867b Changes includes:
anders
parents: 8185
diff changeset
164 return AF_ERROR;
d6f40a06867b Changes includes:
anders
parents: 8185
diff changeset
165 return AF_OK;
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
166 }
14335
8380694ba14f af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents: 14272
diff changeset
167 case AF_CONTROL_FORMAT_FMT | AF_CONTROL_SET:{
24561
90b0691d9709 Fix loads of typos
reimar
parents: 24521
diff changeset
168 // Check for errors in configuration
30241
02b9c1a452e1 Add support for distinguishing between little- and big-endian SPDIF AC3
reimar
parents: 29401
diff changeset
169 if(!AF_FORMAT_IS_AC3(*(int*)arg) && AF_OK != check_format(*(int*)arg))
8607
d6f40a06867b Changes includes:
anders
parents: 8185
diff changeset
170 return AF_ERROR;
d6f40a06867b Changes includes:
anders
parents: 8185
diff changeset
171
d6f40a06867b Changes includes:
anders
parents: 8185
diff changeset
172 af->data->format = *(int*)arg;
14335
8380694ba14f af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents: 14272
diff changeset
173 af->data->bps = af_fmt2bits(af->data->format)/8;
8380694ba14f af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents: 14272
diff changeset
174
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
175 return AF_OK;
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
176 }
14335
8380694ba14f af_bits2fmt and af_str2fmt_short, also removed the extra FORMAT_BPS control in format.c
alex
parents: 14272
diff changeset
177 }
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
178 return AF_UNKNOWN;
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
179 }
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
180
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
181 // Deallocate memory
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
182 static void uninit(struct af_instance_s* af)
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
183 {
22179
ecf562795caf Fix memory leaks.
uau
parents: 21507
diff changeset
184 if (af->data)
ecf562795caf Fix memory leaks.
uau
parents: 21507
diff changeset
185 free(af->data->audio);
ecf562795caf Fix memory leaks.
uau
parents: 21507
diff changeset
186 free(af->data);
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
187 af->setup = 0;
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
188 }
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
189
14272
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
190 static af_data_t* play_swapendian(struct af_instance_s* af, af_data_t* data)
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
191 {
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
192 af_data_t* l = af->data; // Local data
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
193 af_data_t* c = data; // Current working data
24561
90b0691d9709 Fix loads of typos
reimar
parents: 24521
diff changeset
194 int len = c->len/c->bps; // Length in samples of current audio block
14272
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
195
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
196 if(AF_OK != RESIZE_LOCAL_BUFFER(af,data))
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
197 return NULL;
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
198
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
199 endian(c->audio,l->audio,len,c->bps);
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
200
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
201 c->audio = l->audio;
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
202 c->format = l->format;
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
203
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
204 return c;
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
205 }
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
206
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
207 static af_data_t* play_float_s16(struct af_instance_s* af, af_data_t* data)
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
208 {
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
209 af_data_t* l = af->data; // Local data
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
210 af_data_t* c = data; // Current working data
24561
90b0691d9709 Fix loads of typos
reimar
parents: 24521
diff changeset
211 int len = c->len/4; // Length in samples of current audio block
14272
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
212
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
213 if(AF_OK != RESIZE_LOCAL_BUFFER(af,data))
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
214 return NULL;
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
215
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
216 float2int(c->audio, l->audio, len, 2);
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
217
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
218 c->audio = l->audio;
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
219 c->len = len*2;
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
220 c->bps = 2;
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
221 c->format = l->format;
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
222
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
223 return c;
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
224 }
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
225
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
226 static af_data_t* play_s16_float(struct af_instance_s* af, af_data_t* data)
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
227 {
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
228 af_data_t* l = af->data; // Local data
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
229 af_data_t* c = data; // Current working data
24561
90b0691d9709 Fix loads of typos
reimar
parents: 24521
diff changeset
230 int len = c->len/2; // Length in samples of current audio block
14272
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
231
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
232 if(AF_OK != RESIZE_LOCAL_BUFFER(af,data))
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
233 return NULL;
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
234
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
235 int2float(c->audio, l->audio, len, 2);
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
236
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
237 c->audio = l->audio;
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
238 c->len = len*4;
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
239 c->bps = 4;
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
240 c->format = l->format;
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
241
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
242 return c;
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
243 }
5a2473f37499 accelerated conversions
alex
parents: 14263
diff changeset
244
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
245 // Filter data through filter
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
246 static af_data_t* play(struct af_instance_s* af, af_data_t* data)
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
247 {
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
248 af_data_t* l = af->data; // Local data
e8832e66babd New features:
anders
parents: 7998
diff changeset
249 af_data_t* c = data; // Current working data
24561
90b0691d9709 Fix loads of typos
reimar
parents: 24521
diff changeset
250 int len = c->len/c->bps; // Length in samples of current audio block
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
251
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
252 if(AF_OK != RESIZE_LOCAL_BUFFER(af,data))
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
253 return NULL;
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
254
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
255 // Change to cpu native endian format
e8832e66babd New features:
anders
parents: 7998
diff changeset
256 if((c->format&AF_FORMAT_END_MASK)!=AF_FORMAT_NE)
e8832e66babd New features:
anders
parents: 7998
diff changeset
257 endian(c->audio,c->audio,len,c->bps);
7719
41e8d0916c60 Fix for audio filters on big endian cpus. It's working now on Solaris SPARC &
jkeil
parents: 7711
diff changeset
258
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
259 // Conversion table
14261
710b223604fa 100l use right mask type when checking for input format
rtognimp
parents: 14256
diff changeset
260 if((c->format & AF_FORMAT_SPECIAL_MASK) == AF_FORMAT_MU_LAW) {
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
261 from_ulaw(c->audio, l->audio, len, l->bps, l->format&AF_FORMAT_POINT_MASK);
e8832e66babd New features:
anders
parents: 7998
diff changeset
262 if(AF_FORMAT_A_LAW == (l->format&AF_FORMAT_SPECIAL_MASK))
e8832e66babd New features:
anders
parents: 7998
diff changeset
263 to_ulaw(l->audio, l->audio, len, 1, AF_FORMAT_SI);
e8832e66babd New features:
anders
parents: 7998
diff changeset
264 if((l->format&AF_FORMAT_SIGN_MASK) == AF_FORMAT_US)
16664
9991e406a2a2 much simpler signed/unsigned conversion.
reimar
parents: 15311
diff changeset
265 si2us(l->audio,len,l->bps);
14261
710b223604fa 100l use right mask type when checking for input format
rtognimp
parents: 14256
diff changeset
266 } else if((c->format & AF_FORMAT_SPECIAL_MASK) == AF_FORMAT_A_LAW) {
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
267 from_alaw(c->audio, l->audio, len, l->bps, l->format&AF_FORMAT_POINT_MASK);
e8832e66babd New features:
anders
parents: 7998
diff changeset
268 if(AF_FORMAT_A_LAW == (l->format&AF_FORMAT_SPECIAL_MASK))
e8832e66babd New features:
anders
parents: 7998
diff changeset
269 to_alaw(l->audio, l->audio, len, 1, AF_FORMAT_SI);
e8832e66babd New features:
anders
parents: 7998
diff changeset
270 if((l->format&AF_FORMAT_SIGN_MASK) == AF_FORMAT_US)
16664
9991e406a2a2 much simpler signed/unsigned conversion.
reimar
parents: 15311
diff changeset
271 si2us(l->audio,len,l->bps);
14261
710b223604fa 100l use right mask type when checking for input format
rtognimp
parents: 14256
diff changeset
272 } else if((c->format & AF_FORMAT_POINT_MASK) == AF_FORMAT_F) {
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
273 switch(l->format&AF_FORMAT_SPECIAL_MASK){
e8832e66babd New features:
anders
parents: 7998
diff changeset
274 case(AF_FORMAT_MU_LAW):
e8832e66babd New features:
anders
parents: 7998
diff changeset
275 to_ulaw(c->audio, l->audio, len, c->bps, c->format&AF_FORMAT_POINT_MASK);
e8832e66babd New features:
anders
parents: 7998
diff changeset
276 break;
e8832e66babd New features:
anders
parents: 7998
diff changeset
277 case(AF_FORMAT_A_LAW):
e8832e66babd New features:
anders
parents: 7998
diff changeset
278 to_alaw(c->audio, l->audio, len, c->bps, c->format&AF_FORMAT_POINT_MASK);
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
279 break;
8180
4ba9aed295f2 Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents: 8167
diff changeset
280 default:
4ba9aed295f2 Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents: 8167
diff changeset
281 float2int(c->audio, l->audio, len, l->bps);
4ba9aed295f2 Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents: 8167
diff changeset
282 if((l->format&AF_FORMAT_SIGN_MASK) == AF_FORMAT_US)
16664
9991e406a2a2 much simpler signed/unsigned conversion.
reimar
parents: 15311
diff changeset
283 si2us(l->audio,len,l->bps);
8180
4ba9aed295f2 Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents: 8167
diff changeset
284 break;
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
285 }
14261
710b223604fa 100l use right mask type when checking for input format
rtognimp
parents: 14256
diff changeset
286 } else {
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
287 // Input must be int
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
288
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
289 // Change signed/unsigned
e8832e66babd New features:
anders
parents: 7998
diff changeset
290 if((c->format&AF_FORMAT_SIGN_MASK) != (l->format&AF_FORMAT_SIGN_MASK)){
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
291 si2us(c->audio,len,c->bps);
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
292 }
e8832e66babd New features:
anders
parents: 7998
diff changeset
293 // Convert to special formats
8180
4ba9aed295f2 Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents: 8167
diff changeset
294 switch(l->format&(AF_FORMAT_SPECIAL_MASK|AF_FORMAT_POINT_MASK)){
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
295 case(AF_FORMAT_MU_LAW):
e8832e66babd New features:
anders
parents: 7998
diff changeset
296 to_ulaw(c->audio, l->audio, len, c->bps, c->format&AF_FORMAT_POINT_MASK);
e8832e66babd New features:
anders
parents: 7998
diff changeset
297 break;
e8832e66babd New features:
anders
parents: 7998
diff changeset
298 case(AF_FORMAT_A_LAW):
e8832e66babd New features:
anders
parents: 7998
diff changeset
299 to_alaw(c->audio, l->audio, len, c->bps, c->format&AF_FORMAT_POINT_MASK);
e8832e66babd New features:
anders
parents: 7998
diff changeset
300 break;
8180
4ba9aed295f2 Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents: 8167
diff changeset
301 case(AF_FORMAT_F):
4ba9aed295f2 Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents: 8167
diff changeset
302 int2float(c->audio, l->audio, len, c->bps);
4ba9aed295f2 Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents: 8167
diff changeset
303 break;
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
304 default:
8180
4ba9aed295f2 Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents: 8167
diff changeset
305 // Change the number of bits
4ba9aed295f2 Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents: 8167
diff changeset
306 if(c->bps != l->bps)
4ba9aed295f2 Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents: 8167
diff changeset
307 change_bps(c->audio,l->audio,len,c->bps,l->bps);
4ba9aed295f2 Fixing segfault bug and addnig support for lrintf() in format conversion
anders
parents: 8167
diff changeset
308 else
23457
a124f3abc1ec Replace implicit use of fast_memcpy via macro by explicit use to allow
reimar
parents: 22748
diff changeset
309 fast_memcpy(l->audio,c->audio,len*c->bps);
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
310 break;
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
311 }
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
312 }
7719
41e8d0916c60 Fix for audio filters on big endian cpus. It's working now on Solaris SPARC &
jkeil
parents: 7711
diff changeset
313
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
314 // Switch from cpu native endian to the correct endianness
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
315 if((l->format&AF_FORMAT_END_MASK)!=AF_FORMAT_NE)
e8832e66babd New features:
anders
parents: 7998
diff changeset
316 endian(l->audio,l->audio,len,l->bps);
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
317
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
318 // Set output data
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
319 c->audio = l->audio;
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
320 c->len = len*l->bps;
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
321 c->bps = l->bps;
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
322 c->format = l->format;
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
323 return c;
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
324 }
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
325
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
326 // Allocate memory and set function pointers
22746
fd6f824ef894 Rename open to af_open so as not to conflict with a previous header definition.
diego
parents: 22179
diff changeset
327 static int af_open(af_instance_t* af){
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
328 af->control=control;
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
329 af->uninit=uninit;
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
330 af->play=play;
24888
b2402b4f0afa libaf: change filter input/output ratio calculations
uau
parents: 24561
diff changeset
331 af->mul=1;
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
332 af->data=calloc(1,sizeof(af_data_t));
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
333 if(af->data == NULL)
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
334 return AF_ERROR;
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
335 return AF_OK;
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
336 }
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
337
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
338 // Description of this filter
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
339 af_info_t af_info_format = {
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
340 "Sample format conversion",
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
341 "format",
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
342 "Anders",
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
343 "",
7615
c67328dd459a Adding Support for non-reentrant audio filters
anders
parents: 7571
diff changeset
344 AF_FLAGS_REENTRANT,
22746
fd6f824ef894 Rename open to af_open so as not to conflict with a previous header definition.
diego
parents: 22179
diff changeset
345 af_open
7568
d08513b9fed6 Adding new audio output filter layer libaf
anders
parents:
diff changeset
346 };
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
347
36391
3b1fb70800f4 Add some "const" to input-only pointers.
reimar
parents: 36384
diff changeset
348 static inline uint32_t load24bit(const void* data, int pos) {
29401
f01023c524c3 Replace WORDS_BIGENDIAN by HAVE_BIGENDIAN in all internal code.
diego
parents: 29263
diff changeset
349 #if HAVE_BIGENDIAN
12478
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
350 return (((uint32_t)((uint8_t*)data)[3*pos])<<24) |
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
351 (((uint32_t)((uint8_t*)data)[3*pos+1])<<16) |
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
352 (((uint32_t)((uint8_t*)data)[3*pos+2])<<8);
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
353 #else
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
354 return (((uint32_t)((uint8_t*)data)[3*pos])<<8) |
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
355 (((uint32_t)((uint8_t*)data)[3*pos+1])<<16) |
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
356 (((uint32_t)((uint8_t*)data)[3*pos+2])<<24);
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
357 #endif
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
358 }
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
359
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
360 static inline void store24bit(void* data, int pos, uint32_t expanded_value) {
29401
f01023c524c3 Replace WORDS_BIGENDIAN by HAVE_BIGENDIAN in all internal code.
diego
parents: 29263
diff changeset
361 #if HAVE_BIGENDIAN
12478
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
362 ((uint8_t*)data)[3*pos]=expanded_value>>24;
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
363 ((uint8_t*)data)[3*pos+1]=expanded_value>>16;
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
364 ((uint8_t*)data)[3*pos+2]=expanded_value>>8;
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
365 #else
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
366 ((uint8_t*)data)[3*pos]=expanded_value>>8;
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
367 ((uint8_t*)data)[3*pos+1]=expanded_value>>16;
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
368 ((uint8_t*)data)[3*pos+2]=expanded_value>>24;
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
369 #endif
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
370 }
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
371
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
372 // Function implementations used by play
36391
3b1fb70800f4 Add some "const" to input-only pointers.
reimar
parents: 36384
diff changeset
373 static void endian(const void* in, void* out, int len, int bps)
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
374 {
e8832e66babd New features:
anders
parents: 7998
diff changeset
375 register int i;
e8832e66babd New features:
anders
parents: 7998
diff changeset
376 switch(bps){
e8832e66babd New features:
anders
parents: 7998
diff changeset
377 case(2):{
e8832e66babd New features:
anders
parents: 7998
diff changeset
378 for(i=0;i<len;i++){
12486
e02a261e4c92 using bswap.h for endianness conversion
reimar
parents: 12481
diff changeset
379 ((uint16_t*)out)[i]=bswap_16(((uint16_t*)in)[i]);
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
380 }
e8832e66babd New features:
anders
parents: 7998
diff changeset
381 break;
e8832e66babd New features:
anders
parents: 7998
diff changeset
382 }
12478
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
383 case(3):{
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
384 register uint8_t s;
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
385 for(i=0;i<len;i++){
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
386 s=((uint8_t*)in)[3*i];
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
387 ((uint8_t*)out)[3*i]=((uint8_t*)in)[3*i+2];
12481
dbbc25ea6403 fix endian conversion for (curently unused) case where in buffer != out buffer
reimar
parents: 12478
diff changeset
388 if (in != out)
dbbc25ea6403 fix endian conversion for (curently unused) case where in buffer != out buffer
reimar
parents: 12478
diff changeset
389 ((uint8_t*)out)[3*i+1]=((uint8_t*)in)[3*i+1];
12478
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
390 ((uint8_t*)out)[3*i+2]=s;
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
391 }
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
392 break;
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
393 }
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
394 case(4):{
e8832e66babd New features:
anders
parents: 7998
diff changeset
395 for(i=0;i<len;i++){
12486
e02a261e4c92 using bswap.h for endianness conversion
reimar
parents: 12481
diff changeset
396 ((uint32_t*)out)[i]=bswap_32(((uint32_t*)in)[i]);
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
397 }
e8832e66babd New features:
anders
parents: 7998
diff changeset
398 break;
e8832e66babd New features:
anders
parents: 7998
diff changeset
399 }
e8832e66babd New features:
anders
parents: 7998
diff changeset
400 }
e8832e66babd New features:
anders
parents: 7998
diff changeset
401 }
e8832e66babd New features:
anders
parents: 7998
diff changeset
402
16664
9991e406a2a2 much simpler signed/unsigned conversion.
reimar
parents: 15311
diff changeset
403 static void si2us(void* data, int len, int bps)
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
404 {
16664
9991e406a2a2 much simpler signed/unsigned conversion.
reimar
parents: 15311
diff changeset
405 register long i = -(len * bps);
9991e406a2a2 much simpler signed/unsigned conversion.
reimar
parents: 15311
diff changeset
406 register uint8_t *p = &((uint8_t *)data)[len * bps];
9991e406a2a2 much simpler signed/unsigned conversion.
reimar
parents: 15311
diff changeset
407 #if AF_FORMAT_NE == AF_FORMAT_LE
9991e406a2a2 much simpler signed/unsigned conversion.
reimar
parents: 15311
diff changeset
408 p += bps - 1;
9991e406a2a2 much simpler signed/unsigned conversion.
reimar
parents: 15311
diff changeset
409 #endif
9991e406a2a2 much simpler signed/unsigned conversion.
reimar
parents: 15311
diff changeset
410 if (len <= 0) return;
9991e406a2a2 much simpler signed/unsigned conversion.
reimar
parents: 15311
diff changeset
411 do {
9991e406a2a2 much simpler signed/unsigned conversion.
reimar
parents: 15311
diff changeset
412 p[i] ^= 0x80;
9991e406a2a2 much simpler signed/unsigned conversion.
reimar
parents: 15311
diff changeset
413 } while (i += bps);
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
414 }
e8832e66babd New features:
anders
parents: 7998
diff changeset
415
36391
3b1fb70800f4 Add some "const" to input-only pointers.
reimar
parents: 36384
diff changeset
416 static void change_bps(const void* in, void* out, int len, int inbps, int outbps)
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
417 {
e8832e66babd New features:
anders
parents: 7998
diff changeset
418 register int i;
e8832e66babd New features:
anders
parents: 7998
diff changeset
419 switch(inbps){
e8832e66babd New features:
anders
parents: 7998
diff changeset
420 case(1):
e8832e66babd New features:
anders
parents: 7998
diff changeset
421 switch(outbps){
e8832e66babd New features:
anders
parents: 7998
diff changeset
422 case(2):
e8832e66babd New features:
anders
parents: 7998
diff changeset
423 for(i=0;i<len;i++)
e8832e66babd New features:
anders
parents: 7998
diff changeset
424 ((uint16_t*)out)[i]=((uint16_t)((uint8_t*)in)[i])<<8;
e8832e66babd New features:
anders
parents: 7998
diff changeset
425 break;
12478
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
426 case(3):
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
427 for(i=0;i<len;i++)
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
428 store24bit(out, i, ((uint32_t)((uint8_t*)in)[i])<<24);
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
429 break;
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
430 case(4):
e8832e66babd New features:
anders
parents: 7998
diff changeset
431 for(i=0;i<len;i++)
e8832e66babd New features:
anders
parents: 7998
diff changeset
432 ((uint32_t*)out)[i]=((uint32_t)((uint8_t*)in)[i])<<24;
e8832e66babd New features:
anders
parents: 7998
diff changeset
433 break;
e8832e66babd New features:
anders
parents: 7998
diff changeset
434 }
e8832e66babd New features:
anders
parents: 7998
diff changeset
435 break;
e8832e66babd New features:
anders
parents: 7998
diff changeset
436 case(2):
e8832e66babd New features:
anders
parents: 7998
diff changeset
437 switch(outbps){
e8832e66babd New features:
anders
parents: 7998
diff changeset
438 case(1):
e8832e66babd New features:
anders
parents: 7998
diff changeset
439 for(i=0;i<len;i++)
e8832e66babd New features:
anders
parents: 7998
diff changeset
440 ((uint8_t*)out)[i]=(uint8_t)((((uint16_t*)in)[i])>>8);
e8832e66babd New features:
anders
parents: 7998
diff changeset
441 break;
12478
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
442 case(3):
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
443 for(i=0;i<len;i++)
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
444 store24bit(out, i, ((uint32_t)((uint16_t*)in)[i])<<16);
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
445 break;
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
446 case(4):
e8832e66babd New features:
anders
parents: 7998
diff changeset
447 for(i=0;i<len;i++)
e8832e66babd New features:
anders
parents: 7998
diff changeset
448 ((uint32_t*)out)[i]=((uint32_t)((uint16_t*)in)[i])<<16;
e8832e66babd New features:
anders
parents: 7998
diff changeset
449 break;
e8832e66babd New features:
anders
parents: 7998
diff changeset
450 }
e8832e66babd New features:
anders
parents: 7998
diff changeset
451 break;
12478
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
452 case(3):
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
453 switch(outbps){
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
454 case(1):
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
455 for(i=0;i<len;i++)
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
456 ((uint8_t*)out)[i]=(uint8_t)(load24bit(in, i)>>24);
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
457 break;
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
458 case(2):
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
459 for(i=0;i<len;i++)
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
460 ((uint16_t*)out)[i]=(uint16_t)(load24bit(in, i)>>16);
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
461 break;
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
462 case(4):
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
463 for(i=0;i<len;i++)
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
464 ((uint32_t*)out)[i]=(uint32_t)load24bit(in, i);
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
465 break;
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
466 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
467 break;
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
468 case(4):
e8832e66babd New features:
anders
parents: 7998
diff changeset
469 switch(outbps){
e8832e66babd New features:
anders
parents: 7998
diff changeset
470 case(1):
e8832e66babd New features:
anders
parents: 7998
diff changeset
471 for(i=0;i<len;i++)
e8832e66babd New features:
anders
parents: 7998
diff changeset
472 ((uint8_t*)out)[i]=(uint8_t)((((uint32_t*)in)[i])>>24);
e8832e66babd New features:
anders
parents: 7998
diff changeset
473 break;
e8832e66babd New features:
anders
parents: 7998
diff changeset
474 case(2):
e8832e66babd New features:
anders
parents: 7998
diff changeset
475 for(i=0;i<len;i++)
e8832e66babd New features:
anders
parents: 7998
diff changeset
476 ((uint16_t*)out)[i]=(uint16_t)((((uint32_t*)in)[i])>>16);
e8832e66babd New features:
anders
parents: 7998
diff changeset
477 break;
12478
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
478 case(3):
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
479 for(i=0;i<len;i++)
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
480 store24bit(out, i, ((uint32_t*)in)[i]);
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
481 break;
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
482 }
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
483 break;
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
484 }
e8832e66babd New features:
anders
parents: 7998
diff changeset
485 }
e8832e66babd New features:
anders
parents: 7998
diff changeset
486
36391
3b1fb70800f4 Add some "const" to input-only pointers.
reimar
parents: 36384
diff changeset
487 static void float2int(const float* in, void* out, int len, int bps)
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
488 {
33723
6c8743e5fa30 Audio format conversion from float to int is not checked for overflow.
iive
parents: 30241
diff changeset
489 float f;
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
490 register int i;
e8832e66babd New features:
anders
parents: 7998
diff changeset
491 switch(bps){
e8832e66babd New features:
anders
parents: 7998
diff changeset
492 case(1):
e8832e66babd New features:
anders
parents: 7998
diff changeset
493 for(i=0;i<len;i++)
36384
e79bac50b920 Use correct types for constants.
reimar
parents: 35712
diff changeset
494 ((int8_t *)out)[i] = av_clip_int8(lrintf(128.0f * in[i]));
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
495 break;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
496 case(2):
36393
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
497 #if HAVE_NEON
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
498 {
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
499 const float *in_end = in + len;
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
500 while (in < in_end - 7) {
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
501 __asm__(
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
502 "vld1.32 {q0,q1}, [%0]!\n\t"
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
503 "vcvt.s32.f32 q0, q0, #31\n\t"
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
504 "vqrshrn.s32 d0, q0, #15\n\t"
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
505 "vcvt.s32.f32 q1, q1, #31\n\t"
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
506 "vqrshrn.s32 d1, q1, #15\n\t"
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
507 "vst1.16 {q0}, [%1]!\n\t"
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
508 : "+r"(in), "+r"(out)
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
509 :: "q0", "q1", "memory");
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
510 }
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
511 while (in < in_end) {
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
512 __asm__(
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
513 "vld1.32 {d0[0]}, [%0]!\n\t"
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
514 "vcvt.s32.f32 d0, d0, #31\n\t"
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
515 "vqrshrn.s32 d0, q0, #15\n\t"
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
516 "vst1.16 {d0[0]}, [%1]!\n\t"
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
517 : "+r"(in), "+r"(out)
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
518 :: "d0", "memory");
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
519 }
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
520 }
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
521 #else
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
522 for(i=0;i<len;i++)
36384
e79bac50b920 Use correct types for constants.
reimar
parents: 35712
diff changeset
523 ((int16_t*)out)[i] = av_clip_int16(lrintf(32768.0f * in[i]));
36393
06cf8a9249f7 ARM NEON optimization for float->int conversion.
reimar
parents: 36391
diff changeset
524 #endif
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
525 break;
12478
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
526 case(3):
33723
6c8743e5fa30 Audio format conversion from float to int is not checked for overflow.
iive
parents: 30241
diff changeset
527 for(i=0;i<len;i++){
36384
e79bac50b920 Use correct types for constants.
reimar
parents: 35712
diff changeset
528 f = in[i] * 8388608.0f;
33723
6c8743e5fa30 Audio format conversion from float to int is not checked for overflow.
iive
parents: 30241
diff changeset
529 store24bit(out, i, av_clip(lrintf(f), -1*(1<<23), (1<<23)-1) << 8);
6c8743e5fa30 Audio format conversion from float to int is not checked for overflow.
iive
parents: 30241
diff changeset
530 }
12478
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
531 break;
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
532 case(4):
33723
6c8743e5fa30 Audio format conversion from float to int is not checked for overflow.
iive
parents: 30241
diff changeset
533 for(i=0;i<len;i++){
33736
a5a54c7a15ce Fix the precision loss in float -> 32bit conversion case, introduced
iive
parents: 33723
diff changeset
534 f = in[i];
36384
e79bac50b920 Use correct types for constants.
reimar
parents: 35712
diff changeset
535 if (f <= -1.0f)
33736
a5a54c7a15ce Fix the precision loss in float -> 32bit conversion case, introduced
iive
parents: 33723
diff changeset
536 ((int32_t*)out)[i] = INT_MIN;
a5a54c7a15ce Fix the precision loss in float -> 32bit conversion case, introduced
iive
parents: 33723
diff changeset
537 else
36384
e79bac50b920 Use correct types for constants.
reimar
parents: 35712
diff changeset
538 if (f >= 1.0f)//no need to use corrected constant, rounding won't cause overflow
33736
a5a54c7a15ce Fix the precision loss in float -> 32bit conversion case, introduced
iive
parents: 33723
diff changeset
539 ((int32_t*)out)[i] = INT_MAX;
a5a54c7a15ce Fix the precision loss in float -> 32bit conversion case, introduced
iive
parents: 33723
diff changeset
540 else
36384
e79bac50b920 Use correct types for constants.
reimar
parents: 35712
diff changeset
541 ((int32_t*)out)[i] = lrintf(f*2147483648.0f);
33736
a5a54c7a15ce Fix the precision loss in float -> 32bit conversion case, introduced
iive
parents: 33723
diff changeset
542
33723
6c8743e5fa30 Audio format conversion from float to int is not checked for overflow.
iive
parents: 30241
diff changeset
543 }
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
544 break;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
545 }
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
546 }
e8832e66babd New features:
anders
parents: 7998
diff changeset
547
36391
3b1fb70800f4 Add some "const" to input-only pointers.
reimar
parents: 36384
diff changeset
548 static void int2float(const void* in, float* out, int len, int bps)
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
549 {
e8832e66babd New features:
anders
parents: 7998
diff changeset
550 register int i;
e8832e66babd New features:
anders
parents: 7998
diff changeset
551 switch(bps){
e8832e66babd New features:
anders
parents: 7998
diff changeset
552 case(1):
e8832e66babd New features:
anders
parents: 7998
diff changeset
553 for(i=0;i<len;i++)
36384
e79bac50b920 Use correct types for constants.
reimar
parents: 35712
diff changeset
554 out[i]=(1.0f/128.0f)*((int8_t*)in)[i];
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
555 break;
e8832e66babd New features:
anders
parents: 7998
diff changeset
556 case(2):
e8832e66babd New features:
anders
parents: 7998
diff changeset
557 for(i=0;i<len;i++)
36384
e79bac50b920 Use correct types for constants.
reimar
parents: 35712
diff changeset
558 out[i]=(1.0f/32768.0f)*((int16_t*)in)[i];
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
559 break;
12478
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
560 case(3):
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
561 for(i=0;i<len;i++)
36384
e79bac50b920 Use correct types for constants.
reimar
parents: 35712
diff changeset
562 out[i]=(1.0f/2147483648.0f)*((int32_t)load24bit(in, i));
12478
7f8eb5f6814a support for 24 bit pcm/wav files
reimar
parents: 12386
diff changeset
563 break;
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
564 case(4):
e8832e66babd New features:
anders
parents: 7998
diff changeset
565 for(i=0;i<len;i++)
36384
e79bac50b920 Use correct types for constants.
reimar
parents: 35712
diff changeset
566 out[i]=(1.0f/2147483648.0f)*((int32_t*)in)[i];
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
567 break;
29263
0f1b5b68af32 whitespace cosmetics: Remove all trailing whitespace.
diego
parents: 29049
diff changeset
568 }
8167
e8832e66babd New features:
anders
parents: 7998
diff changeset
569 }