planar formats are now chosen like any other parameter.
Unified · Split
| @@ -202,11 +202,11 @@ int main(int argc, char **argv){ · 201 unmodified lines | |||
| 202 | in_layout_string, out_layout_string, | 202 | in_layout_string, out_layout_string, |
| 203 | in_sample_rate, out_sample_rate, | 203 | in_sample_rate, out_sample_rate, |
| 204 | av_get_sample_fmt_name(in_sample_fmt), av_get_sample_fmt_name(out_sample_fmt)); | 204 | av_get_sample_fmt_name(in_sample_fmt), av_get_sample_fmt_name(out_sample_fmt)); |
| 205 | forw_ctx = swr_alloc_set_opts(forw_ctx, out_ch_layout, av_get_alt_sample_fmt(out_sample_fmt, 1), out_sample_rate, | 205 | forw_ctx = swr_alloc_set_opts(forw_ctx, out_ch_layout, out_sample_fmt, out_sample_rate, |
| 206 | in_ch_layout, av_get_alt_sample_fmt( in_sample_fmt, 1), in_sample_rate, | 206 | in_ch_layout, in_sample_fmt, in_sample_rate, |
| 207 | 0, 0); | 207 | 0, 0); |
| 208 | backw_ctx = swr_alloc_set_opts(backw_ctx, in_ch_layout, in_sample_fmt, in_sample_rate, | 208 | backw_ctx = swr_alloc_set_opts(backw_ctx, in_ch_layout, in_sample_fmt, in_sample_rate, |
| 209 | out_ch_layout, av_get_alt_sample_fmt(out_sample_fmt, 1), out_sample_rate, | 209 | out_ch_layout, out_sample_fmt, out_sample_rate, |
| 210 | 0, 0); | 210 | 0, 0); |
| 211 | if(swr_init( forw_ctx) < 0) | 211 | if(swr_init( forw_ctx) < 0) |
| 212 | fprintf(stderr, "swr_init(->) failed\n"); | 212 | fprintf(stderr, "swr_init(->) failed\n"); |
| @@ -217,12 +217,12 @@ int main(int argc, char **argv){ · 4 unmodified lines | |||
| 217 | if(!backw_ctx) | 217 | if(!backw_ctx) |
| 218 | fprintf(stderr, "Failed to init backw_ctx\n"); | 218 | fprintf(stderr, "Failed to init backw_ctx\n"); |
| 219 | //FIXME test planar | 219 | //FIXME test planar |
| 220 | setup_array(ain , array_in , av_get_alt_sample_fmt( in_sample_fmt, 1), SAMPLES); | 220 | setup_array(ain , array_in , in_sample_fmt, SAMPLES); |
| 221 | setup_array(amid, array_mid, av_get_alt_sample_fmt(out_sample_fmt, 1), 3*SAMPLES); | 221 | setup_array(amid, array_mid, out_sample_fmt, 3*SAMPLES); |
| 222 | setup_array(aout, array_out, in_sample_fmt , SAMPLES); | 222 | setup_array(aout, array_out, in_sample_fmt , SAMPLES); |
| 223 | for(ch=0; ch<in_ch_count; ch++){ | 223 | for(ch=0; ch<in_ch_count; ch++){ |
| 224 | for(i=0; i<SAMPLES; i++) | 224 | for(i=0; i<SAMPLES; i++) |
| 225 | set(ain, ch, i, in_ch_count, av_get_alt_sample_fmt(in_sample_fmt, 1), sin(i*i*3/SAMPLES)); | 225 | set(ain, ch, i, in_ch_count, in_sample_fmt, sin(i*i*3/SAMPLES)); |
| 226 | } | 226 | } |
| 227 | mode++; | 227 | mode++; |
| 228 | mode%=3; | 228 | mode%=3; |
| @@ -235,17 +235,17 @@ int main(int argc, char **argv){ · 6 unmodified lines | |||
| 235 | int tmp_count; | 235 | int tmp_count; |
| 236 | mid_count= swr_convert(forw_ctx, amid, 0, ain, 1); | 236 | mid_count= swr_convert(forw_ctx, amid, 0, ain, 1); |
| 237 | av_assert0(mid_count==0); | 237 | av_assert0(mid_count==0); |
| 238 | shift(ain, 1, in_ch_count, av_get_alt_sample_fmt(in_sample_fmt, 1)); | 238 | shift(ain, 1, in_ch_count, in_sample_fmt); |
| 239 | mid_count+=swr_convert(forw_ctx, amid, 3*SAMPLES, ain, 0); | 239 | mid_count+=swr_convert(forw_ctx, amid, 3*SAMPLES, ain, 0); |
| 240 | shift(amid, mid_count, out_ch_count, av_get_alt_sample_fmt(out_sample_fmt, 1)); tmp_count = mid_count; | 240 | shift(amid, mid_count, out_ch_count, out_sample_fmt); tmp_count = mid_count; |
| 241 | mid_count+=swr_convert(forw_ctx, amid, 2, ain, 2); | 241 | mid_count+=swr_convert(forw_ctx, amid, 2, ain, 2); |
| 242 | shift(amid, mid_count-tmp_count, out_ch_count, av_get_alt_sample_fmt(out_sample_fmt, 1)); tmp_count = mid_count; | 242 | shift(amid, mid_count-tmp_count, out_ch_count, out_sample_fmt); tmp_count = mid_count; |
| 243 | shift(ain, 2, in_ch_count, av_get_alt_sample_fmt(in_sample_fmt, 1)); | 243 | shift(ain, 2, in_ch_count, in_sample_fmt); |
| 244 | mid_count+=swr_convert(forw_ctx, amid, 1, ain, SAMPLES-3); | 244 | mid_count+=swr_convert(forw_ctx, amid, 1, ain, SAMPLES-3); |
| 245 | shift(amid, mid_count-tmp_count, out_ch_count, av_get_alt_sample_fmt(out_sample_fmt, 1)); tmp_count = mid_count; | 245 | shift(amid, mid_count-tmp_count, out_ch_count, out_sample_fmt); tmp_count = mid_count; |
| 246 | shift(ain, -3, in_ch_count, av_get_alt_sample_fmt(in_sample_fmt, 1)); | 246 | shift(ain, -3, in_ch_count, in_sample_fmt); |
| 247 | mid_count+=swr_convert(forw_ctx, amid, 3*SAMPLES, ain, 0); | 247 | mid_count+=swr_convert(forw_ctx, amid, 3*SAMPLES, ain, 0); |
| 248 | shift(amid, -tmp_count, out_ch_count, av_get_alt_sample_fmt(out_sample_fmt, 1)); | 248 | shift(amid, -tmp_count, out_ch_count, out_sample_fmt); |
| 249 | } | 249 | } |
| 250 | out_count= swr_convert(backw_ctx,aout, SAMPLES, amid, mid_count); | 250 | out_count= swr_convert(backw_ctx,aout, SAMPLES, amid, mid_count); |
| 251 | 251 | ||
| @@ -257,7 +257,7 @@ int main(int argc, char **argv){ · 5 unmodified lines | |||
| 257 | double sum_bb= 0; | 257 | double sum_bb= 0; |
| 258 | double sum_ab= 0; | 258 | double sum_ab= 0; |
| 259 | for(i=0; i<out_count; i++){ | 259 | for(i=0; i<out_count; i++){ |
| 260 | double a= get(ain , ch, i, in_ch_count, av_get_alt_sample_fmt(in_sample_fmt, 1)); | 260 | double a= get(ain , ch, i, in_ch_count, in_sample_fmt); |
| 261 | double b= get(aout, ch, i, in_ch_count, in_sample_fmt); | 261 | double b= get(aout, ch, i, in_ch_count, in_sample_fmt); |
| 262 | sum_a += a; | 262 | sum_a += a; |
| 263 | sum_b += b; | 263 | sum_b += b; |
| @@ -286,7 +286,7 @@ int main(int argc, char **argv){ · 22 unmodified lines | |||
| 286 | double sum_bb= 0; | 286 | double sum_bb= 0; |
| 287 | double sum_ab= 0; | 287 | double sum_ab= 0; |
| 288 | for(i=0; i<flush_count; i++){ | 288 | for(i=0; i<flush_count; i++){ |
| 289 | double a= get(ain , ch, i+out_count, in_ch_count, av_get_alt_sample_fmt(in_sample_fmt, 1)); | 289 | double a= get(ain , ch, i+out_count, in_ch_count, in_sample_fmt); |
| 290 | double b= get(aout, ch, i, in_ch_count, in_sample_fmt); | 290 | double b= get(aout, ch, i, in_ch_count, in_sample_fmt); |
| 291 | sum_a += a; | 291 | sum_a += a; |
| 292 | sum_b += b; | 292 | sum_b += b; |