comparison src/audio/SDL_audiotypecvt.c @ 3021:f3dcf04412cf

First shot at new audio resampling code.
author Ryan C. Gordon <icculus@icculus.org>
date Sun, 11 Jan 2009 04:46:42 +0000
parents 1210d5a28e16
children 77c3e67f0740
comparison
equal deleted inserted replaced
3020:70d876a0b90e 3021:f3dcf04412cf
23 23
24 #include "SDL_config.h" 24 #include "SDL_config.h"
25 #include "SDL_audio.h" 25 #include "SDL_audio.h"
26 #include "SDL_audio_c.h" 26 #include "SDL_audio_c.h"
27 27
28 #ifndef DEBUG_CONVERT
29 #define DEBUG_CONVERT 0
30 #endif
31
32
33 /* If you can guarantee your data and need space, you can eliminate code... */
34
35 /* Just build the arbitrary resamplers if you're saving code space. */
36 #ifndef LESS_RESAMPLERS
37 #define LESS_RESAMPLERS 0
38 #endif
39
40 /* Don't build any resamplers if you're REALLY saving code space. */
41 #ifndef NO_RESAMPLERS
42 #define NO_RESAMPLERS 0
43 #endif
44
45 /* Don't build any type converters if you're saving code space. */
46 #ifndef NO_CONVERTERS
47 #define NO_CONVERTERS 0
48 #endif
49
50
28 /* *INDENT-OFF* */ 51 /* *INDENT-OFF* */
29 52
30 #define DIVBY127 0.0078740157480315f 53 #define DIVBY127 0.0078740157480315f
31 #define DIVBY32767 3.05185094759972e-05f 54 #define DIVBY32767 3.05185094759972e-05f
32 #define DIVBY2147483647 4.6566128752458e-10f 55 #define DIVBY2147483647 4.6566128752458e-10f
56
57 #if !NO_CONVERTERS
33 58
34 static void SDLCALL 59 static void SDLCALL
35 SDL_Convert_U8_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format) 60 SDL_Convert_U8_to_S8(SDL_AudioCVT * cvt, SDL_AudioFormat format)
36 { 61 {
37 int i; 62 int i;
2163 if (cvt->filters[++cvt->filter_index]) { 2188 if (cvt->filters[++cvt->filter_index]) {
2164 cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB); 2189 cvt->filters[cvt->filter_index] (cvt, AUDIO_F32LSB);
2165 } 2190 }
2166 } 2191 }
2167 2192
2193 #endif /* !NO_CONVERTERS */
2194
2195
2168 const SDL_AudioTypeFilters sdl_audio_type_filters[] = 2196 const SDL_AudioTypeFilters sdl_audio_type_filters[] =
2169 { 2197 {
2198 #if !NO_CONVERTERS
2170 { AUDIO_U8, AUDIO_S8, SDL_Convert_U8_to_S8 }, 2199 { AUDIO_U8, AUDIO_S8, SDL_Convert_U8_to_S8 },
2171 { AUDIO_U8, AUDIO_U16LSB, SDL_Convert_U8_to_U16LSB }, 2200 { AUDIO_U8, AUDIO_U16LSB, SDL_Convert_U8_to_U16LSB },
2172 { AUDIO_U8, AUDIO_S16LSB, SDL_Convert_U8_to_S16LSB }, 2201 { AUDIO_U8, AUDIO_S16LSB, SDL_Convert_U8_to_S16LSB },
2173 { AUDIO_U8, AUDIO_U16MSB, SDL_Convert_U8_to_U16MSB }, 2202 { AUDIO_U8, AUDIO_U16MSB, SDL_Convert_U8_to_U16MSB },
2174 { AUDIO_U8, AUDIO_S16MSB, SDL_Convert_U8_to_S16MSB }, 2203 { AUDIO_U8, AUDIO_S16MSB, SDL_Convert_U8_to_S16MSB },
2255 { AUDIO_F32MSB, AUDIO_U16MSB, SDL_Convert_F32MSB_to_U16MSB }, 2284 { AUDIO_F32MSB, AUDIO_U16MSB, SDL_Convert_F32MSB_to_U16MSB },
2256 { AUDIO_F32MSB, AUDIO_S16MSB, SDL_Convert_F32MSB_to_S16MSB }, 2285 { AUDIO_F32MSB, AUDIO_S16MSB, SDL_Convert_F32MSB_to_S16MSB },
2257 { AUDIO_F32MSB, AUDIO_S32LSB, SDL_Convert_F32MSB_to_S32LSB }, 2286 { AUDIO_F32MSB, AUDIO_S32LSB, SDL_Convert_F32MSB_to_S32LSB },
2258 { AUDIO_F32MSB, AUDIO_S32MSB, SDL_Convert_F32MSB_to_S32MSB }, 2287 { AUDIO_F32MSB, AUDIO_S32MSB, SDL_Convert_F32MSB_to_S32MSB },
2259 { AUDIO_F32MSB, AUDIO_F32LSB, SDL_Convert_F32MSB_to_F32LSB }, 2288 { AUDIO_F32MSB, AUDIO_F32LSB, SDL_Convert_F32MSB_to_F32LSB },
2289 #endif /* !NO_CONVERTERS */
2290 { 0, 0, NULL }
2260 }; 2291 };
2261 2292
2262 2293
2294 #if !NO_RESAMPLERS
2295
2296 static void SDLCALL
2297 SDL_Upsample_U8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
2298 {
2299 #ifdef DEBUG_CONVERT
2300 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 1 channels.\n", cvt->rate_incr);
2301 #endif
2302
2303 const int srcsize = cvt->len_cvt - 16;
2304 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
2305 register int eps = 0;
2306 Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 1;
2307 const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
2308 const Uint8 *target = ((const Uint8 *) cvt->buf) - 1;
2309 Uint8 sample0 = src[0];
2310 Uint8 last_sample0 = sample0;
2311 while (dst != target) {
2312 dst[0] = sample0;
2313 dst--;
2314 eps += srcsize;
2315 if ((eps << 1) >= dstsize) {
2316 src--;
2317 sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
2318 last_sample0 = sample0;
2319 eps -= dstsize;
2320 }
2321 }
2322 cvt->len_cvt = dstsize;
2323 if (cvt->filters[++cvt->filter_index]) {
2324 cvt->filters[cvt->filter_index] (cvt, format);
2325 }
2326 }
2327
2328 static void SDLCALL
2329 SDL_Downsample_U8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
2330 {
2331 #ifdef DEBUG_CONVERT
2332 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 1 channels.\n", cvt->rate_incr);
2333 #endif
2334
2335 const int srcsize = cvt->len_cvt - 16;
2336 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
2337 register int eps = 0;
2338 Uint8 *dst = (Uint8 *) cvt->buf;
2339 const Uint8 *src = (Uint8 *) cvt->buf;
2340 const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
2341 Uint8 sample0 = src[0];
2342 Uint8 last_sample0 = sample0;
2343 while (dst != target) {
2344 src++;
2345 eps += dstsize;
2346 if ((eps << 1) >= srcsize) {
2347 dst[0] = sample0;
2348 dst++;
2349 sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
2350 last_sample0 = sample0;
2351 eps -= srcsize;
2352 }
2353 }
2354 cvt->len_cvt = dstsize;
2355 if (cvt->filters[++cvt->filter_index]) {
2356 cvt->filters[cvt->filter_index] (cvt, format);
2357 }
2358 }
2359
2360 static void SDLCALL
2361 SDL_Upsample_U8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
2362 {
2363 #ifdef DEBUG_CONVERT
2364 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 2 channels.\n", cvt->rate_incr);
2365 #endif
2366
2367 const int srcsize = cvt->len_cvt - 32;
2368 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
2369 register int eps = 0;
2370 Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 2;
2371 const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 2;
2372 const Uint8 *target = ((const Uint8 *) cvt->buf) - 2;
2373 Uint8 sample1 = src[1];
2374 Uint8 sample0 = src[0];
2375 Uint8 last_sample1 = sample1;
2376 Uint8 last_sample0 = sample0;
2377 while (dst != target) {
2378 dst[1] = sample1;
2379 dst[0] = sample0;
2380 dst -= 2;
2381 eps += srcsize;
2382 if ((eps << 1) >= dstsize) {
2383 src -= 2;
2384 sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
2385 sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
2386 last_sample1 = sample1;
2387 last_sample0 = sample0;
2388 eps -= dstsize;
2389 }
2390 }
2391 cvt->len_cvt = dstsize;
2392 if (cvt->filters[++cvt->filter_index]) {
2393 cvt->filters[cvt->filter_index] (cvt, format);
2394 }
2395 }
2396
2397 static void SDLCALL
2398 SDL_Downsample_U8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
2399 {
2400 #ifdef DEBUG_CONVERT
2401 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 2 channels.\n", cvt->rate_incr);
2402 #endif
2403
2404 const int srcsize = cvt->len_cvt - 32;
2405 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
2406 register int eps = 0;
2407 Uint8 *dst = (Uint8 *) cvt->buf;
2408 const Uint8 *src = (Uint8 *) cvt->buf;
2409 const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
2410 Uint8 sample0 = src[0];
2411 Uint8 sample1 = src[1];
2412 Uint8 last_sample0 = sample0;
2413 Uint8 last_sample1 = sample1;
2414 while (dst != target) {
2415 src += 2;
2416 eps += dstsize;
2417 if ((eps << 1) >= srcsize) {
2418 dst[0] = sample0;
2419 dst[1] = sample1;
2420 dst += 2;
2421 sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
2422 sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
2423 last_sample0 = sample0;
2424 last_sample1 = sample1;
2425 eps -= srcsize;
2426 }
2427 }
2428 cvt->len_cvt = dstsize;
2429 if (cvt->filters[++cvt->filter_index]) {
2430 cvt->filters[cvt->filter_index] (cvt, format);
2431 }
2432 }
2433
2434 static void SDLCALL
2435 SDL_Upsample_U8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
2436 {
2437 #ifdef DEBUG_CONVERT
2438 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 4 channels.\n", cvt->rate_incr);
2439 #endif
2440
2441 const int srcsize = cvt->len_cvt - 64;
2442 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
2443 register int eps = 0;
2444 Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 4;
2445 const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 4;
2446 const Uint8 *target = ((const Uint8 *) cvt->buf) - 4;
2447 Uint8 sample3 = src[3];
2448 Uint8 sample2 = src[2];
2449 Uint8 sample1 = src[1];
2450 Uint8 sample0 = src[0];
2451 Uint8 last_sample3 = sample3;
2452 Uint8 last_sample2 = sample2;
2453 Uint8 last_sample1 = sample1;
2454 Uint8 last_sample0 = sample0;
2455 while (dst != target) {
2456 dst[3] = sample3;
2457 dst[2] = sample2;
2458 dst[1] = sample1;
2459 dst[0] = sample0;
2460 dst -= 4;
2461 eps += srcsize;
2462 if ((eps << 1) >= dstsize) {
2463 src -= 4;
2464 sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
2465 sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
2466 sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
2467 sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
2468 last_sample3 = sample3;
2469 last_sample2 = sample2;
2470 last_sample1 = sample1;
2471 last_sample0 = sample0;
2472 eps -= dstsize;
2473 }
2474 }
2475 cvt->len_cvt = dstsize;
2476 if (cvt->filters[++cvt->filter_index]) {
2477 cvt->filters[cvt->filter_index] (cvt, format);
2478 }
2479 }
2480
2481 static void SDLCALL
2482 SDL_Downsample_U8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
2483 {
2484 #ifdef DEBUG_CONVERT
2485 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 4 channels.\n", cvt->rate_incr);
2486 #endif
2487
2488 const int srcsize = cvt->len_cvt - 64;
2489 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
2490 register int eps = 0;
2491 Uint8 *dst = (Uint8 *) cvt->buf;
2492 const Uint8 *src = (Uint8 *) cvt->buf;
2493 const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
2494 Uint8 sample0 = src[0];
2495 Uint8 sample1 = src[1];
2496 Uint8 sample2 = src[2];
2497 Uint8 sample3 = src[3];
2498 Uint8 last_sample0 = sample0;
2499 Uint8 last_sample1 = sample1;
2500 Uint8 last_sample2 = sample2;
2501 Uint8 last_sample3 = sample3;
2502 while (dst != target) {
2503 src += 4;
2504 eps += dstsize;
2505 if ((eps << 1) >= srcsize) {
2506 dst[0] = sample0;
2507 dst[1] = sample1;
2508 dst[2] = sample2;
2509 dst[3] = sample3;
2510 dst += 4;
2511 sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
2512 sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
2513 sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
2514 sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
2515 last_sample0 = sample0;
2516 last_sample1 = sample1;
2517 last_sample2 = sample2;
2518 last_sample3 = sample3;
2519 eps -= srcsize;
2520 }
2521 }
2522 cvt->len_cvt = dstsize;
2523 if (cvt->filters[++cvt->filter_index]) {
2524 cvt->filters[cvt->filter_index] (cvt, format);
2525 }
2526 }
2527
2528 static void SDLCALL
2529 SDL_Upsample_U8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
2530 {
2531 #ifdef DEBUG_CONVERT
2532 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 6 channels.\n", cvt->rate_incr);
2533 #endif
2534
2535 const int srcsize = cvt->len_cvt - 96;
2536 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
2537 register int eps = 0;
2538 Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 6;
2539 const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 6;
2540 const Uint8 *target = ((const Uint8 *) cvt->buf) - 6;
2541 Uint8 sample5 = src[5];
2542 Uint8 sample4 = src[4];
2543 Uint8 sample3 = src[3];
2544 Uint8 sample2 = src[2];
2545 Uint8 sample1 = src[1];
2546 Uint8 sample0 = src[0];
2547 Uint8 last_sample5 = sample5;
2548 Uint8 last_sample4 = sample4;
2549 Uint8 last_sample3 = sample3;
2550 Uint8 last_sample2 = sample2;
2551 Uint8 last_sample1 = sample1;
2552 Uint8 last_sample0 = sample0;
2553 while (dst != target) {
2554 dst[5] = sample5;
2555 dst[4] = sample4;
2556 dst[3] = sample3;
2557 dst[2] = sample2;
2558 dst[1] = sample1;
2559 dst[0] = sample0;
2560 dst -= 6;
2561 eps += srcsize;
2562 if ((eps << 1) >= dstsize) {
2563 src -= 6;
2564 sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
2565 sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
2566 sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
2567 sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
2568 sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
2569 sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
2570 last_sample5 = sample5;
2571 last_sample4 = sample4;
2572 last_sample3 = sample3;
2573 last_sample2 = sample2;
2574 last_sample1 = sample1;
2575 last_sample0 = sample0;
2576 eps -= dstsize;
2577 }
2578 }
2579 cvt->len_cvt = dstsize;
2580 if (cvt->filters[++cvt->filter_index]) {
2581 cvt->filters[cvt->filter_index] (cvt, format);
2582 }
2583 }
2584
2585 static void SDLCALL
2586 SDL_Downsample_U8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
2587 {
2588 #ifdef DEBUG_CONVERT
2589 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 6 channels.\n", cvt->rate_incr);
2590 #endif
2591
2592 const int srcsize = cvt->len_cvt - 96;
2593 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
2594 register int eps = 0;
2595 Uint8 *dst = (Uint8 *) cvt->buf;
2596 const Uint8 *src = (Uint8 *) cvt->buf;
2597 const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
2598 Uint8 sample0 = src[0];
2599 Uint8 sample1 = src[1];
2600 Uint8 sample2 = src[2];
2601 Uint8 sample3 = src[3];
2602 Uint8 sample4 = src[4];
2603 Uint8 sample5 = src[5];
2604 Uint8 last_sample0 = sample0;
2605 Uint8 last_sample1 = sample1;
2606 Uint8 last_sample2 = sample2;
2607 Uint8 last_sample3 = sample3;
2608 Uint8 last_sample4 = sample4;
2609 Uint8 last_sample5 = sample5;
2610 while (dst != target) {
2611 src += 6;
2612 eps += dstsize;
2613 if ((eps << 1) >= srcsize) {
2614 dst[0] = sample0;
2615 dst[1] = sample1;
2616 dst[2] = sample2;
2617 dst[3] = sample3;
2618 dst[4] = sample4;
2619 dst[5] = sample5;
2620 dst += 6;
2621 sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
2622 sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
2623 sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
2624 sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
2625 sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
2626 sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
2627 last_sample0 = sample0;
2628 last_sample1 = sample1;
2629 last_sample2 = sample2;
2630 last_sample3 = sample3;
2631 last_sample4 = sample4;
2632 last_sample5 = sample5;
2633 eps -= srcsize;
2634 }
2635 }
2636 cvt->len_cvt = dstsize;
2637 if (cvt->filters[++cvt->filter_index]) {
2638 cvt->filters[cvt->filter_index] (cvt, format);
2639 }
2640 }
2641
2642 static void SDLCALL
2643 SDL_Upsample_U8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
2644 {
2645 #ifdef DEBUG_CONVERT
2646 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U8, 8 channels.\n", cvt->rate_incr);
2647 #endif
2648
2649 const int srcsize = cvt->len_cvt - 128;
2650 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
2651 register int eps = 0;
2652 Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 8;
2653 const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 8;
2654 const Uint8 *target = ((const Uint8 *) cvt->buf) - 8;
2655 Uint8 sample7 = src[7];
2656 Uint8 sample6 = src[6];
2657 Uint8 sample5 = src[5];
2658 Uint8 sample4 = src[4];
2659 Uint8 sample3 = src[3];
2660 Uint8 sample2 = src[2];
2661 Uint8 sample1 = src[1];
2662 Uint8 sample0 = src[0];
2663 Uint8 last_sample7 = sample7;
2664 Uint8 last_sample6 = sample6;
2665 Uint8 last_sample5 = sample5;
2666 Uint8 last_sample4 = sample4;
2667 Uint8 last_sample3 = sample3;
2668 Uint8 last_sample2 = sample2;
2669 Uint8 last_sample1 = sample1;
2670 Uint8 last_sample0 = sample0;
2671 while (dst != target) {
2672 dst[7] = sample7;
2673 dst[6] = sample6;
2674 dst[5] = sample5;
2675 dst[4] = sample4;
2676 dst[3] = sample3;
2677 dst[2] = sample2;
2678 dst[1] = sample1;
2679 dst[0] = sample0;
2680 dst -= 8;
2681 eps += srcsize;
2682 if ((eps << 1) >= dstsize) {
2683 src -= 8;
2684 sample7 = (Uint8) ((((Sint16) src[7]) + ((Sint16) last_sample7)) >> 1);
2685 sample6 = (Uint8) ((((Sint16) src[6]) + ((Sint16) last_sample6)) >> 1);
2686 sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
2687 sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
2688 sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
2689 sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
2690 sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
2691 sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
2692 last_sample7 = sample7;
2693 last_sample6 = sample6;
2694 last_sample5 = sample5;
2695 last_sample4 = sample4;
2696 last_sample3 = sample3;
2697 last_sample2 = sample2;
2698 last_sample1 = sample1;
2699 last_sample0 = sample0;
2700 eps -= dstsize;
2701 }
2702 }
2703 cvt->len_cvt = dstsize;
2704 if (cvt->filters[++cvt->filter_index]) {
2705 cvt->filters[cvt->filter_index] (cvt, format);
2706 }
2707 }
2708
2709 static void SDLCALL
2710 SDL_Downsample_U8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
2711 {
2712 #ifdef DEBUG_CONVERT
2713 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U8, 8 channels.\n", cvt->rate_incr);
2714 #endif
2715
2716 const int srcsize = cvt->len_cvt - 128;
2717 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
2718 register int eps = 0;
2719 Uint8 *dst = (Uint8 *) cvt->buf;
2720 const Uint8 *src = (Uint8 *) cvt->buf;
2721 const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
2722 Uint8 sample0 = src[0];
2723 Uint8 sample1 = src[1];
2724 Uint8 sample2 = src[2];
2725 Uint8 sample3 = src[3];
2726 Uint8 sample4 = src[4];
2727 Uint8 sample5 = src[5];
2728 Uint8 sample6 = src[6];
2729 Uint8 sample7 = src[7];
2730 Uint8 last_sample0 = sample0;
2731 Uint8 last_sample1 = sample1;
2732 Uint8 last_sample2 = sample2;
2733 Uint8 last_sample3 = sample3;
2734 Uint8 last_sample4 = sample4;
2735 Uint8 last_sample5 = sample5;
2736 Uint8 last_sample6 = sample6;
2737 Uint8 last_sample7 = sample7;
2738 while (dst != target) {
2739 src += 8;
2740 eps += dstsize;
2741 if ((eps << 1) >= srcsize) {
2742 dst[0] = sample0;
2743 dst[1] = sample1;
2744 dst[2] = sample2;
2745 dst[3] = sample3;
2746 dst[4] = sample4;
2747 dst[5] = sample5;
2748 dst[6] = sample6;
2749 dst[7] = sample7;
2750 dst += 8;
2751 sample0 = (Uint8) ((((Sint16) src[0]) + ((Sint16) last_sample0)) >> 1);
2752 sample1 = (Uint8) ((((Sint16) src[1]) + ((Sint16) last_sample1)) >> 1);
2753 sample2 = (Uint8) ((((Sint16) src[2]) + ((Sint16) last_sample2)) >> 1);
2754 sample3 = (Uint8) ((((Sint16) src[3]) + ((Sint16) last_sample3)) >> 1);
2755 sample4 = (Uint8) ((((Sint16) src[4]) + ((Sint16) last_sample4)) >> 1);
2756 sample5 = (Uint8) ((((Sint16) src[5]) + ((Sint16) last_sample5)) >> 1);
2757 sample6 = (Uint8) ((((Sint16) src[6]) + ((Sint16) last_sample6)) >> 1);
2758 sample7 = (Uint8) ((((Sint16) src[7]) + ((Sint16) last_sample7)) >> 1);
2759 last_sample0 = sample0;
2760 last_sample1 = sample1;
2761 last_sample2 = sample2;
2762 last_sample3 = sample3;
2763 last_sample4 = sample4;
2764 last_sample5 = sample5;
2765 last_sample6 = sample6;
2766 last_sample7 = sample7;
2767 eps -= srcsize;
2768 }
2769 }
2770 cvt->len_cvt = dstsize;
2771 if (cvt->filters[++cvt->filter_index]) {
2772 cvt->filters[cvt->filter_index] (cvt, format);
2773 }
2774 }
2775
2776 static void SDLCALL
2777 SDL_Upsample_S8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
2778 {
2779 #ifdef DEBUG_CONVERT
2780 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 1 channels.\n", cvt->rate_incr);
2781 #endif
2782
2783 const int srcsize = cvt->len_cvt - 16;
2784 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
2785 register int eps = 0;
2786 Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 1;
2787 const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 1;
2788 const Sint8 *target = ((const Sint8 *) cvt->buf) - 1;
2789 Sint8 sample0 = ((Sint8) src[0]);
2790 Sint8 last_sample0 = sample0;
2791 while (dst != target) {
2792 dst[0] = ((Sint8) sample0);
2793 dst--;
2794 eps += srcsize;
2795 if ((eps << 1) >= dstsize) {
2796 src--;
2797 sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
2798 last_sample0 = sample0;
2799 eps -= dstsize;
2800 }
2801 }
2802 cvt->len_cvt = dstsize;
2803 if (cvt->filters[++cvt->filter_index]) {
2804 cvt->filters[cvt->filter_index] (cvt, format);
2805 }
2806 }
2807
2808 static void SDLCALL
2809 SDL_Downsample_S8_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
2810 {
2811 #ifdef DEBUG_CONVERT
2812 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 1 channels.\n", cvt->rate_incr);
2813 #endif
2814
2815 const int srcsize = cvt->len_cvt - 16;
2816 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
2817 register int eps = 0;
2818 Sint8 *dst = (Sint8 *) cvt->buf;
2819 const Sint8 *src = (Sint8 *) cvt->buf;
2820 const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
2821 Sint8 sample0 = ((Sint8) src[0]);
2822 Sint8 last_sample0 = sample0;
2823 while (dst != target) {
2824 src++;
2825 eps += dstsize;
2826 if ((eps << 1) >= srcsize) {
2827 dst[0] = ((Sint8) sample0);
2828 dst++;
2829 sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
2830 last_sample0 = sample0;
2831 eps -= srcsize;
2832 }
2833 }
2834 cvt->len_cvt = dstsize;
2835 if (cvt->filters[++cvt->filter_index]) {
2836 cvt->filters[cvt->filter_index] (cvt, format);
2837 }
2838 }
2839
2840 static void SDLCALL
2841 SDL_Upsample_S8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
2842 {
2843 #ifdef DEBUG_CONVERT
2844 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 2 channels.\n", cvt->rate_incr);
2845 #endif
2846
2847 const int srcsize = cvt->len_cvt - 32;
2848 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
2849 register int eps = 0;
2850 Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 2;
2851 const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 2;
2852 const Sint8 *target = ((const Sint8 *) cvt->buf) - 2;
2853 Sint8 sample1 = ((Sint8) src[1]);
2854 Sint8 sample0 = ((Sint8) src[0]);
2855 Sint8 last_sample1 = sample1;
2856 Sint8 last_sample0 = sample0;
2857 while (dst != target) {
2858 dst[1] = ((Sint8) sample1);
2859 dst[0] = ((Sint8) sample0);
2860 dst -= 2;
2861 eps += srcsize;
2862 if ((eps << 1) >= dstsize) {
2863 src -= 2;
2864 sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
2865 sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
2866 last_sample1 = sample1;
2867 last_sample0 = sample0;
2868 eps -= dstsize;
2869 }
2870 }
2871 cvt->len_cvt = dstsize;
2872 if (cvt->filters[++cvt->filter_index]) {
2873 cvt->filters[cvt->filter_index] (cvt, format);
2874 }
2875 }
2876
2877 static void SDLCALL
2878 SDL_Downsample_S8_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
2879 {
2880 #ifdef DEBUG_CONVERT
2881 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 2 channels.\n", cvt->rate_incr);
2882 #endif
2883
2884 const int srcsize = cvt->len_cvt - 32;
2885 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
2886 register int eps = 0;
2887 Sint8 *dst = (Sint8 *) cvt->buf;
2888 const Sint8 *src = (Sint8 *) cvt->buf;
2889 const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
2890 Sint8 sample0 = ((Sint8) src[0]);
2891 Sint8 sample1 = ((Sint8) src[1]);
2892 Sint8 last_sample0 = sample0;
2893 Sint8 last_sample1 = sample1;
2894 while (dst != target) {
2895 src += 2;
2896 eps += dstsize;
2897 if ((eps << 1) >= srcsize) {
2898 dst[0] = ((Sint8) sample0);
2899 dst[1] = ((Sint8) sample1);
2900 dst += 2;
2901 sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
2902 sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
2903 last_sample0 = sample0;
2904 last_sample1 = sample1;
2905 eps -= srcsize;
2906 }
2907 }
2908 cvt->len_cvt = dstsize;
2909 if (cvt->filters[++cvt->filter_index]) {
2910 cvt->filters[cvt->filter_index] (cvt, format);
2911 }
2912 }
2913
2914 static void SDLCALL
2915 SDL_Upsample_S8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
2916 {
2917 #ifdef DEBUG_CONVERT
2918 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 4 channels.\n", cvt->rate_incr);
2919 #endif
2920
2921 const int srcsize = cvt->len_cvt - 64;
2922 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
2923 register int eps = 0;
2924 Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 4;
2925 const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 4;
2926 const Sint8 *target = ((const Sint8 *) cvt->buf) - 4;
2927 Sint8 sample3 = ((Sint8) src[3]);
2928 Sint8 sample2 = ((Sint8) src[2]);
2929 Sint8 sample1 = ((Sint8) src[1]);
2930 Sint8 sample0 = ((Sint8) src[0]);
2931 Sint8 last_sample3 = sample3;
2932 Sint8 last_sample2 = sample2;
2933 Sint8 last_sample1 = sample1;
2934 Sint8 last_sample0 = sample0;
2935 while (dst != target) {
2936 dst[3] = ((Sint8) sample3);
2937 dst[2] = ((Sint8) sample2);
2938 dst[1] = ((Sint8) sample1);
2939 dst[0] = ((Sint8) sample0);
2940 dst -= 4;
2941 eps += srcsize;
2942 if ((eps << 1) >= dstsize) {
2943 src -= 4;
2944 sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
2945 sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
2946 sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
2947 sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
2948 last_sample3 = sample3;
2949 last_sample2 = sample2;
2950 last_sample1 = sample1;
2951 last_sample0 = sample0;
2952 eps -= dstsize;
2953 }
2954 }
2955 cvt->len_cvt = dstsize;
2956 if (cvt->filters[++cvt->filter_index]) {
2957 cvt->filters[cvt->filter_index] (cvt, format);
2958 }
2959 }
2960
2961 static void SDLCALL
2962 SDL_Downsample_S8_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
2963 {
2964 #ifdef DEBUG_CONVERT
2965 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 4 channels.\n", cvt->rate_incr);
2966 #endif
2967
2968 const int srcsize = cvt->len_cvt - 64;
2969 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
2970 register int eps = 0;
2971 Sint8 *dst = (Sint8 *) cvt->buf;
2972 const Sint8 *src = (Sint8 *) cvt->buf;
2973 const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
2974 Sint8 sample0 = ((Sint8) src[0]);
2975 Sint8 sample1 = ((Sint8) src[1]);
2976 Sint8 sample2 = ((Sint8) src[2]);
2977 Sint8 sample3 = ((Sint8) src[3]);
2978 Sint8 last_sample0 = sample0;
2979 Sint8 last_sample1 = sample1;
2980 Sint8 last_sample2 = sample2;
2981 Sint8 last_sample3 = sample3;
2982 while (dst != target) {
2983 src += 4;
2984 eps += dstsize;
2985 if ((eps << 1) >= srcsize) {
2986 dst[0] = ((Sint8) sample0);
2987 dst[1] = ((Sint8) sample1);
2988 dst[2] = ((Sint8) sample2);
2989 dst[3] = ((Sint8) sample3);
2990 dst += 4;
2991 sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
2992 sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
2993 sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
2994 sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
2995 last_sample0 = sample0;
2996 last_sample1 = sample1;
2997 last_sample2 = sample2;
2998 last_sample3 = sample3;
2999 eps -= srcsize;
3000 }
3001 }
3002 cvt->len_cvt = dstsize;
3003 if (cvt->filters[++cvt->filter_index]) {
3004 cvt->filters[cvt->filter_index] (cvt, format);
3005 }
3006 }
3007
3008 static void SDLCALL
3009 SDL_Upsample_S8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
3010 {
3011 #ifdef DEBUG_CONVERT
3012 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 6 channels.\n", cvt->rate_incr);
3013 #endif
3014
3015 const int srcsize = cvt->len_cvt - 96;
3016 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
3017 register int eps = 0;
3018 Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 6;
3019 const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 6;
3020 const Sint8 *target = ((const Sint8 *) cvt->buf) - 6;
3021 Sint8 sample5 = ((Sint8) src[5]);
3022 Sint8 sample4 = ((Sint8) src[4]);
3023 Sint8 sample3 = ((Sint8) src[3]);
3024 Sint8 sample2 = ((Sint8) src[2]);
3025 Sint8 sample1 = ((Sint8) src[1]);
3026 Sint8 sample0 = ((Sint8) src[0]);
3027 Sint8 last_sample5 = sample5;
3028 Sint8 last_sample4 = sample4;
3029 Sint8 last_sample3 = sample3;
3030 Sint8 last_sample2 = sample2;
3031 Sint8 last_sample1 = sample1;
3032 Sint8 last_sample0 = sample0;
3033 while (dst != target) {
3034 dst[5] = ((Sint8) sample5);
3035 dst[4] = ((Sint8) sample4);
3036 dst[3] = ((Sint8) sample3);
3037 dst[2] = ((Sint8) sample2);
3038 dst[1] = ((Sint8) sample1);
3039 dst[0] = ((Sint8) sample0);
3040 dst -= 6;
3041 eps += srcsize;
3042 if ((eps << 1) >= dstsize) {
3043 src -= 6;
3044 sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
3045 sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
3046 sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
3047 sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
3048 sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
3049 sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
3050 last_sample5 = sample5;
3051 last_sample4 = sample4;
3052 last_sample3 = sample3;
3053 last_sample2 = sample2;
3054 last_sample1 = sample1;
3055 last_sample0 = sample0;
3056 eps -= dstsize;
3057 }
3058 }
3059 cvt->len_cvt = dstsize;
3060 if (cvt->filters[++cvt->filter_index]) {
3061 cvt->filters[cvt->filter_index] (cvt, format);
3062 }
3063 }
3064
3065 static void SDLCALL
3066 SDL_Downsample_S8_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
3067 {
3068 #ifdef DEBUG_CONVERT
3069 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 6 channels.\n", cvt->rate_incr);
3070 #endif
3071
3072 const int srcsize = cvt->len_cvt - 96;
3073 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
3074 register int eps = 0;
3075 Sint8 *dst = (Sint8 *) cvt->buf;
3076 const Sint8 *src = (Sint8 *) cvt->buf;
3077 const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
3078 Sint8 sample0 = ((Sint8) src[0]);
3079 Sint8 sample1 = ((Sint8) src[1]);
3080 Sint8 sample2 = ((Sint8) src[2]);
3081 Sint8 sample3 = ((Sint8) src[3]);
3082 Sint8 sample4 = ((Sint8) src[4]);
3083 Sint8 sample5 = ((Sint8) src[5]);
3084 Sint8 last_sample0 = sample0;
3085 Sint8 last_sample1 = sample1;
3086 Sint8 last_sample2 = sample2;
3087 Sint8 last_sample3 = sample3;
3088 Sint8 last_sample4 = sample4;
3089 Sint8 last_sample5 = sample5;
3090 while (dst != target) {
3091 src += 6;
3092 eps += dstsize;
3093 if ((eps << 1) >= srcsize) {
3094 dst[0] = ((Sint8) sample0);
3095 dst[1] = ((Sint8) sample1);
3096 dst[2] = ((Sint8) sample2);
3097 dst[3] = ((Sint8) sample3);
3098 dst[4] = ((Sint8) sample4);
3099 dst[5] = ((Sint8) sample5);
3100 dst += 6;
3101 sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
3102 sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
3103 sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
3104 sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
3105 sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
3106 sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
3107 last_sample0 = sample0;
3108 last_sample1 = sample1;
3109 last_sample2 = sample2;
3110 last_sample3 = sample3;
3111 last_sample4 = sample4;
3112 last_sample5 = sample5;
3113 eps -= srcsize;
3114 }
3115 }
3116 cvt->len_cvt = dstsize;
3117 if (cvt->filters[++cvt->filter_index]) {
3118 cvt->filters[cvt->filter_index] (cvt, format);
3119 }
3120 }
3121
3122 static void SDLCALL
3123 SDL_Upsample_S8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
3124 {
3125 #ifdef DEBUG_CONVERT
3126 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S8, 8 channels.\n", cvt->rate_incr);
3127 #endif
3128
3129 const int srcsize = cvt->len_cvt - 128;
3130 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
3131 register int eps = 0;
3132 Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 8;
3133 const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 8;
3134 const Sint8 *target = ((const Sint8 *) cvt->buf) - 8;
3135 Sint8 sample7 = ((Sint8) src[7]);
3136 Sint8 sample6 = ((Sint8) src[6]);
3137 Sint8 sample5 = ((Sint8) src[5]);
3138 Sint8 sample4 = ((Sint8) src[4]);
3139 Sint8 sample3 = ((Sint8) src[3]);
3140 Sint8 sample2 = ((Sint8) src[2]);
3141 Sint8 sample1 = ((Sint8) src[1]);
3142 Sint8 sample0 = ((Sint8) src[0]);
3143 Sint8 last_sample7 = sample7;
3144 Sint8 last_sample6 = sample6;
3145 Sint8 last_sample5 = sample5;
3146 Sint8 last_sample4 = sample4;
3147 Sint8 last_sample3 = sample3;
3148 Sint8 last_sample2 = sample2;
3149 Sint8 last_sample1 = sample1;
3150 Sint8 last_sample0 = sample0;
3151 while (dst != target) {
3152 dst[7] = ((Sint8) sample7);
3153 dst[6] = ((Sint8) sample6);
3154 dst[5] = ((Sint8) sample5);
3155 dst[4] = ((Sint8) sample4);
3156 dst[3] = ((Sint8) sample3);
3157 dst[2] = ((Sint8) sample2);
3158 dst[1] = ((Sint8) sample1);
3159 dst[0] = ((Sint8) sample0);
3160 dst -= 8;
3161 eps += srcsize;
3162 if ((eps << 1) >= dstsize) {
3163 src -= 8;
3164 sample7 = (Sint8) ((((Sint16) ((Sint8) src[7])) + ((Sint16) last_sample7)) >> 1);
3165 sample6 = (Sint8) ((((Sint16) ((Sint8) src[6])) + ((Sint16) last_sample6)) >> 1);
3166 sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
3167 sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
3168 sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
3169 sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
3170 sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
3171 sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
3172 last_sample7 = sample7;
3173 last_sample6 = sample6;
3174 last_sample5 = sample5;
3175 last_sample4 = sample4;
3176 last_sample3 = sample3;
3177 last_sample2 = sample2;
3178 last_sample1 = sample1;
3179 last_sample0 = sample0;
3180 eps -= dstsize;
3181 }
3182 }
3183 cvt->len_cvt = dstsize;
3184 if (cvt->filters[++cvt->filter_index]) {
3185 cvt->filters[cvt->filter_index] (cvt, format);
3186 }
3187 }
3188
3189 static void SDLCALL
3190 SDL_Downsample_S8_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
3191 {
3192 #ifdef DEBUG_CONVERT
3193 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S8, 8 channels.\n", cvt->rate_incr);
3194 #endif
3195
3196 const int srcsize = cvt->len_cvt - 128;
3197 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
3198 register int eps = 0;
3199 Sint8 *dst = (Sint8 *) cvt->buf;
3200 const Sint8 *src = (Sint8 *) cvt->buf;
3201 const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
3202 Sint8 sample0 = ((Sint8) src[0]);
3203 Sint8 sample1 = ((Sint8) src[1]);
3204 Sint8 sample2 = ((Sint8) src[2]);
3205 Sint8 sample3 = ((Sint8) src[3]);
3206 Sint8 sample4 = ((Sint8) src[4]);
3207 Sint8 sample5 = ((Sint8) src[5]);
3208 Sint8 sample6 = ((Sint8) src[6]);
3209 Sint8 sample7 = ((Sint8) src[7]);
3210 Sint8 last_sample0 = sample0;
3211 Sint8 last_sample1 = sample1;
3212 Sint8 last_sample2 = sample2;
3213 Sint8 last_sample3 = sample3;
3214 Sint8 last_sample4 = sample4;
3215 Sint8 last_sample5 = sample5;
3216 Sint8 last_sample6 = sample6;
3217 Sint8 last_sample7 = sample7;
3218 while (dst != target) {
3219 src += 8;
3220 eps += dstsize;
3221 if ((eps << 1) >= srcsize) {
3222 dst[0] = ((Sint8) sample0);
3223 dst[1] = ((Sint8) sample1);
3224 dst[2] = ((Sint8) sample2);
3225 dst[3] = ((Sint8) sample3);
3226 dst[4] = ((Sint8) sample4);
3227 dst[5] = ((Sint8) sample5);
3228 dst[6] = ((Sint8) sample6);
3229 dst[7] = ((Sint8) sample7);
3230 dst += 8;
3231 sample0 = (Sint8) ((((Sint16) ((Sint8) src[0])) + ((Sint16) last_sample0)) >> 1);
3232 sample1 = (Sint8) ((((Sint16) ((Sint8) src[1])) + ((Sint16) last_sample1)) >> 1);
3233 sample2 = (Sint8) ((((Sint16) ((Sint8) src[2])) + ((Sint16) last_sample2)) >> 1);
3234 sample3 = (Sint8) ((((Sint16) ((Sint8) src[3])) + ((Sint16) last_sample3)) >> 1);
3235 sample4 = (Sint8) ((((Sint16) ((Sint8) src[4])) + ((Sint16) last_sample4)) >> 1);
3236 sample5 = (Sint8) ((((Sint16) ((Sint8) src[5])) + ((Sint16) last_sample5)) >> 1);
3237 sample6 = (Sint8) ((((Sint16) ((Sint8) src[6])) + ((Sint16) last_sample6)) >> 1);
3238 sample7 = (Sint8) ((((Sint16) ((Sint8) src[7])) + ((Sint16) last_sample7)) >> 1);
3239 last_sample0 = sample0;
3240 last_sample1 = sample1;
3241 last_sample2 = sample2;
3242 last_sample3 = sample3;
3243 last_sample4 = sample4;
3244 last_sample5 = sample5;
3245 last_sample6 = sample6;
3246 last_sample7 = sample7;
3247 eps -= srcsize;
3248 }
3249 }
3250 cvt->len_cvt = dstsize;
3251 if (cvt->filters[++cvt->filter_index]) {
3252 cvt->filters[cvt->filter_index] (cvt, format);
3253 }
3254 }
3255
3256 static void SDLCALL
3257 SDL_Upsample_U16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
3258 {
3259 #ifdef DEBUG_CONVERT
3260 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 1 channels.\n", cvt->rate_incr);
3261 #endif
3262
3263 const int srcsize = cvt->len_cvt - 32;
3264 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
3265 register int eps = 0;
3266 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1;
3267 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
3268 const Uint16 *target = ((const Uint16 *) cvt->buf) - 1;
3269 Uint16 sample0 = SDL_SwapLE16(src[0]);
3270 Uint16 last_sample0 = sample0;
3271 while (dst != target) {
3272 dst[0] = SDL_SwapLE16(sample0);
3273 dst--;
3274 eps += srcsize;
3275 if ((eps << 1) >= dstsize) {
3276 src--;
3277 sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
3278 last_sample0 = sample0;
3279 eps -= dstsize;
3280 }
3281 }
3282 cvt->len_cvt = dstsize;
3283 if (cvt->filters[++cvt->filter_index]) {
3284 cvt->filters[cvt->filter_index] (cvt, format);
3285 }
3286 }
3287
3288 static void SDLCALL
3289 SDL_Downsample_U16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
3290 {
3291 #ifdef DEBUG_CONVERT
3292 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 1 channels.\n", cvt->rate_incr);
3293 #endif
3294
3295 const int srcsize = cvt->len_cvt - 32;
3296 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
3297 register int eps = 0;
3298 Uint16 *dst = (Uint16 *) cvt->buf;
3299 const Uint16 *src = (Uint16 *) cvt->buf;
3300 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
3301 Uint16 sample0 = SDL_SwapLE16(src[0]);
3302 Uint16 last_sample0 = sample0;
3303 while (dst != target) {
3304 src++;
3305 eps += dstsize;
3306 if ((eps << 1) >= srcsize) {
3307 dst[0] = SDL_SwapLE16(sample0);
3308 dst++;
3309 sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
3310 last_sample0 = sample0;
3311 eps -= srcsize;
3312 }
3313 }
3314 cvt->len_cvt = dstsize;
3315 if (cvt->filters[++cvt->filter_index]) {
3316 cvt->filters[cvt->filter_index] (cvt, format);
3317 }
3318 }
3319
3320 static void SDLCALL
3321 SDL_Upsample_U16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
3322 {
3323 #ifdef DEBUG_CONVERT
3324 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 2 channels.\n", cvt->rate_incr);
3325 #endif
3326
3327 const int srcsize = cvt->len_cvt - 64;
3328 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
3329 register int eps = 0;
3330 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2;
3331 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
3332 const Uint16 *target = ((const Uint16 *) cvt->buf) - 2;
3333 Uint16 sample1 = SDL_SwapLE16(src[1]);
3334 Uint16 sample0 = SDL_SwapLE16(src[0]);
3335 Uint16 last_sample1 = sample1;
3336 Uint16 last_sample0 = sample0;
3337 while (dst != target) {
3338 dst[1] = SDL_SwapLE16(sample1);
3339 dst[0] = SDL_SwapLE16(sample0);
3340 dst -= 2;
3341 eps += srcsize;
3342 if ((eps << 1) >= dstsize) {
3343 src -= 2;
3344 sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
3345 sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
3346 last_sample1 = sample1;
3347 last_sample0 = sample0;
3348 eps -= dstsize;
3349 }
3350 }
3351 cvt->len_cvt = dstsize;
3352 if (cvt->filters[++cvt->filter_index]) {
3353 cvt->filters[cvt->filter_index] (cvt, format);
3354 }
3355 }
3356
3357 static void SDLCALL
3358 SDL_Downsample_U16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
3359 {
3360 #ifdef DEBUG_CONVERT
3361 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 2 channels.\n", cvt->rate_incr);
3362 #endif
3363
3364 const int srcsize = cvt->len_cvt - 64;
3365 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
3366 register int eps = 0;
3367 Uint16 *dst = (Uint16 *) cvt->buf;
3368 const Uint16 *src = (Uint16 *) cvt->buf;
3369 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
3370 Uint16 sample0 = SDL_SwapLE16(src[0]);
3371 Uint16 sample1 = SDL_SwapLE16(src[1]);
3372 Uint16 last_sample0 = sample0;
3373 Uint16 last_sample1 = sample1;
3374 while (dst != target) {
3375 src += 2;
3376 eps += dstsize;
3377 if ((eps << 1) >= srcsize) {
3378 dst[0] = SDL_SwapLE16(sample0);
3379 dst[1] = SDL_SwapLE16(sample1);
3380 dst += 2;
3381 sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
3382 sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
3383 last_sample0 = sample0;
3384 last_sample1 = sample1;
3385 eps -= srcsize;
3386 }
3387 }
3388 cvt->len_cvt = dstsize;
3389 if (cvt->filters[++cvt->filter_index]) {
3390 cvt->filters[cvt->filter_index] (cvt, format);
3391 }
3392 }
3393
3394 static void SDLCALL
3395 SDL_Upsample_U16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
3396 {
3397 #ifdef DEBUG_CONVERT
3398 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 4 channels.\n", cvt->rate_incr);
3399 #endif
3400
3401 const int srcsize = cvt->len_cvt - 128;
3402 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
3403 register int eps = 0;
3404 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4;
3405 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
3406 const Uint16 *target = ((const Uint16 *) cvt->buf) - 4;
3407 Uint16 sample3 = SDL_SwapLE16(src[3]);
3408 Uint16 sample2 = SDL_SwapLE16(src[2]);
3409 Uint16 sample1 = SDL_SwapLE16(src[1]);
3410 Uint16 sample0 = SDL_SwapLE16(src[0]);
3411 Uint16 last_sample3 = sample3;
3412 Uint16 last_sample2 = sample2;
3413 Uint16 last_sample1 = sample1;
3414 Uint16 last_sample0 = sample0;
3415 while (dst != target) {
3416 dst[3] = SDL_SwapLE16(sample3);
3417 dst[2] = SDL_SwapLE16(sample2);
3418 dst[1] = SDL_SwapLE16(sample1);
3419 dst[0] = SDL_SwapLE16(sample0);
3420 dst -= 4;
3421 eps += srcsize;
3422 if ((eps << 1) >= dstsize) {
3423 src -= 4;
3424 sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
3425 sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
3426 sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
3427 sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
3428 last_sample3 = sample3;
3429 last_sample2 = sample2;
3430 last_sample1 = sample1;
3431 last_sample0 = sample0;
3432 eps -= dstsize;
3433 }
3434 }
3435 cvt->len_cvt = dstsize;
3436 if (cvt->filters[++cvt->filter_index]) {
3437 cvt->filters[cvt->filter_index] (cvt, format);
3438 }
3439 }
3440
3441 static void SDLCALL
3442 SDL_Downsample_U16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
3443 {
3444 #ifdef DEBUG_CONVERT
3445 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 4 channels.\n", cvt->rate_incr);
3446 #endif
3447
3448 const int srcsize = cvt->len_cvt - 128;
3449 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
3450 register int eps = 0;
3451 Uint16 *dst = (Uint16 *) cvt->buf;
3452 const Uint16 *src = (Uint16 *) cvt->buf;
3453 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
3454 Uint16 sample0 = SDL_SwapLE16(src[0]);
3455 Uint16 sample1 = SDL_SwapLE16(src[1]);
3456 Uint16 sample2 = SDL_SwapLE16(src[2]);
3457 Uint16 sample3 = SDL_SwapLE16(src[3]);
3458 Uint16 last_sample0 = sample0;
3459 Uint16 last_sample1 = sample1;
3460 Uint16 last_sample2 = sample2;
3461 Uint16 last_sample3 = sample3;
3462 while (dst != target) {
3463 src += 4;
3464 eps += dstsize;
3465 if ((eps << 1) >= srcsize) {
3466 dst[0] = SDL_SwapLE16(sample0);
3467 dst[1] = SDL_SwapLE16(sample1);
3468 dst[2] = SDL_SwapLE16(sample2);
3469 dst[3] = SDL_SwapLE16(sample3);
3470 dst += 4;
3471 sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
3472 sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
3473 sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
3474 sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
3475 last_sample0 = sample0;
3476 last_sample1 = sample1;
3477 last_sample2 = sample2;
3478 last_sample3 = sample3;
3479 eps -= srcsize;
3480 }
3481 }
3482 cvt->len_cvt = dstsize;
3483 if (cvt->filters[++cvt->filter_index]) {
3484 cvt->filters[cvt->filter_index] (cvt, format);
3485 }
3486 }
3487
3488 static void SDLCALL
3489 SDL_Upsample_U16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
3490 {
3491 #ifdef DEBUG_CONVERT
3492 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 6 channels.\n", cvt->rate_incr);
3493 #endif
3494
3495 const int srcsize = cvt->len_cvt - 192;
3496 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
3497 register int eps = 0;
3498 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6;
3499 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
3500 const Uint16 *target = ((const Uint16 *) cvt->buf) - 6;
3501 Uint16 sample5 = SDL_SwapLE16(src[5]);
3502 Uint16 sample4 = SDL_SwapLE16(src[4]);
3503 Uint16 sample3 = SDL_SwapLE16(src[3]);
3504 Uint16 sample2 = SDL_SwapLE16(src[2]);
3505 Uint16 sample1 = SDL_SwapLE16(src[1]);
3506 Uint16 sample0 = SDL_SwapLE16(src[0]);
3507 Uint16 last_sample5 = sample5;
3508 Uint16 last_sample4 = sample4;
3509 Uint16 last_sample3 = sample3;
3510 Uint16 last_sample2 = sample2;
3511 Uint16 last_sample1 = sample1;
3512 Uint16 last_sample0 = sample0;
3513 while (dst != target) {
3514 dst[5] = SDL_SwapLE16(sample5);
3515 dst[4] = SDL_SwapLE16(sample4);
3516 dst[3] = SDL_SwapLE16(sample3);
3517 dst[2] = SDL_SwapLE16(sample2);
3518 dst[1] = SDL_SwapLE16(sample1);
3519 dst[0] = SDL_SwapLE16(sample0);
3520 dst -= 6;
3521 eps += srcsize;
3522 if ((eps << 1) >= dstsize) {
3523 src -= 6;
3524 sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
3525 sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
3526 sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
3527 sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
3528 sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
3529 sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
3530 last_sample5 = sample5;
3531 last_sample4 = sample4;
3532 last_sample3 = sample3;
3533 last_sample2 = sample2;
3534 last_sample1 = sample1;
3535 last_sample0 = sample0;
3536 eps -= dstsize;
3537 }
3538 }
3539 cvt->len_cvt = dstsize;
3540 if (cvt->filters[++cvt->filter_index]) {
3541 cvt->filters[cvt->filter_index] (cvt, format);
3542 }
3543 }
3544
3545 static void SDLCALL
3546 SDL_Downsample_U16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
3547 {
3548 #ifdef DEBUG_CONVERT
3549 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 6 channels.\n", cvt->rate_incr);
3550 #endif
3551
3552 const int srcsize = cvt->len_cvt - 192;
3553 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
3554 register int eps = 0;
3555 Uint16 *dst = (Uint16 *) cvt->buf;
3556 const Uint16 *src = (Uint16 *) cvt->buf;
3557 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
3558 Uint16 sample0 = SDL_SwapLE16(src[0]);
3559 Uint16 sample1 = SDL_SwapLE16(src[1]);
3560 Uint16 sample2 = SDL_SwapLE16(src[2]);
3561 Uint16 sample3 = SDL_SwapLE16(src[3]);
3562 Uint16 sample4 = SDL_SwapLE16(src[4]);
3563 Uint16 sample5 = SDL_SwapLE16(src[5]);
3564 Uint16 last_sample0 = sample0;
3565 Uint16 last_sample1 = sample1;
3566 Uint16 last_sample2 = sample2;
3567 Uint16 last_sample3 = sample3;
3568 Uint16 last_sample4 = sample4;
3569 Uint16 last_sample5 = sample5;
3570 while (dst != target) {
3571 src += 6;
3572 eps += dstsize;
3573 if ((eps << 1) >= srcsize) {
3574 dst[0] = SDL_SwapLE16(sample0);
3575 dst[1] = SDL_SwapLE16(sample1);
3576 dst[2] = SDL_SwapLE16(sample2);
3577 dst[3] = SDL_SwapLE16(sample3);
3578 dst[4] = SDL_SwapLE16(sample4);
3579 dst[5] = SDL_SwapLE16(sample5);
3580 dst += 6;
3581 sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
3582 sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
3583 sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
3584 sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
3585 sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
3586 sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
3587 last_sample0 = sample0;
3588 last_sample1 = sample1;
3589 last_sample2 = sample2;
3590 last_sample3 = sample3;
3591 last_sample4 = sample4;
3592 last_sample5 = sample5;
3593 eps -= srcsize;
3594 }
3595 }
3596 cvt->len_cvt = dstsize;
3597 if (cvt->filters[++cvt->filter_index]) {
3598 cvt->filters[cvt->filter_index] (cvt, format);
3599 }
3600 }
3601
3602 static void SDLCALL
3603 SDL_Upsample_U16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
3604 {
3605 #ifdef DEBUG_CONVERT
3606 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16LSB, 8 channels.\n", cvt->rate_incr);
3607 #endif
3608
3609 const int srcsize = cvt->len_cvt - 256;
3610 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
3611 register int eps = 0;
3612 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8;
3613 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
3614 const Uint16 *target = ((const Uint16 *) cvt->buf) - 8;
3615 Uint16 sample7 = SDL_SwapLE16(src[7]);
3616 Uint16 sample6 = SDL_SwapLE16(src[6]);
3617 Uint16 sample5 = SDL_SwapLE16(src[5]);
3618 Uint16 sample4 = SDL_SwapLE16(src[4]);
3619 Uint16 sample3 = SDL_SwapLE16(src[3]);
3620 Uint16 sample2 = SDL_SwapLE16(src[2]);
3621 Uint16 sample1 = SDL_SwapLE16(src[1]);
3622 Uint16 sample0 = SDL_SwapLE16(src[0]);
3623 Uint16 last_sample7 = sample7;
3624 Uint16 last_sample6 = sample6;
3625 Uint16 last_sample5 = sample5;
3626 Uint16 last_sample4 = sample4;
3627 Uint16 last_sample3 = sample3;
3628 Uint16 last_sample2 = sample2;
3629 Uint16 last_sample1 = sample1;
3630 Uint16 last_sample0 = sample0;
3631 while (dst != target) {
3632 dst[7] = SDL_SwapLE16(sample7);
3633 dst[6] = SDL_SwapLE16(sample6);
3634 dst[5] = SDL_SwapLE16(sample5);
3635 dst[4] = SDL_SwapLE16(sample4);
3636 dst[3] = SDL_SwapLE16(sample3);
3637 dst[2] = SDL_SwapLE16(sample2);
3638 dst[1] = SDL_SwapLE16(sample1);
3639 dst[0] = SDL_SwapLE16(sample0);
3640 dst -= 8;
3641 eps += srcsize;
3642 if ((eps << 1) >= dstsize) {
3643 src -= 8;
3644 sample7 = (Uint16) ((((Sint32) SDL_SwapLE16(src[7])) + ((Sint32) last_sample7)) >> 1);
3645 sample6 = (Uint16) ((((Sint32) SDL_SwapLE16(src[6])) + ((Sint32) last_sample6)) >> 1);
3646 sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
3647 sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
3648 sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
3649 sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
3650 sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
3651 sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
3652 last_sample7 = sample7;
3653 last_sample6 = sample6;
3654 last_sample5 = sample5;
3655 last_sample4 = sample4;
3656 last_sample3 = sample3;
3657 last_sample2 = sample2;
3658 last_sample1 = sample1;
3659 last_sample0 = sample0;
3660 eps -= dstsize;
3661 }
3662 }
3663 cvt->len_cvt = dstsize;
3664 if (cvt->filters[++cvt->filter_index]) {
3665 cvt->filters[cvt->filter_index] (cvt, format);
3666 }
3667 }
3668
3669 static void SDLCALL
3670 SDL_Downsample_U16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
3671 {
3672 #ifdef DEBUG_CONVERT
3673 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16LSB, 8 channels.\n", cvt->rate_incr);
3674 #endif
3675
3676 const int srcsize = cvt->len_cvt - 256;
3677 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
3678 register int eps = 0;
3679 Uint16 *dst = (Uint16 *) cvt->buf;
3680 const Uint16 *src = (Uint16 *) cvt->buf;
3681 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
3682 Uint16 sample0 = SDL_SwapLE16(src[0]);
3683 Uint16 sample1 = SDL_SwapLE16(src[1]);
3684 Uint16 sample2 = SDL_SwapLE16(src[2]);
3685 Uint16 sample3 = SDL_SwapLE16(src[3]);
3686 Uint16 sample4 = SDL_SwapLE16(src[4]);
3687 Uint16 sample5 = SDL_SwapLE16(src[5]);
3688 Uint16 sample6 = SDL_SwapLE16(src[6]);
3689 Uint16 sample7 = SDL_SwapLE16(src[7]);
3690 Uint16 last_sample0 = sample0;
3691 Uint16 last_sample1 = sample1;
3692 Uint16 last_sample2 = sample2;
3693 Uint16 last_sample3 = sample3;
3694 Uint16 last_sample4 = sample4;
3695 Uint16 last_sample5 = sample5;
3696 Uint16 last_sample6 = sample6;
3697 Uint16 last_sample7 = sample7;
3698 while (dst != target) {
3699 src += 8;
3700 eps += dstsize;
3701 if ((eps << 1) >= srcsize) {
3702 dst[0] = SDL_SwapLE16(sample0);
3703 dst[1] = SDL_SwapLE16(sample1);
3704 dst[2] = SDL_SwapLE16(sample2);
3705 dst[3] = SDL_SwapLE16(sample3);
3706 dst[4] = SDL_SwapLE16(sample4);
3707 dst[5] = SDL_SwapLE16(sample5);
3708 dst[6] = SDL_SwapLE16(sample6);
3709 dst[7] = SDL_SwapLE16(sample7);
3710 dst += 8;
3711 sample0 = (Uint16) ((((Sint32) SDL_SwapLE16(src[0])) + ((Sint32) last_sample0)) >> 1);
3712 sample1 = (Uint16) ((((Sint32) SDL_SwapLE16(src[1])) + ((Sint32) last_sample1)) >> 1);
3713 sample2 = (Uint16) ((((Sint32) SDL_SwapLE16(src[2])) + ((Sint32) last_sample2)) >> 1);
3714 sample3 = (Uint16) ((((Sint32) SDL_SwapLE16(src[3])) + ((Sint32) last_sample3)) >> 1);
3715 sample4 = (Uint16) ((((Sint32) SDL_SwapLE16(src[4])) + ((Sint32) last_sample4)) >> 1);
3716 sample5 = (Uint16) ((((Sint32) SDL_SwapLE16(src[5])) + ((Sint32) last_sample5)) >> 1);
3717 sample6 = (Uint16) ((((Sint32) SDL_SwapLE16(src[6])) + ((Sint32) last_sample6)) >> 1);
3718 sample7 = (Uint16) ((((Sint32) SDL_SwapLE16(src[7])) + ((Sint32) last_sample7)) >> 1);
3719 last_sample0 = sample0;
3720 last_sample1 = sample1;
3721 last_sample2 = sample2;
3722 last_sample3 = sample3;
3723 last_sample4 = sample4;
3724 last_sample5 = sample5;
3725 last_sample6 = sample6;
3726 last_sample7 = sample7;
3727 eps -= srcsize;
3728 }
3729 }
3730 cvt->len_cvt = dstsize;
3731 if (cvt->filters[++cvt->filter_index]) {
3732 cvt->filters[cvt->filter_index] (cvt, format);
3733 }
3734 }
3735
3736 static void SDLCALL
3737 SDL_Upsample_S16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
3738 {
3739 #ifdef DEBUG_CONVERT
3740 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 1 channels.\n", cvt->rate_incr);
3741 #endif
3742
3743 const int srcsize = cvt->len_cvt - 32;
3744 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
3745 register int eps = 0;
3746 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1;
3747 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
3748 const Sint16 *target = ((const Sint16 *) cvt->buf) - 1;
3749 Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
3750 Sint16 last_sample0 = sample0;
3751 while (dst != target) {
3752 dst[0] = ((Sint16) SDL_SwapLE16(sample0));
3753 dst--;
3754 eps += srcsize;
3755 if ((eps << 1) >= dstsize) {
3756 src--;
3757 sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
3758 last_sample0 = sample0;
3759 eps -= dstsize;
3760 }
3761 }
3762 cvt->len_cvt = dstsize;
3763 if (cvt->filters[++cvt->filter_index]) {
3764 cvt->filters[cvt->filter_index] (cvt, format);
3765 }
3766 }
3767
3768 static void SDLCALL
3769 SDL_Downsample_S16LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
3770 {
3771 #ifdef DEBUG_CONVERT
3772 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 1 channels.\n", cvt->rate_incr);
3773 #endif
3774
3775 const int srcsize = cvt->len_cvt - 32;
3776 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
3777 register int eps = 0;
3778 Sint16 *dst = (Sint16 *) cvt->buf;
3779 const Sint16 *src = (Sint16 *) cvt->buf;
3780 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
3781 Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
3782 Sint16 last_sample0 = sample0;
3783 while (dst != target) {
3784 src++;
3785 eps += dstsize;
3786 if ((eps << 1) >= srcsize) {
3787 dst[0] = ((Sint16) SDL_SwapLE16(sample0));
3788 dst++;
3789 sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
3790 last_sample0 = sample0;
3791 eps -= srcsize;
3792 }
3793 }
3794 cvt->len_cvt = dstsize;
3795 if (cvt->filters[++cvt->filter_index]) {
3796 cvt->filters[cvt->filter_index] (cvt, format);
3797 }
3798 }
3799
3800 static void SDLCALL
3801 SDL_Upsample_S16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
3802 {
3803 #ifdef DEBUG_CONVERT
3804 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 2 channels.\n", cvt->rate_incr);
3805 #endif
3806
3807 const int srcsize = cvt->len_cvt - 64;
3808 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
3809 register int eps = 0;
3810 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
3811 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
3812 const Sint16 *target = ((const Sint16 *) cvt->buf) - 2;
3813 Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
3814 Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
3815 Sint16 last_sample1 = sample1;
3816 Sint16 last_sample0 = sample0;
3817 while (dst != target) {
3818 dst[1] = ((Sint16) SDL_SwapLE16(sample1));
3819 dst[0] = ((Sint16) SDL_SwapLE16(sample0));
3820 dst -= 2;
3821 eps += srcsize;
3822 if ((eps << 1) >= dstsize) {
3823 src -= 2;
3824 sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
3825 sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
3826 last_sample1 = sample1;
3827 last_sample0 = sample0;
3828 eps -= dstsize;
3829 }
3830 }
3831 cvt->len_cvt = dstsize;
3832 if (cvt->filters[++cvt->filter_index]) {
3833 cvt->filters[cvt->filter_index] (cvt, format);
3834 }
3835 }
3836
3837 static void SDLCALL
3838 SDL_Downsample_S16LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
3839 {
3840 #ifdef DEBUG_CONVERT
3841 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 2 channels.\n", cvt->rate_incr);
3842 #endif
3843
3844 const int srcsize = cvt->len_cvt - 64;
3845 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
3846 register int eps = 0;
3847 Sint16 *dst = (Sint16 *) cvt->buf;
3848 const Sint16 *src = (Sint16 *) cvt->buf;
3849 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
3850 Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
3851 Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
3852 Sint16 last_sample0 = sample0;
3853 Sint16 last_sample1 = sample1;
3854 while (dst != target) {
3855 src += 2;
3856 eps += dstsize;
3857 if ((eps << 1) >= srcsize) {
3858 dst[0] = ((Sint16) SDL_SwapLE16(sample0));
3859 dst[1] = ((Sint16) SDL_SwapLE16(sample1));
3860 dst += 2;
3861 sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
3862 sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
3863 last_sample0 = sample0;
3864 last_sample1 = sample1;
3865 eps -= srcsize;
3866 }
3867 }
3868 cvt->len_cvt = dstsize;
3869 if (cvt->filters[++cvt->filter_index]) {
3870 cvt->filters[cvt->filter_index] (cvt, format);
3871 }
3872 }
3873
3874 static void SDLCALL
3875 SDL_Upsample_S16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
3876 {
3877 #ifdef DEBUG_CONVERT
3878 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 4 channels.\n", cvt->rate_incr);
3879 #endif
3880
3881 const int srcsize = cvt->len_cvt - 128;
3882 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
3883 register int eps = 0;
3884 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4;
3885 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
3886 const Sint16 *target = ((const Sint16 *) cvt->buf) - 4;
3887 Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
3888 Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
3889 Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
3890 Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
3891 Sint16 last_sample3 = sample3;
3892 Sint16 last_sample2 = sample2;
3893 Sint16 last_sample1 = sample1;
3894 Sint16 last_sample0 = sample0;
3895 while (dst != target) {
3896 dst[3] = ((Sint16) SDL_SwapLE16(sample3));
3897 dst[2] = ((Sint16) SDL_SwapLE16(sample2));
3898 dst[1] = ((Sint16) SDL_SwapLE16(sample1));
3899 dst[0] = ((Sint16) SDL_SwapLE16(sample0));
3900 dst -= 4;
3901 eps += srcsize;
3902 if ((eps << 1) >= dstsize) {
3903 src -= 4;
3904 sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
3905 sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
3906 sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
3907 sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
3908 last_sample3 = sample3;
3909 last_sample2 = sample2;
3910 last_sample1 = sample1;
3911 last_sample0 = sample0;
3912 eps -= dstsize;
3913 }
3914 }
3915 cvt->len_cvt = dstsize;
3916 if (cvt->filters[++cvt->filter_index]) {
3917 cvt->filters[cvt->filter_index] (cvt, format);
3918 }
3919 }
3920
3921 static void SDLCALL
3922 SDL_Downsample_S16LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
3923 {
3924 #ifdef DEBUG_CONVERT
3925 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 4 channels.\n", cvt->rate_incr);
3926 #endif
3927
3928 const int srcsize = cvt->len_cvt - 128;
3929 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
3930 register int eps = 0;
3931 Sint16 *dst = (Sint16 *) cvt->buf;
3932 const Sint16 *src = (Sint16 *) cvt->buf;
3933 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
3934 Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
3935 Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
3936 Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
3937 Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
3938 Sint16 last_sample0 = sample0;
3939 Sint16 last_sample1 = sample1;
3940 Sint16 last_sample2 = sample2;
3941 Sint16 last_sample3 = sample3;
3942 while (dst != target) {
3943 src += 4;
3944 eps += dstsize;
3945 if ((eps << 1) >= srcsize) {
3946 dst[0] = ((Sint16) SDL_SwapLE16(sample0));
3947 dst[1] = ((Sint16) SDL_SwapLE16(sample1));
3948 dst[2] = ((Sint16) SDL_SwapLE16(sample2));
3949 dst[3] = ((Sint16) SDL_SwapLE16(sample3));
3950 dst += 4;
3951 sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
3952 sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
3953 sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
3954 sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
3955 last_sample0 = sample0;
3956 last_sample1 = sample1;
3957 last_sample2 = sample2;
3958 last_sample3 = sample3;
3959 eps -= srcsize;
3960 }
3961 }
3962 cvt->len_cvt = dstsize;
3963 if (cvt->filters[++cvt->filter_index]) {
3964 cvt->filters[cvt->filter_index] (cvt, format);
3965 }
3966 }
3967
3968 static void SDLCALL
3969 SDL_Upsample_S16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
3970 {
3971 #ifdef DEBUG_CONVERT
3972 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 6 channels.\n", cvt->rate_incr);
3973 #endif
3974
3975 const int srcsize = cvt->len_cvt - 192;
3976 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
3977 register int eps = 0;
3978 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6;
3979 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
3980 const Sint16 *target = ((const Sint16 *) cvt->buf) - 6;
3981 Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
3982 Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
3983 Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
3984 Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
3985 Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
3986 Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
3987 Sint16 last_sample5 = sample5;
3988 Sint16 last_sample4 = sample4;
3989 Sint16 last_sample3 = sample3;
3990 Sint16 last_sample2 = sample2;
3991 Sint16 last_sample1 = sample1;
3992 Sint16 last_sample0 = sample0;
3993 while (dst != target) {
3994 dst[5] = ((Sint16) SDL_SwapLE16(sample5));
3995 dst[4] = ((Sint16) SDL_SwapLE16(sample4));
3996 dst[3] = ((Sint16) SDL_SwapLE16(sample3));
3997 dst[2] = ((Sint16) SDL_SwapLE16(sample2));
3998 dst[1] = ((Sint16) SDL_SwapLE16(sample1));
3999 dst[0] = ((Sint16) SDL_SwapLE16(sample0));
4000 dst -= 6;
4001 eps += srcsize;
4002 if ((eps << 1) >= dstsize) {
4003 src -= 6;
4004 sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
4005 sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
4006 sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
4007 sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
4008 sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
4009 sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
4010 last_sample5 = sample5;
4011 last_sample4 = sample4;
4012 last_sample3 = sample3;
4013 last_sample2 = sample2;
4014 last_sample1 = sample1;
4015 last_sample0 = sample0;
4016 eps -= dstsize;
4017 }
4018 }
4019 cvt->len_cvt = dstsize;
4020 if (cvt->filters[++cvt->filter_index]) {
4021 cvt->filters[cvt->filter_index] (cvt, format);
4022 }
4023 }
4024
4025 static void SDLCALL
4026 SDL_Downsample_S16LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
4027 {
4028 #ifdef DEBUG_CONVERT
4029 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 6 channels.\n", cvt->rate_incr);
4030 #endif
4031
4032 const int srcsize = cvt->len_cvt - 192;
4033 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
4034 register int eps = 0;
4035 Sint16 *dst = (Sint16 *) cvt->buf;
4036 const Sint16 *src = (Sint16 *) cvt->buf;
4037 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
4038 Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
4039 Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
4040 Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
4041 Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
4042 Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
4043 Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
4044 Sint16 last_sample0 = sample0;
4045 Sint16 last_sample1 = sample1;
4046 Sint16 last_sample2 = sample2;
4047 Sint16 last_sample3 = sample3;
4048 Sint16 last_sample4 = sample4;
4049 Sint16 last_sample5 = sample5;
4050 while (dst != target) {
4051 src += 6;
4052 eps += dstsize;
4053 if ((eps << 1) >= srcsize) {
4054 dst[0] = ((Sint16) SDL_SwapLE16(sample0));
4055 dst[1] = ((Sint16) SDL_SwapLE16(sample1));
4056 dst[2] = ((Sint16) SDL_SwapLE16(sample2));
4057 dst[3] = ((Sint16) SDL_SwapLE16(sample3));
4058 dst[4] = ((Sint16) SDL_SwapLE16(sample4));
4059 dst[5] = ((Sint16) SDL_SwapLE16(sample5));
4060 dst += 6;
4061 sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
4062 sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
4063 sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
4064 sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
4065 sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
4066 sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
4067 last_sample0 = sample0;
4068 last_sample1 = sample1;
4069 last_sample2 = sample2;
4070 last_sample3 = sample3;
4071 last_sample4 = sample4;
4072 last_sample5 = sample5;
4073 eps -= srcsize;
4074 }
4075 }
4076 cvt->len_cvt = dstsize;
4077 if (cvt->filters[++cvt->filter_index]) {
4078 cvt->filters[cvt->filter_index] (cvt, format);
4079 }
4080 }
4081
4082 static void SDLCALL
4083 SDL_Upsample_S16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
4084 {
4085 #ifdef DEBUG_CONVERT
4086 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16LSB, 8 channels.\n", cvt->rate_incr);
4087 #endif
4088
4089 const int srcsize = cvt->len_cvt - 256;
4090 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
4091 register int eps = 0;
4092 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8;
4093 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
4094 const Sint16 *target = ((const Sint16 *) cvt->buf) - 8;
4095 Sint16 sample7 = ((Sint16) SDL_SwapLE16(src[7]));
4096 Sint16 sample6 = ((Sint16) SDL_SwapLE16(src[6]));
4097 Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
4098 Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
4099 Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
4100 Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
4101 Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
4102 Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
4103 Sint16 last_sample7 = sample7;
4104 Sint16 last_sample6 = sample6;
4105 Sint16 last_sample5 = sample5;
4106 Sint16 last_sample4 = sample4;
4107 Sint16 last_sample3 = sample3;
4108 Sint16 last_sample2 = sample2;
4109 Sint16 last_sample1 = sample1;
4110 Sint16 last_sample0 = sample0;
4111 while (dst != target) {
4112 dst[7] = ((Sint16) SDL_SwapLE16(sample7));
4113 dst[6] = ((Sint16) SDL_SwapLE16(sample6));
4114 dst[5] = ((Sint16) SDL_SwapLE16(sample5));
4115 dst[4] = ((Sint16) SDL_SwapLE16(sample4));
4116 dst[3] = ((Sint16) SDL_SwapLE16(sample3));
4117 dst[2] = ((Sint16) SDL_SwapLE16(sample2));
4118 dst[1] = ((Sint16) SDL_SwapLE16(sample1));
4119 dst[0] = ((Sint16) SDL_SwapLE16(sample0));
4120 dst -= 8;
4121 eps += srcsize;
4122 if ((eps << 1) >= dstsize) {
4123 src -= 8;
4124 sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
4125 sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
4126 sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
4127 sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
4128 sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
4129 sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
4130 sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
4131 sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
4132 last_sample7 = sample7;
4133 last_sample6 = sample6;
4134 last_sample5 = sample5;
4135 last_sample4 = sample4;
4136 last_sample3 = sample3;
4137 last_sample2 = sample2;
4138 last_sample1 = sample1;
4139 last_sample0 = sample0;
4140 eps -= dstsize;
4141 }
4142 }
4143 cvt->len_cvt = dstsize;
4144 if (cvt->filters[++cvt->filter_index]) {
4145 cvt->filters[cvt->filter_index] (cvt, format);
4146 }
4147 }
4148
4149 static void SDLCALL
4150 SDL_Downsample_S16LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
4151 {
4152 #ifdef DEBUG_CONVERT
4153 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16LSB, 8 channels.\n", cvt->rate_incr);
4154 #endif
4155
4156 const int srcsize = cvt->len_cvt - 256;
4157 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
4158 register int eps = 0;
4159 Sint16 *dst = (Sint16 *) cvt->buf;
4160 const Sint16 *src = (Sint16 *) cvt->buf;
4161 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
4162 Sint16 sample0 = ((Sint16) SDL_SwapLE16(src[0]));
4163 Sint16 sample1 = ((Sint16) SDL_SwapLE16(src[1]));
4164 Sint16 sample2 = ((Sint16) SDL_SwapLE16(src[2]));
4165 Sint16 sample3 = ((Sint16) SDL_SwapLE16(src[3]));
4166 Sint16 sample4 = ((Sint16) SDL_SwapLE16(src[4]));
4167 Sint16 sample5 = ((Sint16) SDL_SwapLE16(src[5]));
4168 Sint16 sample6 = ((Sint16) SDL_SwapLE16(src[6]));
4169 Sint16 sample7 = ((Sint16) SDL_SwapLE16(src[7]));
4170 Sint16 last_sample0 = sample0;
4171 Sint16 last_sample1 = sample1;
4172 Sint16 last_sample2 = sample2;
4173 Sint16 last_sample3 = sample3;
4174 Sint16 last_sample4 = sample4;
4175 Sint16 last_sample5 = sample5;
4176 Sint16 last_sample6 = sample6;
4177 Sint16 last_sample7 = sample7;
4178 while (dst != target) {
4179 src += 8;
4180 eps += dstsize;
4181 if ((eps << 1) >= srcsize) {
4182 dst[0] = ((Sint16) SDL_SwapLE16(sample0));
4183 dst[1] = ((Sint16) SDL_SwapLE16(sample1));
4184 dst[2] = ((Sint16) SDL_SwapLE16(sample2));
4185 dst[3] = ((Sint16) SDL_SwapLE16(sample3));
4186 dst[4] = ((Sint16) SDL_SwapLE16(sample4));
4187 dst[5] = ((Sint16) SDL_SwapLE16(sample5));
4188 dst[6] = ((Sint16) SDL_SwapLE16(sample6));
4189 dst[7] = ((Sint16) SDL_SwapLE16(sample7));
4190 dst += 8;
4191 sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
4192 sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
4193 sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
4194 sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
4195 sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
4196 sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
4197 sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
4198 sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapLE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
4199 last_sample0 = sample0;
4200 last_sample1 = sample1;
4201 last_sample2 = sample2;
4202 last_sample3 = sample3;
4203 last_sample4 = sample4;
4204 last_sample5 = sample5;
4205 last_sample6 = sample6;
4206 last_sample7 = sample7;
4207 eps -= srcsize;
4208 }
4209 }
4210 cvt->len_cvt = dstsize;
4211 if (cvt->filters[++cvt->filter_index]) {
4212 cvt->filters[cvt->filter_index] (cvt, format);
4213 }
4214 }
4215
4216 static void SDLCALL
4217 SDL_Upsample_U16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
4218 {
4219 #ifdef DEBUG_CONVERT
4220 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 1 channels.\n", cvt->rate_incr);
4221 #endif
4222
4223 const int srcsize = cvt->len_cvt - 32;
4224 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
4225 register int eps = 0;
4226 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1;
4227 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
4228 const Uint16 *target = ((const Uint16 *) cvt->buf) - 1;
4229 Uint16 sample0 = SDL_SwapBE16(src[0]);
4230 Uint16 last_sample0 = sample0;
4231 while (dst != target) {
4232 dst[0] = SDL_SwapBE16(sample0);
4233 dst--;
4234 eps += srcsize;
4235 if ((eps << 1) >= dstsize) {
4236 src--;
4237 sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
4238 last_sample0 = sample0;
4239 eps -= dstsize;
4240 }
4241 }
4242 cvt->len_cvt = dstsize;
4243 if (cvt->filters[++cvt->filter_index]) {
4244 cvt->filters[cvt->filter_index] (cvt, format);
4245 }
4246 }
4247
4248 static void SDLCALL
4249 SDL_Downsample_U16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
4250 {
4251 #ifdef DEBUG_CONVERT
4252 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 1 channels.\n", cvt->rate_incr);
4253 #endif
4254
4255 const int srcsize = cvt->len_cvt - 32;
4256 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
4257 register int eps = 0;
4258 Uint16 *dst = (Uint16 *) cvt->buf;
4259 const Uint16 *src = (Uint16 *) cvt->buf;
4260 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
4261 Uint16 sample0 = SDL_SwapBE16(src[0]);
4262 Uint16 last_sample0 = sample0;
4263 while (dst != target) {
4264 src++;
4265 eps += dstsize;
4266 if ((eps << 1) >= srcsize) {
4267 dst[0] = SDL_SwapBE16(sample0);
4268 dst++;
4269 sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
4270 last_sample0 = sample0;
4271 eps -= srcsize;
4272 }
4273 }
4274 cvt->len_cvt = dstsize;
4275 if (cvt->filters[++cvt->filter_index]) {
4276 cvt->filters[cvt->filter_index] (cvt, format);
4277 }
4278 }
4279
4280 static void SDLCALL
4281 SDL_Upsample_U16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
4282 {
4283 #ifdef DEBUG_CONVERT
4284 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 2 channels.\n", cvt->rate_incr);
4285 #endif
4286
4287 const int srcsize = cvt->len_cvt - 64;
4288 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
4289 register int eps = 0;
4290 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2;
4291 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
4292 const Uint16 *target = ((const Uint16 *) cvt->buf) - 2;
4293 Uint16 sample1 = SDL_SwapBE16(src[1]);
4294 Uint16 sample0 = SDL_SwapBE16(src[0]);
4295 Uint16 last_sample1 = sample1;
4296 Uint16 last_sample0 = sample0;
4297 while (dst != target) {
4298 dst[1] = SDL_SwapBE16(sample1);
4299 dst[0] = SDL_SwapBE16(sample0);
4300 dst -= 2;
4301 eps += srcsize;
4302 if ((eps << 1) >= dstsize) {
4303 src -= 2;
4304 sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
4305 sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
4306 last_sample1 = sample1;
4307 last_sample0 = sample0;
4308 eps -= dstsize;
4309 }
4310 }
4311 cvt->len_cvt = dstsize;
4312 if (cvt->filters[++cvt->filter_index]) {
4313 cvt->filters[cvt->filter_index] (cvt, format);
4314 }
4315 }
4316
4317 static void SDLCALL
4318 SDL_Downsample_U16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
4319 {
4320 #ifdef DEBUG_CONVERT
4321 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 2 channels.\n", cvt->rate_incr);
4322 #endif
4323
4324 const int srcsize = cvt->len_cvt - 64;
4325 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
4326 register int eps = 0;
4327 Uint16 *dst = (Uint16 *) cvt->buf;
4328 const Uint16 *src = (Uint16 *) cvt->buf;
4329 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
4330 Uint16 sample0 = SDL_SwapBE16(src[0]);
4331 Uint16 sample1 = SDL_SwapBE16(src[1]);
4332 Uint16 last_sample0 = sample0;
4333 Uint16 last_sample1 = sample1;
4334 while (dst != target) {
4335 src += 2;
4336 eps += dstsize;
4337 if ((eps << 1) >= srcsize) {
4338 dst[0] = SDL_SwapBE16(sample0);
4339 dst[1] = SDL_SwapBE16(sample1);
4340 dst += 2;
4341 sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
4342 sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
4343 last_sample0 = sample0;
4344 last_sample1 = sample1;
4345 eps -= srcsize;
4346 }
4347 }
4348 cvt->len_cvt = dstsize;
4349 if (cvt->filters[++cvt->filter_index]) {
4350 cvt->filters[cvt->filter_index] (cvt, format);
4351 }
4352 }
4353
4354 static void SDLCALL
4355 SDL_Upsample_U16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
4356 {
4357 #ifdef DEBUG_CONVERT
4358 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 4 channels.\n", cvt->rate_incr);
4359 #endif
4360
4361 const int srcsize = cvt->len_cvt - 128;
4362 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
4363 register int eps = 0;
4364 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4;
4365 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
4366 const Uint16 *target = ((const Uint16 *) cvt->buf) - 4;
4367 Uint16 sample3 = SDL_SwapBE16(src[3]);
4368 Uint16 sample2 = SDL_SwapBE16(src[2]);
4369 Uint16 sample1 = SDL_SwapBE16(src[1]);
4370 Uint16 sample0 = SDL_SwapBE16(src[0]);
4371 Uint16 last_sample3 = sample3;
4372 Uint16 last_sample2 = sample2;
4373 Uint16 last_sample1 = sample1;
4374 Uint16 last_sample0 = sample0;
4375 while (dst != target) {
4376 dst[3] = SDL_SwapBE16(sample3);
4377 dst[2] = SDL_SwapBE16(sample2);
4378 dst[1] = SDL_SwapBE16(sample1);
4379 dst[0] = SDL_SwapBE16(sample0);
4380 dst -= 4;
4381 eps += srcsize;
4382 if ((eps << 1) >= dstsize) {
4383 src -= 4;
4384 sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
4385 sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
4386 sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
4387 sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
4388 last_sample3 = sample3;
4389 last_sample2 = sample2;
4390 last_sample1 = sample1;
4391 last_sample0 = sample0;
4392 eps -= dstsize;
4393 }
4394 }
4395 cvt->len_cvt = dstsize;
4396 if (cvt->filters[++cvt->filter_index]) {
4397 cvt->filters[cvt->filter_index] (cvt, format);
4398 }
4399 }
4400
4401 static void SDLCALL
4402 SDL_Downsample_U16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
4403 {
4404 #ifdef DEBUG_CONVERT
4405 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 4 channels.\n", cvt->rate_incr);
4406 #endif
4407
4408 const int srcsize = cvt->len_cvt - 128;
4409 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
4410 register int eps = 0;
4411 Uint16 *dst = (Uint16 *) cvt->buf;
4412 const Uint16 *src = (Uint16 *) cvt->buf;
4413 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
4414 Uint16 sample0 = SDL_SwapBE16(src[0]);
4415 Uint16 sample1 = SDL_SwapBE16(src[1]);
4416 Uint16 sample2 = SDL_SwapBE16(src[2]);
4417 Uint16 sample3 = SDL_SwapBE16(src[3]);
4418 Uint16 last_sample0 = sample0;
4419 Uint16 last_sample1 = sample1;
4420 Uint16 last_sample2 = sample2;
4421 Uint16 last_sample3 = sample3;
4422 while (dst != target) {
4423 src += 4;
4424 eps += dstsize;
4425 if ((eps << 1) >= srcsize) {
4426 dst[0] = SDL_SwapBE16(sample0);
4427 dst[1] = SDL_SwapBE16(sample1);
4428 dst[2] = SDL_SwapBE16(sample2);
4429 dst[3] = SDL_SwapBE16(sample3);
4430 dst += 4;
4431 sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
4432 sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
4433 sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
4434 sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
4435 last_sample0 = sample0;
4436 last_sample1 = sample1;
4437 last_sample2 = sample2;
4438 last_sample3 = sample3;
4439 eps -= srcsize;
4440 }
4441 }
4442 cvt->len_cvt = dstsize;
4443 if (cvt->filters[++cvt->filter_index]) {
4444 cvt->filters[cvt->filter_index] (cvt, format);
4445 }
4446 }
4447
4448 static void SDLCALL
4449 SDL_Upsample_U16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
4450 {
4451 #ifdef DEBUG_CONVERT
4452 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 6 channels.\n", cvt->rate_incr);
4453 #endif
4454
4455 const int srcsize = cvt->len_cvt - 192;
4456 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
4457 register int eps = 0;
4458 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6;
4459 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
4460 const Uint16 *target = ((const Uint16 *) cvt->buf) - 6;
4461 Uint16 sample5 = SDL_SwapBE16(src[5]);
4462 Uint16 sample4 = SDL_SwapBE16(src[4]);
4463 Uint16 sample3 = SDL_SwapBE16(src[3]);
4464 Uint16 sample2 = SDL_SwapBE16(src[2]);
4465 Uint16 sample1 = SDL_SwapBE16(src[1]);
4466 Uint16 sample0 = SDL_SwapBE16(src[0]);
4467 Uint16 last_sample5 = sample5;
4468 Uint16 last_sample4 = sample4;
4469 Uint16 last_sample3 = sample3;
4470 Uint16 last_sample2 = sample2;
4471 Uint16 last_sample1 = sample1;
4472 Uint16 last_sample0 = sample0;
4473 while (dst != target) {
4474 dst[5] = SDL_SwapBE16(sample5);
4475 dst[4] = SDL_SwapBE16(sample4);
4476 dst[3] = SDL_SwapBE16(sample3);
4477 dst[2] = SDL_SwapBE16(sample2);
4478 dst[1] = SDL_SwapBE16(sample1);
4479 dst[0] = SDL_SwapBE16(sample0);
4480 dst -= 6;
4481 eps += srcsize;
4482 if ((eps << 1) >= dstsize) {
4483 src -= 6;
4484 sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
4485 sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
4486 sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
4487 sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
4488 sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
4489 sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
4490 last_sample5 = sample5;
4491 last_sample4 = sample4;
4492 last_sample3 = sample3;
4493 last_sample2 = sample2;
4494 last_sample1 = sample1;
4495 last_sample0 = sample0;
4496 eps -= dstsize;
4497 }
4498 }
4499 cvt->len_cvt = dstsize;
4500 if (cvt->filters[++cvt->filter_index]) {
4501 cvt->filters[cvt->filter_index] (cvt, format);
4502 }
4503 }
4504
4505 static void SDLCALL
4506 SDL_Downsample_U16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
4507 {
4508 #ifdef DEBUG_CONVERT
4509 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 6 channels.\n", cvt->rate_incr);
4510 #endif
4511
4512 const int srcsize = cvt->len_cvt - 192;
4513 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
4514 register int eps = 0;
4515 Uint16 *dst = (Uint16 *) cvt->buf;
4516 const Uint16 *src = (Uint16 *) cvt->buf;
4517 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
4518 Uint16 sample0 = SDL_SwapBE16(src[0]);
4519 Uint16 sample1 = SDL_SwapBE16(src[1]);
4520 Uint16 sample2 = SDL_SwapBE16(src[2]);
4521 Uint16 sample3 = SDL_SwapBE16(src[3]);
4522 Uint16 sample4 = SDL_SwapBE16(src[4]);
4523 Uint16 sample5 = SDL_SwapBE16(src[5]);
4524 Uint16 last_sample0 = sample0;
4525 Uint16 last_sample1 = sample1;
4526 Uint16 last_sample2 = sample2;
4527 Uint16 last_sample3 = sample3;
4528 Uint16 last_sample4 = sample4;
4529 Uint16 last_sample5 = sample5;
4530 while (dst != target) {
4531 src += 6;
4532 eps += dstsize;
4533 if ((eps << 1) >= srcsize) {
4534 dst[0] = SDL_SwapBE16(sample0);
4535 dst[1] = SDL_SwapBE16(sample1);
4536 dst[2] = SDL_SwapBE16(sample2);
4537 dst[3] = SDL_SwapBE16(sample3);
4538 dst[4] = SDL_SwapBE16(sample4);
4539 dst[5] = SDL_SwapBE16(sample5);
4540 dst += 6;
4541 sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
4542 sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
4543 sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
4544 sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
4545 sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
4546 sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
4547 last_sample0 = sample0;
4548 last_sample1 = sample1;
4549 last_sample2 = sample2;
4550 last_sample3 = sample3;
4551 last_sample4 = sample4;
4552 last_sample5 = sample5;
4553 eps -= srcsize;
4554 }
4555 }
4556 cvt->len_cvt = dstsize;
4557 if (cvt->filters[++cvt->filter_index]) {
4558 cvt->filters[cvt->filter_index] (cvt, format);
4559 }
4560 }
4561
4562 static void SDLCALL
4563 SDL_Upsample_U16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
4564 {
4565 #ifdef DEBUG_CONVERT
4566 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_U16MSB, 8 channels.\n", cvt->rate_incr);
4567 #endif
4568
4569 const int srcsize = cvt->len_cvt - 256;
4570 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
4571 register int eps = 0;
4572 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8;
4573 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
4574 const Uint16 *target = ((const Uint16 *) cvt->buf) - 8;
4575 Uint16 sample7 = SDL_SwapBE16(src[7]);
4576 Uint16 sample6 = SDL_SwapBE16(src[6]);
4577 Uint16 sample5 = SDL_SwapBE16(src[5]);
4578 Uint16 sample4 = SDL_SwapBE16(src[4]);
4579 Uint16 sample3 = SDL_SwapBE16(src[3]);
4580 Uint16 sample2 = SDL_SwapBE16(src[2]);
4581 Uint16 sample1 = SDL_SwapBE16(src[1]);
4582 Uint16 sample0 = SDL_SwapBE16(src[0]);
4583 Uint16 last_sample7 = sample7;
4584 Uint16 last_sample6 = sample6;
4585 Uint16 last_sample5 = sample5;
4586 Uint16 last_sample4 = sample4;
4587 Uint16 last_sample3 = sample3;
4588 Uint16 last_sample2 = sample2;
4589 Uint16 last_sample1 = sample1;
4590 Uint16 last_sample0 = sample0;
4591 while (dst != target) {
4592 dst[7] = SDL_SwapBE16(sample7);
4593 dst[6] = SDL_SwapBE16(sample6);
4594 dst[5] = SDL_SwapBE16(sample5);
4595 dst[4] = SDL_SwapBE16(sample4);
4596 dst[3] = SDL_SwapBE16(sample3);
4597 dst[2] = SDL_SwapBE16(sample2);
4598 dst[1] = SDL_SwapBE16(sample1);
4599 dst[0] = SDL_SwapBE16(sample0);
4600 dst -= 8;
4601 eps += srcsize;
4602 if ((eps << 1) >= dstsize) {
4603 src -= 8;
4604 sample7 = (Uint16) ((((Sint32) SDL_SwapBE16(src[7])) + ((Sint32) last_sample7)) >> 1);
4605 sample6 = (Uint16) ((((Sint32) SDL_SwapBE16(src[6])) + ((Sint32) last_sample6)) >> 1);
4606 sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
4607 sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
4608 sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
4609 sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
4610 sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
4611 sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
4612 last_sample7 = sample7;
4613 last_sample6 = sample6;
4614 last_sample5 = sample5;
4615 last_sample4 = sample4;
4616 last_sample3 = sample3;
4617 last_sample2 = sample2;
4618 last_sample1 = sample1;
4619 last_sample0 = sample0;
4620 eps -= dstsize;
4621 }
4622 }
4623 cvt->len_cvt = dstsize;
4624 if (cvt->filters[++cvt->filter_index]) {
4625 cvt->filters[cvt->filter_index] (cvt, format);
4626 }
4627 }
4628
4629 static void SDLCALL
4630 SDL_Downsample_U16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
4631 {
4632 #ifdef DEBUG_CONVERT
4633 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_U16MSB, 8 channels.\n", cvt->rate_incr);
4634 #endif
4635
4636 const int srcsize = cvt->len_cvt - 256;
4637 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
4638 register int eps = 0;
4639 Uint16 *dst = (Uint16 *) cvt->buf;
4640 const Uint16 *src = (Uint16 *) cvt->buf;
4641 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
4642 Uint16 sample0 = SDL_SwapBE16(src[0]);
4643 Uint16 sample1 = SDL_SwapBE16(src[1]);
4644 Uint16 sample2 = SDL_SwapBE16(src[2]);
4645 Uint16 sample3 = SDL_SwapBE16(src[3]);
4646 Uint16 sample4 = SDL_SwapBE16(src[4]);
4647 Uint16 sample5 = SDL_SwapBE16(src[5]);
4648 Uint16 sample6 = SDL_SwapBE16(src[6]);
4649 Uint16 sample7 = SDL_SwapBE16(src[7]);
4650 Uint16 last_sample0 = sample0;
4651 Uint16 last_sample1 = sample1;
4652 Uint16 last_sample2 = sample2;
4653 Uint16 last_sample3 = sample3;
4654 Uint16 last_sample4 = sample4;
4655 Uint16 last_sample5 = sample5;
4656 Uint16 last_sample6 = sample6;
4657 Uint16 last_sample7 = sample7;
4658 while (dst != target) {
4659 src += 8;
4660 eps += dstsize;
4661 if ((eps << 1) >= srcsize) {
4662 dst[0] = SDL_SwapBE16(sample0);
4663 dst[1] = SDL_SwapBE16(sample1);
4664 dst[2] = SDL_SwapBE16(sample2);
4665 dst[3] = SDL_SwapBE16(sample3);
4666 dst[4] = SDL_SwapBE16(sample4);
4667 dst[5] = SDL_SwapBE16(sample5);
4668 dst[6] = SDL_SwapBE16(sample6);
4669 dst[7] = SDL_SwapBE16(sample7);
4670 dst += 8;
4671 sample0 = (Uint16) ((((Sint32) SDL_SwapBE16(src[0])) + ((Sint32) last_sample0)) >> 1);
4672 sample1 = (Uint16) ((((Sint32) SDL_SwapBE16(src[1])) + ((Sint32) last_sample1)) >> 1);
4673 sample2 = (Uint16) ((((Sint32) SDL_SwapBE16(src[2])) + ((Sint32) last_sample2)) >> 1);
4674 sample3 = (Uint16) ((((Sint32) SDL_SwapBE16(src[3])) + ((Sint32) last_sample3)) >> 1);
4675 sample4 = (Uint16) ((((Sint32) SDL_SwapBE16(src[4])) + ((Sint32) last_sample4)) >> 1);
4676 sample5 = (Uint16) ((((Sint32) SDL_SwapBE16(src[5])) + ((Sint32) last_sample5)) >> 1);
4677 sample6 = (Uint16) ((((Sint32) SDL_SwapBE16(src[6])) + ((Sint32) last_sample6)) >> 1);
4678 sample7 = (Uint16) ((((Sint32) SDL_SwapBE16(src[7])) + ((Sint32) last_sample7)) >> 1);
4679 last_sample0 = sample0;
4680 last_sample1 = sample1;
4681 last_sample2 = sample2;
4682 last_sample3 = sample3;
4683 last_sample4 = sample4;
4684 last_sample5 = sample5;
4685 last_sample6 = sample6;
4686 last_sample7 = sample7;
4687 eps -= srcsize;
4688 }
4689 }
4690 cvt->len_cvt = dstsize;
4691 if (cvt->filters[++cvt->filter_index]) {
4692 cvt->filters[cvt->filter_index] (cvt, format);
4693 }
4694 }
4695
4696 static void SDLCALL
4697 SDL_Upsample_S16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
4698 {
4699 #ifdef DEBUG_CONVERT
4700 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 1 channels.\n", cvt->rate_incr);
4701 #endif
4702
4703 const int srcsize = cvt->len_cvt - 32;
4704 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
4705 register int eps = 0;
4706 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1;
4707 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
4708 const Sint16 *target = ((const Sint16 *) cvt->buf) - 1;
4709 Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
4710 Sint16 last_sample0 = sample0;
4711 while (dst != target) {
4712 dst[0] = ((Sint16) SDL_SwapBE16(sample0));
4713 dst--;
4714 eps += srcsize;
4715 if ((eps << 1) >= dstsize) {
4716 src--;
4717 sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
4718 last_sample0 = sample0;
4719 eps -= dstsize;
4720 }
4721 }
4722 cvt->len_cvt = dstsize;
4723 if (cvt->filters[++cvt->filter_index]) {
4724 cvt->filters[cvt->filter_index] (cvt, format);
4725 }
4726 }
4727
4728 static void SDLCALL
4729 SDL_Downsample_S16MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
4730 {
4731 #ifdef DEBUG_CONVERT
4732 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 1 channels.\n", cvt->rate_incr);
4733 #endif
4734
4735 const int srcsize = cvt->len_cvt - 32;
4736 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
4737 register int eps = 0;
4738 Sint16 *dst = (Sint16 *) cvt->buf;
4739 const Sint16 *src = (Sint16 *) cvt->buf;
4740 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
4741 Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
4742 Sint16 last_sample0 = sample0;
4743 while (dst != target) {
4744 src++;
4745 eps += dstsize;
4746 if ((eps << 1) >= srcsize) {
4747 dst[0] = ((Sint16) SDL_SwapBE16(sample0));
4748 dst++;
4749 sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
4750 last_sample0 = sample0;
4751 eps -= srcsize;
4752 }
4753 }
4754 cvt->len_cvt = dstsize;
4755 if (cvt->filters[++cvt->filter_index]) {
4756 cvt->filters[cvt->filter_index] (cvt, format);
4757 }
4758 }
4759
4760 static void SDLCALL
4761 SDL_Upsample_S16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
4762 {
4763 #ifdef DEBUG_CONVERT
4764 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 2 channels.\n", cvt->rate_incr);
4765 #endif
4766
4767 const int srcsize = cvt->len_cvt - 64;
4768 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
4769 register int eps = 0;
4770 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
4771 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
4772 const Sint16 *target = ((const Sint16 *) cvt->buf) - 2;
4773 Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
4774 Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
4775 Sint16 last_sample1 = sample1;
4776 Sint16 last_sample0 = sample0;
4777 while (dst != target) {
4778 dst[1] = ((Sint16) SDL_SwapBE16(sample1));
4779 dst[0] = ((Sint16) SDL_SwapBE16(sample0));
4780 dst -= 2;
4781 eps += srcsize;
4782 if ((eps << 1) >= dstsize) {
4783 src -= 2;
4784 sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
4785 sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
4786 last_sample1 = sample1;
4787 last_sample0 = sample0;
4788 eps -= dstsize;
4789 }
4790 }
4791 cvt->len_cvt = dstsize;
4792 if (cvt->filters[++cvt->filter_index]) {
4793 cvt->filters[cvt->filter_index] (cvt, format);
4794 }
4795 }
4796
4797 static void SDLCALL
4798 SDL_Downsample_S16MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
4799 {
4800 #ifdef DEBUG_CONVERT
4801 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 2 channels.\n", cvt->rate_incr);
4802 #endif
4803
4804 const int srcsize = cvt->len_cvt - 64;
4805 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
4806 register int eps = 0;
4807 Sint16 *dst = (Sint16 *) cvt->buf;
4808 const Sint16 *src = (Sint16 *) cvt->buf;
4809 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
4810 Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
4811 Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
4812 Sint16 last_sample0 = sample0;
4813 Sint16 last_sample1 = sample1;
4814 while (dst != target) {
4815 src += 2;
4816 eps += dstsize;
4817 if ((eps << 1) >= srcsize) {
4818 dst[0] = ((Sint16) SDL_SwapBE16(sample0));
4819 dst[1] = ((Sint16) SDL_SwapBE16(sample1));
4820 dst += 2;
4821 sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
4822 sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
4823 last_sample0 = sample0;
4824 last_sample1 = sample1;
4825 eps -= srcsize;
4826 }
4827 }
4828 cvt->len_cvt = dstsize;
4829 if (cvt->filters[++cvt->filter_index]) {
4830 cvt->filters[cvt->filter_index] (cvt, format);
4831 }
4832 }
4833
4834 static void SDLCALL
4835 SDL_Upsample_S16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
4836 {
4837 #ifdef DEBUG_CONVERT
4838 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 4 channels.\n", cvt->rate_incr);
4839 #endif
4840
4841 const int srcsize = cvt->len_cvt - 128;
4842 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
4843 register int eps = 0;
4844 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4;
4845 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
4846 const Sint16 *target = ((const Sint16 *) cvt->buf) - 4;
4847 Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
4848 Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
4849 Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
4850 Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
4851 Sint16 last_sample3 = sample3;
4852 Sint16 last_sample2 = sample2;
4853 Sint16 last_sample1 = sample1;
4854 Sint16 last_sample0 = sample0;
4855 while (dst != target) {
4856 dst[3] = ((Sint16) SDL_SwapBE16(sample3));
4857 dst[2] = ((Sint16) SDL_SwapBE16(sample2));
4858 dst[1] = ((Sint16) SDL_SwapBE16(sample1));
4859 dst[0] = ((Sint16) SDL_SwapBE16(sample0));
4860 dst -= 4;
4861 eps += srcsize;
4862 if ((eps << 1) >= dstsize) {
4863 src -= 4;
4864 sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
4865 sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
4866 sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
4867 sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
4868 last_sample3 = sample3;
4869 last_sample2 = sample2;
4870 last_sample1 = sample1;
4871 last_sample0 = sample0;
4872 eps -= dstsize;
4873 }
4874 }
4875 cvt->len_cvt = dstsize;
4876 if (cvt->filters[++cvt->filter_index]) {
4877 cvt->filters[cvt->filter_index] (cvt, format);
4878 }
4879 }
4880
4881 static void SDLCALL
4882 SDL_Downsample_S16MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
4883 {
4884 #ifdef DEBUG_CONVERT
4885 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 4 channels.\n", cvt->rate_incr);
4886 #endif
4887
4888 const int srcsize = cvt->len_cvt - 128;
4889 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
4890 register int eps = 0;
4891 Sint16 *dst = (Sint16 *) cvt->buf;
4892 const Sint16 *src = (Sint16 *) cvt->buf;
4893 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
4894 Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
4895 Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
4896 Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
4897 Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
4898 Sint16 last_sample0 = sample0;
4899 Sint16 last_sample1 = sample1;
4900 Sint16 last_sample2 = sample2;
4901 Sint16 last_sample3 = sample3;
4902 while (dst != target) {
4903 src += 4;
4904 eps += dstsize;
4905 if ((eps << 1) >= srcsize) {
4906 dst[0] = ((Sint16) SDL_SwapBE16(sample0));
4907 dst[1] = ((Sint16) SDL_SwapBE16(sample1));
4908 dst[2] = ((Sint16) SDL_SwapBE16(sample2));
4909 dst[3] = ((Sint16) SDL_SwapBE16(sample3));
4910 dst += 4;
4911 sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
4912 sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
4913 sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
4914 sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
4915 last_sample0 = sample0;
4916 last_sample1 = sample1;
4917 last_sample2 = sample2;
4918 last_sample3 = sample3;
4919 eps -= srcsize;
4920 }
4921 }
4922 cvt->len_cvt = dstsize;
4923 if (cvt->filters[++cvt->filter_index]) {
4924 cvt->filters[cvt->filter_index] (cvt, format);
4925 }
4926 }
4927
4928 static void SDLCALL
4929 SDL_Upsample_S16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
4930 {
4931 #ifdef DEBUG_CONVERT
4932 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 6 channels.\n", cvt->rate_incr);
4933 #endif
4934
4935 const int srcsize = cvt->len_cvt - 192;
4936 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
4937 register int eps = 0;
4938 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6;
4939 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
4940 const Sint16 *target = ((const Sint16 *) cvt->buf) - 6;
4941 Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
4942 Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
4943 Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
4944 Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
4945 Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
4946 Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
4947 Sint16 last_sample5 = sample5;
4948 Sint16 last_sample4 = sample4;
4949 Sint16 last_sample3 = sample3;
4950 Sint16 last_sample2 = sample2;
4951 Sint16 last_sample1 = sample1;
4952 Sint16 last_sample0 = sample0;
4953 while (dst != target) {
4954 dst[5] = ((Sint16) SDL_SwapBE16(sample5));
4955 dst[4] = ((Sint16) SDL_SwapBE16(sample4));
4956 dst[3] = ((Sint16) SDL_SwapBE16(sample3));
4957 dst[2] = ((Sint16) SDL_SwapBE16(sample2));
4958 dst[1] = ((Sint16) SDL_SwapBE16(sample1));
4959 dst[0] = ((Sint16) SDL_SwapBE16(sample0));
4960 dst -= 6;
4961 eps += srcsize;
4962 if ((eps << 1) >= dstsize) {
4963 src -= 6;
4964 sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
4965 sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
4966 sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
4967 sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
4968 sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
4969 sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
4970 last_sample5 = sample5;
4971 last_sample4 = sample4;
4972 last_sample3 = sample3;
4973 last_sample2 = sample2;
4974 last_sample1 = sample1;
4975 last_sample0 = sample0;
4976 eps -= dstsize;
4977 }
4978 }
4979 cvt->len_cvt = dstsize;
4980 if (cvt->filters[++cvt->filter_index]) {
4981 cvt->filters[cvt->filter_index] (cvt, format);
4982 }
4983 }
4984
4985 static void SDLCALL
4986 SDL_Downsample_S16MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
4987 {
4988 #ifdef DEBUG_CONVERT
4989 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 6 channels.\n", cvt->rate_incr);
4990 #endif
4991
4992 const int srcsize = cvt->len_cvt - 192;
4993 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
4994 register int eps = 0;
4995 Sint16 *dst = (Sint16 *) cvt->buf;
4996 const Sint16 *src = (Sint16 *) cvt->buf;
4997 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
4998 Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
4999 Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
5000 Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
5001 Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
5002 Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
5003 Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
5004 Sint16 last_sample0 = sample0;
5005 Sint16 last_sample1 = sample1;
5006 Sint16 last_sample2 = sample2;
5007 Sint16 last_sample3 = sample3;
5008 Sint16 last_sample4 = sample4;
5009 Sint16 last_sample5 = sample5;
5010 while (dst != target) {
5011 src += 6;
5012 eps += dstsize;
5013 if ((eps << 1) >= srcsize) {
5014 dst[0] = ((Sint16) SDL_SwapBE16(sample0));
5015 dst[1] = ((Sint16) SDL_SwapBE16(sample1));
5016 dst[2] = ((Sint16) SDL_SwapBE16(sample2));
5017 dst[3] = ((Sint16) SDL_SwapBE16(sample3));
5018 dst[4] = ((Sint16) SDL_SwapBE16(sample4));
5019 dst[5] = ((Sint16) SDL_SwapBE16(sample5));
5020 dst += 6;
5021 sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
5022 sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
5023 sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
5024 sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
5025 sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
5026 sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
5027 last_sample0 = sample0;
5028 last_sample1 = sample1;
5029 last_sample2 = sample2;
5030 last_sample3 = sample3;
5031 last_sample4 = sample4;
5032 last_sample5 = sample5;
5033 eps -= srcsize;
5034 }
5035 }
5036 cvt->len_cvt = dstsize;
5037 if (cvt->filters[++cvt->filter_index]) {
5038 cvt->filters[cvt->filter_index] (cvt, format);
5039 }
5040 }
5041
5042 static void SDLCALL
5043 SDL_Upsample_S16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
5044 {
5045 #ifdef DEBUG_CONVERT
5046 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S16MSB, 8 channels.\n", cvt->rate_incr);
5047 #endif
5048
5049 const int srcsize = cvt->len_cvt - 256;
5050 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
5051 register int eps = 0;
5052 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8;
5053 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
5054 const Sint16 *target = ((const Sint16 *) cvt->buf) - 8;
5055 Sint16 sample7 = ((Sint16) SDL_SwapBE16(src[7]));
5056 Sint16 sample6 = ((Sint16) SDL_SwapBE16(src[6]));
5057 Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
5058 Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
5059 Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
5060 Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
5061 Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
5062 Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
5063 Sint16 last_sample7 = sample7;
5064 Sint16 last_sample6 = sample6;
5065 Sint16 last_sample5 = sample5;
5066 Sint16 last_sample4 = sample4;
5067 Sint16 last_sample3 = sample3;
5068 Sint16 last_sample2 = sample2;
5069 Sint16 last_sample1 = sample1;
5070 Sint16 last_sample0 = sample0;
5071 while (dst != target) {
5072 dst[7] = ((Sint16) SDL_SwapBE16(sample7));
5073 dst[6] = ((Sint16) SDL_SwapBE16(sample6));
5074 dst[5] = ((Sint16) SDL_SwapBE16(sample5));
5075 dst[4] = ((Sint16) SDL_SwapBE16(sample4));
5076 dst[3] = ((Sint16) SDL_SwapBE16(sample3));
5077 dst[2] = ((Sint16) SDL_SwapBE16(sample2));
5078 dst[1] = ((Sint16) SDL_SwapBE16(sample1));
5079 dst[0] = ((Sint16) SDL_SwapBE16(sample0));
5080 dst -= 8;
5081 eps += srcsize;
5082 if ((eps << 1) >= dstsize) {
5083 src -= 8;
5084 sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
5085 sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
5086 sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
5087 sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
5088 sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
5089 sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
5090 sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
5091 sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
5092 last_sample7 = sample7;
5093 last_sample6 = sample6;
5094 last_sample5 = sample5;
5095 last_sample4 = sample4;
5096 last_sample3 = sample3;
5097 last_sample2 = sample2;
5098 last_sample1 = sample1;
5099 last_sample0 = sample0;
5100 eps -= dstsize;
5101 }
5102 }
5103 cvt->len_cvt = dstsize;
5104 if (cvt->filters[++cvt->filter_index]) {
5105 cvt->filters[cvt->filter_index] (cvt, format);
5106 }
5107 }
5108
5109 static void SDLCALL
5110 SDL_Downsample_S16MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
5111 {
5112 #ifdef DEBUG_CONVERT
5113 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S16MSB, 8 channels.\n", cvt->rate_incr);
5114 #endif
5115
5116 const int srcsize = cvt->len_cvt - 256;
5117 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
5118 register int eps = 0;
5119 Sint16 *dst = (Sint16 *) cvt->buf;
5120 const Sint16 *src = (Sint16 *) cvt->buf;
5121 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
5122 Sint16 sample0 = ((Sint16) SDL_SwapBE16(src[0]));
5123 Sint16 sample1 = ((Sint16) SDL_SwapBE16(src[1]));
5124 Sint16 sample2 = ((Sint16) SDL_SwapBE16(src[2]));
5125 Sint16 sample3 = ((Sint16) SDL_SwapBE16(src[3]));
5126 Sint16 sample4 = ((Sint16) SDL_SwapBE16(src[4]));
5127 Sint16 sample5 = ((Sint16) SDL_SwapBE16(src[5]));
5128 Sint16 sample6 = ((Sint16) SDL_SwapBE16(src[6]));
5129 Sint16 sample7 = ((Sint16) SDL_SwapBE16(src[7]));
5130 Sint16 last_sample0 = sample0;
5131 Sint16 last_sample1 = sample1;
5132 Sint16 last_sample2 = sample2;
5133 Sint16 last_sample3 = sample3;
5134 Sint16 last_sample4 = sample4;
5135 Sint16 last_sample5 = sample5;
5136 Sint16 last_sample6 = sample6;
5137 Sint16 last_sample7 = sample7;
5138 while (dst != target) {
5139 src += 8;
5140 eps += dstsize;
5141 if ((eps << 1) >= srcsize) {
5142 dst[0] = ((Sint16) SDL_SwapBE16(sample0));
5143 dst[1] = ((Sint16) SDL_SwapBE16(sample1));
5144 dst[2] = ((Sint16) SDL_SwapBE16(sample2));
5145 dst[3] = ((Sint16) SDL_SwapBE16(sample3));
5146 dst[4] = ((Sint16) SDL_SwapBE16(sample4));
5147 dst[5] = ((Sint16) SDL_SwapBE16(sample5));
5148 dst[6] = ((Sint16) SDL_SwapBE16(sample6));
5149 dst[7] = ((Sint16) SDL_SwapBE16(sample7));
5150 dst += 8;
5151 sample0 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[0]))) + ((Sint32) last_sample0)) >> 1);
5152 sample1 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[1]))) + ((Sint32) last_sample1)) >> 1);
5153 sample2 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[2]))) + ((Sint32) last_sample2)) >> 1);
5154 sample3 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[3]))) + ((Sint32) last_sample3)) >> 1);
5155 sample4 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[4]))) + ((Sint32) last_sample4)) >> 1);
5156 sample5 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[5]))) + ((Sint32) last_sample5)) >> 1);
5157 sample6 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[6]))) + ((Sint32) last_sample6)) >> 1);
5158 sample7 = (Sint16) ((((Sint32) ((Sint16) SDL_SwapBE16(src[7]))) + ((Sint32) last_sample7)) >> 1);
5159 last_sample0 = sample0;
5160 last_sample1 = sample1;
5161 last_sample2 = sample2;
5162 last_sample3 = sample3;
5163 last_sample4 = sample4;
5164 last_sample5 = sample5;
5165 last_sample6 = sample6;
5166 last_sample7 = sample7;
5167 eps -= srcsize;
5168 }
5169 }
5170 cvt->len_cvt = dstsize;
5171 if (cvt->filters[++cvt->filter_index]) {
5172 cvt->filters[cvt->filter_index] (cvt, format);
5173 }
5174 }
5175
5176 static void SDLCALL
5177 SDL_Upsample_S32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
5178 {
5179 #ifdef DEBUG_CONVERT
5180 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 1 channels.\n", cvt->rate_incr);
5181 #endif
5182
5183 const int srcsize = cvt->len_cvt - 64;
5184 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
5185 register int eps = 0;
5186 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1;
5187 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
5188 const Sint32 *target = ((const Sint32 *) cvt->buf) - 1;
5189 Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
5190 Sint32 last_sample0 = sample0;
5191 while (dst != target) {
5192 dst[0] = ((Sint32) SDL_SwapLE32(sample0));
5193 dst--;
5194 eps += srcsize;
5195 if ((eps << 1) >= dstsize) {
5196 src--;
5197 sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
5198 last_sample0 = sample0;
5199 eps -= dstsize;
5200 }
5201 }
5202 cvt->len_cvt = dstsize;
5203 if (cvt->filters[++cvt->filter_index]) {
5204 cvt->filters[cvt->filter_index] (cvt, format);
5205 }
5206 }
5207
5208 static void SDLCALL
5209 SDL_Downsample_S32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
5210 {
5211 #ifdef DEBUG_CONVERT
5212 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 1 channels.\n", cvt->rate_incr);
5213 #endif
5214
5215 const int srcsize = cvt->len_cvt - 64;
5216 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
5217 register int eps = 0;
5218 Sint32 *dst = (Sint32 *) cvt->buf;
5219 const Sint32 *src = (Sint32 *) cvt->buf;
5220 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
5221 Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
5222 Sint32 last_sample0 = sample0;
5223 while (dst != target) {
5224 src++;
5225 eps += dstsize;
5226 if ((eps << 1) >= srcsize) {
5227 dst[0] = ((Sint32) SDL_SwapLE32(sample0));
5228 dst++;
5229 sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
5230 last_sample0 = sample0;
5231 eps -= srcsize;
5232 }
5233 }
5234 cvt->len_cvt = dstsize;
5235 if (cvt->filters[++cvt->filter_index]) {
5236 cvt->filters[cvt->filter_index] (cvt, format);
5237 }
5238 }
5239
5240 static void SDLCALL
5241 SDL_Upsample_S32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
5242 {
5243 #ifdef DEBUG_CONVERT
5244 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 2 channels.\n", cvt->rate_incr);
5245 #endif
5246
5247 const int srcsize = cvt->len_cvt - 128;
5248 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
5249 register int eps = 0;
5250 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2;
5251 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
5252 const Sint32 *target = ((const Sint32 *) cvt->buf) - 2;
5253 Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
5254 Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
5255 Sint32 last_sample1 = sample1;
5256 Sint32 last_sample0 = sample0;
5257 while (dst != target) {
5258 dst[1] = ((Sint32) SDL_SwapLE32(sample1));
5259 dst[0] = ((Sint32) SDL_SwapLE32(sample0));
5260 dst -= 2;
5261 eps += srcsize;
5262 if ((eps << 1) >= dstsize) {
5263 src -= 2;
5264 sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
5265 sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
5266 last_sample1 = sample1;
5267 last_sample0 = sample0;
5268 eps -= dstsize;
5269 }
5270 }
5271 cvt->len_cvt = dstsize;
5272 if (cvt->filters[++cvt->filter_index]) {
5273 cvt->filters[cvt->filter_index] (cvt, format);
5274 }
5275 }
5276
5277 static void SDLCALL
5278 SDL_Downsample_S32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
5279 {
5280 #ifdef DEBUG_CONVERT
5281 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 2 channels.\n", cvt->rate_incr);
5282 #endif
5283
5284 const int srcsize = cvt->len_cvt - 128;
5285 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
5286 register int eps = 0;
5287 Sint32 *dst = (Sint32 *) cvt->buf;
5288 const Sint32 *src = (Sint32 *) cvt->buf;
5289 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
5290 Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
5291 Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
5292 Sint32 last_sample0 = sample0;
5293 Sint32 last_sample1 = sample1;
5294 while (dst != target) {
5295 src += 2;
5296 eps += dstsize;
5297 if ((eps << 1) >= srcsize) {
5298 dst[0] = ((Sint32) SDL_SwapLE32(sample0));
5299 dst[1] = ((Sint32) SDL_SwapLE32(sample1));
5300 dst += 2;
5301 sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
5302 sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
5303 last_sample0 = sample0;
5304 last_sample1 = sample1;
5305 eps -= srcsize;
5306 }
5307 }
5308 cvt->len_cvt = dstsize;
5309 if (cvt->filters[++cvt->filter_index]) {
5310 cvt->filters[cvt->filter_index] (cvt, format);
5311 }
5312 }
5313
5314 static void SDLCALL
5315 SDL_Upsample_S32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
5316 {
5317 #ifdef DEBUG_CONVERT
5318 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 4 channels.\n", cvt->rate_incr);
5319 #endif
5320
5321 const int srcsize = cvt->len_cvt - 256;
5322 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
5323 register int eps = 0;
5324 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4;
5325 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
5326 const Sint32 *target = ((const Sint32 *) cvt->buf) - 4;
5327 Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
5328 Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
5329 Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
5330 Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
5331 Sint32 last_sample3 = sample3;
5332 Sint32 last_sample2 = sample2;
5333 Sint32 last_sample1 = sample1;
5334 Sint32 last_sample0 = sample0;
5335 while (dst != target) {
5336 dst[3] = ((Sint32) SDL_SwapLE32(sample3));
5337 dst[2] = ((Sint32) SDL_SwapLE32(sample2));
5338 dst[1] = ((Sint32) SDL_SwapLE32(sample1));
5339 dst[0] = ((Sint32) SDL_SwapLE32(sample0));
5340 dst -= 4;
5341 eps += srcsize;
5342 if ((eps << 1) >= dstsize) {
5343 src -= 4;
5344 sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
5345 sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
5346 sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
5347 sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
5348 last_sample3 = sample3;
5349 last_sample2 = sample2;
5350 last_sample1 = sample1;
5351 last_sample0 = sample0;
5352 eps -= dstsize;
5353 }
5354 }
5355 cvt->len_cvt = dstsize;
5356 if (cvt->filters[++cvt->filter_index]) {
5357 cvt->filters[cvt->filter_index] (cvt, format);
5358 }
5359 }
5360
5361 static void SDLCALL
5362 SDL_Downsample_S32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
5363 {
5364 #ifdef DEBUG_CONVERT
5365 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 4 channels.\n", cvt->rate_incr);
5366 #endif
5367
5368 const int srcsize = cvt->len_cvt - 256;
5369 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
5370 register int eps = 0;
5371 Sint32 *dst = (Sint32 *) cvt->buf;
5372 const Sint32 *src = (Sint32 *) cvt->buf;
5373 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
5374 Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
5375 Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
5376 Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
5377 Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
5378 Sint32 last_sample0 = sample0;
5379 Sint32 last_sample1 = sample1;
5380 Sint32 last_sample2 = sample2;
5381 Sint32 last_sample3 = sample3;
5382 while (dst != target) {
5383 src += 4;
5384 eps += dstsize;
5385 if ((eps << 1) >= srcsize) {
5386 dst[0] = ((Sint32) SDL_SwapLE32(sample0));
5387 dst[1] = ((Sint32) SDL_SwapLE32(sample1));
5388 dst[2] = ((Sint32) SDL_SwapLE32(sample2));
5389 dst[3] = ((Sint32) SDL_SwapLE32(sample3));
5390 dst += 4;
5391 sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
5392 sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
5393 sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
5394 sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
5395 last_sample0 = sample0;
5396 last_sample1 = sample1;
5397 last_sample2 = sample2;
5398 last_sample3 = sample3;
5399 eps -= srcsize;
5400 }
5401 }
5402 cvt->len_cvt = dstsize;
5403 if (cvt->filters[++cvt->filter_index]) {
5404 cvt->filters[cvt->filter_index] (cvt, format);
5405 }
5406 }
5407
5408 static void SDLCALL
5409 SDL_Upsample_S32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
5410 {
5411 #ifdef DEBUG_CONVERT
5412 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 6 channels.\n", cvt->rate_incr);
5413 #endif
5414
5415 const int srcsize = cvt->len_cvt - 384;
5416 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
5417 register int eps = 0;
5418 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6;
5419 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
5420 const Sint32 *target = ((const Sint32 *) cvt->buf) - 6;
5421 Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
5422 Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
5423 Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
5424 Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
5425 Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
5426 Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
5427 Sint32 last_sample5 = sample5;
5428 Sint32 last_sample4 = sample4;
5429 Sint32 last_sample3 = sample3;
5430 Sint32 last_sample2 = sample2;
5431 Sint32 last_sample1 = sample1;
5432 Sint32 last_sample0 = sample0;
5433 while (dst != target) {
5434 dst[5] = ((Sint32) SDL_SwapLE32(sample5));
5435 dst[4] = ((Sint32) SDL_SwapLE32(sample4));
5436 dst[3] = ((Sint32) SDL_SwapLE32(sample3));
5437 dst[2] = ((Sint32) SDL_SwapLE32(sample2));
5438 dst[1] = ((Sint32) SDL_SwapLE32(sample1));
5439 dst[0] = ((Sint32) SDL_SwapLE32(sample0));
5440 dst -= 6;
5441 eps += srcsize;
5442 if ((eps << 1) >= dstsize) {
5443 src -= 6;
5444 sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
5445 sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
5446 sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
5447 sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
5448 sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
5449 sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
5450 last_sample5 = sample5;
5451 last_sample4 = sample4;
5452 last_sample3 = sample3;
5453 last_sample2 = sample2;
5454 last_sample1 = sample1;
5455 last_sample0 = sample0;
5456 eps -= dstsize;
5457 }
5458 }
5459 cvt->len_cvt = dstsize;
5460 if (cvt->filters[++cvt->filter_index]) {
5461 cvt->filters[cvt->filter_index] (cvt, format);
5462 }
5463 }
5464
5465 static void SDLCALL
5466 SDL_Downsample_S32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
5467 {
5468 #ifdef DEBUG_CONVERT
5469 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 6 channels.\n", cvt->rate_incr);
5470 #endif
5471
5472 const int srcsize = cvt->len_cvt - 384;
5473 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
5474 register int eps = 0;
5475 Sint32 *dst = (Sint32 *) cvt->buf;
5476 const Sint32 *src = (Sint32 *) cvt->buf;
5477 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
5478 Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
5479 Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
5480 Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
5481 Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
5482 Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
5483 Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
5484 Sint32 last_sample0 = sample0;
5485 Sint32 last_sample1 = sample1;
5486 Sint32 last_sample2 = sample2;
5487 Sint32 last_sample3 = sample3;
5488 Sint32 last_sample4 = sample4;
5489 Sint32 last_sample5 = sample5;
5490 while (dst != target) {
5491 src += 6;
5492 eps += dstsize;
5493 if ((eps << 1) >= srcsize) {
5494 dst[0] = ((Sint32) SDL_SwapLE32(sample0));
5495 dst[1] = ((Sint32) SDL_SwapLE32(sample1));
5496 dst[2] = ((Sint32) SDL_SwapLE32(sample2));
5497 dst[3] = ((Sint32) SDL_SwapLE32(sample3));
5498 dst[4] = ((Sint32) SDL_SwapLE32(sample4));
5499 dst[5] = ((Sint32) SDL_SwapLE32(sample5));
5500 dst += 6;
5501 sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
5502 sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
5503 sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
5504 sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
5505 sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
5506 sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
5507 last_sample0 = sample0;
5508 last_sample1 = sample1;
5509 last_sample2 = sample2;
5510 last_sample3 = sample3;
5511 last_sample4 = sample4;
5512 last_sample5 = sample5;
5513 eps -= srcsize;
5514 }
5515 }
5516 cvt->len_cvt = dstsize;
5517 if (cvt->filters[++cvt->filter_index]) {
5518 cvt->filters[cvt->filter_index] (cvt, format);
5519 }
5520 }
5521
5522 static void SDLCALL
5523 SDL_Upsample_S32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
5524 {
5525 #ifdef DEBUG_CONVERT
5526 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32LSB, 8 channels.\n", cvt->rate_incr);
5527 #endif
5528
5529 const int srcsize = cvt->len_cvt - 512;
5530 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
5531 register int eps = 0;
5532 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8;
5533 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
5534 const Sint32 *target = ((const Sint32 *) cvt->buf) - 8;
5535 Sint32 sample7 = ((Sint32) SDL_SwapLE32(src[7]));
5536 Sint32 sample6 = ((Sint32) SDL_SwapLE32(src[6]));
5537 Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
5538 Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
5539 Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
5540 Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
5541 Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
5542 Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
5543 Sint32 last_sample7 = sample7;
5544 Sint32 last_sample6 = sample6;
5545 Sint32 last_sample5 = sample5;
5546 Sint32 last_sample4 = sample4;
5547 Sint32 last_sample3 = sample3;
5548 Sint32 last_sample2 = sample2;
5549 Sint32 last_sample1 = sample1;
5550 Sint32 last_sample0 = sample0;
5551 while (dst != target) {
5552 dst[7] = ((Sint32) SDL_SwapLE32(sample7));
5553 dst[6] = ((Sint32) SDL_SwapLE32(sample6));
5554 dst[5] = ((Sint32) SDL_SwapLE32(sample5));
5555 dst[4] = ((Sint32) SDL_SwapLE32(sample4));
5556 dst[3] = ((Sint32) SDL_SwapLE32(sample3));
5557 dst[2] = ((Sint32) SDL_SwapLE32(sample2));
5558 dst[1] = ((Sint32) SDL_SwapLE32(sample1));
5559 dst[0] = ((Sint32) SDL_SwapLE32(sample0));
5560 dst -= 8;
5561 eps += srcsize;
5562 if ((eps << 1) >= dstsize) {
5563 src -= 8;
5564 sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
5565 sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
5566 sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
5567 sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
5568 sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
5569 sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
5570 sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
5571 sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
5572 last_sample7 = sample7;
5573 last_sample6 = sample6;
5574 last_sample5 = sample5;
5575 last_sample4 = sample4;
5576 last_sample3 = sample3;
5577 last_sample2 = sample2;
5578 last_sample1 = sample1;
5579 last_sample0 = sample0;
5580 eps -= dstsize;
5581 }
5582 }
5583 cvt->len_cvt = dstsize;
5584 if (cvt->filters[++cvt->filter_index]) {
5585 cvt->filters[cvt->filter_index] (cvt, format);
5586 }
5587 }
5588
5589 static void SDLCALL
5590 SDL_Downsample_S32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
5591 {
5592 #ifdef DEBUG_CONVERT
5593 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32LSB, 8 channels.\n", cvt->rate_incr);
5594 #endif
5595
5596 const int srcsize = cvt->len_cvt - 512;
5597 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
5598 register int eps = 0;
5599 Sint32 *dst = (Sint32 *) cvt->buf;
5600 const Sint32 *src = (Sint32 *) cvt->buf;
5601 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
5602 Sint32 sample0 = ((Sint32) SDL_SwapLE32(src[0]));
5603 Sint32 sample1 = ((Sint32) SDL_SwapLE32(src[1]));
5604 Sint32 sample2 = ((Sint32) SDL_SwapLE32(src[2]));
5605 Sint32 sample3 = ((Sint32) SDL_SwapLE32(src[3]));
5606 Sint32 sample4 = ((Sint32) SDL_SwapLE32(src[4]));
5607 Sint32 sample5 = ((Sint32) SDL_SwapLE32(src[5]));
5608 Sint32 sample6 = ((Sint32) SDL_SwapLE32(src[6]));
5609 Sint32 sample7 = ((Sint32) SDL_SwapLE32(src[7]));
5610 Sint32 last_sample0 = sample0;
5611 Sint32 last_sample1 = sample1;
5612 Sint32 last_sample2 = sample2;
5613 Sint32 last_sample3 = sample3;
5614 Sint32 last_sample4 = sample4;
5615 Sint32 last_sample5 = sample5;
5616 Sint32 last_sample6 = sample6;
5617 Sint32 last_sample7 = sample7;
5618 while (dst != target) {
5619 src += 8;
5620 eps += dstsize;
5621 if ((eps << 1) >= srcsize) {
5622 dst[0] = ((Sint32) SDL_SwapLE32(sample0));
5623 dst[1] = ((Sint32) SDL_SwapLE32(sample1));
5624 dst[2] = ((Sint32) SDL_SwapLE32(sample2));
5625 dst[3] = ((Sint32) SDL_SwapLE32(sample3));
5626 dst[4] = ((Sint32) SDL_SwapLE32(sample4));
5627 dst[5] = ((Sint32) SDL_SwapLE32(sample5));
5628 dst[6] = ((Sint32) SDL_SwapLE32(sample6));
5629 dst[7] = ((Sint32) SDL_SwapLE32(sample7));
5630 dst += 8;
5631 sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
5632 sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
5633 sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
5634 sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
5635 sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
5636 sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
5637 sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
5638 sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapLE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
5639 last_sample0 = sample0;
5640 last_sample1 = sample1;
5641 last_sample2 = sample2;
5642 last_sample3 = sample3;
5643 last_sample4 = sample4;
5644 last_sample5 = sample5;
5645 last_sample6 = sample6;
5646 last_sample7 = sample7;
5647 eps -= srcsize;
5648 }
5649 }
5650 cvt->len_cvt = dstsize;
5651 if (cvt->filters[++cvt->filter_index]) {
5652 cvt->filters[cvt->filter_index] (cvt, format);
5653 }
5654 }
5655
5656 static void SDLCALL
5657 SDL_Upsample_S32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
5658 {
5659 #ifdef DEBUG_CONVERT
5660 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 1 channels.\n", cvt->rate_incr);
5661 #endif
5662
5663 const int srcsize = cvt->len_cvt - 64;
5664 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
5665 register int eps = 0;
5666 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1;
5667 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
5668 const Sint32 *target = ((const Sint32 *) cvt->buf) - 1;
5669 Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
5670 Sint32 last_sample0 = sample0;
5671 while (dst != target) {
5672 dst[0] = ((Sint32) SDL_SwapBE32(sample0));
5673 dst--;
5674 eps += srcsize;
5675 if ((eps << 1) >= dstsize) {
5676 src--;
5677 sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
5678 last_sample0 = sample0;
5679 eps -= dstsize;
5680 }
5681 }
5682 cvt->len_cvt = dstsize;
5683 if (cvt->filters[++cvt->filter_index]) {
5684 cvt->filters[cvt->filter_index] (cvt, format);
5685 }
5686 }
5687
5688 static void SDLCALL
5689 SDL_Downsample_S32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
5690 {
5691 #ifdef DEBUG_CONVERT
5692 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 1 channels.\n", cvt->rate_incr);
5693 #endif
5694
5695 const int srcsize = cvt->len_cvt - 64;
5696 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
5697 register int eps = 0;
5698 Sint32 *dst = (Sint32 *) cvt->buf;
5699 const Sint32 *src = (Sint32 *) cvt->buf;
5700 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
5701 Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
5702 Sint32 last_sample0 = sample0;
5703 while (dst != target) {
5704 src++;
5705 eps += dstsize;
5706 if ((eps << 1) >= srcsize) {
5707 dst[0] = ((Sint32) SDL_SwapBE32(sample0));
5708 dst++;
5709 sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
5710 last_sample0 = sample0;
5711 eps -= srcsize;
5712 }
5713 }
5714 cvt->len_cvt = dstsize;
5715 if (cvt->filters[++cvt->filter_index]) {
5716 cvt->filters[cvt->filter_index] (cvt, format);
5717 }
5718 }
5719
5720 static void SDLCALL
5721 SDL_Upsample_S32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
5722 {
5723 #ifdef DEBUG_CONVERT
5724 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 2 channels.\n", cvt->rate_incr);
5725 #endif
5726
5727 const int srcsize = cvt->len_cvt - 128;
5728 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
5729 register int eps = 0;
5730 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2;
5731 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
5732 const Sint32 *target = ((const Sint32 *) cvt->buf) - 2;
5733 Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
5734 Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
5735 Sint32 last_sample1 = sample1;
5736 Sint32 last_sample0 = sample0;
5737 while (dst != target) {
5738 dst[1] = ((Sint32) SDL_SwapBE32(sample1));
5739 dst[0] = ((Sint32) SDL_SwapBE32(sample0));
5740 dst -= 2;
5741 eps += srcsize;
5742 if ((eps << 1) >= dstsize) {
5743 src -= 2;
5744 sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
5745 sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
5746 last_sample1 = sample1;
5747 last_sample0 = sample0;
5748 eps -= dstsize;
5749 }
5750 }
5751 cvt->len_cvt = dstsize;
5752 if (cvt->filters[++cvt->filter_index]) {
5753 cvt->filters[cvt->filter_index] (cvt, format);
5754 }
5755 }
5756
5757 static void SDLCALL
5758 SDL_Downsample_S32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
5759 {
5760 #ifdef DEBUG_CONVERT
5761 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 2 channels.\n", cvt->rate_incr);
5762 #endif
5763
5764 const int srcsize = cvt->len_cvt - 128;
5765 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
5766 register int eps = 0;
5767 Sint32 *dst = (Sint32 *) cvt->buf;
5768 const Sint32 *src = (Sint32 *) cvt->buf;
5769 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
5770 Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
5771 Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
5772 Sint32 last_sample0 = sample0;
5773 Sint32 last_sample1 = sample1;
5774 while (dst != target) {
5775 src += 2;
5776 eps += dstsize;
5777 if ((eps << 1) >= srcsize) {
5778 dst[0] = ((Sint32) SDL_SwapBE32(sample0));
5779 dst[1] = ((Sint32) SDL_SwapBE32(sample1));
5780 dst += 2;
5781 sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
5782 sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
5783 last_sample0 = sample0;
5784 last_sample1 = sample1;
5785 eps -= srcsize;
5786 }
5787 }
5788 cvt->len_cvt = dstsize;
5789 if (cvt->filters[++cvt->filter_index]) {
5790 cvt->filters[cvt->filter_index] (cvt, format);
5791 }
5792 }
5793
5794 static void SDLCALL
5795 SDL_Upsample_S32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
5796 {
5797 #ifdef DEBUG_CONVERT
5798 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 4 channels.\n", cvt->rate_incr);
5799 #endif
5800
5801 const int srcsize = cvt->len_cvt - 256;
5802 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
5803 register int eps = 0;
5804 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4;
5805 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
5806 const Sint32 *target = ((const Sint32 *) cvt->buf) - 4;
5807 Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
5808 Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
5809 Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
5810 Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
5811 Sint32 last_sample3 = sample3;
5812 Sint32 last_sample2 = sample2;
5813 Sint32 last_sample1 = sample1;
5814 Sint32 last_sample0 = sample0;
5815 while (dst != target) {
5816 dst[3] = ((Sint32) SDL_SwapBE32(sample3));
5817 dst[2] = ((Sint32) SDL_SwapBE32(sample2));
5818 dst[1] = ((Sint32) SDL_SwapBE32(sample1));
5819 dst[0] = ((Sint32) SDL_SwapBE32(sample0));
5820 dst -= 4;
5821 eps += srcsize;
5822 if ((eps << 1) >= dstsize) {
5823 src -= 4;
5824 sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
5825 sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
5826 sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
5827 sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
5828 last_sample3 = sample3;
5829 last_sample2 = sample2;
5830 last_sample1 = sample1;
5831 last_sample0 = sample0;
5832 eps -= dstsize;
5833 }
5834 }
5835 cvt->len_cvt = dstsize;
5836 if (cvt->filters[++cvt->filter_index]) {
5837 cvt->filters[cvt->filter_index] (cvt, format);
5838 }
5839 }
5840
5841 static void SDLCALL
5842 SDL_Downsample_S32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
5843 {
5844 #ifdef DEBUG_CONVERT
5845 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 4 channels.\n", cvt->rate_incr);
5846 #endif
5847
5848 const int srcsize = cvt->len_cvt - 256;
5849 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
5850 register int eps = 0;
5851 Sint32 *dst = (Sint32 *) cvt->buf;
5852 const Sint32 *src = (Sint32 *) cvt->buf;
5853 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
5854 Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
5855 Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
5856 Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
5857 Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
5858 Sint32 last_sample0 = sample0;
5859 Sint32 last_sample1 = sample1;
5860 Sint32 last_sample2 = sample2;
5861 Sint32 last_sample3 = sample3;
5862 while (dst != target) {
5863 src += 4;
5864 eps += dstsize;
5865 if ((eps << 1) >= srcsize) {
5866 dst[0] = ((Sint32) SDL_SwapBE32(sample0));
5867 dst[1] = ((Sint32) SDL_SwapBE32(sample1));
5868 dst[2] = ((Sint32) SDL_SwapBE32(sample2));
5869 dst[3] = ((Sint32) SDL_SwapBE32(sample3));
5870 dst += 4;
5871 sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
5872 sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
5873 sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
5874 sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
5875 last_sample0 = sample0;
5876 last_sample1 = sample1;
5877 last_sample2 = sample2;
5878 last_sample3 = sample3;
5879 eps -= srcsize;
5880 }
5881 }
5882 cvt->len_cvt = dstsize;
5883 if (cvt->filters[++cvt->filter_index]) {
5884 cvt->filters[cvt->filter_index] (cvt, format);
5885 }
5886 }
5887
5888 static void SDLCALL
5889 SDL_Upsample_S32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
5890 {
5891 #ifdef DEBUG_CONVERT
5892 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 6 channels.\n", cvt->rate_incr);
5893 #endif
5894
5895 const int srcsize = cvt->len_cvt - 384;
5896 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
5897 register int eps = 0;
5898 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6;
5899 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
5900 const Sint32 *target = ((const Sint32 *) cvt->buf) - 6;
5901 Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
5902 Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
5903 Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
5904 Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
5905 Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
5906 Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
5907 Sint32 last_sample5 = sample5;
5908 Sint32 last_sample4 = sample4;
5909 Sint32 last_sample3 = sample3;
5910 Sint32 last_sample2 = sample2;
5911 Sint32 last_sample1 = sample1;
5912 Sint32 last_sample0 = sample0;
5913 while (dst != target) {
5914 dst[5] = ((Sint32) SDL_SwapBE32(sample5));
5915 dst[4] = ((Sint32) SDL_SwapBE32(sample4));
5916 dst[3] = ((Sint32) SDL_SwapBE32(sample3));
5917 dst[2] = ((Sint32) SDL_SwapBE32(sample2));
5918 dst[1] = ((Sint32) SDL_SwapBE32(sample1));
5919 dst[0] = ((Sint32) SDL_SwapBE32(sample0));
5920 dst -= 6;
5921 eps += srcsize;
5922 if ((eps << 1) >= dstsize) {
5923 src -= 6;
5924 sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
5925 sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
5926 sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
5927 sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
5928 sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
5929 sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
5930 last_sample5 = sample5;
5931 last_sample4 = sample4;
5932 last_sample3 = sample3;
5933 last_sample2 = sample2;
5934 last_sample1 = sample1;
5935 last_sample0 = sample0;
5936 eps -= dstsize;
5937 }
5938 }
5939 cvt->len_cvt = dstsize;
5940 if (cvt->filters[++cvt->filter_index]) {
5941 cvt->filters[cvt->filter_index] (cvt, format);
5942 }
5943 }
5944
5945 static void SDLCALL
5946 SDL_Downsample_S32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
5947 {
5948 #ifdef DEBUG_CONVERT
5949 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 6 channels.\n", cvt->rate_incr);
5950 #endif
5951
5952 const int srcsize = cvt->len_cvt - 384;
5953 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
5954 register int eps = 0;
5955 Sint32 *dst = (Sint32 *) cvt->buf;
5956 const Sint32 *src = (Sint32 *) cvt->buf;
5957 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
5958 Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
5959 Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
5960 Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
5961 Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
5962 Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
5963 Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
5964 Sint32 last_sample0 = sample0;
5965 Sint32 last_sample1 = sample1;
5966 Sint32 last_sample2 = sample2;
5967 Sint32 last_sample3 = sample3;
5968 Sint32 last_sample4 = sample4;
5969 Sint32 last_sample5 = sample5;
5970 while (dst != target) {
5971 src += 6;
5972 eps += dstsize;
5973 if ((eps << 1) >= srcsize) {
5974 dst[0] = ((Sint32) SDL_SwapBE32(sample0));
5975 dst[1] = ((Sint32) SDL_SwapBE32(sample1));
5976 dst[2] = ((Sint32) SDL_SwapBE32(sample2));
5977 dst[3] = ((Sint32) SDL_SwapBE32(sample3));
5978 dst[4] = ((Sint32) SDL_SwapBE32(sample4));
5979 dst[5] = ((Sint32) SDL_SwapBE32(sample5));
5980 dst += 6;
5981 sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
5982 sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
5983 sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
5984 sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
5985 sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
5986 sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
5987 last_sample0 = sample0;
5988 last_sample1 = sample1;
5989 last_sample2 = sample2;
5990 last_sample3 = sample3;
5991 last_sample4 = sample4;
5992 last_sample5 = sample5;
5993 eps -= srcsize;
5994 }
5995 }
5996 cvt->len_cvt = dstsize;
5997 if (cvt->filters[++cvt->filter_index]) {
5998 cvt->filters[cvt->filter_index] (cvt, format);
5999 }
6000 }
6001
6002 static void SDLCALL
6003 SDL_Upsample_S32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
6004 {
6005 #ifdef DEBUG_CONVERT
6006 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_S32MSB, 8 channels.\n", cvt->rate_incr);
6007 #endif
6008
6009 const int srcsize = cvt->len_cvt - 512;
6010 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
6011 register int eps = 0;
6012 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8;
6013 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
6014 const Sint32 *target = ((const Sint32 *) cvt->buf) - 8;
6015 Sint32 sample7 = ((Sint32) SDL_SwapBE32(src[7]));
6016 Sint32 sample6 = ((Sint32) SDL_SwapBE32(src[6]));
6017 Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
6018 Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
6019 Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
6020 Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
6021 Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
6022 Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
6023 Sint32 last_sample7 = sample7;
6024 Sint32 last_sample6 = sample6;
6025 Sint32 last_sample5 = sample5;
6026 Sint32 last_sample4 = sample4;
6027 Sint32 last_sample3 = sample3;
6028 Sint32 last_sample2 = sample2;
6029 Sint32 last_sample1 = sample1;
6030 Sint32 last_sample0 = sample0;
6031 while (dst != target) {
6032 dst[7] = ((Sint32) SDL_SwapBE32(sample7));
6033 dst[6] = ((Sint32) SDL_SwapBE32(sample6));
6034 dst[5] = ((Sint32) SDL_SwapBE32(sample5));
6035 dst[4] = ((Sint32) SDL_SwapBE32(sample4));
6036 dst[3] = ((Sint32) SDL_SwapBE32(sample3));
6037 dst[2] = ((Sint32) SDL_SwapBE32(sample2));
6038 dst[1] = ((Sint32) SDL_SwapBE32(sample1));
6039 dst[0] = ((Sint32) SDL_SwapBE32(sample0));
6040 dst -= 8;
6041 eps += srcsize;
6042 if ((eps << 1) >= dstsize) {
6043 src -= 8;
6044 sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
6045 sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
6046 sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
6047 sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
6048 sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
6049 sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
6050 sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
6051 sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
6052 last_sample7 = sample7;
6053 last_sample6 = sample6;
6054 last_sample5 = sample5;
6055 last_sample4 = sample4;
6056 last_sample3 = sample3;
6057 last_sample2 = sample2;
6058 last_sample1 = sample1;
6059 last_sample0 = sample0;
6060 eps -= dstsize;
6061 }
6062 }
6063 cvt->len_cvt = dstsize;
6064 if (cvt->filters[++cvt->filter_index]) {
6065 cvt->filters[cvt->filter_index] (cvt, format);
6066 }
6067 }
6068
6069 static void SDLCALL
6070 SDL_Downsample_S32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
6071 {
6072 #ifdef DEBUG_CONVERT
6073 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_S32MSB, 8 channels.\n", cvt->rate_incr);
6074 #endif
6075
6076 const int srcsize = cvt->len_cvt - 512;
6077 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
6078 register int eps = 0;
6079 Sint32 *dst = (Sint32 *) cvt->buf;
6080 const Sint32 *src = (Sint32 *) cvt->buf;
6081 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
6082 Sint32 sample0 = ((Sint32) SDL_SwapBE32(src[0]));
6083 Sint32 sample1 = ((Sint32) SDL_SwapBE32(src[1]));
6084 Sint32 sample2 = ((Sint32) SDL_SwapBE32(src[2]));
6085 Sint32 sample3 = ((Sint32) SDL_SwapBE32(src[3]));
6086 Sint32 sample4 = ((Sint32) SDL_SwapBE32(src[4]));
6087 Sint32 sample5 = ((Sint32) SDL_SwapBE32(src[5]));
6088 Sint32 sample6 = ((Sint32) SDL_SwapBE32(src[6]));
6089 Sint32 sample7 = ((Sint32) SDL_SwapBE32(src[7]));
6090 Sint32 last_sample0 = sample0;
6091 Sint32 last_sample1 = sample1;
6092 Sint32 last_sample2 = sample2;
6093 Sint32 last_sample3 = sample3;
6094 Sint32 last_sample4 = sample4;
6095 Sint32 last_sample5 = sample5;
6096 Sint32 last_sample6 = sample6;
6097 Sint32 last_sample7 = sample7;
6098 while (dst != target) {
6099 src += 8;
6100 eps += dstsize;
6101 if ((eps << 1) >= srcsize) {
6102 dst[0] = ((Sint32) SDL_SwapBE32(sample0));
6103 dst[1] = ((Sint32) SDL_SwapBE32(sample1));
6104 dst[2] = ((Sint32) SDL_SwapBE32(sample2));
6105 dst[3] = ((Sint32) SDL_SwapBE32(sample3));
6106 dst[4] = ((Sint32) SDL_SwapBE32(sample4));
6107 dst[5] = ((Sint32) SDL_SwapBE32(sample5));
6108 dst[6] = ((Sint32) SDL_SwapBE32(sample6));
6109 dst[7] = ((Sint32) SDL_SwapBE32(sample7));
6110 dst += 8;
6111 sample0 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[0]))) + ((Sint64) last_sample0)) >> 1);
6112 sample1 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[1]))) + ((Sint64) last_sample1)) >> 1);
6113 sample2 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[2]))) + ((Sint64) last_sample2)) >> 1);
6114 sample3 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[3]))) + ((Sint64) last_sample3)) >> 1);
6115 sample4 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[4]))) + ((Sint64) last_sample4)) >> 1);
6116 sample5 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[5]))) + ((Sint64) last_sample5)) >> 1);
6117 sample6 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[6]))) + ((Sint64) last_sample6)) >> 1);
6118 sample7 = (Sint32) ((((Sint64) ((Sint32) SDL_SwapBE32(src[7]))) + ((Sint64) last_sample7)) >> 1);
6119 last_sample0 = sample0;
6120 last_sample1 = sample1;
6121 last_sample2 = sample2;
6122 last_sample3 = sample3;
6123 last_sample4 = sample4;
6124 last_sample5 = sample5;
6125 last_sample6 = sample6;
6126 last_sample7 = sample7;
6127 eps -= srcsize;
6128 }
6129 }
6130 cvt->len_cvt = dstsize;
6131 if (cvt->filters[++cvt->filter_index]) {
6132 cvt->filters[cvt->filter_index] (cvt, format);
6133 }
6134 }
6135
6136 static void SDLCALL
6137 SDL_Upsample_F32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
6138 {
6139 #ifdef DEBUG_CONVERT
6140 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 1 channels.\n", cvt->rate_incr);
6141 #endif
6142
6143 const int srcsize = cvt->len_cvt - 64;
6144 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
6145 register int eps = 0;
6146 float *dst = ((float *) (cvt->buf + dstsize)) - 1;
6147 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
6148 const float *target = ((const float *) cvt->buf) - 1;
6149 float sample0 = SDL_SwapFloatLE(src[0]);
6150 float last_sample0 = sample0;
6151 while (dst != target) {
6152 dst[0] = SDL_SwapFloatLE(sample0);
6153 dst--;
6154 eps += srcsize;
6155 if ((eps << 1) >= dstsize) {
6156 src--;
6157 sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
6158 last_sample0 = sample0;
6159 eps -= dstsize;
6160 }
6161 }
6162 cvt->len_cvt = dstsize;
6163 if (cvt->filters[++cvt->filter_index]) {
6164 cvt->filters[cvt->filter_index] (cvt, format);
6165 }
6166 }
6167
6168 static void SDLCALL
6169 SDL_Downsample_F32LSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
6170 {
6171 #ifdef DEBUG_CONVERT
6172 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 1 channels.\n", cvt->rate_incr);
6173 #endif
6174
6175 const int srcsize = cvt->len_cvt - 64;
6176 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
6177 register int eps = 0;
6178 float *dst = (float *) cvt->buf;
6179 const float *src = (float *) cvt->buf;
6180 const float *target = (const float *) (cvt->buf + dstsize);
6181 float sample0 = SDL_SwapFloatLE(src[0]);
6182 float last_sample0 = sample0;
6183 while (dst != target) {
6184 src++;
6185 eps += dstsize;
6186 if ((eps << 1) >= srcsize) {
6187 dst[0] = SDL_SwapFloatLE(sample0);
6188 dst++;
6189 sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
6190 last_sample0 = sample0;
6191 eps -= srcsize;
6192 }
6193 }
6194 cvt->len_cvt = dstsize;
6195 if (cvt->filters[++cvt->filter_index]) {
6196 cvt->filters[cvt->filter_index] (cvt, format);
6197 }
6198 }
6199
6200 static void SDLCALL
6201 SDL_Upsample_F32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
6202 {
6203 #ifdef DEBUG_CONVERT
6204 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 2 channels.\n", cvt->rate_incr);
6205 #endif
6206
6207 const int srcsize = cvt->len_cvt - 128;
6208 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
6209 register int eps = 0;
6210 float *dst = ((float *) (cvt->buf + dstsize)) - 2;
6211 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
6212 const float *target = ((const float *) cvt->buf) - 2;
6213 float sample1 = SDL_SwapFloatLE(src[1]);
6214 float sample0 = SDL_SwapFloatLE(src[0]);
6215 float last_sample1 = sample1;
6216 float last_sample0 = sample0;
6217 while (dst != target) {
6218 dst[1] = SDL_SwapFloatLE(sample1);
6219 dst[0] = SDL_SwapFloatLE(sample0);
6220 dst -= 2;
6221 eps += srcsize;
6222 if ((eps << 1) >= dstsize) {
6223 src -= 2;
6224 sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
6225 sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
6226 last_sample1 = sample1;
6227 last_sample0 = sample0;
6228 eps -= dstsize;
6229 }
6230 }
6231 cvt->len_cvt = dstsize;
6232 if (cvt->filters[++cvt->filter_index]) {
6233 cvt->filters[cvt->filter_index] (cvt, format);
6234 }
6235 }
6236
6237 static void SDLCALL
6238 SDL_Downsample_F32LSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
6239 {
6240 #ifdef DEBUG_CONVERT
6241 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 2 channels.\n", cvt->rate_incr);
6242 #endif
6243
6244 const int srcsize = cvt->len_cvt - 128;
6245 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
6246 register int eps = 0;
6247 float *dst = (float *) cvt->buf;
6248 const float *src = (float *) cvt->buf;
6249 const float *target = (const float *) (cvt->buf + dstsize);
6250 float sample0 = SDL_SwapFloatLE(src[0]);
6251 float sample1 = SDL_SwapFloatLE(src[1]);
6252 float last_sample0 = sample0;
6253 float last_sample1 = sample1;
6254 while (dst != target) {
6255 src += 2;
6256 eps += dstsize;
6257 if ((eps << 1) >= srcsize) {
6258 dst[0] = SDL_SwapFloatLE(sample0);
6259 dst[1] = SDL_SwapFloatLE(sample1);
6260 dst += 2;
6261 sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
6262 sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
6263 last_sample0 = sample0;
6264 last_sample1 = sample1;
6265 eps -= srcsize;
6266 }
6267 }
6268 cvt->len_cvt = dstsize;
6269 if (cvt->filters[++cvt->filter_index]) {
6270 cvt->filters[cvt->filter_index] (cvt, format);
6271 }
6272 }
6273
6274 static void SDLCALL
6275 SDL_Upsample_F32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
6276 {
6277 #ifdef DEBUG_CONVERT
6278 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 4 channels.\n", cvt->rate_incr);
6279 #endif
6280
6281 const int srcsize = cvt->len_cvt - 256;
6282 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
6283 register int eps = 0;
6284 float *dst = ((float *) (cvt->buf + dstsize)) - 4;
6285 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
6286 const float *target = ((const float *) cvt->buf) - 4;
6287 float sample3 = SDL_SwapFloatLE(src[3]);
6288 float sample2 = SDL_SwapFloatLE(src[2]);
6289 float sample1 = SDL_SwapFloatLE(src[1]);
6290 float sample0 = SDL_SwapFloatLE(src[0]);
6291 float last_sample3 = sample3;
6292 float last_sample2 = sample2;
6293 float last_sample1 = sample1;
6294 float last_sample0 = sample0;
6295 while (dst != target) {
6296 dst[3] = SDL_SwapFloatLE(sample3);
6297 dst[2] = SDL_SwapFloatLE(sample2);
6298 dst[1] = SDL_SwapFloatLE(sample1);
6299 dst[0] = SDL_SwapFloatLE(sample0);
6300 dst -= 4;
6301 eps += srcsize;
6302 if ((eps << 1) >= dstsize) {
6303 src -= 4;
6304 sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
6305 sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
6306 sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
6307 sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
6308 last_sample3 = sample3;
6309 last_sample2 = sample2;
6310 last_sample1 = sample1;
6311 last_sample0 = sample0;
6312 eps -= dstsize;
6313 }
6314 }
6315 cvt->len_cvt = dstsize;
6316 if (cvt->filters[++cvt->filter_index]) {
6317 cvt->filters[cvt->filter_index] (cvt, format);
6318 }
6319 }
6320
6321 static void SDLCALL
6322 SDL_Downsample_F32LSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
6323 {
6324 #ifdef DEBUG_CONVERT
6325 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 4 channels.\n", cvt->rate_incr);
6326 #endif
6327
6328 const int srcsize = cvt->len_cvt - 256;
6329 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
6330 register int eps = 0;
6331 float *dst = (float *) cvt->buf;
6332 const float *src = (float *) cvt->buf;
6333 const float *target = (const float *) (cvt->buf + dstsize);
6334 float sample0 = SDL_SwapFloatLE(src[0]);
6335 float sample1 = SDL_SwapFloatLE(src[1]);
6336 float sample2 = SDL_SwapFloatLE(src[2]);
6337 float sample3 = SDL_SwapFloatLE(src[3]);
6338 float last_sample0 = sample0;
6339 float last_sample1 = sample1;
6340 float last_sample2 = sample2;
6341 float last_sample3 = sample3;
6342 while (dst != target) {
6343 src += 4;
6344 eps += dstsize;
6345 if ((eps << 1) >= srcsize) {
6346 dst[0] = SDL_SwapFloatLE(sample0);
6347 dst[1] = SDL_SwapFloatLE(sample1);
6348 dst[2] = SDL_SwapFloatLE(sample2);
6349 dst[3] = SDL_SwapFloatLE(sample3);
6350 dst += 4;
6351 sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
6352 sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
6353 sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
6354 sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
6355 last_sample0 = sample0;
6356 last_sample1 = sample1;
6357 last_sample2 = sample2;
6358 last_sample3 = sample3;
6359 eps -= srcsize;
6360 }
6361 }
6362 cvt->len_cvt = dstsize;
6363 if (cvt->filters[++cvt->filter_index]) {
6364 cvt->filters[cvt->filter_index] (cvt, format);
6365 }
6366 }
6367
6368 static void SDLCALL
6369 SDL_Upsample_F32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
6370 {
6371 #ifdef DEBUG_CONVERT
6372 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 6 channels.\n", cvt->rate_incr);
6373 #endif
6374
6375 const int srcsize = cvt->len_cvt - 384;
6376 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
6377 register int eps = 0;
6378 float *dst = ((float *) (cvt->buf + dstsize)) - 6;
6379 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
6380 const float *target = ((const float *) cvt->buf) - 6;
6381 float sample5 = SDL_SwapFloatLE(src[5]);
6382 float sample4 = SDL_SwapFloatLE(src[4]);
6383 float sample3 = SDL_SwapFloatLE(src[3]);
6384 float sample2 = SDL_SwapFloatLE(src[2]);
6385 float sample1 = SDL_SwapFloatLE(src[1]);
6386 float sample0 = SDL_SwapFloatLE(src[0]);
6387 float last_sample5 = sample5;
6388 float last_sample4 = sample4;
6389 float last_sample3 = sample3;
6390 float last_sample2 = sample2;
6391 float last_sample1 = sample1;
6392 float last_sample0 = sample0;
6393 while (dst != target) {
6394 dst[5] = SDL_SwapFloatLE(sample5);
6395 dst[4] = SDL_SwapFloatLE(sample4);
6396 dst[3] = SDL_SwapFloatLE(sample3);
6397 dst[2] = SDL_SwapFloatLE(sample2);
6398 dst[1] = SDL_SwapFloatLE(sample1);
6399 dst[0] = SDL_SwapFloatLE(sample0);
6400 dst -= 6;
6401 eps += srcsize;
6402 if ((eps << 1) >= dstsize) {
6403 src -= 6;
6404 sample5 = (float) ((((double) SDL_SwapFloatLE(src[5])) + ((double) last_sample5)) * 0.5);
6405 sample4 = (float) ((((double) SDL_SwapFloatLE(src[4])) + ((double) last_sample4)) * 0.5);
6406 sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
6407 sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
6408 sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
6409 sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
6410 last_sample5 = sample5;
6411 last_sample4 = sample4;
6412 last_sample3 = sample3;
6413 last_sample2 = sample2;
6414 last_sample1 = sample1;
6415 last_sample0 = sample0;
6416 eps -= dstsize;
6417 }
6418 }
6419 cvt->len_cvt = dstsize;
6420 if (cvt->filters[++cvt->filter_index]) {
6421 cvt->filters[cvt->filter_index] (cvt, format);
6422 }
6423 }
6424
6425 static void SDLCALL
6426 SDL_Downsample_F32LSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
6427 {
6428 #ifdef DEBUG_CONVERT
6429 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 6 channels.\n", cvt->rate_incr);
6430 #endif
6431
6432 const int srcsize = cvt->len_cvt - 384;
6433 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
6434 register int eps = 0;
6435 float *dst = (float *) cvt->buf;
6436 const float *src = (float *) cvt->buf;
6437 const float *target = (const float *) (cvt->buf + dstsize);
6438 float sample0 = SDL_SwapFloatLE(src[0]);
6439 float sample1 = SDL_SwapFloatLE(src[1]);
6440 float sample2 = SDL_SwapFloatLE(src[2]);
6441 float sample3 = SDL_SwapFloatLE(src[3]);
6442 float sample4 = SDL_SwapFloatLE(src[4]);
6443 float sample5 = SDL_SwapFloatLE(src[5]);
6444 float last_sample0 = sample0;
6445 float last_sample1 = sample1;
6446 float last_sample2 = sample2;
6447 float last_sample3 = sample3;
6448 float last_sample4 = sample4;
6449 float last_sample5 = sample5;
6450 while (dst != target) {
6451 src += 6;
6452 eps += dstsize;
6453 if ((eps << 1) >= srcsize) {
6454 dst[0] = SDL_SwapFloatLE(sample0);
6455 dst[1] = SDL_SwapFloatLE(sample1);
6456 dst[2] = SDL_SwapFloatLE(sample2);
6457 dst[3] = SDL_SwapFloatLE(sample3);
6458 dst[4] = SDL_SwapFloatLE(sample4);
6459 dst[5] = SDL_SwapFloatLE(sample5);
6460 dst += 6;
6461 sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
6462 sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
6463 sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
6464 sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
6465 sample4 = (float) ((((double) SDL_SwapFloatLE(src[4])) + ((double) last_sample4)) * 0.5);
6466 sample5 = (float) ((((double) SDL_SwapFloatLE(src[5])) + ((double) last_sample5)) * 0.5);
6467 last_sample0 = sample0;
6468 last_sample1 = sample1;
6469 last_sample2 = sample2;
6470 last_sample3 = sample3;
6471 last_sample4 = sample4;
6472 last_sample5 = sample5;
6473 eps -= srcsize;
6474 }
6475 }
6476 cvt->len_cvt = dstsize;
6477 if (cvt->filters[++cvt->filter_index]) {
6478 cvt->filters[cvt->filter_index] (cvt, format);
6479 }
6480 }
6481
6482 static void SDLCALL
6483 SDL_Upsample_F32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
6484 {
6485 #ifdef DEBUG_CONVERT
6486 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32LSB, 8 channels.\n", cvt->rate_incr);
6487 #endif
6488
6489 const int srcsize = cvt->len_cvt - 512;
6490 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
6491 register int eps = 0;
6492 float *dst = ((float *) (cvt->buf + dstsize)) - 8;
6493 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
6494 const float *target = ((const float *) cvt->buf) - 8;
6495 float sample7 = SDL_SwapFloatLE(src[7]);
6496 float sample6 = SDL_SwapFloatLE(src[6]);
6497 float sample5 = SDL_SwapFloatLE(src[5]);
6498 float sample4 = SDL_SwapFloatLE(src[4]);
6499 float sample3 = SDL_SwapFloatLE(src[3]);
6500 float sample2 = SDL_SwapFloatLE(src[2]);
6501 float sample1 = SDL_SwapFloatLE(src[1]);
6502 float sample0 = SDL_SwapFloatLE(src[0]);
6503 float last_sample7 = sample7;
6504 float last_sample6 = sample6;
6505 float last_sample5 = sample5;
6506 float last_sample4 = sample4;
6507 float last_sample3 = sample3;
6508 float last_sample2 = sample2;
6509 float last_sample1 = sample1;
6510 float last_sample0 = sample0;
6511 while (dst != target) {
6512 dst[7] = SDL_SwapFloatLE(sample7);
6513 dst[6] = SDL_SwapFloatLE(sample6);
6514 dst[5] = SDL_SwapFloatLE(sample5);
6515 dst[4] = SDL_SwapFloatLE(sample4);
6516 dst[3] = SDL_SwapFloatLE(sample3);
6517 dst[2] = SDL_SwapFloatLE(sample2);
6518 dst[1] = SDL_SwapFloatLE(sample1);
6519 dst[0] = SDL_SwapFloatLE(sample0);
6520 dst -= 8;
6521 eps += srcsize;
6522 if ((eps << 1) >= dstsize) {
6523 src -= 8;
6524 sample7 = (float) ((((double) SDL_SwapFloatLE(src[7])) + ((double) last_sample7)) * 0.5);
6525 sample6 = (float) ((((double) SDL_SwapFloatLE(src[6])) + ((double) last_sample6)) * 0.5);
6526 sample5 = (float) ((((double) SDL_SwapFloatLE(src[5])) + ((double) last_sample5)) * 0.5);
6527 sample4 = (float) ((((double) SDL_SwapFloatLE(src[4])) + ((double) last_sample4)) * 0.5);
6528 sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
6529 sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
6530 sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
6531 sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
6532 last_sample7 = sample7;
6533 last_sample6 = sample6;
6534 last_sample5 = sample5;
6535 last_sample4 = sample4;
6536 last_sample3 = sample3;
6537 last_sample2 = sample2;
6538 last_sample1 = sample1;
6539 last_sample0 = sample0;
6540 eps -= dstsize;
6541 }
6542 }
6543 cvt->len_cvt = dstsize;
6544 if (cvt->filters[++cvt->filter_index]) {
6545 cvt->filters[cvt->filter_index] (cvt, format);
6546 }
6547 }
6548
6549 static void SDLCALL
6550 SDL_Downsample_F32LSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
6551 {
6552 #ifdef DEBUG_CONVERT
6553 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32LSB, 8 channels.\n", cvt->rate_incr);
6554 #endif
6555
6556 const int srcsize = cvt->len_cvt - 512;
6557 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
6558 register int eps = 0;
6559 float *dst = (float *) cvt->buf;
6560 const float *src = (float *) cvt->buf;
6561 const float *target = (const float *) (cvt->buf + dstsize);
6562 float sample0 = SDL_SwapFloatLE(src[0]);
6563 float sample1 = SDL_SwapFloatLE(src[1]);
6564 float sample2 = SDL_SwapFloatLE(src[2]);
6565 float sample3 = SDL_SwapFloatLE(src[3]);
6566 float sample4 = SDL_SwapFloatLE(src[4]);
6567 float sample5 = SDL_SwapFloatLE(src[5]);
6568 float sample6 = SDL_SwapFloatLE(src[6]);
6569 float sample7 = SDL_SwapFloatLE(src[7]);
6570 float last_sample0 = sample0;
6571 float last_sample1 = sample1;
6572 float last_sample2 = sample2;
6573 float last_sample3 = sample3;
6574 float last_sample4 = sample4;
6575 float last_sample5 = sample5;
6576 float last_sample6 = sample6;
6577 float last_sample7 = sample7;
6578 while (dst != target) {
6579 src += 8;
6580 eps += dstsize;
6581 if ((eps << 1) >= srcsize) {
6582 dst[0] = SDL_SwapFloatLE(sample0);
6583 dst[1] = SDL_SwapFloatLE(sample1);
6584 dst[2] = SDL_SwapFloatLE(sample2);
6585 dst[3] = SDL_SwapFloatLE(sample3);
6586 dst[4] = SDL_SwapFloatLE(sample4);
6587 dst[5] = SDL_SwapFloatLE(sample5);
6588 dst[6] = SDL_SwapFloatLE(sample6);
6589 dst[7] = SDL_SwapFloatLE(sample7);
6590 dst += 8;
6591 sample0 = (float) ((((double) SDL_SwapFloatLE(src[0])) + ((double) last_sample0)) * 0.5);
6592 sample1 = (float) ((((double) SDL_SwapFloatLE(src[1])) + ((double) last_sample1)) * 0.5);
6593 sample2 = (float) ((((double) SDL_SwapFloatLE(src[2])) + ((double) last_sample2)) * 0.5);
6594 sample3 = (float) ((((double) SDL_SwapFloatLE(src[3])) + ((double) last_sample3)) * 0.5);
6595 sample4 = (float) ((((double) SDL_SwapFloatLE(src[4])) + ((double) last_sample4)) * 0.5);
6596 sample5 = (float) ((((double) SDL_SwapFloatLE(src[5])) + ((double) last_sample5)) * 0.5);
6597 sample6 = (float) ((((double) SDL_SwapFloatLE(src[6])) + ((double) last_sample6)) * 0.5);
6598 sample7 = (float) ((((double) SDL_SwapFloatLE(src[7])) + ((double) last_sample7)) * 0.5);
6599 last_sample0 = sample0;
6600 last_sample1 = sample1;
6601 last_sample2 = sample2;
6602 last_sample3 = sample3;
6603 last_sample4 = sample4;
6604 last_sample5 = sample5;
6605 last_sample6 = sample6;
6606 last_sample7 = sample7;
6607 eps -= srcsize;
6608 }
6609 }
6610 cvt->len_cvt = dstsize;
6611 if (cvt->filters[++cvt->filter_index]) {
6612 cvt->filters[cvt->filter_index] (cvt, format);
6613 }
6614 }
6615
6616 static void SDLCALL
6617 SDL_Upsample_F32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
6618 {
6619 #ifdef DEBUG_CONVERT
6620 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 1 channels.\n", cvt->rate_incr);
6621 #endif
6622
6623 const int srcsize = cvt->len_cvt - 64;
6624 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
6625 register int eps = 0;
6626 float *dst = ((float *) (cvt->buf + dstsize)) - 1;
6627 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
6628 const float *target = ((const float *) cvt->buf) - 1;
6629 float sample0 = SDL_SwapFloatBE(src[0]);
6630 float last_sample0 = sample0;
6631 while (dst != target) {
6632 dst[0] = SDL_SwapFloatBE(sample0);
6633 dst--;
6634 eps += srcsize;
6635 if ((eps << 1) >= dstsize) {
6636 src--;
6637 sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
6638 last_sample0 = sample0;
6639 eps -= dstsize;
6640 }
6641 }
6642 cvt->len_cvt = dstsize;
6643 if (cvt->filters[++cvt->filter_index]) {
6644 cvt->filters[cvt->filter_index] (cvt, format);
6645 }
6646 }
6647
6648 static void SDLCALL
6649 SDL_Downsample_F32MSB_1c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
6650 {
6651 #ifdef DEBUG_CONVERT
6652 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 1 channels.\n", cvt->rate_incr);
6653 #endif
6654
6655 const int srcsize = cvt->len_cvt - 64;
6656 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
6657 register int eps = 0;
6658 float *dst = (float *) cvt->buf;
6659 const float *src = (float *) cvt->buf;
6660 const float *target = (const float *) (cvt->buf + dstsize);
6661 float sample0 = SDL_SwapFloatBE(src[0]);
6662 float last_sample0 = sample0;
6663 while (dst != target) {
6664 src++;
6665 eps += dstsize;
6666 if ((eps << 1) >= srcsize) {
6667 dst[0] = SDL_SwapFloatBE(sample0);
6668 dst++;
6669 sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
6670 last_sample0 = sample0;
6671 eps -= srcsize;
6672 }
6673 }
6674 cvt->len_cvt = dstsize;
6675 if (cvt->filters[++cvt->filter_index]) {
6676 cvt->filters[cvt->filter_index] (cvt, format);
6677 }
6678 }
6679
6680 static void SDLCALL
6681 SDL_Upsample_F32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
6682 {
6683 #ifdef DEBUG_CONVERT
6684 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 2 channels.\n", cvt->rate_incr);
6685 #endif
6686
6687 const int srcsize = cvt->len_cvt - 128;
6688 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
6689 register int eps = 0;
6690 float *dst = ((float *) (cvt->buf + dstsize)) - 2;
6691 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
6692 const float *target = ((const float *) cvt->buf) - 2;
6693 float sample1 = SDL_SwapFloatBE(src[1]);
6694 float sample0 = SDL_SwapFloatBE(src[0]);
6695 float last_sample1 = sample1;
6696 float last_sample0 = sample0;
6697 while (dst != target) {
6698 dst[1] = SDL_SwapFloatBE(sample1);
6699 dst[0] = SDL_SwapFloatBE(sample0);
6700 dst -= 2;
6701 eps += srcsize;
6702 if ((eps << 1) >= dstsize) {
6703 src -= 2;
6704 sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
6705 sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
6706 last_sample1 = sample1;
6707 last_sample0 = sample0;
6708 eps -= dstsize;
6709 }
6710 }
6711 cvt->len_cvt = dstsize;
6712 if (cvt->filters[++cvt->filter_index]) {
6713 cvt->filters[cvt->filter_index] (cvt, format);
6714 }
6715 }
6716
6717 static void SDLCALL
6718 SDL_Downsample_F32MSB_2c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
6719 {
6720 #ifdef DEBUG_CONVERT
6721 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 2 channels.\n", cvt->rate_incr);
6722 #endif
6723
6724 const int srcsize = cvt->len_cvt - 128;
6725 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
6726 register int eps = 0;
6727 float *dst = (float *) cvt->buf;
6728 const float *src = (float *) cvt->buf;
6729 const float *target = (const float *) (cvt->buf + dstsize);
6730 float sample0 = SDL_SwapFloatBE(src[0]);
6731 float sample1 = SDL_SwapFloatBE(src[1]);
6732 float last_sample0 = sample0;
6733 float last_sample1 = sample1;
6734 while (dst != target) {
6735 src += 2;
6736 eps += dstsize;
6737 if ((eps << 1) >= srcsize) {
6738 dst[0] = SDL_SwapFloatBE(sample0);
6739 dst[1] = SDL_SwapFloatBE(sample1);
6740 dst += 2;
6741 sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
6742 sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
6743 last_sample0 = sample0;
6744 last_sample1 = sample1;
6745 eps -= srcsize;
6746 }
6747 }
6748 cvt->len_cvt = dstsize;
6749 if (cvt->filters[++cvt->filter_index]) {
6750 cvt->filters[cvt->filter_index] (cvt, format);
6751 }
6752 }
6753
6754 static void SDLCALL
6755 SDL_Upsample_F32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
6756 {
6757 #ifdef DEBUG_CONVERT
6758 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 4 channels.\n", cvt->rate_incr);
6759 #endif
6760
6761 const int srcsize = cvt->len_cvt - 256;
6762 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
6763 register int eps = 0;
6764 float *dst = ((float *) (cvt->buf + dstsize)) - 4;
6765 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
6766 const float *target = ((const float *) cvt->buf) - 4;
6767 float sample3 = SDL_SwapFloatBE(src[3]);
6768 float sample2 = SDL_SwapFloatBE(src[2]);
6769 float sample1 = SDL_SwapFloatBE(src[1]);
6770 float sample0 = SDL_SwapFloatBE(src[0]);
6771 float last_sample3 = sample3;
6772 float last_sample2 = sample2;
6773 float last_sample1 = sample1;
6774 float last_sample0 = sample0;
6775 while (dst != target) {
6776 dst[3] = SDL_SwapFloatBE(sample3);
6777 dst[2] = SDL_SwapFloatBE(sample2);
6778 dst[1] = SDL_SwapFloatBE(sample1);
6779 dst[0] = SDL_SwapFloatBE(sample0);
6780 dst -= 4;
6781 eps += srcsize;
6782 if ((eps << 1) >= dstsize) {
6783 src -= 4;
6784 sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
6785 sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
6786 sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
6787 sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
6788 last_sample3 = sample3;
6789 last_sample2 = sample2;
6790 last_sample1 = sample1;
6791 last_sample0 = sample0;
6792 eps -= dstsize;
6793 }
6794 }
6795 cvt->len_cvt = dstsize;
6796 if (cvt->filters[++cvt->filter_index]) {
6797 cvt->filters[cvt->filter_index] (cvt, format);
6798 }
6799 }
6800
6801 static void SDLCALL
6802 SDL_Downsample_F32MSB_4c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
6803 {
6804 #ifdef DEBUG_CONVERT
6805 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 4 channels.\n", cvt->rate_incr);
6806 #endif
6807
6808 const int srcsize = cvt->len_cvt - 256;
6809 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
6810 register int eps = 0;
6811 float *dst = (float *) cvt->buf;
6812 const float *src = (float *) cvt->buf;
6813 const float *target = (const float *) (cvt->buf + dstsize);
6814 float sample0 = SDL_SwapFloatBE(src[0]);
6815 float sample1 = SDL_SwapFloatBE(src[1]);
6816 float sample2 = SDL_SwapFloatBE(src[2]);
6817 float sample3 = SDL_SwapFloatBE(src[3]);
6818 float last_sample0 = sample0;
6819 float last_sample1 = sample1;
6820 float last_sample2 = sample2;
6821 float last_sample3 = sample3;
6822 while (dst != target) {
6823 src += 4;
6824 eps += dstsize;
6825 if ((eps << 1) >= srcsize) {
6826 dst[0] = SDL_SwapFloatBE(sample0);
6827 dst[1] = SDL_SwapFloatBE(sample1);
6828 dst[2] = SDL_SwapFloatBE(sample2);
6829 dst[3] = SDL_SwapFloatBE(sample3);
6830 dst += 4;
6831 sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
6832 sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
6833 sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
6834 sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
6835 last_sample0 = sample0;
6836 last_sample1 = sample1;
6837 last_sample2 = sample2;
6838 last_sample3 = sample3;
6839 eps -= srcsize;
6840 }
6841 }
6842 cvt->len_cvt = dstsize;
6843 if (cvt->filters[++cvt->filter_index]) {
6844 cvt->filters[cvt->filter_index] (cvt, format);
6845 }
6846 }
6847
6848 static void SDLCALL
6849 SDL_Upsample_F32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
6850 {
6851 #ifdef DEBUG_CONVERT
6852 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 6 channels.\n", cvt->rate_incr);
6853 #endif
6854
6855 const int srcsize = cvt->len_cvt - 384;
6856 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
6857 register int eps = 0;
6858 float *dst = ((float *) (cvt->buf + dstsize)) - 6;
6859 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
6860 const float *target = ((const float *) cvt->buf) - 6;
6861 float sample5 = SDL_SwapFloatBE(src[5]);
6862 float sample4 = SDL_SwapFloatBE(src[4]);
6863 float sample3 = SDL_SwapFloatBE(src[3]);
6864 float sample2 = SDL_SwapFloatBE(src[2]);
6865 float sample1 = SDL_SwapFloatBE(src[1]);
6866 float sample0 = SDL_SwapFloatBE(src[0]);
6867 float last_sample5 = sample5;
6868 float last_sample4 = sample4;
6869 float last_sample3 = sample3;
6870 float last_sample2 = sample2;
6871 float last_sample1 = sample1;
6872 float last_sample0 = sample0;
6873 while (dst != target) {
6874 dst[5] = SDL_SwapFloatBE(sample5);
6875 dst[4] = SDL_SwapFloatBE(sample4);
6876 dst[3] = SDL_SwapFloatBE(sample3);
6877 dst[2] = SDL_SwapFloatBE(sample2);
6878 dst[1] = SDL_SwapFloatBE(sample1);
6879 dst[0] = SDL_SwapFloatBE(sample0);
6880 dst -= 6;
6881 eps += srcsize;
6882 if ((eps << 1) >= dstsize) {
6883 src -= 6;
6884 sample5 = (float) ((((double) SDL_SwapFloatBE(src[5])) + ((double) last_sample5)) * 0.5);
6885 sample4 = (float) ((((double) SDL_SwapFloatBE(src[4])) + ((double) last_sample4)) * 0.5);
6886 sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
6887 sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
6888 sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
6889 sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
6890 last_sample5 = sample5;
6891 last_sample4 = sample4;
6892 last_sample3 = sample3;
6893 last_sample2 = sample2;
6894 last_sample1 = sample1;
6895 last_sample0 = sample0;
6896 eps -= dstsize;
6897 }
6898 }
6899 cvt->len_cvt = dstsize;
6900 if (cvt->filters[++cvt->filter_index]) {
6901 cvt->filters[cvt->filter_index] (cvt, format);
6902 }
6903 }
6904
6905 static void SDLCALL
6906 SDL_Downsample_F32MSB_6c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
6907 {
6908 #ifdef DEBUG_CONVERT
6909 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 6 channels.\n", cvt->rate_incr);
6910 #endif
6911
6912 const int srcsize = cvt->len_cvt - 384;
6913 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
6914 register int eps = 0;
6915 float *dst = (float *) cvt->buf;
6916 const float *src = (float *) cvt->buf;
6917 const float *target = (const float *) (cvt->buf + dstsize);
6918 float sample0 = SDL_SwapFloatBE(src[0]);
6919 float sample1 = SDL_SwapFloatBE(src[1]);
6920 float sample2 = SDL_SwapFloatBE(src[2]);
6921 float sample3 = SDL_SwapFloatBE(src[3]);
6922 float sample4 = SDL_SwapFloatBE(src[4]);
6923 float sample5 = SDL_SwapFloatBE(src[5]);
6924 float last_sample0 = sample0;
6925 float last_sample1 = sample1;
6926 float last_sample2 = sample2;
6927 float last_sample3 = sample3;
6928 float last_sample4 = sample4;
6929 float last_sample5 = sample5;
6930 while (dst != target) {
6931 src += 6;
6932 eps += dstsize;
6933 if ((eps << 1) >= srcsize) {
6934 dst[0] = SDL_SwapFloatBE(sample0);
6935 dst[1] = SDL_SwapFloatBE(sample1);
6936 dst[2] = SDL_SwapFloatBE(sample2);
6937 dst[3] = SDL_SwapFloatBE(sample3);
6938 dst[4] = SDL_SwapFloatBE(sample4);
6939 dst[5] = SDL_SwapFloatBE(sample5);
6940 dst += 6;
6941 sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
6942 sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
6943 sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
6944 sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
6945 sample4 = (float) ((((double) SDL_SwapFloatBE(src[4])) + ((double) last_sample4)) * 0.5);
6946 sample5 = (float) ((((double) SDL_SwapFloatBE(src[5])) + ((double) last_sample5)) * 0.5);
6947 last_sample0 = sample0;
6948 last_sample1 = sample1;
6949 last_sample2 = sample2;
6950 last_sample3 = sample3;
6951 last_sample4 = sample4;
6952 last_sample5 = sample5;
6953 eps -= srcsize;
6954 }
6955 }
6956 cvt->len_cvt = dstsize;
6957 if (cvt->filters[++cvt->filter_index]) {
6958 cvt->filters[cvt->filter_index] (cvt, format);
6959 }
6960 }
6961
6962 static void SDLCALL
6963 SDL_Upsample_F32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
6964 {
6965 #ifdef DEBUG_CONVERT
6966 fprintf(stderr, "Upsample arbitrary (x%f) AUDIO_F32MSB, 8 channels.\n", cvt->rate_incr);
6967 #endif
6968
6969 const int srcsize = cvt->len_cvt - 512;
6970 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
6971 register int eps = 0;
6972 float *dst = ((float *) (cvt->buf + dstsize)) - 8;
6973 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
6974 const float *target = ((const float *) cvt->buf) - 8;
6975 float sample7 = SDL_SwapFloatBE(src[7]);
6976 float sample6 = SDL_SwapFloatBE(src[6]);
6977 float sample5 = SDL_SwapFloatBE(src[5]);
6978 float sample4 = SDL_SwapFloatBE(src[4]);
6979 float sample3 = SDL_SwapFloatBE(src[3]);
6980 float sample2 = SDL_SwapFloatBE(src[2]);
6981 float sample1 = SDL_SwapFloatBE(src[1]);
6982 float sample0 = SDL_SwapFloatBE(src[0]);
6983 float last_sample7 = sample7;
6984 float last_sample6 = sample6;
6985 float last_sample5 = sample5;
6986 float last_sample4 = sample4;
6987 float last_sample3 = sample3;
6988 float last_sample2 = sample2;
6989 float last_sample1 = sample1;
6990 float last_sample0 = sample0;
6991 while (dst != target) {
6992 dst[7] = SDL_SwapFloatBE(sample7);
6993 dst[6] = SDL_SwapFloatBE(sample6);
6994 dst[5] = SDL_SwapFloatBE(sample5);
6995 dst[4] = SDL_SwapFloatBE(sample4);
6996 dst[3] = SDL_SwapFloatBE(sample3);
6997 dst[2] = SDL_SwapFloatBE(sample2);
6998 dst[1] = SDL_SwapFloatBE(sample1);
6999 dst[0] = SDL_SwapFloatBE(sample0);
7000 dst -= 8;
7001 eps += srcsize;
7002 if ((eps << 1) >= dstsize) {
7003 src -= 8;
7004 sample7 = (float) ((((double) SDL_SwapFloatBE(src[7])) + ((double) last_sample7)) * 0.5);
7005 sample6 = (float) ((((double) SDL_SwapFloatBE(src[6])) + ((double) last_sample6)) * 0.5);
7006 sample5 = (float) ((((double) SDL_SwapFloatBE(src[5])) + ((double) last_sample5)) * 0.5);
7007 sample4 = (float) ((((double) SDL_SwapFloatBE(src[4])) + ((double) last_sample4)) * 0.5);
7008 sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
7009 sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
7010 sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
7011 sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
7012 last_sample7 = sample7;
7013 last_sample6 = sample6;
7014 last_sample5 = sample5;
7015 last_sample4 = sample4;
7016 last_sample3 = sample3;
7017 last_sample2 = sample2;
7018 last_sample1 = sample1;
7019 last_sample0 = sample0;
7020 eps -= dstsize;
7021 }
7022 }
7023 cvt->len_cvt = dstsize;
7024 if (cvt->filters[++cvt->filter_index]) {
7025 cvt->filters[cvt->filter_index] (cvt, format);
7026 }
7027 }
7028
7029 static void SDLCALL
7030 SDL_Downsample_F32MSB_8c(SDL_AudioCVT * cvt, SDL_AudioFormat format)
7031 {
7032 #ifdef DEBUG_CONVERT
7033 fprintf(stderr, "Downsample arbitrary (x%f) AUDIO_F32MSB, 8 channels.\n", cvt->rate_incr);
7034 #endif
7035
7036 const int srcsize = cvt->len_cvt - 512;
7037 const int dstsize = (int) (((double)cvt->len_cvt) * cvt->rate_incr);
7038 register int eps = 0;
7039 float *dst = (float *) cvt->buf;
7040 const float *src = (float *) cvt->buf;
7041 const float *target = (const float *) (cvt->buf + dstsize);
7042 float sample0 = SDL_SwapFloatBE(src[0]);
7043 float sample1 = SDL_SwapFloatBE(src[1]);
7044 float sample2 = SDL_SwapFloatBE(src[2]);
7045 float sample3 = SDL_SwapFloatBE(src[3]);
7046 float sample4 = SDL_SwapFloatBE(src[4]);
7047 float sample5 = SDL_SwapFloatBE(src[5]);
7048 float sample6 = SDL_SwapFloatBE(src[6]);
7049 float sample7 = SDL_SwapFloatBE(src[7]);
7050 float last_sample0 = sample0;
7051 float last_sample1 = sample1;
7052 float last_sample2 = sample2;
7053 float last_sample3 = sample3;
7054 float last_sample4 = sample4;
7055 float last_sample5 = sample5;
7056 float last_sample6 = sample6;
7057 float last_sample7 = sample7;
7058 while (dst != target) {
7059 src += 8;
7060 eps += dstsize;
7061 if ((eps << 1) >= srcsize) {
7062 dst[0] = SDL_SwapFloatBE(sample0);
7063 dst[1] = SDL_SwapFloatBE(sample1);
7064 dst[2] = SDL_SwapFloatBE(sample2);
7065 dst[3] = SDL_SwapFloatBE(sample3);
7066 dst[4] = SDL_SwapFloatBE(sample4);
7067 dst[5] = SDL_SwapFloatBE(sample5);
7068 dst[6] = SDL_SwapFloatBE(sample6);
7069 dst[7] = SDL_SwapFloatBE(sample7);
7070 dst += 8;
7071 sample0 = (float) ((((double) SDL_SwapFloatBE(src[0])) + ((double) last_sample0)) * 0.5);
7072 sample1 = (float) ((((double) SDL_SwapFloatBE(src[1])) + ((double) last_sample1)) * 0.5);
7073 sample2 = (float) ((((double) SDL_SwapFloatBE(src[2])) + ((double) last_sample2)) * 0.5);
7074 sample3 = (float) ((((double) SDL_SwapFloatBE(src[3])) + ((double) last_sample3)) * 0.5);
7075 sample4 = (float) ((((double) SDL_SwapFloatBE(src[4])) + ((double) last_sample4)) * 0.5);
7076 sample5 = (float) ((((double) SDL_SwapFloatBE(src[5])) + ((double) last_sample5)) * 0.5);
7077 sample6 = (float) ((((double) SDL_SwapFloatBE(src[6])) + ((double) last_sample6)) * 0.5);
7078 sample7 = (float) ((((double) SDL_SwapFloatBE(src[7])) + ((double) last_sample7)) * 0.5);
7079 last_sample0 = sample0;
7080 last_sample1 = sample1;
7081 last_sample2 = sample2;
7082 last_sample3 = sample3;
7083 last_sample4 = sample4;
7084 last_sample5 = sample5;
7085 last_sample6 = sample6;
7086 last_sample7 = sample7;
7087 eps -= srcsize;
7088 }
7089 }
7090 cvt->len_cvt = dstsize;
7091 if (cvt->filters[++cvt->filter_index]) {
7092 cvt->filters[cvt->filter_index] (cvt, format);
7093 }
7094 }
7095
7096
7097 #if !LESS_RESAMPLERS
7098
7099 static void SDLCALL
7100 SDL_Upsample_U8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
7101 {
7102 #ifdef DEBUG_CONVERT
7103 fprintf(stderr, "Upsample (x2) AUDIO_U8, 1 channels.\n");
7104 #endif
7105
7106 const int srcsize = cvt->len_cvt;
7107 const int dstsize = cvt->len_cvt * 2;
7108 Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 1;
7109 const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
7110 const Uint8 *target = ((const Uint8 *) cvt->buf) - 1;
7111 Sint16 last_sample0 = (Sint16) src[0];
7112 while (dst != target) {
7113 const Sint16 sample0 = (Sint16) src[0];
7114 src--;
7115 dst[1] = (Uint8) ((sample0 + last_sample0) >> 1);
7116 dst[0] = (Uint8) sample0;
7117 last_sample0 = sample0;
7118 dst -= 2;
7119 }
7120
7121 cvt->len_cvt = dstsize;
7122 if (cvt->filters[++cvt->filter_index]) {
7123 cvt->filters[cvt->filter_index] (cvt, format);
7124 }
7125 }
7126
7127 static void SDLCALL
7128 SDL_Downsample_U8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
7129 {
7130 #ifdef DEBUG_CONVERT
7131 fprintf(stderr, "Downsample (x2) AUDIO_U8, 1 channels.\n");
7132 #endif
7133
7134 const int srcsize = cvt->len_cvt;
7135 const int dstsize = cvt->len_cvt / 2;
7136 Uint8 *dst = (Uint8 *) cvt->buf;
7137 const Uint8 *src = (Uint8 *) cvt->buf;
7138 const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
7139 Sint16 last_sample0 = (Sint16) src[0];
7140 while (dst != target) {
7141 const Sint16 sample0 = (Sint16) src[0];
7142 src += 2;
7143 dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
7144 last_sample0 = sample0;
7145 dst++;
7146 }
7147
7148 cvt->len_cvt = dstsize;
7149 if (cvt->filters[++cvt->filter_index]) {
7150 cvt->filters[cvt->filter_index] (cvt, format);
7151 }
7152 }
7153
7154 static void SDLCALL
7155 SDL_Upsample_U8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
7156 {
7157 #ifdef DEBUG_CONVERT
7158 fprintf(stderr, "Upsample (x4) AUDIO_U8, 1 channels.\n");
7159 #endif
7160
7161 const int srcsize = cvt->len_cvt;
7162 const int dstsize = cvt->len_cvt * 4;
7163 Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 1;
7164 const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 1;
7165 const Uint8 *target = ((const Uint8 *) cvt->buf) - 1;
7166 Sint16 last_sample0 = (Sint16) src[0];
7167 while (dst != target) {
7168 const Sint16 sample0 = (Sint16) src[0];
7169 src--;
7170 dst[3] = (Uint8) sample0;
7171 dst[2] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
7172 dst[1] = (Uint8) ((sample0 + last_sample0) >> 1);
7173 dst[0] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
7174 last_sample0 = sample0;
7175 dst -= 4;
7176 }
7177
7178 cvt->len_cvt = dstsize;
7179 if (cvt->filters[++cvt->filter_index]) {
7180 cvt->filters[cvt->filter_index] (cvt, format);
7181 }
7182 }
7183
7184 static void SDLCALL
7185 SDL_Downsample_U8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
7186 {
7187 #ifdef DEBUG_CONVERT
7188 fprintf(stderr, "Downsample (x4) AUDIO_U8, 1 channels.\n");
7189 #endif
7190
7191 const int srcsize = cvt->len_cvt;
7192 const int dstsize = cvt->len_cvt / 4;
7193 Uint8 *dst = (Uint8 *) cvt->buf;
7194 const Uint8 *src = (Uint8 *) cvt->buf;
7195 const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
7196 Sint16 last_sample0 = (Sint16) src[0];
7197 while (dst != target) {
7198 const Sint16 sample0 = (Sint16) src[0];
7199 src += 4;
7200 dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
7201 last_sample0 = sample0;
7202 dst++;
7203 }
7204
7205 cvt->len_cvt = dstsize;
7206 if (cvt->filters[++cvt->filter_index]) {
7207 cvt->filters[cvt->filter_index] (cvt, format);
7208 }
7209 }
7210
7211 static void SDLCALL
7212 SDL_Upsample_U8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
7213 {
7214 #ifdef DEBUG_CONVERT
7215 fprintf(stderr, "Upsample (x2) AUDIO_U8, 2 channels.\n");
7216 #endif
7217
7218 const int srcsize = cvt->len_cvt;
7219 const int dstsize = cvt->len_cvt * 2;
7220 Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 2;
7221 const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 2;
7222 const Uint8 *target = ((const Uint8 *) cvt->buf) - 2;
7223 Sint16 last_sample1 = (Sint16) src[1];
7224 Sint16 last_sample0 = (Sint16) src[0];
7225 while (dst != target) {
7226 const Sint16 sample1 = (Sint16) src[1];
7227 const Sint16 sample0 = (Sint16) src[0];
7228 src -= 2;
7229 dst[3] = (Uint8) ((sample1 + last_sample1) >> 1);
7230 dst[2] = (Uint8) ((sample0 + last_sample0) >> 1);
7231 dst[1] = (Uint8) sample1;
7232 dst[0] = (Uint8) sample0;
7233 last_sample1 = sample1;
7234 last_sample0 = sample0;
7235 dst -= 4;
7236 }
7237
7238 cvt->len_cvt = dstsize;
7239 if (cvt->filters[++cvt->filter_index]) {
7240 cvt->filters[cvt->filter_index] (cvt, format);
7241 }
7242 }
7243
7244 static void SDLCALL
7245 SDL_Downsample_U8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
7246 {
7247 #ifdef DEBUG_CONVERT
7248 fprintf(stderr, "Downsample (x2) AUDIO_U8, 2 channels.\n");
7249 #endif
7250
7251 const int srcsize = cvt->len_cvt;
7252 const int dstsize = cvt->len_cvt / 2;
7253 Uint8 *dst = (Uint8 *) cvt->buf;
7254 const Uint8 *src = (Uint8 *) cvt->buf;
7255 const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
7256 Sint16 last_sample0 = (Sint16) src[0];
7257 Sint16 last_sample1 = (Sint16) src[1];
7258 while (dst != target) {
7259 const Sint16 sample0 = (Sint16) src[0];
7260 const Sint16 sample1 = (Sint16) src[1];
7261 src += 4;
7262 dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
7263 dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
7264 last_sample0 = sample0;
7265 last_sample1 = sample1;
7266 dst += 2;
7267 }
7268
7269 cvt->len_cvt = dstsize;
7270 if (cvt->filters[++cvt->filter_index]) {
7271 cvt->filters[cvt->filter_index] (cvt, format);
7272 }
7273 }
7274
7275 static void SDLCALL
7276 SDL_Upsample_U8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
7277 {
7278 #ifdef DEBUG_CONVERT
7279 fprintf(stderr, "Upsample (x4) AUDIO_U8, 2 channels.\n");
7280 #endif
7281
7282 const int srcsize = cvt->len_cvt;
7283 const int dstsize = cvt->len_cvt * 4;
7284 Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 2;
7285 const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 2;
7286 const Uint8 *target = ((const Uint8 *) cvt->buf) - 2;
7287 Sint16 last_sample1 = (Sint16) src[1];
7288 Sint16 last_sample0 = (Sint16) src[0];
7289 while (dst != target) {
7290 const Sint16 sample1 = (Sint16) src[1];
7291 const Sint16 sample0 = (Sint16) src[0];
7292 src -= 2;
7293 dst[7] = (Uint8) sample1;
7294 dst[6] = (Uint8) sample0;
7295 dst[5] = (Uint8) (((3 * sample1) + last_sample1) >> 2);
7296 dst[4] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
7297 dst[3] = (Uint8) ((sample1 + last_sample1) >> 1);
7298 dst[2] = (Uint8) ((sample0 + last_sample0) >> 1);
7299 dst[1] = (Uint8) ((sample1 + (3 * last_sample1)) >> 2);
7300 dst[0] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
7301 last_sample1 = sample1;
7302 last_sample0 = sample0;
7303 dst -= 8;
7304 }
7305
7306 cvt->len_cvt = dstsize;
7307 if (cvt->filters[++cvt->filter_index]) {
7308 cvt->filters[cvt->filter_index] (cvt, format);
7309 }
7310 }
7311
7312 static void SDLCALL
7313 SDL_Downsample_U8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
7314 {
7315 #ifdef DEBUG_CONVERT
7316 fprintf(stderr, "Downsample (x4) AUDIO_U8, 2 channels.\n");
7317 #endif
7318
7319 const int srcsize = cvt->len_cvt;
7320 const int dstsize = cvt->len_cvt / 4;
7321 Uint8 *dst = (Uint8 *) cvt->buf;
7322 const Uint8 *src = (Uint8 *) cvt->buf;
7323 const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
7324 Sint16 last_sample0 = (Sint16) src[0];
7325 Sint16 last_sample1 = (Sint16) src[1];
7326 while (dst != target) {
7327 const Sint16 sample0 = (Sint16) src[0];
7328 const Sint16 sample1 = (Sint16) src[1];
7329 src += 8;
7330 dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
7331 dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
7332 last_sample0 = sample0;
7333 last_sample1 = sample1;
7334 dst += 2;
7335 }
7336
7337 cvt->len_cvt = dstsize;
7338 if (cvt->filters[++cvt->filter_index]) {
7339 cvt->filters[cvt->filter_index] (cvt, format);
7340 }
7341 }
7342
7343 static void SDLCALL
7344 SDL_Upsample_U8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
7345 {
7346 #ifdef DEBUG_CONVERT
7347 fprintf(stderr, "Upsample (x2) AUDIO_U8, 4 channels.\n");
7348 #endif
7349
7350 const int srcsize = cvt->len_cvt;
7351 const int dstsize = cvt->len_cvt * 2;
7352 Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 4;
7353 const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 4;
7354 const Uint8 *target = ((const Uint8 *) cvt->buf) - 4;
7355 Sint16 last_sample3 = (Sint16) src[3];
7356 Sint16 last_sample2 = (Sint16) src[2];
7357 Sint16 last_sample1 = (Sint16) src[1];
7358 Sint16 last_sample0 = (Sint16) src[0];
7359 while (dst != target) {
7360 const Sint16 sample3 = (Sint16) src[3];
7361 const Sint16 sample2 = (Sint16) src[2];
7362 const Sint16 sample1 = (Sint16) src[1];
7363 const Sint16 sample0 = (Sint16) src[0];
7364 src -= 4;
7365 dst[7] = (Uint8) ((sample3 + last_sample3) >> 1);
7366 dst[6] = (Uint8) ((sample2 + last_sample2) >> 1);
7367 dst[5] = (Uint8) ((sample1 + last_sample1) >> 1);
7368 dst[4] = (Uint8) ((sample0 + last_sample0) >> 1);
7369 dst[3] = (Uint8) sample3;
7370 dst[2] = (Uint8) sample2;
7371 dst[1] = (Uint8) sample1;
7372 dst[0] = (Uint8) sample0;
7373 last_sample3 = sample3;
7374 last_sample2 = sample2;
7375 last_sample1 = sample1;
7376 last_sample0 = sample0;
7377 dst -= 8;
7378 }
7379
7380 cvt->len_cvt = dstsize;
7381 if (cvt->filters[++cvt->filter_index]) {
7382 cvt->filters[cvt->filter_index] (cvt, format);
7383 }
7384 }
7385
7386 static void SDLCALL
7387 SDL_Downsample_U8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
7388 {
7389 #ifdef DEBUG_CONVERT
7390 fprintf(stderr, "Downsample (x2) AUDIO_U8, 4 channels.\n");
7391 #endif
7392
7393 const int srcsize = cvt->len_cvt;
7394 const int dstsize = cvt->len_cvt / 2;
7395 Uint8 *dst = (Uint8 *) cvt->buf;
7396 const Uint8 *src = (Uint8 *) cvt->buf;
7397 const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
7398 Sint16 last_sample0 = (Sint16) src[0];
7399 Sint16 last_sample1 = (Sint16) src[1];
7400 Sint16 last_sample2 = (Sint16) src[2];
7401 Sint16 last_sample3 = (Sint16) src[3];
7402 while (dst != target) {
7403 const Sint16 sample0 = (Sint16) src[0];
7404 const Sint16 sample1 = (Sint16) src[1];
7405 const Sint16 sample2 = (Sint16) src[2];
7406 const Sint16 sample3 = (Sint16) src[3];
7407 src += 8;
7408 dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
7409 dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
7410 dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
7411 dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
7412 last_sample0 = sample0;
7413 last_sample1 = sample1;
7414 last_sample2 = sample2;
7415 last_sample3 = sample3;
7416 dst += 4;
7417 }
7418
7419 cvt->len_cvt = dstsize;
7420 if (cvt->filters[++cvt->filter_index]) {
7421 cvt->filters[cvt->filter_index] (cvt, format);
7422 }
7423 }
7424
7425 static void SDLCALL
7426 SDL_Upsample_U8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
7427 {
7428 #ifdef DEBUG_CONVERT
7429 fprintf(stderr, "Upsample (x4) AUDIO_U8, 4 channels.\n");
7430 #endif
7431
7432 const int srcsize = cvt->len_cvt;
7433 const int dstsize = cvt->len_cvt * 4;
7434 Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 4;
7435 const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 4;
7436 const Uint8 *target = ((const Uint8 *) cvt->buf) - 4;
7437 Sint16 last_sample3 = (Sint16) src[3];
7438 Sint16 last_sample2 = (Sint16) src[2];
7439 Sint16 last_sample1 = (Sint16) src[1];
7440 Sint16 last_sample0 = (Sint16) src[0];
7441 while (dst != target) {
7442 const Sint16 sample3 = (Sint16) src[3];
7443 const Sint16 sample2 = (Sint16) src[2];
7444 const Sint16 sample1 = (Sint16) src[1];
7445 const Sint16 sample0 = (Sint16) src[0];
7446 src -= 4;
7447 dst[15] = (Uint8) sample3;
7448 dst[14] = (Uint8) sample2;
7449 dst[13] = (Uint8) sample1;
7450 dst[12] = (Uint8) sample0;
7451 dst[11] = (Uint8) (((3 * sample3) + last_sample3) >> 2);
7452 dst[10] = (Uint8) (((3 * sample2) + last_sample2) >> 2);
7453 dst[9] = (Uint8) (((3 * sample1) + last_sample1) >> 2);
7454 dst[8] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
7455 dst[7] = (Uint8) ((sample3 + last_sample3) >> 1);
7456 dst[6] = (Uint8) ((sample2 + last_sample2) >> 1);
7457 dst[5] = (Uint8) ((sample1 + last_sample1) >> 1);
7458 dst[4] = (Uint8) ((sample0 + last_sample0) >> 1);
7459 dst[3] = (Uint8) ((sample3 + (3 * last_sample3)) >> 2);
7460 dst[2] = (Uint8) ((sample2 + (3 * last_sample2)) >> 2);
7461 dst[1] = (Uint8) ((sample1 + (3 * last_sample1)) >> 2);
7462 dst[0] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
7463 last_sample3 = sample3;
7464 last_sample2 = sample2;
7465 last_sample1 = sample1;
7466 last_sample0 = sample0;
7467 dst -= 16;
7468 }
7469
7470 cvt->len_cvt = dstsize;
7471 if (cvt->filters[++cvt->filter_index]) {
7472 cvt->filters[cvt->filter_index] (cvt, format);
7473 }
7474 }
7475
7476 static void SDLCALL
7477 SDL_Downsample_U8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
7478 {
7479 #ifdef DEBUG_CONVERT
7480 fprintf(stderr, "Downsample (x4) AUDIO_U8, 4 channels.\n");
7481 #endif
7482
7483 const int srcsize = cvt->len_cvt;
7484 const int dstsize = cvt->len_cvt / 4;
7485 Uint8 *dst = (Uint8 *) cvt->buf;
7486 const Uint8 *src = (Uint8 *) cvt->buf;
7487 const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
7488 Sint16 last_sample0 = (Sint16) src[0];
7489 Sint16 last_sample1 = (Sint16) src[1];
7490 Sint16 last_sample2 = (Sint16) src[2];
7491 Sint16 last_sample3 = (Sint16) src[3];
7492 while (dst != target) {
7493 const Sint16 sample0 = (Sint16) src[0];
7494 const Sint16 sample1 = (Sint16) src[1];
7495 const Sint16 sample2 = (Sint16) src[2];
7496 const Sint16 sample3 = (Sint16) src[3];
7497 src += 16;
7498 dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
7499 dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
7500 dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
7501 dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
7502 last_sample0 = sample0;
7503 last_sample1 = sample1;
7504 last_sample2 = sample2;
7505 last_sample3 = sample3;
7506 dst += 4;
7507 }
7508
7509 cvt->len_cvt = dstsize;
7510 if (cvt->filters[++cvt->filter_index]) {
7511 cvt->filters[cvt->filter_index] (cvt, format);
7512 }
7513 }
7514
7515 static void SDLCALL
7516 SDL_Upsample_U8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
7517 {
7518 #ifdef DEBUG_CONVERT
7519 fprintf(stderr, "Upsample (x2) AUDIO_U8, 6 channels.\n");
7520 #endif
7521
7522 const int srcsize = cvt->len_cvt;
7523 const int dstsize = cvt->len_cvt * 2;
7524 Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 6;
7525 const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 6;
7526 const Uint8 *target = ((const Uint8 *) cvt->buf) - 6;
7527 Sint16 last_sample5 = (Sint16) src[5];
7528 Sint16 last_sample4 = (Sint16) src[4];
7529 Sint16 last_sample3 = (Sint16) src[3];
7530 Sint16 last_sample2 = (Sint16) src[2];
7531 Sint16 last_sample1 = (Sint16) src[1];
7532 Sint16 last_sample0 = (Sint16) src[0];
7533 while (dst != target) {
7534 const Sint16 sample5 = (Sint16) src[5];
7535 const Sint16 sample4 = (Sint16) src[4];
7536 const Sint16 sample3 = (Sint16) src[3];
7537 const Sint16 sample2 = (Sint16) src[2];
7538 const Sint16 sample1 = (Sint16) src[1];
7539 const Sint16 sample0 = (Sint16) src[0];
7540 src -= 6;
7541 dst[11] = (Uint8) ((sample5 + last_sample5) >> 1);
7542 dst[10] = (Uint8) ((sample4 + last_sample4) >> 1);
7543 dst[9] = (Uint8) ((sample3 + last_sample3) >> 1);
7544 dst[8] = (Uint8) ((sample2 + last_sample2) >> 1);
7545 dst[7] = (Uint8) ((sample1 + last_sample1) >> 1);
7546 dst[6] = (Uint8) ((sample0 + last_sample0) >> 1);
7547 dst[5] = (Uint8) sample5;
7548 dst[4] = (Uint8) sample4;
7549 dst[3] = (Uint8) sample3;
7550 dst[2] = (Uint8) sample2;
7551 dst[1] = (Uint8) sample1;
7552 dst[0] = (Uint8) sample0;
7553 last_sample5 = sample5;
7554 last_sample4 = sample4;
7555 last_sample3 = sample3;
7556 last_sample2 = sample2;
7557 last_sample1 = sample1;
7558 last_sample0 = sample0;
7559 dst -= 12;
7560 }
7561
7562 cvt->len_cvt = dstsize;
7563 if (cvt->filters[++cvt->filter_index]) {
7564 cvt->filters[cvt->filter_index] (cvt, format);
7565 }
7566 }
7567
7568 static void SDLCALL
7569 SDL_Downsample_U8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
7570 {
7571 #ifdef DEBUG_CONVERT
7572 fprintf(stderr, "Downsample (x2) AUDIO_U8, 6 channels.\n");
7573 #endif
7574
7575 const int srcsize = cvt->len_cvt;
7576 const int dstsize = cvt->len_cvt / 2;
7577 Uint8 *dst = (Uint8 *) cvt->buf;
7578 const Uint8 *src = (Uint8 *) cvt->buf;
7579 const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
7580 Sint16 last_sample0 = (Sint16) src[0];
7581 Sint16 last_sample1 = (Sint16) src[1];
7582 Sint16 last_sample2 = (Sint16) src[2];
7583 Sint16 last_sample3 = (Sint16) src[3];
7584 Sint16 last_sample4 = (Sint16) src[4];
7585 Sint16 last_sample5 = (Sint16) src[5];
7586 while (dst != target) {
7587 const Sint16 sample0 = (Sint16) src[0];
7588 const Sint16 sample1 = (Sint16) src[1];
7589 const Sint16 sample2 = (Sint16) src[2];
7590 const Sint16 sample3 = (Sint16) src[3];
7591 const Sint16 sample4 = (Sint16) src[4];
7592 const Sint16 sample5 = (Sint16) src[5];
7593 src += 12;
7594 dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
7595 dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
7596 dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
7597 dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
7598 dst[4] = (Uint8) ((sample4 + last_sample4) >> 1);
7599 dst[5] = (Uint8) ((sample5 + last_sample5) >> 1);
7600 last_sample0 = sample0;
7601 last_sample1 = sample1;
7602 last_sample2 = sample2;
7603 last_sample3 = sample3;
7604 last_sample4 = sample4;
7605 last_sample5 = sample5;
7606 dst += 6;
7607 }
7608
7609 cvt->len_cvt = dstsize;
7610 if (cvt->filters[++cvt->filter_index]) {
7611 cvt->filters[cvt->filter_index] (cvt, format);
7612 }
7613 }
7614
7615 static void SDLCALL
7616 SDL_Upsample_U8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
7617 {
7618 #ifdef DEBUG_CONVERT
7619 fprintf(stderr, "Upsample (x4) AUDIO_U8, 6 channels.\n");
7620 #endif
7621
7622 const int srcsize = cvt->len_cvt;
7623 const int dstsize = cvt->len_cvt * 4;
7624 Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 6;
7625 const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 6;
7626 const Uint8 *target = ((const Uint8 *) cvt->buf) - 6;
7627 Sint16 last_sample5 = (Sint16) src[5];
7628 Sint16 last_sample4 = (Sint16) src[4];
7629 Sint16 last_sample3 = (Sint16) src[3];
7630 Sint16 last_sample2 = (Sint16) src[2];
7631 Sint16 last_sample1 = (Sint16) src[1];
7632 Sint16 last_sample0 = (Sint16) src[0];
7633 while (dst != target) {
7634 const Sint16 sample5 = (Sint16) src[5];
7635 const Sint16 sample4 = (Sint16) src[4];
7636 const Sint16 sample3 = (Sint16) src[3];
7637 const Sint16 sample2 = (Sint16) src[2];
7638 const Sint16 sample1 = (Sint16) src[1];
7639 const Sint16 sample0 = (Sint16) src[0];
7640 src -= 6;
7641 dst[23] = (Uint8) sample5;
7642 dst[22] = (Uint8) sample4;
7643 dst[21] = (Uint8) sample3;
7644 dst[20] = (Uint8) sample2;
7645 dst[19] = (Uint8) sample1;
7646 dst[18] = (Uint8) sample0;
7647 dst[17] = (Uint8) (((3 * sample5) + last_sample5) >> 2);
7648 dst[16] = (Uint8) (((3 * sample4) + last_sample4) >> 2);
7649 dst[15] = (Uint8) (((3 * sample3) + last_sample3) >> 2);
7650 dst[14] = (Uint8) (((3 * sample2) + last_sample2) >> 2);
7651 dst[13] = (Uint8) (((3 * sample1) + last_sample1) >> 2);
7652 dst[12] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
7653 dst[11] = (Uint8) ((sample5 + last_sample5) >> 1);
7654 dst[10] = (Uint8) ((sample4 + last_sample4) >> 1);
7655 dst[9] = (Uint8) ((sample3 + last_sample3) >> 1);
7656 dst[8] = (Uint8) ((sample2 + last_sample2) >> 1);
7657 dst[7] = (Uint8) ((sample1 + last_sample1) >> 1);
7658 dst[6] = (Uint8) ((sample0 + last_sample0) >> 1);
7659 dst[5] = (Uint8) ((sample5 + (3 * last_sample5)) >> 2);
7660 dst[4] = (Uint8) ((sample4 + (3 * last_sample4)) >> 2);
7661 dst[3] = (Uint8) ((sample3 + (3 * last_sample3)) >> 2);
7662 dst[2] = (Uint8) ((sample2 + (3 * last_sample2)) >> 2);
7663 dst[1] = (Uint8) ((sample1 + (3 * last_sample1)) >> 2);
7664 dst[0] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
7665 last_sample5 = sample5;
7666 last_sample4 = sample4;
7667 last_sample3 = sample3;
7668 last_sample2 = sample2;
7669 last_sample1 = sample1;
7670 last_sample0 = sample0;
7671 dst -= 24;
7672 }
7673
7674 cvt->len_cvt = dstsize;
7675 if (cvt->filters[++cvt->filter_index]) {
7676 cvt->filters[cvt->filter_index] (cvt, format);
7677 }
7678 }
7679
7680 static void SDLCALL
7681 SDL_Downsample_U8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
7682 {
7683 #ifdef DEBUG_CONVERT
7684 fprintf(stderr, "Downsample (x4) AUDIO_U8, 6 channels.\n");
7685 #endif
7686
7687 const int srcsize = cvt->len_cvt;
7688 const int dstsize = cvt->len_cvt / 4;
7689 Uint8 *dst = (Uint8 *) cvt->buf;
7690 const Uint8 *src = (Uint8 *) cvt->buf;
7691 const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
7692 Sint16 last_sample0 = (Sint16) src[0];
7693 Sint16 last_sample1 = (Sint16) src[1];
7694 Sint16 last_sample2 = (Sint16) src[2];
7695 Sint16 last_sample3 = (Sint16) src[3];
7696 Sint16 last_sample4 = (Sint16) src[4];
7697 Sint16 last_sample5 = (Sint16) src[5];
7698 while (dst != target) {
7699 const Sint16 sample0 = (Sint16) src[0];
7700 const Sint16 sample1 = (Sint16) src[1];
7701 const Sint16 sample2 = (Sint16) src[2];
7702 const Sint16 sample3 = (Sint16) src[3];
7703 const Sint16 sample4 = (Sint16) src[4];
7704 const Sint16 sample5 = (Sint16) src[5];
7705 src += 24;
7706 dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
7707 dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
7708 dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
7709 dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
7710 dst[4] = (Uint8) ((sample4 + last_sample4) >> 1);
7711 dst[5] = (Uint8) ((sample5 + last_sample5) >> 1);
7712 last_sample0 = sample0;
7713 last_sample1 = sample1;
7714 last_sample2 = sample2;
7715 last_sample3 = sample3;
7716 last_sample4 = sample4;
7717 last_sample5 = sample5;
7718 dst += 6;
7719 }
7720
7721 cvt->len_cvt = dstsize;
7722 if (cvt->filters[++cvt->filter_index]) {
7723 cvt->filters[cvt->filter_index] (cvt, format);
7724 }
7725 }
7726
7727 static void SDLCALL
7728 SDL_Upsample_U8_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
7729 {
7730 #ifdef DEBUG_CONVERT
7731 fprintf(stderr, "Upsample (x2) AUDIO_U8, 8 channels.\n");
7732 #endif
7733
7734 const int srcsize = cvt->len_cvt;
7735 const int dstsize = cvt->len_cvt * 2;
7736 Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 8;
7737 const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 8;
7738 const Uint8 *target = ((const Uint8 *) cvt->buf) - 8;
7739 Sint16 last_sample7 = (Sint16) src[7];
7740 Sint16 last_sample6 = (Sint16) src[6];
7741 Sint16 last_sample5 = (Sint16) src[5];
7742 Sint16 last_sample4 = (Sint16) src[4];
7743 Sint16 last_sample3 = (Sint16) src[3];
7744 Sint16 last_sample2 = (Sint16) src[2];
7745 Sint16 last_sample1 = (Sint16) src[1];
7746 Sint16 last_sample0 = (Sint16) src[0];
7747 while (dst != target) {
7748 const Sint16 sample7 = (Sint16) src[7];
7749 const Sint16 sample6 = (Sint16) src[6];
7750 const Sint16 sample5 = (Sint16) src[5];
7751 const Sint16 sample4 = (Sint16) src[4];
7752 const Sint16 sample3 = (Sint16) src[3];
7753 const Sint16 sample2 = (Sint16) src[2];
7754 const Sint16 sample1 = (Sint16) src[1];
7755 const Sint16 sample0 = (Sint16) src[0];
7756 src -= 8;
7757 dst[15] = (Uint8) ((sample7 + last_sample7) >> 1);
7758 dst[14] = (Uint8) ((sample6 + last_sample6) >> 1);
7759 dst[13] = (Uint8) ((sample5 + last_sample5) >> 1);
7760 dst[12] = (Uint8) ((sample4 + last_sample4) >> 1);
7761 dst[11] = (Uint8) ((sample3 + last_sample3) >> 1);
7762 dst[10] = (Uint8) ((sample2 + last_sample2) >> 1);
7763 dst[9] = (Uint8) ((sample1 + last_sample1) >> 1);
7764 dst[8] = (Uint8) ((sample0 + last_sample0) >> 1);
7765 dst[7] = (Uint8) sample7;
7766 dst[6] = (Uint8) sample6;
7767 dst[5] = (Uint8) sample5;
7768 dst[4] = (Uint8) sample4;
7769 dst[3] = (Uint8) sample3;
7770 dst[2] = (Uint8) sample2;
7771 dst[1] = (Uint8) sample1;
7772 dst[0] = (Uint8) sample0;
7773 last_sample7 = sample7;
7774 last_sample6 = sample6;
7775 last_sample5 = sample5;
7776 last_sample4 = sample4;
7777 last_sample3 = sample3;
7778 last_sample2 = sample2;
7779 last_sample1 = sample1;
7780 last_sample0 = sample0;
7781 dst -= 16;
7782 }
7783
7784 cvt->len_cvt = dstsize;
7785 if (cvt->filters[++cvt->filter_index]) {
7786 cvt->filters[cvt->filter_index] (cvt, format);
7787 }
7788 }
7789
7790 static void SDLCALL
7791 SDL_Downsample_U8_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
7792 {
7793 #ifdef DEBUG_CONVERT
7794 fprintf(stderr, "Downsample (x2) AUDIO_U8, 8 channels.\n");
7795 #endif
7796
7797 const int srcsize = cvt->len_cvt;
7798 const int dstsize = cvt->len_cvt / 2;
7799 Uint8 *dst = (Uint8 *) cvt->buf;
7800 const Uint8 *src = (Uint8 *) cvt->buf;
7801 const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
7802 Sint16 last_sample0 = (Sint16) src[0];
7803 Sint16 last_sample1 = (Sint16) src[1];
7804 Sint16 last_sample2 = (Sint16) src[2];
7805 Sint16 last_sample3 = (Sint16) src[3];
7806 Sint16 last_sample4 = (Sint16) src[4];
7807 Sint16 last_sample5 = (Sint16) src[5];
7808 Sint16 last_sample6 = (Sint16) src[6];
7809 Sint16 last_sample7 = (Sint16) src[7];
7810 while (dst != target) {
7811 const Sint16 sample0 = (Sint16) src[0];
7812 const Sint16 sample1 = (Sint16) src[1];
7813 const Sint16 sample2 = (Sint16) src[2];
7814 const Sint16 sample3 = (Sint16) src[3];
7815 const Sint16 sample4 = (Sint16) src[4];
7816 const Sint16 sample5 = (Sint16) src[5];
7817 const Sint16 sample6 = (Sint16) src[6];
7818 const Sint16 sample7 = (Sint16) src[7];
7819 src += 16;
7820 dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
7821 dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
7822 dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
7823 dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
7824 dst[4] = (Uint8) ((sample4 + last_sample4) >> 1);
7825 dst[5] = (Uint8) ((sample5 + last_sample5) >> 1);
7826 dst[6] = (Uint8) ((sample6 + last_sample6) >> 1);
7827 dst[7] = (Uint8) ((sample7 + last_sample7) >> 1);
7828 last_sample0 = sample0;
7829 last_sample1 = sample1;
7830 last_sample2 = sample2;
7831 last_sample3 = sample3;
7832 last_sample4 = sample4;
7833 last_sample5 = sample5;
7834 last_sample6 = sample6;
7835 last_sample7 = sample7;
7836 dst += 8;
7837 }
7838
7839 cvt->len_cvt = dstsize;
7840 if (cvt->filters[++cvt->filter_index]) {
7841 cvt->filters[cvt->filter_index] (cvt, format);
7842 }
7843 }
7844
7845 static void SDLCALL
7846 SDL_Upsample_U8_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
7847 {
7848 #ifdef DEBUG_CONVERT
7849 fprintf(stderr, "Upsample (x4) AUDIO_U8, 8 channels.\n");
7850 #endif
7851
7852 const int srcsize = cvt->len_cvt;
7853 const int dstsize = cvt->len_cvt * 4;
7854 Uint8 *dst = ((Uint8 *) (cvt->buf + dstsize)) - 8;
7855 const Uint8 *src = ((Uint8 *) (cvt->buf + cvt->len_cvt)) - 8;
7856 const Uint8 *target = ((const Uint8 *) cvt->buf) - 8;
7857 Sint16 last_sample7 = (Sint16) src[7];
7858 Sint16 last_sample6 = (Sint16) src[6];
7859 Sint16 last_sample5 = (Sint16) src[5];
7860 Sint16 last_sample4 = (Sint16) src[4];
7861 Sint16 last_sample3 = (Sint16) src[3];
7862 Sint16 last_sample2 = (Sint16) src[2];
7863 Sint16 last_sample1 = (Sint16) src[1];
7864 Sint16 last_sample0 = (Sint16) src[0];
7865 while (dst != target) {
7866 const Sint16 sample7 = (Sint16) src[7];
7867 const Sint16 sample6 = (Sint16) src[6];
7868 const Sint16 sample5 = (Sint16) src[5];
7869 const Sint16 sample4 = (Sint16) src[4];
7870 const Sint16 sample3 = (Sint16) src[3];
7871 const Sint16 sample2 = (Sint16) src[2];
7872 const Sint16 sample1 = (Sint16) src[1];
7873 const Sint16 sample0 = (Sint16) src[0];
7874 src -= 8;
7875 dst[31] = (Uint8) sample7;
7876 dst[30] = (Uint8) sample6;
7877 dst[29] = (Uint8) sample5;
7878 dst[28] = (Uint8) sample4;
7879 dst[27] = (Uint8) sample3;
7880 dst[26] = (Uint8) sample2;
7881 dst[25] = (Uint8) sample1;
7882 dst[24] = (Uint8) sample0;
7883 dst[23] = (Uint8) (((3 * sample7) + last_sample7) >> 2);
7884 dst[22] = (Uint8) (((3 * sample6) + last_sample6) >> 2);
7885 dst[21] = (Uint8) (((3 * sample5) + last_sample5) >> 2);
7886 dst[20] = (Uint8) (((3 * sample4) + last_sample4) >> 2);
7887 dst[19] = (Uint8) (((3 * sample3) + last_sample3) >> 2);
7888 dst[18] = (Uint8) (((3 * sample2) + last_sample2) >> 2);
7889 dst[17] = (Uint8) (((3 * sample1) + last_sample1) >> 2);
7890 dst[16] = (Uint8) (((3 * sample0) + last_sample0) >> 2);
7891 dst[15] = (Uint8) ((sample7 + last_sample7) >> 1);
7892 dst[14] = (Uint8) ((sample6 + last_sample6) >> 1);
7893 dst[13] = (Uint8) ((sample5 + last_sample5) >> 1);
7894 dst[12] = (Uint8) ((sample4 + last_sample4) >> 1);
7895 dst[11] = (Uint8) ((sample3 + last_sample3) >> 1);
7896 dst[10] = (Uint8) ((sample2 + last_sample2) >> 1);
7897 dst[9] = (Uint8) ((sample1 + last_sample1) >> 1);
7898 dst[8] = (Uint8) ((sample0 + last_sample0) >> 1);
7899 dst[7] = (Uint8) ((sample7 + (3 * last_sample7)) >> 2);
7900 dst[6] = (Uint8) ((sample6 + (3 * last_sample6)) >> 2);
7901 dst[5] = (Uint8) ((sample5 + (3 * last_sample5)) >> 2);
7902 dst[4] = (Uint8) ((sample4 + (3 * last_sample4)) >> 2);
7903 dst[3] = (Uint8) ((sample3 + (3 * last_sample3)) >> 2);
7904 dst[2] = (Uint8) ((sample2 + (3 * last_sample2)) >> 2);
7905 dst[1] = (Uint8) ((sample1 + (3 * last_sample1)) >> 2);
7906 dst[0] = (Uint8) ((sample0 + (3 * last_sample0)) >> 2);
7907 last_sample7 = sample7;
7908 last_sample6 = sample6;
7909 last_sample5 = sample5;
7910 last_sample4 = sample4;
7911 last_sample3 = sample3;
7912 last_sample2 = sample2;
7913 last_sample1 = sample1;
7914 last_sample0 = sample0;
7915 dst -= 32;
7916 }
7917
7918 cvt->len_cvt = dstsize;
7919 if (cvt->filters[++cvt->filter_index]) {
7920 cvt->filters[cvt->filter_index] (cvt, format);
7921 }
7922 }
7923
7924 static void SDLCALL
7925 SDL_Downsample_U8_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
7926 {
7927 #ifdef DEBUG_CONVERT
7928 fprintf(stderr, "Downsample (x4) AUDIO_U8, 8 channels.\n");
7929 #endif
7930
7931 const int srcsize = cvt->len_cvt;
7932 const int dstsize = cvt->len_cvt / 4;
7933 Uint8 *dst = (Uint8 *) cvt->buf;
7934 const Uint8 *src = (Uint8 *) cvt->buf;
7935 const Uint8 *target = (const Uint8 *) (cvt->buf + dstsize);
7936 Sint16 last_sample0 = (Sint16) src[0];
7937 Sint16 last_sample1 = (Sint16) src[1];
7938 Sint16 last_sample2 = (Sint16) src[2];
7939 Sint16 last_sample3 = (Sint16) src[3];
7940 Sint16 last_sample4 = (Sint16) src[4];
7941 Sint16 last_sample5 = (Sint16) src[5];
7942 Sint16 last_sample6 = (Sint16) src[6];
7943 Sint16 last_sample7 = (Sint16) src[7];
7944 while (dst != target) {
7945 const Sint16 sample0 = (Sint16) src[0];
7946 const Sint16 sample1 = (Sint16) src[1];
7947 const Sint16 sample2 = (Sint16) src[2];
7948 const Sint16 sample3 = (Sint16) src[3];
7949 const Sint16 sample4 = (Sint16) src[4];
7950 const Sint16 sample5 = (Sint16) src[5];
7951 const Sint16 sample6 = (Sint16) src[6];
7952 const Sint16 sample7 = (Sint16) src[7];
7953 src += 32;
7954 dst[0] = (Uint8) ((sample0 + last_sample0) >> 1);
7955 dst[1] = (Uint8) ((sample1 + last_sample1) >> 1);
7956 dst[2] = (Uint8) ((sample2 + last_sample2) >> 1);
7957 dst[3] = (Uint8) ((sample3 + last_sample3) >> 1);
7958 dst[4] = (Uint8) ((sample4 + last_sample4) >> 1);
7959 dst[5] = (Uint8) ((sample5 + last_sample5) >> 1);
7960 dst[6] = (Uint8) ((sample6 + last_sample6) >> 1);
7961 dst[7] = (Uint8) ((sample7 + last_sample7) >> 1);
7962 last_sample0 = sample0;
7963 last_sample1 = sample1;
7964 last_sample2 = sample2;
7965 last_sample3 = sample3;
7966 last_sample4 = sample4;
7967 last_sample5 = sample5;
7968 last_sample6 = sample6;
7969 last_sample7 = sample7;
7970 dst += 8;
7971 }
7972
7973 cvt->len_cvt = dstsize;
7974 if (cvt->filters[++cvt->filter_index]) {
7975 cvt->filters[cvt->filter_index] (cvt, format);
7976 }
7977 }
7978
7979 static void SDLCALL
7980 SDL_Upsample_S8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
7981 {
7982 #ifdef DEBUG_CONVERT
7983 fprintf(stderr, "Upsample (x2) AUDIO_S8, 1 channels.\n");
7984 #endif
7985
7986 const int srcsize = cvt->len_cvt;
7987 const int dstsize = cvt->len_cvt * 2;
7988 Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 1;
7989 const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 1;
7990 const Sint8 *target = ((const Sint8 *) cvt->buf) - 1;
7991 Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
7992 while (dst != target) {
7993 const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
7994 src--;
7995 dst[1] = (Sint8) ((sample0 + last_sample0) >> 1);
7996 dst[0] = (Sint8) sample0;
7997 last_sample0 = sample0;
7998 dst -= 2;
7999 }
8000
8001 cvt->len_cvt = dstsize;
8002 if (cvt->filters[++cvt->filter_index]) {
8003 cvt->filters[cvt->filter_index] (cvt, format);
8004 }
8005 }
8006
8007 static void SDLCALL
8008 SDL_Downsample_S8_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8009 {
8010 #ifdef DEBUG_CONVERT
8011 fprintf(stderr, "Downsample (x2) AUDIO_S8, 1 channels.\n");
8012 #endif
8013
8014 const int srcsize = cvt->len_cvt;
8015 const int dstsize = cvt->len_cvt / 2;
8016 Sint8 *dst = (Sint8 *) cvt->buf;
8017 const Sint8 *src = (Sint8 *) cvt->buf;
8018 const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
8019 Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
8020 while (dst != target) {
8021 const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
8022 src += 2;
8023 dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
8024 last_sample0 = sample0;
8025 dst++;
8026 }
8027
8028 cvt->len_cvt = dstsize;
8029 if (cvt->filters[++cvt->filter_index]) {
8030 cvt->filters[cvt->filter_index] (cvt, format);
8031 }
8032 }
8033
8034 static void SDLCALL
8035 SDL_Upsample_S8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8036 {
8037 #ifdef DEBUG_CONVERT
8038 fprintf(stderr, "Upsample (x4) AUDIO_S8, 1 channels.\n");
8039 #endif
8040
8041 const int srcsize = cvt->len_cvt;
8042 const int dstsize = cvt->len_cvt * 4;
8043 Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 1;
8044 const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 1;
8045 const Sint8 *target = ((const Sint8 *) cvt->buf) - 1;
8046 Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
8047 while (dst != target) {
8048 const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
8049 src--;
8050 dst[3] = (Sint8) sample0;
8051 dst[2] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
8052 dst[1] = (Sint8) ((sample0 + last_sample0) >> 1);
8053 dst[0] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
8054 last_sample0 = sample0;
8055 dst -= 4;
8056 }
8057
8058 cvt->len_cvt = dstsize;
8059 if (cvt->filters[++cvt->filter_index]) {
8060 cvt->filters[cvt->filter_index] (cvt, format);
8061 }
8062 }
8063
8064 static void SDLCALL
8065 SDL_Downsample_S8_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8066 {
8067 #ifdef DEBUG_CONVERT
8068 fprintf(stderr, "Downsample (x4) AUDIO_S8, 1 channels.\n");
8069 #endif
8070
8071 const int srcsize = cvt->len_cvt;
8072 const int dstsize = cvt->len_cvt / 4;
8073 Sint8 *dst = (Sint8 *) cvt->buf;
8074 const Sint8 *src = (Sint8 *) cvt->buf;
8075 const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
8076 Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
8077 while (dst != target) {
8078 const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
8079 src += 4;
8080 dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
8081 last_sample0 = sample0;
8082 dst++;
8083 }
8084
8085 cvt->len_cvt = dstsize;
8086 if (cvt->filters[++cvt->filter_index]) {
8087 cvt->filters[cvt->filter_index] (cvt, format);
8088 }
8089 }
8090
8091 static void SDLCALL
8092 SDL_Upsample_S8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8093 {
8094 #ifdef DEBUG_CONVERT
8095 fprintf(stderr, "Upsample (x2) AUDIO_S8, 2 channels.\n");
8096 #endif
8097
8098 const int srcsize = cvt->len_cvt;
8099 const int dstsize = cvt->len_cvt * 2;
8100 Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 2;
8101 const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 2;
8102 const Sint8 *target = ((const Sint8 *) cvt->buf) - 2;
8103 Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
8104 Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
8105 while (dst != target) {
8106 const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
8107 const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
8108 src -= 2;
8109 dst[3] = (Sint8) ((sample1 + last_sample1) >> 1);
8110 dst[2] = (Sint8) ((sample0 + last_sample0) >> 1);
8111 dst[1] = (Sint8) sample1;
8112 dst[0] = (Sint8) sample0;
8113 last_sample1 = sample1;
8114 last_sample0 = sample0;
8115 dst -= 4;
8116 }
8117
8118 cvt->len_cvt = dstsize;
8119 if (cvt->filters[++cvt->filter_index]) {
8120 cvt->filters[cvt->filter_index] (cvt, format);
8121 }
8122 }
8123
8124 static void SDLCALL
8125 SDL_Downsample_S8_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8126 {
8127 #ifdef DEBUG_CONVERT
8128 fprintf(stderr, "Downsample (x2) AUDIO_S8, 2 channels.\n");
8129 #endif
8130
8131 const int srcsize = cvt->len_cvt;
8132 const int dstsize = cvt->len_cvt / 2;
8133 Sint8 *dst = (Sint8 *) cvt->buf;
8134 const Sint8 *src = (Sint8 *) cvt->buf;
8135 const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
8136 Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
8137 Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
8138 while (dst != target) {
8139 const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
8140 const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
8141 src += 4;
8142 dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
8143 dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
8144 last_sample0 = sample0;
8145 last_sample1 = sample1;
8146 dst += 2;
8147 }
8148
8149 cvt->len_cvt = dstsize;
8150 if (cvt->filters[++cvt->filter_index]) {
8151 cvt->filters[cvt->filter_index] (cvt, format);
8152 }
8153 }
8154
8155 static void SDLCALL
8156 SDL_Upsample_S8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8157 {
8158 #ifdef DEBUG_CONVERT
8159 fprintf(stderr, "Upsample (x4) AUDIO_S8, 2 channels.\n");
8160 #endif
8161
8162 const int srcsize = cvt->len_cvt;
8163 const int dstsize = cvt->len_cvt * 4;
8164 Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 2;
8165 const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 2;
8166 const Sint8 *target = ((const Sint8 *) cvt->buf) - 2;
8167 Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
8168 Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
8169 while (dst != target) {
8170 const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
8171 const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
8172 src -= 2;
8173 dst[7] = (Sint8) sample1;
8174 dst[6] = (Sint8) sample0;
8175 dst[5] = (Sint8) (((3 * sample1) + last_sample1) >> 2);
8176 dst[4] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
8177 dst[3] = (Sint8) ((sample1 + last_sample1) >> 1);
8178 dst[2] = (Sint8) ((sample0 + last_sample0) >> 1);
8179 dst[1] = (Sint8) ((sample1 + (3 * last_sample1)) >> 2);
8180 dst[0] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
8181 last_sample1 = sample1;
8182 last_sample0 = sample0;
8183 dst -= 8;
8184 }
8185
8186 cvt->len_cvt = dstsize;
8187 if (cvt->filters[++cvt->filter_index]) {
8188 cvt->filters[cvt->filter_index] (cvt, format);
8189 }
8190 }
8191
8192 static void SDLCALL
8193 SDL_Downsample_S8_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8194 {
8195 #ifdef DEBUG_CONVERT
8196 fprintf(stderr, "Downsample (x4) AUDIO_S8, 2 channels.\n");
8197 #endif
8198
8199 const int srcsize = cvt->len_cvt;
8200 const int dstsize = cvt->len_cvt / 4;
8201 Sint8 *dst = (Sint8 *) cvt->buf;
8202 const Sint8 *src = (Sint8 *) cvt->buf;
8203 const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
8204 Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
8205 Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
8206 while (dst != target) {
8207 const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
8208 const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
8209 src += 8;
8210 dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
8211 dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
8212 last_sample0 = sample0;
8213 last_sample1 = sample1;
8214 dst += 2;
8215 }
8216
8217 cvt->len_cvt = dstsize;
8218 if (cvt->filters[++cvt->filter_index]) {
8219 cvt->filters[cvt->filter_index] (cvt, format);
8220 }
8221 }
8222
8223 static void SDLCALL
8224 SDL_Upsample_S8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8225 {
8226 #ifdef DEBUG_CONVERT
8227 fprintf(stderr, "Upsample (x2) AUDIO_S8, 4 channels.\n");
8228 #endif
8229
8230 const int srcsize = cvt->len_cvt;
8231 const int dstsize = cvt->len_cvt * 2;
8232 Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 4;
8233 const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 4;
8234 const Sint8 *target = ((const Sint8 *) cvt->buf) - 4;
8235 Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
8236 Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
8237 Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
8238 Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
8239 while (dst != target) {
8240 const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
8241 const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
8242 const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
8243 const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
8244 src -= 4;
8245 dst[7] = (Sint8) ((sample3 + last_sample3) >> 1);
8246 dst[6] = (Sint8) ((sample2 + last_sample2) >> 1);
8247 dst[5] = (Sint8) ((sample1 + last_sample1) >> 1);
8248 dst[4] = (Sint8) ((sample0 + last_sample0) >> 1);
8249 dst[3] = (Sint8) sample3;
8250 dst[2] = (Sint8) sample2;
8251 dst[1] = (Sint8) sample1;
8252 dst[0] = (Sint8) sample0;
8253 last_sample3 = sample3;
8254 last_sample2 = sample2;
8255 last_sample1 = sample1;
8256 last_sample0 = sample0;
8257 dst -= 8;
8258 }
8259
8260 cvt->len_cvt = dstsize;
8261 if (cvt->filters[++cvt->filter_index]) {
8262 cvt->filters[cvt->filter_index] (cvt, format);
8263 }
8264 }
8265
8266 static void SDLCALL
8267 SDL_Downsample_S8_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8268 {
8269 #ifdef DEBUG_CONVERT
8270 fprintf(stderr, "Downsample (x2) AUDIO_S8, 4 channels.\n");
8271 #endif
8272
8273 const int srcsize = cvt->len_cvt;
8274 const int dstsize = cvt->len_cvt / 2;
8275 Sint8 *dst = (Sint8 *) cvt->buf;
8276 const Sint8 *src = (Sint8 *) cvt->buf;
8277 const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
8278 Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
8279 Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
8280 Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
8281 Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
8282 while (dst != target) {
8283 const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
8284 const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
8285 const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
8286 const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
8287 src += 8;
8288 dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
8289 dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
8290 dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
8291 dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
8292 last_sample0 = sample0;
8293 last_sample1 = sample1;
8294 last_sample2 = sample2;
8295 last_sample3 = sample3;
8296 dst += 4;
8297 }
8298
8299 cvt->len_cvt = dstsize;
8300 if (cvt->filters[++cvt->filter_index]) {
8301 cvt->filters[cvt->filter_index] (cvt, format);
8302 }
8303 }
8304
8305 static void SDLCALL
8306 SDL_Upsample_S8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8307 {
8308 #ifdef DEBUG_CONVERT
8309 fprintf(stderr, "Upsample (x4) AUDIO_S8, 4 channels.\n");
8310 #endif
8311
8312 const int srcsize = cvt->len_cvt;
8313 const int dstsize = cvt->len_cvt * 4;
8314 Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 4;
8315 const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 4;
8316 const Sint8 *target = ((const Sint8 *) cvt->buf) - 4;
8317 Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
8318 Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
8319 Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
8320 Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
8321 while (dst != target) {
8322 const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
8323 const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
8324 const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
8325 const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
8326 src -= 4;
8327 dst[15] = (Sint8) sample3;
8328 dst[14] = (Sint8) sample2;
8329 dst[13] = (Sint8) sample1;
8330 dst[12] = (Sint8) sample0;
8331 dst[11] = (Sint8) (((3 * sample3) + last_sample3) >> 2);
8332 dst[10] = (Sint8) (((3 * sample2) + last_sample2) >> 2);
8333 dst[9] = (Sint8) (((3 * sample1) + last_sample1) >> 2);
8334 dst[8] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
8335 dst[7] = (Sint8) ((sample3 + last_sample3) >> 1);
8336 dst[6] = (Sint8) ((sample2 + last_sample2) >> 1);
8337 dst[5] = (Sint8) ((sample1 + last_sample1) >> 1);
8338 dst[4] = (Sint8) ((sample0 + last_sample0) >> 1);
8339 dst[3] = (Sint8) ((sample3 + (3 * last_sample3)) >> 2);
8340 dst[2] = (Sint8) ((sample2 + (3 * last_sample2)) >> 2);
8341 dst[1] = (Sint8) ((sample1 + (3 * last_sample1)) >> 2);
8342 dst[0] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
8343 last_sample3 = sample3;
8344 last_sample2 = sample2;
8345 last_sample1 = sample1;
8346 last_sample0 = sample0;
8347 dst -= 16;
8348 }
8349
8350 cvt->len_cvt = dstsize;
8351 if (cvt->filters[++cvt->filter_index]) {
8352 cvt->filters[cvt->filter_index] (cvt, format);
8353 }
8354 }
8355
8356 static void SDLCALL
8357 SDL_Downsample_S8_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8358 {
8359 #ifdef DEBUG_CONVERT
8360 fprintf(stderr, "Downsample (x4) AUDIO_S8, 4 channels.\n");
8361 #endif
8362
8363 const int srcsize = cvt->len_cvt;
8364 const int dstsize = cvt->len_cvt / 4;
8365 Sint8 *dst = (Sint8 *) cvt->buf;
8366 const Sint8 *src = (Sint8 *) cvt->buf;
8367 const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
8368 Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
8369 Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
8370 Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
8371 Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
8372 while (dst != target) {
8373 const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
8374 const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
8375 const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
8376 const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
8377 src += 16;
8378 dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
8379 dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
8380 dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
8381 dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
8382 last_sample0 = sample0;
8383 last_sample1 = sample1;
8384 last_sample2 = sample2;
8385 last_sample3 = sample3;
8386 dst += 4;
8387 }
8388
8389 cvt->len_cvt = dstsize;
8390 if (cvt->filters[++cvt->filter_index]) {
8391 cvt->filters[cvt->filter_index] (cvt, format);
8392 }
8393 }
8394
8395 static void SDLCALL
8396 SDL_Upsample_S8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8397 {
8398 #ifdef DEBUG_CONVERT
8399 fprintf(stderr, "Upsample (x2) AUDIO_S8, 6 channels.\n");
8400 #endif
8401
8402 const int srcsize = cvt->len_cvt;
8403 const int dstsize = cvt->len_cvt * 2;
8404 Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 6;
8405 const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 6;
8406 const Sint8 *target = ((const Sint8 *) cvt->buf) - 6;
8407 Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
8408 Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
8409 Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
8410 Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
8411 Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
8412 Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
8413 while (dst != target) {
8414 const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
8415 const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
8416 const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
8417 const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
8418 const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
8419 const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
8420 src -= 6;
8421 dst[11] = (Sint8) ((sample5 + last_sample5) >> 1);
8422 dst[10] = (Sint8) ((sample4 + last_sample4) >> 1);
8423 dst[9] = (Sint8) ((sample3 + last_sample3) >> 1);
8424 dst[8] = (Sint8) ((sample2 + last_sample2) >> 1);
8425 dst[7] = (Sint8) ((sample1 + last_sample1) >> 1);
8426 dst[6] = (Sint8) ((sample0 + last_sample0) >> 1);
8427 dst[5] = (Sint8) sample5;
8428 dst[4] = (Sint8) sample4;
8429 dst[3] = (Sint8) sample3;
8430 dst[2] = (Sint8) sample2;
8431 dst[1] = (Sint8) sample1;
8432 dst[0] = (Sint8) sample0;
8433 last_sample5 = sample5;
8434 last_sample4 = sample4;
8435 last_sample3 = sample3;
8436 last_sample2 = sample2;
8437 last_sample1 = sample1;
8438 last_sample0 = sample0;
8439 dst -= 12;
8440 }
8441
8442 cvt->len_cvt = dstsize;
8443 if (cvt->filters[++cvt->filter_index]) {
8444 cvt->filters[cvt->filter_index] (cvt, format);
8445 }
8446 }
8447
8448 static void SDLCALL
8449 SDL_Downsample_S8_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8450 {
8451 #ifdef DEBUG_CONVERT
8452 fprintf(stderr, "Downsample (x2) AUDIO_S8, 6 channels.\n");
8453 #endif
8454
8455 const int srcsize = cvt->len_cvt;
8456 const int dstsize = cvt->len_cvt / 2;
8457 Sint8 *dst = (Sint8 *) cvt->buf;
8458 const Sint8 *src = (Sint8 *) cvt->buf;
8459 const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
8460 Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
8461 Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
8462 Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
8463 Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
8464 Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
8465 Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
8466 while (dst != target) {
8467 const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
8468 const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
8469 const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
8470 const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
8471 const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
8472 const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
8473 src += 12;
8474 dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
8475 dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
8476 dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
8477 dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
8478 dst[4] = (Sint8) ((sample4 + last_sample4) >> 1);
8479 dst[5] = (Sint8) ((sample5 + last_sample5) >> 1);
8480 last_sample0 = sample0;
8481 last_sample1 = sample1;
8482 last_sample2 = sample2;
8483 last_sample3 = sample3;
8484 last_sample4 = sample4;
8485 last_sample5 = sample5;
8486 dst += 6;
8487 }
8488
8489 cvt->len_cvt = dstsize;
8490 if (cvt->filters[++cvt->filter_index]) {
8491 cvt->filters[cvt->filter_index] (cvt, format);
8492 }
8493 }
8494
8495 static void SDLCALL
8496 SDL_Upsample_S8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8497 {
8498 #ifdef DEBUG_CONVERT
8499 fprintf(stderr, "Upsample (x4) AUDIO_S8, 6 channels.\n");
8500 #endif
8501
8502 const int srcsize = cvt->len_cvt;
8503 const int dstsize = cvt->len_cvt * 4;
8504 Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 6;
8505 const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 6;
8506 const Sint8 *target = ((const Sint8 *) cvt->buf) - 6;
8507 Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
8508 Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
8509 Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
8510 Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
8511 Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
8512 Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
8513 while (dst != target) {
8514 const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
8515 const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
8516 const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
8517 const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
8518 const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
8519 const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
8520 src -= 6;
8521 dst[23] = (Sint8) sample5;
8522 dst[22] = (Sint8) sample4;
8523 dst[21] = (Sint8) sample3;
8524 dst[20] = (Sint8) sample2;
8525 dst[19] = (Sint8) sample1;
8526 dst[18] = (Sint8) sample0;
8527 dst[17] = (Sint8) (((3 * sample5) + last_sample5) >> 2);
8528 dst[16] = (Sint8) (((3 * sample4) + last_sample4) >> 2);
8529 dst[15] = (Sint8) (((3 * sample3) + last_sample3) >> 2);
8530 dst[14] = (Sint8) (((3 * sample2) + last_sample2) >> 2);
8531 dst[13] = (Sint8) (((3 * sample1) + last_sample1) >> 2);
8532 dst[12] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
8533 dst[11] = (Sint8) ((sample5 + last_sample5) >> 1);
8534 dst[10] = (Sint8) ((sample4 + last_sample4) >> 1);
8535 dst[9] = (Sint8) ((sample3 + last_sample3) >> 1);
8536 dst[8] = (Sint8) ((sample2 + last_sample2) >> 1);
8537 dst[7] = (Sint8) ((sample1 + last_sample1) >> 1);
8538 dst[6] = (Sint8) ((sample0 + last_sample0) >> 1);
8539 dst[5] = (Sint8) ((sample5 + (3 * last_sample5)) >> 2);
8540 dst[4] = (Sint8) ((sample4 + (3 * last_sample4)) >> 2);
8541 dst[3] = (Sint8) ((sample3 + (3 * last_sample3)) >> 2);
8542 dst[2] = (Sint8) ((sample2 + (3 * last_sample2)) >> 2);
8543 dst[1] = (Sint8) ((sample1 + (3 * last_sample1)) >> 2);
8544 dst[0] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
8545 last_sample5 = sample5;
8546 last_sample4 = sample4;
8547 last_sample3 = sample3;
8548 last_sample2 = sample2;
8549 last_sample1 = sample1;
8550 last_sample0 = sample0;
8551 dst -= 24;
8552 }
8553
8554 cvt->len_cvt = dstsize;
8555 if (cvt->filters[++cvt->filter_index]) {
8556 cvt->filters[cvt->filter_index] (cvt, format);
8557 }
8558 }
8559
8560 static void SDLCALL
8561 SDL_Downsample_S8_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8562 {
8563 #ifdef DEBUG_CONVERT
8564 fprintf(stderr, "Downsample (x4) AUDIO_S8, 6 channels.\n");
8565 #endif
8566
8567 const int srcsize = cvt->len_cvt;
8568 const int dstsize = cvt->len_cvt / 4;
8569 Sint8 *dst = (Sint8 *) cvt->buf;
8570 const Sint8 *src = (Sint8 *) cvt->buf;
8571 const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
8572 Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
8573 Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
8574 Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
8575 Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
8576 Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
8577 Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
8578 while (dst != target) {
8579 const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
8580 const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
8581 const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
8582 const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
8583 const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
8584 const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
8585 src += 24;
8586 dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
8587 dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
8588 dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
8589 dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
8590 dst[4] = (Sint8) ((sample4 + last_sample4) >> 1);
8591 dst[5] = (Sint8) ((sample5 + last_sample5) >> 1);
8592 last_sample0 = sample0;
8593 last_sample1 = sample1;
8594 last_sample2 = sample2;
8595 last_sample3 = sample3;
8596 last_sample4 = sample4;
8597 last_sample5 = sample5;
8598 dst += 6;
8599 }
8600
8601 cvt->len_cvt = dstsize;
8602 if (cvt->filters[++cvt->filter_index]) {
8603 cvt->filters[cvt->filter_index] (cvt, format);
8604 }
8605 }
8606
8607 static void SDLCALL
8608 SDL_Upsample_S8_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8609 {
8610 #ifdef DEBUG_CONVERT
8611 fprintf(stderr, "Upsample (x2) AUDIO_S8, 8 channels.\n");
8612 #endif
8613
8614 const int srcsize = cvt->len_cvt;
8615 const int dstsize = cvt->len_cvt * 2;
8616 Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 8;
8617 const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 8;
8618 const Sint8 *target = ((const Sint8 *) cvt->buf) - 8;
8619 Sint16 last_sample7 = (Sint16) ((Sint8) src[7]);
8620 Sint16 last_sample6 = (Sint16) ((Sint8) src[6]);
8621 Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
8622 Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
8623 Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
8624 Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
8625 Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
8626 Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
8627 while (dst != target) {
8628 const Sint16 sample7 = (Sint16) ((Sint8) src[7]);
8629 const Sint16 sample6 = (Sint16) ((Sint8) src[6]);
8630 const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
8631 const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
8632 const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
8633 const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
8634 const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
8635 const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
8636 src -= 8;
8637 dst[15] = (Sint8) ((sample7 + last_sample7) >> 1);
8638 dst[14] = (Sint8) ((sample6 + last_sample6) >> 1);
8639 dst[13] = (Sint8) ((sample5 + last_sample5) >> 1);
8640 dst[12] = (Sint8) ((sample4 + last_sample4) >> 1);
8641 dst[11] = (Sint8) ((sample3 + last_sample3) >> 1);
8642 dst[10] = (Sint8) ((sample2 + last_sample2) >> 1);
8643 dst[9] = (Sint8) ((sample1 + last_sample1) >> 1);
8644 dst[8] = (Sint8) ((sample0 + last_sample0) >> 1);
8645 dst[7] = (Sint8) sample7;
8646 dst[6] = (Sint8) sample6;
8647 dst[5] = (Sint8) sample5;
8648 dst[4] = (Sint8) sample4;
8649 dst[3] = (Sint8) sample3;
8650 dst[2] = (Sint8) sample2;
8651 dst[1] = (Sint8) sample1;
8652 dst[0] = (Sint8) sample0;
8653 last_sample7 = sample7;
8654 last_sample6 = sample6;
8655 last_sample5 = sample5;
8656 last_sample4 = sample4;
8657 last_sample3 = sample3;
8658 last_sample2 = sample2;
8659 last_sample1 = sample1;
8660 last_sample0 = sample0;
8661 dst -= 16;
8662 }
8663
8664 cvt->len_cvt = dstsize;
8665 if (cvt->filters[++cvt->filter_index]) {
8666 cvt->filters[cvt->filter_index] (cvt, format);
8667 }
8668 }
8669
8670 static void SDLCALL
8671 SDL_Downsample_S8_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8672 {
8673 #ifdef DEBUG_CONVERT
8674 fprintf(stderr, "Downsample (x2) AUDIO_S8, 8 channels.\n");
8675 #endif
8676
8677 const int srcsize = cvt->len_cvt;
8678 const int dstsize = cvt->len_cvt / 2;
8679 Sint8 *dst = (Sint8 *) cvt->buf;
8680 const Sint8 *src = (Sint8 *) cvt->buf;
8681 const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
8682 Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
8683 Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
8684 Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
8685 Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
8686 Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
8687 Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
8688 Sint16 last_sample6 = (Sint16) ((Sint8) src[6]);
8689 Sint16 last_sample7 = (Sint16) ((Sint8) src[7]);
8690 while (dst != target) {
8691 const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
8692 const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
8693 const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
8694 const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
8695 const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
8696 const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
8697 const Sint16 sample6 = (Sint16) ((Sint8) src[6]);
8698 const Sint16 sample7 = (Sint16) ((Sint8) src[7]);
8699 src += 16;
8700 dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
8701 dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
8702 dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
8703 dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
8704 dst[4] = (Sint8) ((sample4 + last_sample4) >> 1);
8705 dst[5] = (Sint8) ((sample5 + last_sample5) >> 1);
8706 dst[6] = (Sint8) ((sample6 + last_sample6) >> 1);
8707 dst[7] = (Sint8) ((sample7 + last_sample7) >> 1);
8708 last_sample0 = sample0;
8709 last_sample1 = sample1;
8710 last_sample2 = sample2;
8711 last_sample3 = sample3;
8712 last_sample4 = sample4;
8713 last_sample5 = sample5;
8714 last_sample6 = sample6;
8715 last_sample7 = sample7;
8716 dst += 8;
8717 }
8718
8719 cvt->len_cvt = dstsize;
8720 if (cvt->filters[++cvt->filter_index]) {
8721 cvt->filters[cvt->filter_index] (cvt, format);
8722 }
8723 }
8724
8725 static void SDLCALL
8726 SDL_Upsample_S8_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8727 {
8728 #ifdef DEBUG_CONVERT
8729 fprintf(stderr, "Upsample (x4) AUDIO_S8, 8 channels.\n");
8730 #endif
8731
8732 const int srcsize = cvt->len_cvt;
8733 const int dstsize = cvt->len_cvt * 4;
8734 Sint8 *dst = ((Sint8 *) (cvt->buf + dstsize)) - 8;
8735 const Sint8 *src = ((Sint8 *) (cvt->buf + cvt->len_cvt)) - 8;
8736 const Sint8 *target = ((const Sint8 *) cvt->buf) - 8;
8737 Sint16 last_sample7 = (Sint16) ((Sint8) src[7]);
8738 Sint16 last_sample6 = (Sint16) ((Sint8) src[6]);
8739 Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
8740 Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
8741 Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
8742 Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
8743 Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
8744 Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
8745 while (dst != target) {
8746 const Sint16 sample7 = (Sint16) ((Sint8) src[7]);
8747 const Sint16 sample6 = (Sint16) ((Sint8) src[6]);
8748 const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
8749 const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
8750 const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
8751 const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
8752 const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
8753 const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
8754 src -= 8;
8755 dst[31] = (Sint8) sample7;
8756 dst[30] = (Sint8) sample6;
8757 dst[29] = (Sint8) sample5;
8758 dst[28] = (Sint8) sample4;
8759 dst[27] = (Sint8) sample3;
8760 dst[26] = (Sint8) sample2;
8761 dst[25] = (Sint8) sample1;
8762 dst[24] = (Sint8) sample0;
8763 dst[23] = (Sint8) (((3 * sample7) + last_sample7) >> 2);
8764 dst[22] = (Sint8) (((3 * sample6) + last_sample6) >> 2);
8765 dst[21] = (Sint8) (((3 * sample5) + last_sample5) >> 2);
8766 dst[20] = (Sint8) (((3 * sample4) + last_sample4) >> 2);
8767 dst[19] = (Sint8) (((3 * sample3) + last_sample3) >> 2);
8768 dst[18] = (Sint8) (((3 * sample2) + last_sample2) >> 2);
8769 dst[17] = (Sint8) (((3 * sample1) + last_sample1) >> 2);
8770 dst[16] = (Sint8) (((3 * sample0) + last_sample0) >> 2);
8771 dst[15] = (Sint8) ((sample7 + last_sample7) >> 1);
8772 dst[14] = (Sint8) ((sample6 + last_sample6) >> 1);
8773 dst[13] = (Sint8) ((sample5 + last_sample5) >> 1);
8774 dst[12] = (Sint8) ((sample4 + last_sample4) >> 1);
8775 dst[11] = (Sint8) ((sample3 + last_sample3) >> 1);
8776 dst[10] = (Sint8) ((sample2 + last_sample2) >> 1);
8777 dst[9] = (Sint8) ((sample1 + last_sample1) >> 1);
8778 dst[8] = (Sint8) ((sample0 + last_sample0) >> 1);
8779 dst[7] = (Sint8) ((sample7 + (3 * last_sample7)) >> 2);
8780 dst[6] = (Sint8) ((sample6 + (3 * last_sample6)) >> 2);
8781 dst[5] = (Sint8) ((sample5 + (3 * last_sample5)) >> 2);
8782 dst[4] = (Sint8) ((sample4 + (3 * last_sample4)) >> 2);
8783 dst[3] = (Sint8) ((sample3 + (3 * last_sample3)) >> 2);
8784 dst[2] = (Sint8) ((sample2 + (3 * last_sample2)) >> 2);
8785 dst[1] = (Sint8) ((sample1 + (3 * last_sample1)) >> 2);
8786 dst[0] = (Sint8) ((sample0 + (3 * last_sample0)) >> 2);
8787 last_sample7 = sample7;
8788 last_sample6 = sample6;
8789 last_sample5 = sample5;
8790 last_sample4 = sample4;
8791 last_sample3 = sample3;
8792 last_sample2 = sample2;
8793 last_sample1 = sample1;
8794 last_sample0 = sample0;
8795 dst -= 32;
8796 }
8797
8798 cvt->len_cvt = dstsize;
8799 if (cvt->filters[++cvt->filter_index]) {
8800 cvt->filters[cvt->filter_index] (cvt, format);
8801 }
8802 }
8803
8804 static void SDLCALL
8805 SDL_Downsample_S8_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8806 {
8807 #ifdef DEBUG_CONVERT
8808 fprintf(stderr, "Downsample (x4) AUDIO_S8, 8 channels.\n");
8809 #endif
8810
8811 const int srcsize = cvt->len_cvt;
8812 const int dstsize = cvt->len_cvt / 4;
8813 Sint8 *dst = (Sint8 *) cvt->buf;
8814 const Sint8 *src = (Sint8 *) cvt->buf;
8815 const Sint8 *target = (const Sint8 *) (cvt->buf + dstsize);
8816 Sint16 last_sample0 = (Sint16) ((Sint8) src[0]);
8817 Sint16 last_sample1 = (Sint16) ((Sint8) src[1]);
8818 Sint16 last_sample2 = (Sint16) ((Sint8) src[2]);
8819 Sint16 last_sample3 = (Sint16) ((Sint8) src[3]);
8820 Sint16 last_sample4 = (Sint16) ((Sint8) src[4]);
8821 Sint16 last_sample5 = (Sint16) ((Sint8) src[5]);
8822 Sint16 last_sample6 = (Sint16) ((Sint8) src[6]);
8823 Sint16 last_sample7 = (Sint16) ((Sint8) src[7]);
8824 while (dst != target) {
8825 const Sint16 sample0 = (Sint16) ((Sint8) src[0]);
8826 const Sint16 sample1 = (Sint16) ((Sint8) src[1]);
8827 const Sint16 sample2 = (Sint16) ((Sint8) src[2]);
8828 const Sint16 sample3 = (Sint16) ((Sint8) src[3]);
8829 const Sint16 sample4 = (Sint16) ((Sint8) src[4]);
8830 const Sint16 sample5 = (Sint16) ((Sint8) src[5]);
8831 const Sint16 sample6 = (Sint16) ((Sint8) src[6]);
8832 const Sint16 sample7 = (Sint16) ((Sint8) src[7]);
8833 src += 32;
8834 dst[0] = (Sint8) ((sample0 + last_sample0) >> 1);
8835 dst[1] = (Sint8) ((sample1 + last_sample1) >> 1);
8836 dst[2] = (Sint8) ((sample2 + last_sample2) >> 1);
8837 dst[3] = (Sint8) ((sample3 + last_sample3) >> 1);
8838 dst[4] = (Sint8) ((sample4 + last_sample4) >> 1);
8839 dst[5] = (Sint8) ((sample5 + last_sample5) >> 1);
8840 dst[6] = (Sint8) ((sample6 + last_sample6) >> 1);
8841 dst[7] = (Sint8) ((sample7 + last_sample7) >> 1);
8842 last_sample0 = sample0;
8843 last_sample1 = sample1;
8844 last_sample2 = sample2;
8845 last_sample3 = sample3;
8846 last_sample4 = sample4;
8847 last_sample5 = sample5;
8848 last_sample6 = sample6;
8849 last_sample7 = sample7;
8850 dst += 8;
8851 }
8852
8853 cvt->len_cvt = dstsize;
8854 if (cvt->filters[++cvt->filter_index]) {
8855 cvt->filters[cvt->filter_index] (cvt, format);
8856 }
8857 }
8858
8859 static void SDLCALL
8860 SDL_Upsample_U16LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8861 {
8862 #ifdef DEBUG_CONVERT
8863 fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 1 channels.\n");
8864 #endif
8865
8866 const int srcsize = cvt->len_cvt;
8867 const int dstsize = cvt->len_cvt * 2;
8868 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1;
8869 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
8870 const Uint16 *target = ((const Uint16 *) cvt->buf) - 1;
8871 Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
8872 while (dst != target) {
8873 const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
8874 src--;
8875 dst[1] = (Uint16) ((sample0 + last_sample0) >> 1);
8876 dst[0] = (Uint16) sample0;
8877 last_sample0 = sample0;
8878 dst -= 2;
8879 }
8880
8881 cvt->len_cvt = dstsize;
8882 if (cvt->filters[++cvt->filter_index]) {
8883 cvt->filters[cvt->filter_index] (cvt, format);
8884 }
8885 }
8886
8887 static void SDLCALL
8888 SDL_Downsample_U16LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8889 {
8890 #ifdef DEBUG_CONVERT
8891 fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 1 channels.\n");
8892 #endif
8893
8894 const int srcsize = cvt->len_cvt;
8895 const int dstsize = cvt->len_cvt / 2;
8896 Uint16 *dst = (Uint16 *) cvt->buf;
8897 const Uint16 *src = (Uint16 *) cvt->buf;
8898 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
8899 Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
8900 while (dst != target) {
8901 const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
8902 src += 2;
8903 dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
8904 last_sample0 = sample0;
8905 dst++;
8906 }
8907
8908 cvt->len_cvt = dstsize;
8909 if (cvt->filters[++cvt->filter_index]) {
8910 cvt->filters[cvt->filter_index] (cvt, format);
8911 }
8912 }
8913
8914 static void SDLCALL
8915 SDL_Upsample_U16LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8916 {
8917 #ifdef DEBUG_CONVERT
8918 fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 1 channels.\n");
8919 #endif
8920
8921 const int srcsize = cvt->len_cvt;
8922 const int dstsize = cvt->len_cvt * 4;
8923 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1;
8924 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
8925 const Uint16 *target = ((const Uint16 *) cvt->buf) - 1;
8926 Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
8927 while (dst != target) {
8928 const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
8929 src--;
8930 dst[3] = (Uint16) sample0;
8931 dst[2] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
8932 dst[1] = (Uint16) ((sample0 + last_sample0) >> 1);
8933 dst[0] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
8934 last_sample0 = sample0;
8935 dst -= 4;
8936 }
8937
8938 cvt->len_cvt = dstsize;
8939 if (cvt->filters[++cvt->filter_index]) {
8940 cvt->filters[cvt->filter_index] (cvt, format);
8941 }
8942 }
8943
8944 static void SDLCALL
8945 SDL_Downsample_U16LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8946 {
8947 #ifdef DEBUG_CONVERT
8948 fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 1 channels.\n");
8949 #endif
8950
8951 const int srcsize = cvt->len_cvt;
8952 const int dstsize = cvt->len_cvt / 4;
8953 Uint16 *dst = (Uint16 *) cvt->buf;
8954 const Uint16 *src = (Uint16 *) cvt->buf;
8955 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
8956 Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
8957 while (dst != target) {
8958 const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
8959 src += 4;
8960 dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
8961 last_sample0 = sample0;
8962 dst++;
8963 }
8964
8965 cvt->len_cvt = dstsize;
8966 if (cvt->filters[++cvt->filter_index]) {
8967 cvt->filters[cvt->filter_index] (cvt, format);
8968 }
8969 }
8970
8971 static void SDLCALL
8972 SDL_Upsample_U16LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
8973 {
8974 #ifdef DEBUG_CONVERT
8975 fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 2 channels.\n");
8976 #endif
8977
8978 const int srcsize = cvt->len_cvt;
8979 const int dstsize = cvt->len_cvt * 2;
8980 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2;
8981 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
8982 const Uint16 *target = ((const Uint16 *) cvt->buf) - 2;
8983 Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
8984 Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
8985 while (dst != target) {
8986 const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
8987 const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
8988 src -= 2;
8989 dst[3] = (Uint16) ((sample1 + last_sample1) >> 1);
8990 dst[2] = (Uint16) ((sample0 + last_sample0) >> 1);
8991 dst[1] = (Uint16) sample1;
8992 dst[0] = (Uint16) sample0;
8993 last_sample1 = sample1;
8994 last_sample0 = sample0;
8995 dst -= 4;
8996 }
8997
8998 cvt->len_cvt = dstsize;
8999 if (cvt->filters[++cvt->filter_index]) {
9000 cvt->filters[cvt->filter_index] (cvt, format);
9001 }
9002 }
9003
9004 static void SDLCALL
9005 SDL_Downsample_U16LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9006 {
9007 #ifdef DEBUG_CONVERT
9008 fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 2 channels.\n");
9009 #endif
9010
9011 const int srcsize = cvt->len_cvt;
9012 const int dstsize = cvt->len_cvt / 2;
9013 Uint16 *dst = (Uint16 *) cvt->buf;
9014 const Uint16 *src = (Uint16 *) cvt->buf;
9015 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
9016 Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
9017 Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
9018 while (dst != target) {
9019 const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
9020 const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
9021 src += 4;
9022 dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
9023 dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
9024 last_sample0 = sample0;
9025 last_sample1 = sample1;
9026 dst += 2;
9027 }
9028
9029 cvt->len_cvt = dstsize;
9030 if (cvt->filters[++cvt->filter_index]) {
9031 cvt->filters[cvt->filter_index] (cvt, format);
9032 }
9033 }
9034
9035 static void SDLCALL
9036 SDL_Upsample_U16LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9037 {
9038 #ifdef DEBUG_CONVERT
9039 fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 2 channels.\n");
9040 #endif
9041
9042 const int srcsize = cvt->len_cvt;
9043 const int dstsize = cvt->len_cvt * 4;
9044 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2;
9045 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
9046 const Uint16 *target = ((const Uint16 *) cvt->buf) - 2;
9047 Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
9048 Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
9049 while (dst != target) {
9050 const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
9051 const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
9052 src -= 2;
9053 dst[7] = (Uint16) sample1;
9054 dst[6] = (Uint16) sample0;
9055 dst[5] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
9056 dst[4] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
9057 dst[3] = (Uint16) ((sample1 + last_sample1) >> 1);
9058 dst[2] = (Uint16) ((sample0 + last_sample0) >> 1);
9059 dst[1] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
9060 dst[0] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
9061 last_sample1 = sample1;
9062 last_sample0 = sample0;
9063 dst -= 8;
9064 }
9065
9066 cvt->len_cvt = dstsize;
9067 if (cvt->filters[++cvt->filter_index]) {
9068 cvt->filters[cvt->filter_index] (cvt, format);
9069 }
9070 }
9071
9072 static void SDLCALL
9073 SDL_Downsample_U16LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9074 {
9075 #ifdef DEBUG_CONVERT
9076 fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 2 channels.\n");
9077 #endif
9078
9079 const int srcsize = cvt->len_cvt;
9080 const int dstsize = cvt->len_cvt / 4;
9081 Uint16 *dst = (Uint16 *) cvt->buf;
9082 const Uint16 *src = (Uint16 *) cvt->buf;
9083 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
9084 Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
9085 Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
9086 while (dst != target) {
9087 const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
9088 const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
9089 src += 8;
9090 dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
9091 dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
9092 last_sample0 = sample0;
9093 last_sample1 = sample1;
9094 dst += 2;
9095 }
9096
9097 cvt->len_cvt = dstsize;
9098 if (cvt->filters[++cvt->filter_index]) {
9099 cvt->filters[cvt->filter_index] (cvt, format);
9100 }
9101 }
9102
9103 static void SDLCALL
9104 SDL_Upsample_U16LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9105 {
9106 #ifdef DEBUG_CONVERT
9107 fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 4 channels.\n");
9108 #endif
9109
9110 const int srcsize = cvt->len_cvt;
9111 const int dstsize = cvt->len_cvt * 2;
9112 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4;
9113 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
9114 const Uint16 *target = ((const Uint16 *) cvt->buf) - 4;
9115 Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
9116 Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
9117 Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
9118 Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
9119 while (dst != target) {
9120 const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
9121 const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
9122 const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
9123 const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
9124 src -= 4;
9125 dst[7] = (Uint16) ((sample3 + last_sample3) >> 1);
9126 dst[6] = (Uint16) ((sample2 + last_sample2) >> 1);
9127 dst[5] = (Uint16) ((sample1 + last_sample1) >> 1);
9128 dst[4] = (Uint16) ((sample0 + last_sample0) >> 1);
9129 dst[3] = (Uint16) sample3;
9130 dst[2] = (Uint16) sample2;
9131 dst[1] = (Uint16) sample1;
9132 dst[0] = (Uint16) sample0;
9133 last_sample3 = sample3;
9134 last_sample2 = sample2;
9135 last_sample1 = sample1;
9136 last_sample0 = sample0;
9137 dst -= 8;
9138 }
9139
9140 cvt->len_cvt = dstsize;
9141 if (cvt->filters[++cvt->filter_index]) {
9142 cvt->filters[cvt->filter_index] (cvt, format);
9143 }
9144 }
9145
9146 static void SDLCALL
9147 SDL_Downsample_U16LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9148 {
9149 #ifdef DEBUG_CONVERT
9150 fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 4 channels.\n");
9151 #endif
9152
9153 const int srcsize = cvt->len_cvt;
9154 const int dstsize = cvt->len_cvt / 2;
9155 Uint16 *dst = (Uint16 *) cvt->buf;
9156 const Uint16 *src = (Uint16 *) cvt->buf;
9157 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
9158 Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
9159 Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
9160 Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
9161 Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
9162 while (dst != target) {
9163 const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
9164 const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
9165 const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
9166 const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
9167 src += 8;
9168 dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
9169 dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
9170 dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
9171 dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
9172 last_sample0 = sample0;
9173 last_sample1 = sample1;
9174 last_sample2 = sample2;
9175 last_sample3 = sample3;
9176 dst += 4;
9177 }
9178
9179 cvt->len_cvt = dstsize;
9180 if (cvt->filters[++cvt->filter_index]) {
9181 cvt->filters[cvt->filter_index] (cvt, format);
9182 }
9183 }
9184
9185 static void SDLCALL
9186 SDL_Upsample_U16LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9187 {
9188 #ifdef DEBUG_CONVERT
9189 fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 4 channels.\n");
9190 #endif
9191
9192 const int srcsize = cvt->len_cvt;
9193 const int dstsize = cvt->len_cvt * 4;
9194 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4;
9195 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
9196 const Uint16 *target = ((const Uint16 *) cvt->buf) - 4;
9197 Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
9198 Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
9199 Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
9200 Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
9201 while (dst != target) {
9202 const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
9203 const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
9204 const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
9205 const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
9206 src -= 4;
9207 dst[15] = (Uint16) sample3;
9208 dst[14] = (Uint16) sample2;
9209 dst[13] = (Uint16) sample1;
9210 dst[12] = (Uint16) sample0;
9211 dst[11] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
9212 dst[10] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
9213 dst[9] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
9214 dst[8] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
9215 dst[7] = (Uint16) ((sample3 + last_sample3) >> 1);
9216 dst[6] = (Uint16) ((sample2 + last_sample2) >> 1);
9217 dst[5] = (Uint16) ((sample1 + last_sample1) >> 1);
9218 dst[4] = (Uint16) ((sample0 + last_sample0) >> 1);
9219 dst[3] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
9220 dst[2] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
9221 dst[1] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
9222 dst[0] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
9223 last_sample3 = sample3;
9224 last_sample2 = sample2;
9225 last_sample1 = sample1;
9226 last_sample0 = sample0;
9227 dst -= 16;
9228 }
9229
9230 cvt->len_cvt = dstsize;
9231 if (cvt->filters[++cvt->filter_index]) {
9232 cvt->filters[cvt->filter_index] (cvt, format);
9233 }
9234 }
9235
9236 static void SDLCALL
9237 SDL_Downsample_U16LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9238 {
9239 #ifdef DEBUG_CONVERT
9240 fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 4 channels.\n");
9241 #endif
9242
9243 const int srcsize = cvt->len_cvt;
9244 const int dstsize = cvt->len_cvt / 4;
9245 Uint16 *dst = (Uint16 *) cvt->buf;
9246 const Uint16 *src = (Uint16 *) cvt->buf;
9247 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
9248 Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
9249 Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
9250 Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
9251 Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
9252 while (dst != target) {
9253 const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
9254 const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
9255 const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
9256 const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
9257 src += 16;
9258 dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
9259 dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
9260 dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
9261 dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
9262 last_sample0 = sample0;
9263 last_sample1 = sample1;
9264 last_sample2 = sample2;
9265 last_sample3 = sample3;
9266 dst += 4;
9267 }
9268
9269 cvt->len_cvt = dstsize;
9270 if (cvt->filters[++cvt->filter_index]) {
9271 cvt->filters[cvt->filter_index] (cvt, format);
9272 }
9273 }
9274
9275 static void SDLCALL
9276 SDL_Upsample_U16LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9277 {
9278 #ifdef DEBUG_CONVERT
9279 fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 6 channels.\n");
9280 #endif
9281
9282 const int srcsize = cvt->len_cvt;
9283 const int dstsize = cvt->len_cvt * 2;
9284 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6;
9285 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
9286 const Uint16 *target = ((const Uint16 *) cvt->buf) - 6;
9287 Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
9288 Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
9289 Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
9290 Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
9291 Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
9292 Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
9293 while (dst != target) {
9294 const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
9295 const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
9296 const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
9297 const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
9298 const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
9299 const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
9300 src -= 6;
9301 dst[11] = (Uint16) ((sample5 + last_sample5) >> 1);
9302 dst[10] = (Uint16) ((sample4 + last_sample4) >> 1);
9303 dst[9] = (Uint16) ((sample3 + last_sample3) >> 1);
9304 dst[8] = (Uint16) ((sample2 + last_sample2) >> 1);
9305 dst[7] = (Uint16) ((sample1 + last_sample1) >> 1);
9306 dst[6] = (Uint16) ((sample0 + last_sample0) >> 1);
9307 dst[5] = (Uint16) sample5;
9308 dst[4] = (Uint16) sample4;
9309 dst[3] = (Uint16) sample3;
9310 dst[2] = (Uint16) sample2;
9311 dst[1] = (Uint16) sample1;
9312 dst[0] = (Uint16) sample0;
9313 last_sample5 = sample5;
9314 last_sample4 = sample4;
9315 last_sample3 = sample3;
9316 last_sample2 = sample2;
9317 last_sample1 = sample1;
9318 last_sample0 = sample0;
9319 dst -= 12;
9320 }
9321
9322 cvt->len_cvt = dstsize;
9323 if (cvt->filters[++cvt->filter_index]) {
9324 cvt->filters[cvt->filter_index] (cvt, format);
9325 }
9326 }
9327
9328 static void SDLCALL
9329 SDL_Downsample_U16LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9330 {
9331 #ifdef DEBUG_CONVERT
9332 fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 6 channels.\n");
9333 #endif
9334
9335 const int srcsize = cvt->len_cvt;
9336 const int dstsize = cvt->len_cvt / 2;
9337 Uint16 *dst = (Uint16 *) cvt->buf;
9338 const Uint16 *src = (Uint16 *) cvt->buf;
9339 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
9340 Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
9341 Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
9342 Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
9343 Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
9344 Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
9345 Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
9346 while (dst != target) {
9347 const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
9348 const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
9349 const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
9350 const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
9351 const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
9352 const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
9353 src += 12;
9354 dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
9355 dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
9356 dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
9357 dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
9358 dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
9359 dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
9360 last_sample0 = sample0;
9361 last_sample1 = sample1;
9362 last_sample2 = sample2;
9363 last_sample3 = sample3;
9364 last_sample4 = sample4;
9365 last_sample5 = sample5;
9366 dst += 6;
9367 }
9368
9369 cvt->len_cvt = dstsize;
9370 if (cvt->filters[++cvt->filter_index]) {
9371 cvt->filters[cvt->filter_index] (cvt, format);
9372 }
9373 }
9374
9375 static void SDLCALL
9376 SDL_Upsample_U16LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9377 {
9378 #ifdef DEBUG_CONVERT
9379 fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 6 channels.\n");
9380 #endif
9381
9382 const int srcsize = cvt->len_cvt;
9383 const int dstsize = cvt->len_cvt * 4;
9384 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6;
9385 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
9386 const Uint16 *target = ((const Uint16 *) cvt->buf) - 6;
9387 Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
9388 Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
9389 Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
9390 Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
9391 Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
9392 Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
9393 while (dst != target) {
9394 const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
9395 const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
9396 const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
9397 const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
9398 const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
9399 const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
9400 src -= 6;
9401 dst[23] = (Uint16) sample5;
9402 dst[22] = (Uint16) sample4;
9403 dst[21] = (Uint16) sample3;
9404 dst[20] = (Uint16) sample2;
9405 dst[19] = (Uint16) sample1;
9406 dst[18] = (Uint16) sample0;
9407 dst[17] = (Uint16) (((3 * sample5) + last_sample5) >> 2);
9408 dst[16] = (Uint16) (((3 * sample4) + last_sample4) >> 2);
9409 dst[15] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
9410 dst[14] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
9411 dst[13] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
9412 dst[12] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
9413 dst[11] = (Uint16) ((sample5 + last_sample5) >> 1);
9414 dst[10] = (Uint16) ((sample4 + last_sample4) >> 1);
9415 dst[9] = (Uint16) ((sample3 + last_sample3) >> 1);
9416 dst[8] = (Uint16) ((sample2 + last_sample2) >> 1);
9417 dst[7] = (Uint16) ((sample1 + last_sample1) >> 1);
9418 dst[6] = (Uint16) ((sample0 + last_sample0) >> 1);
9419 dst[5] = (Uint16) ((sample5 + (3 * last_sample5)) >> 2);
9420 dst[4] = (Uint16) ((sample4 + (3 * last_sample4)) >> 2);
9421 dst[3] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
9422 dst[2] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
9423 dst[1] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
9424 dst[0] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
9425 last_sample5 = sample5;
9426 last_sample4 = sample4;
9427 last_sample3 = sample3;
9428 last_sample2 = sample2;
9429 last_sample1 = sample1;
9430 last_sample0 = sample0;
9431 dst -= 24;
9432 }
9433
9434 cvt->len_cvt = dstsize;
9435 if (cvt->filters[++cvt->filter_index]) {
9436 cvt->filters[cvt->filter_index] (cvt, format);
9437 }
9438 }
9439
9440 static void SDLCALL
9441 SDL_Downsample_U16LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9442 {
9443 #ifdef DEBUG_CONVERT
9444 fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 6 channels.\n");
9445 #endif
9446
9447 const int srcsize = cvt->len_cvt;
9448 const int dstsize = cvt->len_cvt / 4;
9449 Uint16 *dst = (Uint16 *) cvt->buf;
9450 const Uint16 *src = (Uint16 *) cvt->buf;
9451 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
9452 Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
9453 Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
9454 Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
9455 Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
9456 Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
9457 Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
9458 while (dst != target) {
9459 const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
9460 const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
9461 const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
9462 const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
9463 const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
9464 const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
9465 src += 24;
9466 dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
9467 dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
9468 dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
9469 dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
9470 dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
9471 dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
9472 last_sample0 = sample0;
9473 last_sample1 = sample1;
9474 last_sample2 = sample2;
9475 last_sample3 = sample3;
9476 last_sample4 = sample4;
9477 last_sample5 = sample5;
9478 dst += 6;
9479 }
9480
9481 cvt->len_cvt = dstsize;
9482 if (cvt->filters[++cvt->filter_index]) {
9483 cvt->filters[cvt->filter_index] (cvt, format);
9484 }
9485 }
9486
9487 static void SDLCALL
9488 SDL_Upsample_U16LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9489 {
9490 #ifdef DEBUG_CONVERT
9491 fprintf(stderr, "Upsample (x2) AUDIO_U16LSB, 8 channels.\n");
9492 #endif
9493
9494 const int srcsize = cvt->len_cvt;
9495 const int dstsize = cvt->len_cvt * 2;
9496 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8;
9497 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
9498 const Uint16 *target = ((const Uint16 *) cvt->buf) - 8;
9499 Sint32 last_sample7 = (Sint32) SDL_SwapLE16(src[7]);
9500 Sint32 last_sample6 = (Sint32) SDL_SwapLE16(src[6]);
9501 Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
9502 Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
9503 Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
9504 Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
9505 Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
9506 Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
9507 while (dst != target) {
9508 const Sint32 sample7 = (Sint32) SDL_SwapLE16(src[7]);
9509 const Sint32 sample6 = (Sint32) SDL_SwapLE16(src[6]);
9510 const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
9511 const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
9512 const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
9513 const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
9514 const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
9515 const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
9516 src -= 8;
9517 dst[15] = (Uint16) ((sample7 + last_sample7) >> 1);
9518 dst[14] = (Uint16) ((sample6 + last_sample6) >> 1);
9519 dst[13] = (Uint16) ((sample5 + last_sample5) >> 1);
9520 dst[12] = (Uint16) ((sample4 + last_sample4) >> 1);
9521 dst[11] = (Uint16) ((sample3 + last_sample3) >> 1);
9522 dst[10] = (Uint16) ((sample2 + last_sample2) >> 1);
9523 dst[9] = (Uint16) ((sample1 + last_sample1) >> 1);
9524 dst[8] = (Uint16) ((sample0 + last_sample0) >> 1);
9525 dst[7] = (Uint16) sample7;
9526 dst[6] = (Uint16) sample6;
9527 dst[5] = (Uint16) sample5;
9528 dst[4] = (Uint16) sample4;
9529 dst[3] = (Uint16) sample3;
9530 dst[2] = (Uint16) sample2;
9531 dst[1] = (Uint16) sample1;
9532 dst[0] = (Uint16) sample0;
9533 last_sample7 = sample7;
9534 last_sample6 = sample6;
9535 last_sample5 = sample5;
9536 last_sample4 = sample4;
9537 last_sample3 = sample3;
9538 last_sample2 = sample2;
9539 last_sample1 = sample1;
9540 last_sample0 = sample0;
9541 dst -= 16;
9542 }
9543
9544 cvt->len_cvt = dstsize;
9545 if (cvt->filters[++cvt->filter_index]) {
9546 cvt->filters[cvt->filter_index] (cvt, format);
9547 }
9548 }
9549
9550 static void SDLCALL
9551 SDL_Downsample_U16LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9552 {
9553 #ifdef DEBUG_CONVERT
9554 fprintf(stderr, "Downsample (x2) AUDIO_U16LSB, 8 channels.\n");
9555 #endif
9556
9557 const int srcsize = cvt->len_cvt;
9558 const int dstsize = cvt->len_cvt / 2;
9559 Uint16 *dst = (Uint16 *) cvt->buf;
9560 const Uint16 *src = (Uint16 *) cvt->buf;
9561 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
9562 Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
9563 Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
9564 Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
9565 Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
9566 Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
9567 Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
9568 Sint32 last_sample6 = (Sint32) SDL_SwapLE16(src[6]);
9569 Sint32 last_sample7 = (Sint32) SDL_SwapLE16(src[7]);
9570 while (dst != target) {
9571 const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
9572 const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
9573 const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
9574 const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
9575 const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
9576 const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
9577 const Sint32 sample6 = (Sint32) SDL_SwapLE16(src[6]);
9578 const Sint32 sample7 = (Sint32) SDL_SwapLE16(src[7]);
9579 src += 16;
9580 dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
9581 dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
9582 dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
9583 dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
9584 dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
9585 dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
9586 dst[6] = (Uint16) ((sample6 + last_sample6) >> 1);
9587 dst[7] = (Uint16) ((sample7 + last_sample7) >> 1);
9588 last_sample0 = sample0;
9589 last_sample1 = sample1;
9590 last_sample2 = sample2;
9591 last_sample3 = sample3;
9592 last_sample4 = sample4;
9593 last_sample5 = sample5;
9594 last_sample6 = sample6;
9595 last_sample7 = sample7;
9596 dst += 8;
9597 }
9598
9599 cvt->len_cvt = dstsize;
9600 if (cvt->filters[++cvt->filter_index]) {
9601 cvt->filters[cvt->filter_index] (cvt, format);
9602 }
9603 }
9604
9605 static void SDLCALL
9606 SDL_Upsample_U16LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9607 {
9608 #ifdef DEBUG_CONVERT
9609 fprintf(stderr, "Upsample (x4) AUDIO_U16LSB, 8 channels.\n");
9610 #endif
9611
9612 const int srcsize = cvt->len_cvt;
9613 const int dstsize = cvt->len_cvt * 4;
9614 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8;
9615 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
9616 const Uint16 *target = ((const Uint16 *) cvt->buf) - 8;
9617 Sint32 last_sample7 = (Sint32) SDL_SwapLE16(src[7]);
9618 Sint32 last_sample6 = (Sint32) SDL_SwapLE16(src[6]);
9619 Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
9620 Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
9621 Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
9622 Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
9623 Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
9624 Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
9625 while (dst != target) {
9626 const Sint32 sample7 = (Sint32) SDL_SwapLE16(src[7]);
9627 const Sint32 sample6 = (Sint32) SDL_SwapLE16(src[6]);
9628 const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
9629 const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
9630 const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
9631 const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
9632 const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
9633 const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
9634 src -= 8;
9635 dst[31] = (Uint16) sample7;
9636 dst[30] = (Uint16) sample6;
9637 dst[29] = (Uint16) sample5;
9638 dst[28] = (Uint16) sample4;
9639 dst[27] = (Uint16) sample3;
9640 dst[26] = (Uint16) sample2;
9641 dst[25] = (Uint16) sample1;
9642 dst[24] = (Uint16) sample0;
9643 dst[23] = (Uint16) (((3 * sample7) + last_sample7) >> 2);
9644 dst[22] = (Uint16) (((3 * sample6) + last_sample6) >> 2);
9645 dst[21] = (Uint16) (((3 * sample5) + last_sample5) >> 2);
9646 dst[20] = (Uint16) (((3 * sample4) + last_sample4) >> 2);
9647 dst[19] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
9648 dst[18] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
9649 dst[17] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
9650 dst[16] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
9651 dst[15] = (Uint16) ((sample7 + last_sample7) >> 1);
9652 dst[14] = (Uint16) ((sample6 + last_sample6) >> 1);
9653 dst[13] = (Uint16) ((sample5 + last_sample5) >> 1);
9654 dst[12] = (Uint16) ((sample4 + last_sample4) >> 1);
9655 dst[11] = (Uint16) ((sample3 + last_sample3) >> 1);
9656 dst[10] = (Uint16) ((sample2 + last_sample2) >> 1);
9657 dst[9] = (Uint16) ((sample1 + last_sample1) >> 1);
9658 dst[8] = (Uint16) ((sample0 + last_sample0) >> 1);
9659 dst[7] = (Uint16) ((sample7 + (3 * last_sample7)) >> 2);
9660 dst[6] = (Uint16) ((sample6 + (3 * last_sample6)) >> 2);
9661 dst[5] = (Uint16) ((sample5 + (3 * last_sample5)) >> 2);
9662 dst[4] = (Uint16) ((sample4 + (3 * last_sample4)) >> 2);
9663 dst[3] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
9664 dst[2] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
9665 dst[1] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
9666 dst[0] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
9667 last_sample7 = sample7;
9668 last_sample6 = sample6;
9669 last_sample5 = sample5;
9670 last_sample4 = sample4;
9671 last_sample3 = sample3;
9672 last_sample2 = sample2;
9673 last_sample1 = sample1;
9674 last_sample0 = sample0;
9675 dst -= 32;
9676 }
9677
9678 cvt->len_cvt = dstsize;
9679 if (cvt->filters[++cvt->filter_index]) {
9680 cvt->filters[cvt->filter_index] (cvt, format);
9681 }
9682 }
9683
9684 static void SDLCALL
9685 SDL_Downsample_U16LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9686 {
9687 #ifdef DEBUG_CONVERT
9688 fprintf(stderr, "Downsample (x4) AUDIO_U16LSB, 8 channels.\n");
9689 #endif
9690
9691 const int srcsize = cvt->len_cvt;
9692 const int dstsize = cvt->len_cvt / 4;
9693 Uint16 *dst = (Uint16 *) cvt->buf;
9694 const Uint16 *src = (Uint16 *) cvt->buf;
9695 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
9696 Sint32 last_sample0 = (Sint32) SDL_SwapLE16(src[0]);
9697 Sint32 last_sample1 = (Sint32) SDL_SwapLE16(src[1]);
9698 Sint32 last_sample2 = (Sint32) SDL_SwapLE16(src[2]);
9699 Sint32 last_sample3 = (Sint32) SDL_SwapLE16(src[3]);
9700 Sint32 last_sample4 = (Sint32) SDL_SwapLE16(src[4]);
9701 Sint32 last_sample5 = (Sint32) SDL_SwapLE16(src[5]);
9702 Sint32 last_sample6 = (Sint32) SDL_SwapLE16(src[6]);
9703 Sint32 last_sample7 = (Sint32) SDL_SwapLE16(src[7]);
9704 while (dst != target) {
9705 const Sint32 sample0 = (Sint32) SDL_SwapLE16(src[0]);
9706 const Sint32 sample1 = (Sint32) SDL_SwapLE16(src[1]);
9707 const Sint32 sample2 = (Sint32) SDL_SwapLE16(src[2]);
9708 const Sint32 sample3 = (Sint32) SDL_SwapLE16(src[3]);
9709 const Sint32 sample4 = (Sint32) SDL_SwapLE16(src[4]);
9710 const Sint32 sample5 = (Sint32) SDL_SwapLE16(src[5]);
9711 const Sint32 sample6 = (Sint32) SDL_SwapLE16(src[6]);
9712 const Sint32 sample7 = (Sint32) SDL_SwapLE16(src[7]);
9713 src += 32;
9714 dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
9715 dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
9716 dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
9717 dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
9718 dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
9719 dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
9720 dst[6] = (Uint16) ((sample6 + last_sample6) >> 1);
9721 dst[7] = (Uint16) ((sample7 + last_sample7) >> 1);
9722 last_sample0 = sample0;
9723 last_sample1 = sample1;
9724 last_sample2 = sample2;
9725 last_sample3 = sample3;
9726 last_sample4 = sample4;
9727 last_sample5 = sample5;
9728 last_sample6 = sample6;
9729 last_sample7 = sample7;
9730 dst += 8;
9731 }
9732
9733 cvt->len_cvt = dstsize;
9734 if (cvt->filters[++cvt->filter_index]) {
9735 cvt->filters[cvt->filter_index] (cvt, format);
9736 }
9737 }
9738
9739 static void SDLCALL
9740 SDL_Upsample_S16LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9741 {
9742 #ifdef DEBUG_CONVERT
9743 fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 1 channels.\n");
9744 #endif
9745
9746 const int srcsize = cvt->len_cvt;
9747 const int dstsize = cvt->len_cvt * 2;
9748 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1;
9749 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
9750 const Sint16 *target = ((const Sint16 *) cvt->buf) - 1;
9751 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
9752 while (dst != target) {
9753 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
9754 src--;
9755 dst[1] = (Sint16) ((sample0 + last_sample0) >> 1);
9756 dst[0] = (Sint16) sample0;
9757 last_sample0 = sample0;
9758 dst -= 2;
9759 }
9760
9761 cvt->len_cvt = dstsize;
9762 if (cvt->filters[++cvt->filter_index]) {
9763 cvt->filters[cvt->filter_index] (cvt, format);
9764 }
9765 }
9766
9767 static void SDLCALL
9768 SDL_Downsample_S16LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9769 {
9770 #ifdef DEBUG_CONVERT
9771 fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 1 channels.\n");
9772 #endif
9773
9774 const int srcsize = cvt->len_cvt;
9775 const int dstsize = cvt->len_cvt / 2;
9776 Sint16 *dst = (Sint16 *) cvt->buf;
9777 const Sint16 *src = (Sint16 *) cvt->buf;
9778 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
9779 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
9780 while (dst != target) {
9781 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
9782 src += 2;
9783 dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
9784 last_sample0 = sample0;
9785 dst++;
9786 }
9787
9788 cvt->len_cvt = dstsize;
9789 if (cvt->filters[++cvt->filter_index]) {
9790 cvt->filters[cvt->filter_index] (cvt, format);
9791 }
9792 }
9793
9794 static void SDLCALL
9795 SDL_Upsample_S16LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9796 {
9797 #ifdef DEBUG_CONVERT
9798 fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 1 channels.\n");
9799 #endif
9800
9801 const int srcsize = cvt->len_cvt;
9802 const int dstsize = cvt->len_cvt * 4;
9803 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1;
9804 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
9805 const Sint16 *target = ((const Sint16 *) cvt->buf) - 1;
9806 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
9807 while (dst != target) {
9808 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
9809 src--;
9810 dst[3] = (Sint16) sample0;
9811 dst[2] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
9812 dst[1] = (Sint16) ((sample0 + last_sample0) >> 1);
9813 dst[0] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
9814 last_sample0 = sample0;
9815 dst -= 4;
9816 }
9817
9818 cvt->len_cvt = dstsize;
9819 if (cvt->filters[++cvt->filter_index]) {
9820 cvt->filters[cvt->filter_index] (cvt, format);
9821 }
9822 }
9823
9824 static void SDLCALL
9825 SDL_Downsample_S16LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9826 {
9827 #ifdef DEBUG_CONVERT
9828 fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 1 channels.\n");
9829 #endif
9830
9831 const int srcsize = cvt->len_cvt;
9832 const int dstsize = cvt->len_cvt / 4;
9833 Sint16 *dst = (Sint16 *) cvt->buf;
9834 const Sint16 *src = (Sint16 *) cvt->buf;
9835 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
9836 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
9837 while (dst != target) {
9838 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
9839 src += 4;
9840 dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
9841 last_sample0 = sample0;
9842 dst++;
9843 }
9844
9845 cvt->len_cvt = dstsize;
9846 if (cvt->filters[++cvt->filter_index]) {
9847 cvt->filters[cvt->filter_index] (cvt, format);
9848 }
9849 }
9850
9851 static void SDLCALL
9852 SDL_Upsample_S16LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9853 {
9854 #ifdef DEBUG_CONVERT
9855 fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 2 channels.\n");
9856 #endif
9857
9858 const int srcsize = cvt->len_cvt;
9859 const int dstsize = cvt->len_cvt * 2;
9860 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
9861 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
9862 const Sint16 *target = ((const Sint16 *) cvt->buf) - 2;
9863 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
9864 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
9865 while (dst != target) {
9866 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
9867 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
9868 src -= 2;
9869 dst[3] = (Sint16) ((sample1 + last_sample1) >> 1);
9870 dst[2] = (Sint16) ((sample0 + last_sample0) >> 1);
9871 dst[1] = (Sint16) sample1;
9872 dst[0] = (Sint16) sample0;
9873 last_sample1 = sample1;
9874 last_sample0 = sample0;
9875 dst -= 4;
9876 }
9877
9878 cvt->len_cvt = dstsize;
9879 if (cvt->filters[++cvt->filter_index]) {
9880 cvt->filters[cvt->filter_index] (cvt, format);
9881 }
9882 }
9883
9884 static void SDLCALL
9885 SDL_Downsample_S16LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9886 {
9887 #ifdef DEBUG_CONVERT
9888 fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 2 channels.\n");
9889 #endif
9890
9891 const int srcsize = cvt->len_cvt;
9892 const int dstsize = cvt->len_cvt / 2;
9893 Sint16 *dst = (Sint16 *) cvt->buf;
9894 const Sint16 *src = (Sint16 *) cvt->buf;
9895 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
9896 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
9897 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
9898 while (dst != target) {
9899 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
9900 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
9901 src += 4;
9902 dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
9903 dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
9904 last_sample0 = sample0;
9905 last_sample1 = sample1;
9906 dst += 2;
9907 }
9908
9909 cvt->len_cvt = dstsize;
9910 if (cvt->filters[++cvt->filter_index]) {
9911 cvt->filters[cvt->filter_index] (cvt, format);
9912 }
9913 }
9914
9915 static void SDLCALL
9916 SDL_Upsample_S16LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9917 {
9918 #ifdef DEBUG_CONVERT
9919 fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 2 channels.\n");
9920 #endif
9921
9922 const int srcsize = cvt->len_cvt;
9923 const int dstsize = cvt->len_cvt * 4;
9924 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
9925 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
9926 const Sint16 *target = ((const Sint16 *) cvt->buf) - 2;
9927 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
9928 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
9929 while (dst != target) {
9930 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
9931 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
9932 src -= 2;
9933 dst[7] = (Sint16) sample1;
9934 dst[6] = (Sint16) sample0;
9935 dst[5] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
9936 dst[4] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
9937 dst[3] = (Sint16) ((sample1 + last_sample1) >> 1);
9938 dst[2] = (Sint16) ((sample0 + last_sample0) >> 1);
9939 dst[1] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
9940 dst[0] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
9941 last_sample1 = sample1;
9942 last_sample0 = sample0;
9943 dst -= 8;
9944 }
9945
9946 cvt->len_cvt = dstsize;
9947 if (cvt->filters[++cvt->filter_index]) {
9948 cvt->filters[cvt->filter_index] (cvt, format);
9949 }
9950 }
9951
9952 static void SDLCALL
9953 SDL_Downsample_S16LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9954 {
9955 #ifdef DEBUG_CONVERT
9956 fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 2 channels.\n");
9957 #endif
9958
9959 const int srcsize = cvt->len_cvt;
9960 const int dstsize = cvt->len_cvt / 4;
9961 Sint16 *dst = (Sint16 *) cvt->buf;
9962 const Sint16 *src = (Sint16 *) cvt->buf;
9963 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
9964 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
9965 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
9966 while (dst != target) {
9967 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
9968 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
9969 src += 8;
9970 dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
9971 dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
9972 last_sample0 = sample0;
9973 last_sample1 = sample1;
9974 dst += 2;
9975 }
9976
9977 cvt->len_cvt = dstsize;
9978 if (cvt->filters[++cvt->filter_index]) {
9979 cvt->filters[cvt->filter_index] (cvt, format);
9980 }
9981 }
9982
9983 static void SDLCALL
9984 SDL_Upsample_S16LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
9985 {
9986 #ifdef DEBUG_CONVERT
9987 fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 4 channels.\n");
9988 #endif
9989
9990 const int srcsize = cvt->len_cvt;
9991 const int dstsize = cvt->len_cvt * 2;
9992 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4;
9993 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
9994 const Sint16 *target = ((const Sint16 *) cvt->buf) - 4;
9995 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
9996 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
9997 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
9998 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
9999 while (dst != target) {
10000 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
10001 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
10002 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
10003 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
10004 src -= 4;
10005 dst[7] = (Sint16) ((sample3 + last_sample3) >> 1);
10006 dst[6] = (Sint16) ((sample2 + last_sample2) >> 1);
10007 dst[5] = (Sint16) ((sample1 + last_sample1) >> 1);
10008 dst[4] = (Sint16) ((sample0 + last_sample0) >> 1);
10009 dst[3] = (Sint16) sample3;
10010 dst[2] = (Sint16) sample2;
10011 dst[1] = (Sint16) sample1;
10012 dst[0] = (Sint16) sample0;
10013 last_sample3 = sample3;
10014 last_sample2 = sample2;
10015 last_sample1 = sample1;
10016 last_sample0 = sample0;
10017 dst -= 8;
10018 }
10019
10020 cvt->len_cvt = dstsize;
10021 if (cvt->filters[++cvt->filter_index]) {
10022 cvt->filters[cvt->filter_index] (cvt, format);
10023 }
10024 }
10025
10026 static void SDLCALL
10027 SDL_Downsample_S16LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
10028 {
10029 #ifdef DEBUG_CONVERT
10030 fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 4 channels.\n");
10031 #endif
10032
10033 const int srcsize = cvt->len_cvt;
10034 const int dstsize = cvt->len_cvt / 2;
10035 Sint16 *dst = (Sint16 *) cvt->buf;
10036 const Sint16 *src = (Sint16 *) cvt->buf;
10037 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
10038 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
10039 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
10040 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
10041 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
10042 while (dst != target) {
10043 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
10044 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
10045 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
10046 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
10047 src += 8;
10048 dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
10049 dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
10050 dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
10051 dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
10052 last_sample0 = sample0;
10053 last_sample1 = sample1;
10054 last_sample2 = sample2;
10055 last_sample3 = sample3;
10056 dst += 4;
10057 }
10058
10059 cvt->len_cvt = dstsize;
10060 if (cvt->filters[++cvt->filter_index]) {
10061 cvt->filters[cvt->filter_index] (cvt, format);
10062 }
10063 }
10064
10065 static void SDLCALL
10066 SDL_Upsample_S16LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
10067 {
10068 #ifdef DEBUG_CONVERT
10069 fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 4 channels.\n");
10070 #endif
10071
10072 const int srcsize = cvt->len_cvt;
10073 const int dstsize = cvt->len_cvt * 4;
10074 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4;
10075 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
10076 const Sint16 *target = ((const Sint16 *) cvt->buf) - 4;
10077 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
10078 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
10079 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
10080 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
10081 while (dst != target) {
10082 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
10083 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
10084 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
10085 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
10086 src -= 4;
10087 dst[15] = (Sint16) sample3;
10088 dst[14] = (Sint16) sample2;
10089 dst[13] = (Sint16) sample1;
10090 dst[12] = (Sint16) sample0;
10091 dst[11] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
10092 dst[10] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
10093 dst[9] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
10094 dst[8] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
10095 dst[7] = (Sint16) ((sample3 + last_sample3) >> 1);
10096 dst[6] = (Sint16) ((sample2 + last_sample2) >> 1);
10097 dst[5] = (Sint16) ((sample1 + last_sample1) >> 1);
10098 dst[4] = (Sint16) ((sample0 + last_sample0) >> 1);
10099 dst[3] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
10100 dst[2] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
10101 dst[1] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
10102 dst[0] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
10103 last_sample3 = sample3;
10104 last_sample2 = sample2;
10105 last_sample1 = sample1;
10106 last_sample0 = sample0;
10107 dst -= 16;
10108 }
10109
10110 cvt->len_cvt = dstsize;
10111 if (cvt->filters[++cvt->filter_index]) {
10112 cvt->filters[cvt->filter_index] (cvt, format);
10113 }
10114 }
10115
10116 static void SDLCALL
10117 SDL_Downsample_S16LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
10118 {
10119 #ifdef DEBUG_CONVERT
10120 fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 4 channels.\n");
10121 #endif
10122
10123 const int srcsize = cvt->len_cvt;
10124 const int dstsize = cvt->len_cvt / 4;
10125 Sint16 *dst = (Sint16 *) cvt->buf;
10126 const Sint16 *src = (Sint16 *) cvt->buf;
10127 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
10128 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
10129 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
10130 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
10131 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
10132 while (dst != target) {
10133 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
10134 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
10135 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
10136 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
10137 src += 16;
10138 dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
10139 dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
10140 dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
10141 dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
10142 last_sample0 = sample0;
10143 last_sample1 = sample1;
10144 last_sample2 = sample2;
10145 last_sample3 = sample3;
10146 dst += 4;
10147 }
10148
10149 cvt->len_cvt = dstsize;
10150 if (cvt->filters[++cvt->filter_index]) {
10151 cvt->filters[cvt->filter_index] (cvt, format);
10152 }
10153 }
10154
10155 static void SDLCALL
10156 SDL_Upsample_S16LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
10157 {
10158 #ifdef DEBUG_CONVERT
10159 fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 6 channels.\n");
10160 #endif
10161
10162 const int srcsize = cvt->len_cvt;
10163 const int dstsize = cvt->len_cvt * 2;
10164 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6;
10165 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
10166 const Sint16 *target = ((const Sint16 *) cvt->buf) - 6;
10167 Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
10168 Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
10169 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
10170 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
10171 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
10172 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
10173 while (dst != target) {
10174 const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
10175 const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
10176 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
10177 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
10178 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
10179 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
10180 src -= 6;
10181 dst[11] = (Sint16) ((sample5 + last_sample5) >> 1);
10182 dst[10] = (Sint16) ((sample4 + last_sample4) >> 1);
10183 dst[9] = (Sint16) ((sample3 + last_sample3) >> 1);
10184 dst[8] = (Sint16) ((sample2 + last_sample2) >> 1);
10185 dst[7] = (Sint16) ((sample1 + last_sample1) >> 1);
10186 dst[6] = (Sint16) ((sample0 + last_sample0) >> 1);
10187 dst[5] = (Sint16) sample5;
10188 dst[4] = (Sint16) sample4;
10189 dst[3] = (Sint16) sample3;
10190 dst[2] = (Sint16) sample2;
10191 dst[1] = (Sint16) sample1;
10192 dst[0] = (Sint16) sample0;
10193 last_sample5 = sample5;
10194 last_sample4 = sample4;
10195 last_sample3 = sample3;
10196 last_sample2 = sample2;
10197 last_sample1 = sample1;
10198 last_sample0 = sample0;
10199 dst -= 12;
10200 }
10201
10202 cvt->len_cvt = dstsize;
10203 if (cvt->filters[++cvt->filter_index]) {
10204 cvt->filters[cvt->filter_index] (cvt, format);
10205 }
10206 }
10207
10208 static void SDLCALL
10209 SDL_Downsample_S16LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
10210 {
10211 #ifdef DEBUG_CONVERT
10212 fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 6 channels.\n");
10213 #endif
10214
10215 const int srcsize = cvt->len_cvt;
10216 const int dstsize = cvt->len_cvt / 2;
10217 Sint16 *dst = (Sint16 *) cvt->buf;
10218 const Sint16 *src = (Sint16 *) cvt->buf;
10219 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
10220 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
10221 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
10222 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
10223 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
10224 Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
10225 Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
10226 while (dst != target) {
10227 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
10228 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
10229 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
10230 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
10231 const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
10232 const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
10233 src += 12;
10234 dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
10235 dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
10236 dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
10237 dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
10238 dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
10239 dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
10240 last_sample0 = sample0;
10241 last_sample1 = sample1;
10242 last_sample2 = sample2;
10243 last_sample3 = sample3;
10244 last_sample4 = sample4;
10245 last_sample5 = sample5;
10246 dst += 6;
10247 }
10248
10249 cvt->len_cvt = dstsize;
10250 if (cvt->filters[++cvt->filter_index]) {
10251 cvt->filters[cvt->filter_index] (cvt, format);
10252 }
10253 }
10254
10255 static void SDLCALL
10256 SDL_Upsample_S16LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
10257 {
10258 #ifdef DEBUG_CONVERT
10259 fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 6 channels.\n");
10260 #endif
10261
10262 const int srcsize = cvt->len_cvt;
10263 const int dstsize = cvt->len_cvt * 4;
10264 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6;
10265 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
10266 const Sint16 *target = ((const Sint16 *) cvt->buf) - 6;
10267 Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
10268 Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
10269 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
10270 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
10271 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
10272 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
10273 while (dst != target) {
10274 const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
10275 const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
10276 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
10277 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
10278 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
10279 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
10280 src -= 6;
10281 dst[23] = (Sint16) sample5;
10282 dst[22] = (Sint16) sample4;
10283 dst[21] = (Sint16) sample3;
10284 dst[20] = (Sint16) sample2;
10285 dst[19] = (Sint16) sample1;
10286 dst[18] = (Sint16) sample0;
10287 dst[17] = (Sint16) (((3 * sample5) + last_sample5) >> 2);
10288 dst[16] = (Sint16) (((3 * sample4) + last_sample4) >> 2);
10289 dst[15] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
10290 dst[14] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
10291 dst[13] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
10292 dst[12] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
10293 dst[11] = (Sint16) ((sample5 + last_sample5) >> 1);
10294 dst[10] = (Sint16) ((sample4 + last_sample4) >> 1);
10295 dst[9] = (Sint16) ((sample3 + last_sample3) >> 1);
10296 dst[8] = (Sint16) ((sample2 + last_sample2) >> 1);
10297 dst[7] = (Sint16) ((sample1 + last_sample1) >> 1);
10298 dst[6] = (Sint16) ((sample0 + last_sample0) >> 1);
10299 dst[5] = (Sint16) ((sample5 + (3 * last_sample5)) >> 2);
10300 dst[4] = (Sint16) ((sample4 + (3 * last_sample4)) >> 2);
10301 dst[3] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
10302 dst[2] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
10303 dst[1] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
10304 dst[0] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
10305 last_sample5 = sample5;
10306 last_sample4 = sample4;
10307 last_sample3 = sample3;
10308 last_sample2 = sample2;
10309 last_sample1 = sample1;
10310 last_sample0 = sample0;
10311 dst -= 24;
10312 }
10313
10314 cvt->len_cvt = dstsize;
10315 if (cvt->filters[++cvt->filter_index]) {
10316 cvt->filters[cvt->filter_index] (cvt, format);
10317 }
10318 }
10319
10320 static void SDLCALL
10321 SDL_Downsample_S16LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
10322 {
10323 #ifdef DEBUG_CONVERT
10324 fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 6 channels.\n");
10325 #endif
10326
10327 const int srcsize = cvt->len_cvt;
10328 const int dstsize = cvt->len_cvt / 4;
10329 Sint16 *dst = (Sint16 *) cvt->buf;
10330 const Sint16 *src = (Sint16 *) cvt->buf;
10331 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
10332 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
10333 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
10334 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
10335 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
10336 Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
10337 Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
10338 while (dst != target) {
10339 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
10340 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
10341 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
10342 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
10343 const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
10344 const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
10345 src += 24;
10346 dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
10347 dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
10348 dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
10349 dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
10350 dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
10351 dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
10352 last_sample0 = sample0;
10353 last_sample1 = sample1;
10354 last_sample2 = sample2;
10355 last_sample3 = sample3;
10356 last_sample4 = sample4;
10357 last_sample5 = sample5;
10358 dst += 6;
10359 }
10360
10361 cvt->len_cvt = dstsize;
10362 if (cvt->filters[++cvt->filter_index]) {
10363 cvt->filters[cvt->filter_index] (cvt, format);
10364 }
10365 }
10366
10367 static void SDLCALL
10368 SDL_Upsample_S16LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
10369 {
10370 #ifdef DEBUG_CONVERT
10371 fprintf(stderr, "Upsample (x2) AUDIO_S16LSB, 8 channels.\n");
10372 #endif
10373
10374 const int srcsize = cvt->len_cvt;
10375 const int dstsize = cvt->len_cvt * 2;
10376 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8;
10377 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
10378 const Sint16 *target = ((const Sint16 *) cvt->buf) - 8;
10379 Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
10380 Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
10381 Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
10382 Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
10383 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
10384 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
10385 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
10386 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
10387 while (dst != target) {
10388 const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
10389 const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
10390 const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
10391 const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
10392 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
10393 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
10394 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
10395 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
10396 src -= 8;
10397 dst[15] = (Sint16) ((sample7 + last_sample7) >> 1);
10398 dst[14] = (Sint16) ((sample6 + last_sample6) >> 1);
10399 dst[13] = (Sint16) ((sample5 + last_sample5) >> 1);
10400 dst[12] = (Sint16) ((sample4 + last_sample4) >> 1);
10401 dst[11] = (Sint16) ((sample3 + last_sample3) >> 1);
10402 dst[10] = (Sint16) ((sample2 + last_sample2) >> 1);
10403 dst[9] = (Sint16) ((sample1 + last_sample1) >> 1);
10404 dst[8] = (Sint16) ((sample0 + last_sample0) >> 1);
10405 dst[7] = (Sint16) sample7;
10406 dst[6] = (Sint16) sample6;
10407 dst[5] = (Sint16) sample5;
10408 dst[4] = (Sint16) sample4;
10409 dst[3] = (Sint16) sample3;
10410 dst[2] = (Sint16) sample2;
10411 dst[1] = (Sint16) sample1;
10412 dst[0] = (Sint16) sample0;
10413 last_sample7 = sample7;
10414 last_sample6 = sample6;
10415 last_sample5 = sample5;
10416 last_sample4 = sample4;
10417 last_sample3 = sample3;
10418 last_sample2 = sample2;
10419 last_sample1 = sample1;
10420 last_sample0 = sample0;
10421 dst -= 16;
10422 }
10423
10424 cvt->len_cvt = dstsize;
10425 if (cvt->filters[++cvt->filter_index]) {
10426 cvt->filters[cvt->filter_index] (cvt, format);
10427 }
10428 }
10429
10430 static void SDLCALL
10431 SDL_Downsample_S16LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
10432 {
10433 #ifdef DEBUG_CONVERT
10434 fprintf(stderr, "Downsample (x2) AUDIO_S16LSB, 8 channels.\n");
10435 #endif
10436
10437 const int srcsize = cvt->len_cvt;
10438 const int dstsize = cvt->len_cvt / 2;
10439 Sint16 *dst = (Sint16 *) cvt->buf;
10440 const Sint16 *src = (Sint16 *) cvt->buf;
10441 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
10442 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
10443 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
10444 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
10445 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
10446 Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
10447 Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
10448 Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
10449 Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
10450 while (dst != target) {
10451 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
10452 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
10453 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
10454 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
10455 const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
10456 const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
10457 const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
10458 const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
10459 src += 16;
10460 dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
10461 dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
10462 dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
10463 dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
10464 dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
10465 dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
10466 dst[6] = (Sint16) ((sample6 + last_sample6) >> 1);
10467 dst[7] = (Sint16) ((sample7 + last_sample7) >> 1);
10468 last_sample0 = sample0;
10469 last_sample1 = sample1;
10470 last_sample2 = sample2;
10471 last_sample3 = sample3;
10472 last_sample4 = sample4;
10473 last_sample5 = sample5;
10474 last_sample6 = sample6;
10475 last_sample7 = sample7;
10476 dst += 8;
10477 }
10478
10479 cvt->len_cvt = dstsize;
10480 if (cvt->filters[++cvt->filter_index]) {
10481 cvt->filters[cvt->filter_index] (cvt, format);
10482 }
10483 }
10484
10485 static void SDLCALL
10486 SDL_Upsample_S16LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
10487 {
10488 #ifdef DEBUG_CONVERT
10489 fprintf(stderr, "Upsample (x4) AUDIO_S16LSB, 8 channels.\n");
10490 #endif
10491
10492 const int srcsize = cvt->len_cvt;
10493 const int dstsize = cvt->len_cvt * 4;
10494 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8;
10495 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
10496 const Sint16 *target = ((const Sint16 *) cvt->buf) - 8;
10497 Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
10498 Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
10499 Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
10500 Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
10501 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
10502 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
10503 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
10504 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
10505 while (dst != target) {
10506 const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
10507 const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
10508 const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
10509 const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
10510 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
10511 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
10512 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
10513 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
10514 src -= 8;
10515 dst[31] = (Sint16) sample7;
10516 dst[30] = (Sint16) sample6;
10517 dst[29] = (Sint16) sample5;
10518 dst[28] = (Sint16) sample4;
10519 dst[27] = (Sint16) sample3;
10520 dst[26] = (Sint16) sample2;
10521 dst[25] = (Sint16) sample1;
10522 dst[24] = (Sint16) sample0;
10523 dst[23] = (Sint16) (((3 * sample7) + last_sample7) >> 2);
10524 dst[22] = (Sint16) (((3 * sample6) + last_sample6) >> 2);
10525 dst[21] = (Sint16) (((3 * sample5) + last_sample5) >> 2);
10526 dst[20] = (Sint16) (((3 * sample4) + last_sample4) >> 2);
10527 dst[19] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
10528 dst[18] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
10529 dst[17] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
10530 dst[16] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
10531 dst[15] = (Sint16) ((sample7 + last_sample7) >> 1);
10532 dst[14] = (Sint16) ((sample6 + last_sample6) >> 1);
10533 dst[13] = (Sint16) ((sample5 + last_sample5) >> 1);
10534 dst[12] = (Sint16) ((sample4 + last_sample4) >> 1);
10535 dst[11] = (Sint16) ((sample3 + last_sample3) >> 1);
10536 dst[10] = (Sint16) ((sample2 + last_sample2) >> 1);
10537 dst[9] = (Sint16) ((sample1 + last_sample1) >> 1);
10538 dst[8] = (Sint16) ((sample0 + last_sample0) >> 1);
10539 dst[7] = (Sint16) ((sample7 + (3 * last_sample7)) >> 2);
10540 dst[6] = (Sint16) ((sample6 + (3 * last_sample6)) >> 2);
10541 dst[5] = (Sint16) ((sample5 + (3 * last_sample5)) >> 2);
10542 dst[4] = (Sint16) ((sample4 + (3 * last_sample4)) >> 2);
10543 dst[3] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
10544 dst[2] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
10545 dst[1] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
10546 dst[0] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
10547 last_sample7 = sample7;
10548 last_sample6 = sample6;
10549 last_sample5 = sample5;
10550 last_sample4 = sample4;
10551 last_sample3 = sample3;
10552 last_sample2 = sample2;
10553 last_sample1 = sample1;
10554 last_sample0 = sample0;
10555 dst -= 32;
10556 }
10557
10558 cvt->len_cvt = dstsize;
10559 if (cvt->filters[++cvt->filter_index]) {
10560 cvt->filters[cvt->filter_index] (cvt, format);
10561 }
10562 }
10563
10564 static void SDLCALL
10565 SDL_Downsample_S16LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
10566 {
10567 #ifdef DEBUG_CONVERT
10568 fprintf(stderr, "Downsample (x4) AUDIO_S16LSB, 8 channels.\n");
10569 #endif
10570
10571 const int srcsize = cvt->len_cvt;
10572 const int dstsize = cvt->len_cvt / 4;
10573 Sint16 *dst = (Sint16 *) cvt->buf;
10574 const Sint16 *src = (Sint16 *) cvt->buf;
10575 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
10576 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
10577 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
10578 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
10579 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
10580 Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
10581 Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
10582 Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
10583 Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
10584 while (dst != target) {
10585 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapLE16(src[0]));
10586 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapLE16(src[1]));
10587 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapLE16(src[2]));
10588 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapLE16(src[3]));
10589 const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapLE16(src[4]));
10590 const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapLE16(src[5]));
10591 const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapLE16(src[6]));
10592 const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapLE16(src[7]));
10593 src += 32;
10594 dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
10595 dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
10596 dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
10597 dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
10598 dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
10599 dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
10600 dst[6] = (Sint16) ((sample6 + last_sample6) >> 1);
10601 dst[7] = (Sint16) ((sample7 + last_sample7) >> 1);
10602 last_sample0 = sample0;
10603 last_sample1 = sample1;
10604 last_sample2 = sample2;
10605 last_sample3 = sample3;
10606 last_sample4 = sample4;
10607 last_sample5 = sample5;
10608 last_sample6 = sample6;
10609 last_sample7 = sample7;
10610 dst += 8;
10611 }
10612
10613 cvt->len_cvt = dstsize;
10614 if (cvt->filters[++cvt->filter_index]) {
10615 cvt->filters[cvt->filter_index] (cvt, format);
10616 }
10617 }
10618
10619 static void SDLCALL
10620 SDL_Upsample_U16MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
10621 {
10622 #ifdef DEBUG_CONVERT
10623 fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 1 channels.\n");
10624 #endif
10625
10626 const int srcsize = cvt->len_cvt;
10627 const int dstsize = cvt->len_cvt * 2;
10628 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1;
10629 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
10630 const Uint16 *target = ((const Uint16 *) cvt->buf) - 1;
10631 Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
10632 while (dst != target) {
10633 const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
10634 src--;
10635 dst[1] = (Uint16) ((sample0 + last_sample0) >> 1);
10636 dst[0] = (Uint16) sample0;
10637 last_sample0 = sample0;
10638 dst -= 2;
10639 }
10640
10641 cvt->len_cvt = dstsize;
10642 if (cvt->filters[++cvt->filter_index]) {
10643 cvt->filters[cvt->filter_index] (cvt, format);
10644 }
10645 }
10646
10647 static void SDLCALL
10648 SDL_Downsample_U16MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
10649 {
10650 #ifdef DEBUG_CONVERT
10651 fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 1 channels.\n");
10652 #endif
10653
10654 const int srcsize = cvt->len_cvt;
10655 const int dstsize = cvt->len_cvt / 2;
10656 Uint16 *dst = (Uint16 *) cvt->buf;
10657 const Uint16 *src = (Uint16 *) cvt->buf;
10658 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
10659 Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
10660 while (dst != target) {
10661 const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
10662 src += 2;
10663 dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
10664 last_sample0 = sample0;
10665 dst++;
10666 }
10667
10668 cvt->len_cvt = dstsize;
10669 if (cvt->filters[++cvt->filter_index]) {
10670 cvt->filters[cvt->filter_index] (cvt, format);
10671 }
10672 }
10673
10674 static void SDLCALL
10675 SDL_Upsample_U16MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
10676 {
10677 #ifdef DEBUG_CONVERT
10678 fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 1 channels.\n");
10679 #endif
10680
10681 const int srcsize = cvt->len_cvt;
10682 const int dstsize = cvt->len_cvt * 4;
10683 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 1;
10684 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 1;
10685 const Uint16 *target = ((const Uint16 *) cvt->buf) - 1;
10686 Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
10687 while (dst != target) {
10688 const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
10689 src--;
10690 dst[3] = (Uint16) sample0;
10691 dst[2] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
10692 dst[1] = (Uint16) ((sample0 + last_sample0) >> 1);
10693 dst[0] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
10694 last_sample0 = sample0;
10695 dst -= 4;
10696 }
10697
10698 cvt->len_cvt = dstsize;
10699 if (cvt->filters[++cvt->filter_index]) {
10700 cvt->filters[cvt->filter_index] (cvt, format);
10701 }
10702 }
10703
10704 static void SDLCALL
10705 SDL_Downsample_U16MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
10706 {
10707 #ifdef DEBUG_CONVERT
10708 fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 1 channels.\n");
10709 #endif
10710
10711 const int srcsize = cvt->len_cvt;
10712 const int dstsize = cvt->len_cvt / 4;
10713 Uint16 *dst = (Uint16 *) cvt->buf;
10714 const Uint16 *src = (Uint16 *) cvt->buf;
10715 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
10716 Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
10717 while (dst != target) {
10718 const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
10719 src += 4;
10720 dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
10721 last_sample0 = sample0;
10722 dst++;
10723 }
10724
10725 cvt->len_cvt = dstsize;
10726 if (cvt->filters[++cvt->filter_index]) {
10727 cvt->filters[cvt->filter_index] (cvt, format);
10728 }
10729 }
10730
10731 static void SDLCALL
10732 SDL_Upsample_U16MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
10733 {
10734 #ifdef DEBUG_CONVERT
10735 fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 2 channels.\n");
10736 #endif
10737
10738 const int srcsize = cvt->len_cvt;
10739 const int dstsize = cvt->len_cvt * 2;
10740 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2;
10741 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
10742 const Uint16 *target = ((const Uint16 *) cvt->buf) - 2;
10743 Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
10744 Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
10745 while (dst != target) {
10746 const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
10747 const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
10748 src -= 2;
10749 dst[3] = (Uint16) ((sample1 + last_sample1) >> 1);
10750 dst[2] = (Uint16) ((sample0 + last_sample0) >> 1);
10751 dst[1] = (Uint16) sample1;
10752 dst[0] = (Uint16) sample0;
10753 last_sample1 = sample1;
10754 last_sample0 = sample0;
10755 dst -= 4;
10756 }
10757
10758 cvt->len_cvt = dstsize;
10759 if (cvt->filters[++cvt->filter_index]) {
10760 cvt->filters[cvt->filter_index] (cvt, format);
10761 }
10762 }
10763
10764 static void SDLCALL
10765 SDL_Downsample_U16MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
10766 {
10767 #ifdef DEBUG_CONVERT
10768 fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 2 channels.\n");
10769 #endif
10770
10771 const int srcsize = cvt->len_cvt;
10772 const int dstsize = cvt->len_cvt / 2;
10773 Uint16 *dst = (Uint16 *) cvt->buf;
10774 const Uint16 *src = (Uint16 *) cvt->buf;
10775 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
10776 Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
10777 Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
10778 while (dst != target) {
10779 const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
10780 const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
10781 src += 4;
10782 dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
10783 dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
10784 last_sample0 = sample0;
10785 last_sample1 = sample1;
10786 dst += 2;
10787 }
10788
10789 cvt->len_cvt = dstsize;
10790 if (cvt->filters[++cvt->filter_index]) {
10791 cvt->filters[cvt->filter_index] (cvt, format);
10792 }
10793 }
10794
10795 static void SDLCALL
10796 SDL_Upsample_U16MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
10797 {
10798 #ifdef DEBUG_CONVERT
10799 fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 2 channels.\n");
10800 #endif
10801
10802 const int srcsize = cvt->len_cvt;
10803 const int dstsize = cvt->len_cvt * 4;
10804 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 2;
10805 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 2;
10806 const Uint16 *target = ((const Uint16 *) cvt->buf) - 2;
10807 Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
10808 Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
10809 while (dst != target) {
10810 const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
10811 const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
10812 src -= 2;
10813 dst[7] = (Uint16) sample1;
10814 dst[6] = (Uint16) sample0;
10815 dst[5] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
10816 dst[4] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
10817 dst[3] = (Uint16) ((sample1 + last_sample1) >> 1);
10818 dst[2] = (Uint16) ((sample0 + last_sample0) >> 1);
10819 dst[1] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
10820 dst[0] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
10821 last_sample1 = sample1;
10822 last_sample0 = sample0;
10823 dst -= 8;
10824 }
10825
10826 cvt->len_cvt = dstsize;
10827 if (cvt->filters[++cvt->filter_index]) {
10828 cvt->filters[cvt->filter_index] (cvt, format);
10829 }
10830 }
10831
10832 static void SDLCALL
10833 SDL_Downsample_U16MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
10834 {
10835 #ifdef DEBUG_CONVERT
10836 fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 2 channels.\n");
10837 #endif
10838
10839 const int srcsize = cvt->len_cvt;
10840 const int dstsize = cvt->len_cvt / 4;
10841 Uint16 *dst = (Uint16 *) cvt->buf;
10842 const Uint16 *src = (Uint16 *) cvt->buf;
10843 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
10844 Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
10845 Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
10846 while (dst != target) {
10847 const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
10848 const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
10849 src += 8;
10850 dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
10851 dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
10852 last_sample0 = sample0;
10853 last_sample1 = sample1;
10854 dst += 2;
10855 }
10856
10857 cvt->len_cvt = dstsize;
10858 if (cvt->filters[++cvt->filter_index]) {
10859 cvt->filters[cvt->filter_index] (cvt, format);
10860 }
10861 }
10862
10863 static void SDLCALL
10864 SDL_Upsample_U16MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
10865 {
10866 #ifdef DEBUG_CONVERT
10867 fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 4 channels.\n");
10868 #endif
10869
10870 const int srcsize = cvt->len_cvt;
10871 const int dstsize = cvt->len_cvt * 2;
10872 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4;
10873 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
10874 const Uint16 *target = ((const Uint16 *) cvt->buf) - 4;
10875 Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
10876 Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
10877 Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
10878 Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
10879 while (dst != target) {
10880 const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
10881 const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
10882 const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
10883 const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
10884 src -= 4;
10885 dst[7] = (Uint16) ((sample3 + last_sample3) >> 1);
10886 dst[6] = (Uint16) ((sample2 + last_sample2) >> 1);
10887 dst[5] = (Uint16) ((sample1 + last_sample1) >> 1);
10888 dst[4] = (Uint16) ((sample0 + last_sample0) >> 1);
10889 dst[3] = (Uint16) sample3;
10890 dst[2] = (Uint16) sample2;
10891 dst[1] = (Uint16) sample1;
10892 dst[0] = (Uint16) sample0;
10893 last_sample3 = sample3;
10894 last_sample2 = sample2;
10895 last_sample1 = sample1;
10896 last_sample0 = sample0;
10897 dst -= 8;
10898 }
10899
10900 cvt->len_cvt = dstsize;
10901 if (cvt->filters[++cvt->filter_index]) {
10902 cvt->filters[cvt->filter_index] (cvt, format);
10903 }
10904 }
10905
10906 static void SDLCALL
10907 SDL_Downsample_U16MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
10908 {
10909 #ifdef DEBUG_CONVERT
10910 fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 4 channels.\n");
10911 #endif
10912
10913 const int srcsize = cvt->len_cvt;
10914 const int dstsize = cvt->len_cvt / 2;
10915 Uint16 *dst = (Uint16 *) cvt->buf;
10916 const Uint16 *src = (Uint16 *) cvt->buf;
10917 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
10918 Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
10919 Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
10920 Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
10921 Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
10922 while (dst != target) {
10923 const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
10924 const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
10925 const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
10926 const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
10927 src += 8;
10928 dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
10929 dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
10930 dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
10931 dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
10932 last_sample0 = sample0;
10933 last_sample1 = sample1;
10934 last_sample2 = sample2;
10935 last_sample3 = sample3;
10936 dst += 4;
10937 }
10938
10939 cvt->len_cvt = dstsize;
10940 if (cvt->filters[++cvt->filter_index]) {
10941 cvt->filters[cvt->filter_index] (cvt, format);
10942 }
10943 }
10944
10945 static void SDLCALL
10946 SDL_Upsample_U16MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
10947 {
10948 #ifdef DEBUG_CONVERT
10949 fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 4 channels.\n");
10950 #endif
10951
10952 const int srcsize = cvt->len_cvt;
10953 const int dstsize = cvt->len_cvt * 4;
10954 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 4;
10955 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 4;
10956 const Uint16 *target = ((const Uint16 *) cvt->buf) - 4;
10957 Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
10958 Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
10959 Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
10960 Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
10961 while (dst != target) {
10962 const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
10963 const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
10964 const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
10965 const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
10966 src -= 4;
10967 dst[15] = (Uint16) sample3;
10968 dst[14] = (Uint16) sample2;
10969 dst[13] = (Uint16) sample1;
10970 dst[12] = (Uint16) sample0;
10971 dst[11] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
10972 dst[10] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
10973 dst[9] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
10974 dst[8] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
10975 dst[7] = (Uint16) ((sample3 + last_sample3) >> 1);
10976 dst[6] = (Uint16) ((sample2 + last_sample2) >> 1);
10977 dst[5] = (Uint16) ((sample1 + last_sample1) >> 1);
10978 dst[4] = (Uint16) ((sample0 + last_sample0) >> 1);
10979 dst[3] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
10980 dst[2] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
10981 dst[1] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
10982 dst[0] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
10983 last_sample3 = sample3;
10984 last_sample2 = sample2;
10985 last_sample1 = sample1;
10986 last_sample0 = sample0;
10987 dst -= 16;
10988 }
10989
10990 cvt->len_cvt = dstsize;
10991 if (cvt->filters[++cvt->filter_index]) {
10992 cvt->filters[cvt->filter_index] (cvt, format);
10993 }
10994 }
10995
10996 static void SDLCALL
10997 SDL_Downsample_U16MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
10998 {
10999 #ifdef DEBUG_CONVERT
11000 fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 4 channels.\n");
11001 #endif
11002
11003 const int srcsize = cvt->len_cvt;
11004 const int dstsize = cvt->len_cvt / 4;
11005 Uint16 *dst = (Uint16 *) cvt->buf;
11006 const Uint16 *src = (Uint16 *) cvt->buf;
11007 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
11008 Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
11009 Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
11010 Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
11011 Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
11012 while (dst != target) {
11013 const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
11014 const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
11015 const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
11016 const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
11017 src += 16;
11018 dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
11019 dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
11020 dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
11021 dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
11022 last_sample0 = sample0;
11023 last_sample1 = sample1;
11024 last_sample2 = sample2;
11025 last_sample3 = sample3;
11026 dst += 4;
11027 }
11028
11029 cvt->len_cvt = dstsize;
11030 if (cvt->filters[++cvt->filter_index]) {
11031 cvt->filters[cvt->filter_index] (cvt, format);
11032 }
11033 }
11034
11035 static void SDLCALL
11036 SDL_Upsample_U16MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
11037 {
11038 #ifdef DEBUG_CONVERT
11039 fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 6 channels.\n");
11040 #endif
11041
11042 const int srcsize = cvt->len_cvt;
11043 const int dstsize = cvt->len_cvt * 2;
11044 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6;
11045 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
11046 const Uint16 *target = ((const Uint16 *) cvt->buf) - 6;
11047 Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
11048 Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
11049 Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
11050 Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
11051 Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
11052 Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
11053 while (dst != target) {
11054 const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
11055 const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
11056 const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
11057 const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
11058 const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
11059 const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
11060 src -= 6;
11061 dst[11] = (Uint16) ((sample5 + last_sample5) >> 1);
11062 dst[10] = (Uint16) ((sample4 + last_sample4) >> 1);
11063 dst[9] = (Uint16) ((sample3 + last_sample3) >> 1);
11064 dst[8] = (Uint16) ((sample2 + last_sample2) >> 1);
11065 dst[7] = (Uint16) ((sample1 + last_sample1) >> 1);
11066 dst[6] = (Uint16) ((sample0 + last_sample0) >> 1);
11067 dst[5] = (Uint16) sample5;
11068 dst[4] = (Uint16) sample4;
11069 dst[3] = (Uint16) sample3;
11070 dst[2] = (Uint16) sample2;
11071 dst[1] = (Uint16) sample1;
11072 dst[0] = (Uint16) sample0;
11073 last_sample5 = sample5;
11074 last_sample4 = sample4;
11075 last_sample3 = sample3;
11076 last_sample2 = sample2;
11077 last_sample1 = sample1;
11078 last_sample0 = sample0;
11079 dst -= 12;
11080 }
11081
11082 cvt->len_cvt = dstsize;
11083 if (cvt->filters[++cvt->filter_index]) {
11084 cvt->filters[cvt->filter_index] (cvt, format);
11085 }
11086 }
11087
11088 static void SDLCALL
11089 SDL_Downsample_U16MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
11090 {
11091 #ifdef DEBUG_CONVERT
11092 fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 6 channels.\n");
11093 #endif
11094
11095 const int srcsize = cvt->len_cvt;
11096 const int dstsize = cvt->len_cvt / 2;
11097 Uint16 *dst = (Uint16 *) cvt->buf;
11098 const Uint16 *src = (Uint16 *) cvt->buf;
11099 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
11100 Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
11101 Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
11102 Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
11103 Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
11104 Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
11105 Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
11106 while (dst != target) {
11107 const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
11108 const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
11109 const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
11110 const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
11111 const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
11112 const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
11113 src += 12;
11114 dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
11115 dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
11116 dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
11117 dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
11118 dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
11119 dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
11120 last_sample0 = sample0;
11121 last_sample1 = sample1;
11122 last_sample2 = sample2;
11123 last_sample3 = sample3;
11124 last_sample4 = sample4;
11125 last_sample5 = sample5;
11126 dst += 6;
11127 }
11128
11129 cvt->len_cvt = dstsize;
11130 if (cvt->filters[++cvt->filter_index]) {
11131 cvt->filters[cvt->filter_index] (cvt, format);
11132 }
11133 }
11134
11135 static void SDLCALL
11136 SDL_Upsample_U16MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
11137 {
11138 #ifdef DEBUG_CONVERT
11139 fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 6 channels.\n");
11140 #endif
11141
11142 const int srcsize = cvt->len_cvt;
11143 const int dstsize = cvt->len_cvt * 4;
11144 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 6;
11145 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 6;
11146 const Uint16 *target = ((const Uint16 *) cvt->buf) - 6;
11147 Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
11148 Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
11149 Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
11150 Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
11151 Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
11152 Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
11153 while (dst != target) {
11154 const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
11155 const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
11156 const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
11157 const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
11158 const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
11159 const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
11160 src -= 6;
11161 dst[23] = (Uint16) sample5;
11162 dst[22] = (Uint16) sample4;
11163 dst[21] = (Uint16) sample3;
11164 dst[20] = (Uint16) sample2;
11165 dst[19] = (Uint16) sample1;
11166 dst[18] = (Uint16) sample0;
11167 dst[17] = (Uint16) (((3 * sample5) + last_sample5) >> 2);
11168 dst[16] = (Uint16) (((3 * sample4) + last_sample4) >> 2);
11169 dst[15] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
11170 dst[14] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
11171 dst[13] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
11172 dst[12] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
11173 dst[11] = (Uint16) ((sample5 + last_sample5) >> 1);
11174 dst[10] = (Uint16) ((sample4 + last_sample4) >> 1);
11175 dst[9] = (Uint16) ((sample3 + last_sample3) >> 1);
11176 dst[8] = (Uint16) ((sample2 + last_sample2) >> 1);
11177 dst[7] = (Uint16) ((sample1 + last_sample1) >> 1);
11178 dst[6] = (Uint16) ((sample0 + last_sample0) >> 1);
11179 dst[5] = (Uint16) ((sample5 + (3 * last_sample5)) >> 2);
11180 dst[4] = (Uint16) ((sample4 + (3 * last_sample4)) >> 2);
11181 dst[3] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
11182 dst[2] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
11183 dst[1] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
11184 dst[0] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
11185 last_sample5 = sample5;
11186 last_sample4 = sample4;
11187 last_sample3 = sample3;
11188 last_sample2 = sample2;
11189 last_sample1 = sample1;
11190 last_sample0 = sample0;
11191 dst -= 24;
11192 }
11193
11194 cvt->len_cvt = dstsize;
11195 if (cvt->filters[++cvt->filter_index]) {
11196 cvt->filters[cvt->filter_index] (cvt, format);
11197 }
11198 }
11199
11200 static void SDLCALL
11201 SDL_Downsample_U16MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
11202 {
11203 #ifdef DEBUG_CONVERT
11204 fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 6 channels.\n");
11205 #endif
11206
11207 const int srcsize = cvt->len_cvt;
11208 const int dstsize = cvt->len_cvt / 4;
11209 Uint16 *dst = (Uint16 *) cvt->buf;
11210 const Uint16 *src = (Uint16 *) cvt->buf;
11211 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
11212 Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
11213 Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
11214 Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
11215 Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
11216 Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
11217 Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
11218 while (dst != target) {
11219 const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
11220 const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
11221 const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
11222 const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
11223 const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
11224 const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
11225 src += 24;
11226 dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
11227 dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
11228 dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
11229 dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
11230 dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
11231 dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
11232 last_sample0 = sample0;
11233 last_sample1 = sample1;
11234 last_sample2 = sample2;
11235 last_sample3 = sample3;
11236 last_sample4 = sample4;
11237 last_sample5 = sample5;
11238 dst += 6;
11239 }
11240
11241 cvt->len_cvt = dstsize;
11242 if (cvt->filters[++cvt->filter_index]) {
11243 cvt->filters[cvt->filter_index] (cvt, format);
11244 }
11245 }
11246
11247 static void SDLCALL
11248 SDL_Upsample_U16MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
11249 {
11250 #ifdef DEBUG_CONVERT
11251 fprintf(stderr, "Upsample (x2) AUDIO_U16MSB, 8 channels.\n");
11252 #endif
11253
11254 const int srcsize = cvt->len_cvt;
11255 const int dstsize = cvt->len_cvt * 2;
11256 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8;
11257 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
11258 const Uint16 *target = ((const Uint16 *) cvt->buf) - 8;
11259 Sint32 last_sample7 = (Sint32) SDL_SwapBE16(src[7]);
11260 Sint32 last_sample6 = (Sint32) SDL_SwapBE16(src[6]);
11261 Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
11262 Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
11263 Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
11264 Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
11265 Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
11266 Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
11267 while (dst != target) {
11268 const Sint32 sample7 = (Sint32) SDL_SwapBE16(src[7]);
11269 const Sint32 sample6 = (Sint32) SDL_SwapBE16(src[6]);
11270 const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
11271 const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
11272 const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
11273 const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
11274 const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
11275 const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
11276 src -= 8;
11277 dst[15] = (Uint16) ((sample7 + last_sample7) >> 1);
11278 dst[14] = (Uint16) ((sample6 + last_sample6) >> 1);
11279 dst[13] = (Uint16) ((sample5 + last_sample5) >> 1);
11280 dst[12] = (Uint16) ((sample4 + last_sample4) >> 1);
11281 dst[11] = (Uint16) ((sample3 + last_sample3) >> 1);
11282 dst[10] = (Uint16) ((sample2 + last_sample2) >> 1);
11283 dst[9] = (Uint16) ((sample1 + last_sample1) >> 1);
11284 dst[8] = (Uint16) ((sample0 + last_sample0) >> 1);
11285 dst[7] = (Uint16) sample7;
11286 dst[6] = (Uint16) sample6;
11287 dst[5] = (Uint16) sample5;
11288 dst[4] = (Uint16) sample4;
11289 dst[3] = (Uint16) sample3;
11290 dst[2] = (Uint16) sample2;
11291 dst[1] = (Uint16) sample1;
11292 dst[0] = (Uint16) sample0;
11293 last_sample7 = sample7;
11294 last_sample6 = sample6;
11295 last_sample5 = sample5;
11296 last_sample4 = sample4;
11297 last_sample3 = sample3;
11298 last_sample2 = sample2;
11299 last_sample1 = sample1;
11300 last_sample0 = sample0;
11301 dst -= 16;
11302 }
11303
11304 cvt->len_cvt = dstsize;
11305 if (cvt->filters[++cvt->filter_index]) {
11306 cvt->filters[cvt->filter_index] (cvt, format);
11307 }
11308 }
11309
11310 static void SDLCALL
11311 SDL_Downsample_U16MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
11312 {
11313 #ifdef DEBUG_CONVERT
11314 fprintf(stderr, "Downsample (x2) AUDIO_U16MSB, 8 channels.\n");
11315 #endif
11316
11317 const int srcsize = cvt->len_cvt;
11318 const int dstsize = cvt->len_cvt / 2;
11319 Uint16 *dst = (Uint16 *) cvt->buf;
11320 const Uint16 *src = (Uint16 *) cvt->buf;
11321 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
11322 Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
11323 Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
11324 Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
11325 Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
11326 Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
11327 Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
11328 Sint32 last_sample6 = (Sint32) SDL_SwapBE16(src[6]);
11329 Sint32 last_sample7 = (Sint32) SDL_SwapBE16(src[7]);
11330 while (dst != target) {
11331 const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
11332 const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
11333 const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
11334 const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
11335 const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
11336 const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
11337 const Sint32 sample6 = (Sint32) SDL_SwapBE16(src[6]);
11338 const Sint32 sample7 = (Sint32) SDL_SwapBE16(src[7]);
11339 src += 16;
11340 dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
11341 dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
11342 dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
11343 dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
11344 dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
11345 dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
11346 dst[6] = (Uint16) ((sample6 + last_sample6) >> 1);
11347 dst[7] = (Uint16) ((sample7 + last_sample7) >> 1);
11348 last_sample0 = sample0;
11349 last_sample1 = sample1;
11350 last_sample2 = sample2;
11351 last_sample3 = sample3;
11352 last_sample4 = sample4;
11353 last_sample5 = sample5;
11354 last_sample6 = sample6;
11355 last_sample7 = sample7;
11356 dst += 8;
11357 }
11358
11359 cvt->len_cvt = dstsize;
11360 if (cvt->filters[++cvt->filter_index]) {
11361 cvt->filters[cvt->filter_index] (cvt, format);
11362 }
11363 }
11364
11365 static void SDLCALL
11366 SDL_Upsample_U16MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
11367 {
11368 #ifdef DEBUG_CONVERT
11369 fprintf(stderr, "Upsample (x4) AUDIO_U16MSB, 8 channels.\n");
11370 #endif
11371
11372 const int srcsize = cvt->len_cvt;
11373 const int dstsize = cvt->len_cvt * 4;
11374 Uint16 *dst = ((Uint16 *) (cvt->buf + dstsize)) - 8;
11375 const Uint16 *src = ((Uint16 *) (cvt->buf + cvt->len_cvt)) - 8;
11376 const Uint16 *target = ((const Uint16 *) cvt->buf) - 8;
11377 Sint32 last_sample7 = (Sint32) SDL_SwapBE16(src[7]);
11378 Sint32 last_sample6 = (Sint32) SDL_SwapBE16(src[6]);
11379 Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
11380 Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
11381 Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
11382 Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
11383 Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
11384 Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
11385 while (dst != target) {
11386 const Sint32 sample7 = (Sint32) SDL_SwapBE16(src[7]);
11387 const Sint32 sample6 = (Sint32) SDL_SwapBE16(src[6]);
11388 const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
11389 const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
11390 const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
11391 const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
11392 const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
11393 const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
11394 src -= 8;
11395 dst[31] = (Uint16) sample7;
11396 dst[30] = (Uint16) sample6;
11397 dst[29] = (Uint16) sample5;
11398 dst[28] = (Uint16) sample4;
11399 dst[27] = (Uint16) sample3;
11400 dst[26] = (Uint16) sample2;
11401 dst[25] = (Uint16) sample1;
11402 dst[24] = (Uint16) sample0;
11403 dst[23] = (Uint16) (((3 * sample7) + last_sample7) >> 2);
11404 dst[22] = (Uint16) (((3 * sample6) + last_sample6) >> 2);
11405 dst[21] = (Uint16) (((3 * sample5) + last_sample5) >> 2);
11406 dst[20] = (Uint16) (((3 * sample4) + last_sample4) >> 2);
11407 dst[19] = (Uint16) (((3 * sample3) + last_sample3) >> 2);
11408 dst[18] = (Uint16) (((3 * sample2) + last_sample2) >> 2);
11409 dst[17] = (Uint16) (((3 * sample1) + last_sample1) >> 2);
11410 dst[16] = (Uint16) (((3 * sample0) + last_sample0) >> 2);
11411 dst[15] = (Uint16) ((sample7 + last_sample7) >> 1);
11412 dst[14] = (Uint16) ((sample6 + last_sample6) >> 1);
11413 dst[13] = (Uint16) ((sample5 + last_sample5) >> 1);
11414 dst[12] = (Uint16) ((sample4 + last_sample4) >> 1);
11415 dst[11] = (Uint16) ((sample3 + last_sample3) >> 1);
11416 dst[10] = (Uint16) ((sample2 + last_sample2) >> 1);
11417 dst[9] = (Uint16) ((sample1 + last_sample1) >> 1);
11418 dst[8] = (Uint16) ((sample0 + last_sample0) >> 1);
11419 dst[7] = (Uint16) ((sample7 + (3 * last_sample7)) >> 2);
11420 dst[6] = (Uint16) ((sample6 + (3 * last_sample6)) >> 2);
11421 dst[5] = (Uint16) ((sample5 + (3 * last_sample5)) >> 2);
11422 dst[4] = (Uint16) ((sample4 + (3 * last_sample4)) >> 2);
11423 dst[3] = (Uint16) ((sample3 + (3 * last_sample3)) >> 2);
11424 dst[2] = (Uint16) ((sample2 + (3 * last_sample2)) >> 2);
11425 dst[1] = (Uint16) ((sample1 + (3 * last_sample1)) >> 2);
11426 dst[0] = (Uint16) ((sample0 + (3 * last_sample0)) >> 2);
11427 last_sample7 = sample7;
11428 last_sample6 = sample6;
11429 last_sample5 = sample5;
11430 last_sample4 = sample4;
11431 last_sample3 = sample3;
11432 last_sample2 = sample2;
11433 last_sample1 = sample1;
11434 last_sample0 = sample0;
11435 dst -= 32;
11436 }
11437
11438 cvt->len_cvt = dstsize;
11439 if (cvt->filters[++cvt->filter_index]) {
11440 cvt->filters[cvt->filter_index] (cvt, format);
11441 }
11442 }
11443
11444 static void SDLCALL
11445 SDL_Downsample_U16MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
11446 {
11447 #ifdef DEBUG_CONVERT
11448 fprintf(stderr, "Downsample (x4) AUDIO_U16MSB, 8 channels.\n");
11449 #endif
11450
11451 const int srcsize = cvt->len_cvt;
11452 const int dstsize = cvt->len_cvt / 4;
11453 Uint16 *dst = (Uint16 *) cvt->buf;
11454 const Uint16 *src = (Uint16 *) cvt->buf;
11455 const Uint16 *target = (const Uint16 *) (cvt->buf + dstsize);
11456 Sint32 last_sample0 = (Sint32) SDL_SwapBE16(src[0]);
11457 Sint32 last_sample1 = (Sint32) SDL_SwapBE16(src[1]);
11458 Sint32 last_sample2 = (Sint32) SDL_SwapBE16(src[2]);
11459 Sint32 last_sample3 = (Sint32) SDL_SwapBE16(src[3]);
11460 Sint32 last_sample4 = (Sint32) SDL_SwapBE16(src[4]);
11461 Sint32 last_sample5 = (Sint32) SDL_SwapBE16(src[5]);
11462 Sint32 last_sample6 = (Sint32) SDL_SwapBE16(src[6]);
11463 Sint32 last_sample7 = (Sint32) SDL_SwapBE16(src[7]);
11464 while (dst != target) {
11465 const Sint32 sample0 = (Sint32) SDL_SwapBE16(src[0]);
11466 const Sint32 sample1 = (Sint32) SDL_SwapBE16(src[1]);
11467 const Sint32 sample2 = (Sint32) SDL_SwapBE16(src[2]);
11468 const Sint32 sample3 = (Sint32) SDL_SwapBE16(src[3]);
11469 const Sint32 sample4 = (Sint32) SDL_SwapBE16(src[4]);
11470 const Sint32 sample5 = (Sint32) SDL_SwapBE16(src[5]);
11471 const Sint32 sample6 = (Sint32) SDL_SwapBE16(src[6]);
11472 const Sint32 sample7 = (Sint32) SDL_SwapBE16(src[7]);
11473 src += 32;
11474 dst[0] = (Uint16) ((sample0 + last_sample0) >> 1);
11475 dst[1] = (Uint16) ((sample1 + last_sample1) >> 1);
11476 dst[2] = (Uint16) ((sample2 + last_sample2) >> 1);
11477 dst[3] = (Uint16) ((sample3 + last_sample3) >> 1);
11478 dst[4] = (Uint16) ((sample4 + last_sample4) >> 1);
11479 dst[5] = (Uint16) ((sample5 + last_sample5) >> 1);
11480 dst[6] = (Uint16) ((sample6 + last_sample6) >> 1);
11481 dst[7] = (Uint16) ((sample7 + last_sample7) >> 1);
11482 last_sample0 = sample0;
11483 last_sample1 = sample1;
11484 last_sample2 = sample2;
11485 last_sample3 = sample3;
11486 last_sample4 = sample4;
11487 last_sample5 = sample5;
11488 last_sample6 = sample6;
11489 last_sample7 = sample7;
11490 dst += 8;
11491 }
11492
11493 cvt->len_cvt = dstsize;
11494 if (cvt->filters[++cvt->filter_index]) {
11495 cvt->filters[cvt->filter_index] (cvt, format);
11496 }
11497 }
11498
11499 static void SDLCALL
11500 SDL_Upsample_S16MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
11501 {
11502 #ifdef DEBUG_CONVERT
11503 fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 1 channels.\n");
11504 #endif
11505
11506 const int srcsize = cvt->len_cvt;
11507 const int dstsize = cvt->len_cvt * 2;
11508 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1;
11509 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
11510 const Sint16 *target = ((const Sint16 *) cvt->buf) - 1;
11511 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11512 while (dst != target) {
11513 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11514 src--;
11515 dst[1] = (Sint16) ((sample0 + last_sample0) >> 1);
11516 dst[0] = (Sint16) sample0;
11517 last_sample0 = sample0;
11518 dst -= 2;
11519 }
11520
11521 cvt->len_cvt = dstsize;
11522 if (cvt->filters[++cvt->filter_index]) {
11523 cvt->filters[cvt->filter_index] (cvt, format);
11524 }
11525 }
11526
11527 static void SDLCALL
11528 SDL_Downsample_S16MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
11529 {
11530 #ifdef DEBUG_CONVERT
11531 fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 1 channels.\n");
11532 #endif
11533
11534 const int srcsize = cvt->len_cvt;
11535 const int dstsize = cvt->len_cvt / 2;
11536 Sint16 *dst = (Sint16 *) cvt->buf;
11537 const Sint16 *src = (Sint16 *) cvt->buf;
11538 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
11539 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11540 while (dst != target) {
11541 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11542 src += 2;
11543 dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
11544 last_sample0 = sample0;
11545 dst++;
11546 }
11547
11548 cvt->len_cvt = dstsize;
11549 if (cvt->filters[++cvt->filter_index]) {
11550 cvt->filters[cvt->filter_index] (cvt, format);
11551 }
11552 }
11553
11554 static void SDLCALL
11555 SDL_Upsample_S16MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
11556 {
11557 #ifdef DEBUG_CONVERT
11558 fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 1 channels.\n");
11559 #endif
11560
11561 const int srcsize = cvt->len_cvt;
11562 const int dstsize = cvt->len_cvt * 4;
11563 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 1;
11564 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 1;
11565 const Sint16 *target = ((const Sint16 *) cvt->buf) - 1;
11566 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11567 while (dst != target) {
11568 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11569 src--;
11570 dst[3] = (Sint16) sample0;
11571 dst[2] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
11572 dst[1] = (Sint16) ((sample0 + last_sample0) >> 1);
11573 dst[0] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
11574 last_sample0 = sample0;
11575 dst -= 4;
11576 }
11577
11578 cvt->len_cvt = dstsize;
11579 if (cvt->filters[++cvt->filter_index]) {
11580 cvt->filters[cvt->filter_index] (cvt, format);
11581 }
11582 }
11583
11584 static void SDLCALL
11585 SDL_Downsample_S16MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
11586 {
11587 #ifdef DEBUG_CONVERT
11588 fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 1 channels.\n");
11589 #endif
11590
11591 const int srcsize = cvt->len_cvt;
11592 const int dstsize = cvt->len_cvt / 4;
11593 Sint16 *dst = (Sint16 *) cvt->buf;
11594 const Sint16 *src = (Sint16 *) cvt->buf;
11595 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
11596 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11597 while (dst != target) {
11598 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11599 src += 4;
11600 dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
11601 last_sample0 = sample0;
11602 dst++;
11603 }
11604
11605 cvt->len_cvt = dstsize;
11606 if (cvt->filters[++cvt->filter_index]) {
11607 cvt->filters[cvt->filter_index] (cvt, format);
11608 }
11609 }
11610
11611 static void SDLCALL
11612 SDL_Upsample_S16MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
11613 {
11614 #ifdef DEBUG_CONVERT
11615 fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 2 channels.\n");
11616 #endif
11617
11618 const int srcsize = cvt->len_cvt;
11619 const int dstsize = cvt->len_cvt * 2;
11620 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
11621 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
11622 const Sint16 *target = ((const Sint16 *) cvt->buf) - 2;
11623 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
11624 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11625 while (dst != target) {
11626 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
11627 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11628 src -= 2;
11629 dst[3] = (Sint16) ((sample1 + last_sample1) >> 1);
11630 dst[2] = (Sint16) ((sample0 + last_sample0) >> 1);
11631 dst[1] = (Sint16) sample1;
11632 dst[0] = (Sint16) sample0;
11633 last_sample1 = sample1;
11634 last_sample0 = sample0;
11635 dst -= 4;
11636 }
11637
11638 cvt->len_cvt = dstsize;
11639 if (cvt->filters[++cvt->filter_index]) {
11640 cvt->filters[cvt->filter_index] (cvt, format);
11641 }
11642 }
11643
11644 static void SDLCALL
11645 SDL_Downsample_S16MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
11646 {
11647 #ifdef DEBUG_CONVERT
11648 fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 2 channels.\n");
11649 #endif
11650
11651 const int srcsize = cvt->len_cvt;
11652 const int dstsize = cvt->len_cvt / 2;
11653 Sint16 *dst = (Sint16 *) cvt->buf;
11654 const Sint16 *src = (Sint16 *) cvt->buf;
11655 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
11656 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11657 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
11658 while (dst != target) {
11659 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11660 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
11661 src += 4;
11662 dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
11663 dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
11664 last_sample0 = sample0;
11665 last_sample1 = sample1;
11666 dst += 2;
11667 }
11668
11669 cvt->len_cvt = dstsize;
11670 if (cvt->filters[++cvt->filter_index]) {
11671 cvt->filters[cvt->filter_index] (cvt, format);
11672 }
11673 }
11674
11675 static void SDLCALL
11676 SDL_Upsample_S16MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
11677 {
11678 #ifdef DEBUG_CONVERT
11679 fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 2 channels.\n");
11680 #endif
11681
11682 const int srcsize = cvt->len_cvt;
11683 const int dstsize = cvt->len_cvt * 4;
11684 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 2;
11685 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 2;
11686 const Sint16 *target = ((const Sint16 *) cvt->buf) - 2;
11687 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
11688 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11689 while (dst != target) {
11690 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
11691 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11692 src -= 2;
11693 dst[7] = (Sint16) sample1;
11694 dst[6] = (Sint16) sample0;
11695 dst[5] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
11696 dst[4] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
11697 dst[3] = (Sint16) ((sample1 + last_sample1) >> 1);
11698 dst[2] = (Sint16) ((sample0 + last_sample0) >> 1);
11699 dst[1] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
11700 dst[0] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
11701 last_sample1 = sample1;
11702 last_sample0 = sample0;
11703 dst -= 8;
11704 }
11705
11706 cvt->len_cvt = dstsize;
11707 if (cvt->filters[++cvt->filter_index]) {
11708 cvt->filters[cvt->filter_index] (cvt, format);
11709 }
11710 }
11711
11712 static void SDLCALL
11713 SDL_Downsample_S16MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
11714 {
11715 #ifdef DEBUG_CONVERT
11716 fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 2 channels.\n");
11717 #endif
11718
11719 const int srcsize = cvt->len_cvt;
11720 const int dstsize = cvt->len_cvt / 4;
11721 Sint16 *dst = (Sint16 *) cvt->buf;
11722 const Sint16 *src = (Sint16 *) cvt->buf;
11723 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
11724 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11725 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
11726 while (dst != target) {
11727 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11728 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
11729 src += 8;
11730 dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
11731 dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
11732 last_sample0 = sample0;
11733 last_sample1 = sample1;
11734 dst += 2;
11735 }
11736
11737 cvt->len_cvt = dstsize;
11738 if (cvt->filters[++cvt->filter_index]) {
11739 cvt->filters[cvt->filter_index] (cvt, format);
11740 }
11741 }
11742
11743 static void SDLCALL
11744 SDL_Upsample_S16MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
11745 {
11746 #ifdef DEBUG_CONVERT
11747 fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 4 channels.\n");
11748 #endif
11749
11750 const int srcsize = cvt->len_cvt;
11751 const int dstsize = cvt->len_cvt * 2;
11752 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4;
11753 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
11754 const Sint16 *target = ((const Sint16 *) cvt->buf) - 4;
11755 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
11756 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
11757 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
11758 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11759 while (dst != target) {
11760 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
11761 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
11762 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
11763 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11764 src -= 4;
11765 dst[7] = (Sint16) ((sample3 + last_sample3) >> 1);
11766 dst[6] = (Sint16) ((sample2 + last_sample2) >> 1);
11767 dst[5] = (Sint16) ((sample1 + last_sample1) >> 1);
11768 dst[4] = (Sint16) ((sample0 + last_sample0) >> 1);
11769 dst[3] = (Sint16) sample3;
11770 dst[2] = (Sint16) sample2;
11771 dst[1] = (Sint16) sample1;
11772 dst[0] = (Sint16) sample0;
11773 last_sample3 = sample3;
11774 last_sample2 = sample2;
11775 last_sample1 = sample1;
11776 last_sample0 = sample0;
11777 dst -= 8;
11778 }
11779
11780 cvt->len_cvt = dstsize;
11781 if (cvt->filters[++cvt->filter_index]) {
11782 cvt->filters[cvt->filter_index] (cvt, format);
11783 }
11784 }
11785
11786 static void SDLCALL
11787 SDL_Downsample_S16MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
11788 {
11789 #ifdef DEBUG_CONVERT
11790 fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 4 channels.\n");
11791 #endif
11792
11793 const int srcsize = cvt->len_cvt;
11794 const int dstsize = cvt->len_cvt / 2;
11795 Sint16 *dst = (Sint16 *) cvt->buf;
11796 const Sint16 *src = (Sint16 *) cvt->buf;
11797 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
11798 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11799 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
11800 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
11801 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
11802 while (dst != target) {
11803 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11804 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
11805 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
11806 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
11807 src += 8;
11808 dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
11809 dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
11810 dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
11811 dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
11812 last_sample0 = sample0;
11813 last_sample1 = sample1;
11814 last_sample2 = sample2;
11815 last_sample3 = sample3;
11816 dst += 4;
11817 }
11818
11819 cvt->len_cvt = dstsize;
11820 if (cvt->filters[++cvt->filter_index]) {
11821 cvt->filters[cvt->filter_index] (cvt, format);
11822 }
11823 }
11824
11825 static void SDLCALL
11826 SDL_Upsample_S16MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
11827 {
11828 #ifdef DEBUG_CONVERT
11829 fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 4 channels.\n");
11830 #endif
11831
11832 const int srcsize = cvt->len_cvt;
11833 const int dstsize = cvt->len_cvt * 4;
11834 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 4;
11835 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 4;
11836 const Sint16 *target = ((const Sint16 *) cvt->buf) - 4;
11837 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
11838 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
11839 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
11840 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11841 while (dst != target) {
11842 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
11843 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
11844 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
11845 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11846 src -= 4;
11847 dst[15] = (Sint16) sample3;
11848 dst[14] = (Sint16) sample2;
11849 dst[13] = (Sint16) sample1;
11850 dst[12] = (Sint16) sample0;
11851 dst[11] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
11852 dst[10] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
11853 dst[9] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
11854 dst[8] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
11855 dst[7] = (Sint16) ((sample3 + last_sample3) >> 1);
11856 dst[6] = (Sint16) ((sample2 + last_sample2) >> 1);
11857 dst[5] = (Sint16) ((sample1 + last_sample1) >> 1);
11858 dst[4] = (Sint16) ((sample0 + last_sample0) >> 1);
11859 dst[3] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
11860 dst[2] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
11861 dst[1] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
11862 dst[0] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
11863 last_sample3 = sample3;
11864 last_sample2 = sample2;
11865 last_sample1 = sample1;
11866 last_sample0 = sample0;
11867 dst -= 16;
11868 }
11869
11870 cvt->len_cvt = dstsize;
11871 if (cvt->filters[++cvt->filter_index]) {
11872 cvt->filters[cvt->filter_index] (cvt, format);
11873 }
11874 }
11875
11876 static void SDLCALL
11877 SDL_Downsample_S16MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
11878 {
11879 #ifdef DEBUG_CONVERT
11880 fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 4 channels.\n");
11881 #endif
11882
11883 const int srcsize = cvt->len_cvt;
11884 const int dstsize = cvt->len_cvt / 4;
11885 Sint16 *dst = (Sint16 *) cvt->buf;
11886 const Sint16 *src = (Sint16 *) cvt->buf;
11887 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
11888 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11889 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
11890 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
11891 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
11892 while (dst != target) {
11893 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11894 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
11895 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
11896 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
11897 src += 16;
11898 dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
11899 dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
11900 dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
11901 dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
11902 last_sample0 = sample0;
11903 last_sample1 = sample1;
11904 last_sample2 = sample2;
11905 last_sample3 = sample3;
11906 dst += 4;
11907 }
11908
11909 cvt->len_cvt = dstsize;
11910 if (cvt->filters[++cvt->filter_index]) {
11911 cvt->filters[cvt->filter_index] (cvt, format);
11912 }
11913 }
11914
11915 static void SDLCALL
11916 SDL_Upsample_S16MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
11917 {
11918 #ifdef DEBUG_CONVERT
11919 fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 6 channels.\n");
11920 #endif
11921
11922 const int srcsize = cvt->len_cvt;
11923 const int dstsize = cvt->len_cvt * 2;
11924 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6;
11925 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
11926 const Sint16 *target = ((const Sint16 *) cvt->buf) - 6;
11927 Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
11928 Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
11929 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
11930 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
11931 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
11932 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11933 while (dst != target) {
11934 const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
11935 const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
11936 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
11937 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
11938 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
11939 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11940 src -= 6;
11941 dst[11] = (Sint16) ((sample5 + last_sample5) >> 1);
11942 dst[10] = (Sint16) ((sample4 + last_sample4) >> 1);
11943 dst[9] = (Sint16) ((sample3 + last_sample3) >> 1);
11944 dst[8] = (Sint16) ((sample2 + last_sample2) >> 1);
11945 dst[7] = (Sint16) ((sample1 + last_sample1) >> 1);
11946 dst[6] = (Sint16) ((sample0 + last_sample0) >> 1);
11947 dst[5] = (Sint16) sample5;
11948 dst[4] = (Sint16) sample4;
11949 dst[3] = (Sint16) sample3;
11950 dst[2] = (Sint16) sample2;
11951 dst[1] = (Sint16) sample1;
11952 dst[0] = (Sint16) sample0;
11953 last_sample5 = sample5;
11954 last_sample4 = sample4;
11955 last_sample3 = sample3;
11956 last_sample2 = sample2;
11957 last_sample1 = sample1;
11958 last_sample0 = sample0;
11959 dst -= 12;
11960 }
11961
11962 cvt->len_cvt = dstsize;
11963 if (cvt->filters[++cvt->filter_index]) {
11964 cvt->filters[cvt->filter_index] (cvt, format);
11965 }
11966 }
11967
11968 static void SDLCALL
11969 SDL_Downsample_S16MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
11970 {
11971 #ifdef DEBUG_CONVERT
11972 fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 6 channels.\n");
11973 #endif
11974
11975 const int srcsize = cvt->len_cvt;
11976 const int dstsize = cvt->len_cvt / 2;
11977 Sint16 *dst = (Sint16 *) cvt->buf;
11978 const Sint16 *src = (Sint16 *) cvt->buf;
11979 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
11980 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11981 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
11982 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
11983 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
11984 Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
11985 Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
11986 while (dst != target) {
11987 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
11988 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
11989 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
11990 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
11991 const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
11992 const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
11993 src += 12;
11994 dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
11995 dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
11996 dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
11997 dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
11998 dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
11999 dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
12000 last_sample0 = sample0;
12001 last_sample1 = sample1;
12002 last_sample2 = sample2;
12003 last_sample3 = sample3;
12004 last_sample4 = sample4;
12005 last_sample5 = sample5;
12006 dst += 6;
12007 }
12008
12009 cvt->len_cvt = dstsize;
12010 if (cvt->filters[++cvt->filter_index]) {
12011 cvt->filters[cvt->filter_index] (cvt, format);
12012 }
12013 }
12014
12015 static void SDLCALL
12016 SDL_Upsample_S16MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
12017 {
12018 #ifdef DEBUG_CONVERT
12019 fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 6 channels.\n");
12020 #endif
12021
12022 const int srcsize = cvt->len_cvt;
12023 const int dstsize = cvt->len_cvt * 4;
12024 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 6;
12025 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 6;
12026 const Sint16 *target = ((const Sint16 *) cvt->buf) - 6;
12027 Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
12028 Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
12029 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
12030 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
12031 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
12032 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
12033 while (dst != target) {
12034 const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
12035 const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
12036 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
12037 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
12038 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
12039 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
12040 src -= 6;
12041 dst[23] = (Sint16) sample5;
12042 dst[22] = (Sint16) sample4;
12043 dst[21] = (Sint16) sample3;
12044 dst[20] = (Sint16) sample2;
12045 dst[19] = (Sint16) sample1;
12046 dst[18] = (Sint16) sample0;
12047 dst[17] = (Sint16) (((3 * sample5) + last_sample5) >> 2);
12048 dst[16] = (Sint16) (((3 * sample4) + last_sample4) >> 2);
12049 dst[15] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
12050 dst[14] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
12051 dst[13] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
12052 dst[12] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
12053 dst[11] = (Sint16) ((sample5 + last_sample5) >> 1);
12054 dst[10] = (Sint16) ((sample4 + last_sample4) >> 1);
12055 dst[9] = (Sint16) ((sample3 + last_sample3) >> 1);
12056 dst[8] = (Sint16) ((sample2 + last_sample2) >> 1);
12057 dst[7] = (Sint16) ((sample1 + last_sample1) >> 1);
12058 dst[6] = (Sint16) ((sample0 + last_sample0) >> 1);
12059 dst[5] = (Sint16) ((sample5 + (3 * last_sample5)) >> 2);
12060 dst[4] = (Sint16) ((sample4 + (3 * last_sample4)) >> 2);
12061 dst[3] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
12062 dst[2] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
12063 dst[1] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
12064 dst[0] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
12065 last_sample5 = sample5;
12066 last_sample4 = sample4;
12067 last_sample3 = sample3;
12068 last_sample2 = sample2;
12069 last_sample1 = sample1;
12070 last_sample0 = sample0;
12071 dst -= 24;
12072 }
12073
12074 cvt->len_cvt = dstsize;
12075 if (cvt->filters[++cvt->filter_index]) {
12076 cvt->filters[cvt->filter_index] (cvt, format);
12077 }
12078 }
12079
12080 static void SDLCALL
12081 SDL_Downsample_S16MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
12082 {
12083 #ifdef DEBUG_CONVERT
12084 fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 6 channels.\n");
12085 #endif
12086
12087 const int srcsize = cvt->len_cvt;
12088 const int dstsize = cvt->len_cvt / 4;
12089 Sint16 *dst = (Sint16 *) cvt->buf;
12090 const Sint16 *src = (Sint16 *) cvt->buf;
12091 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
12092 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
12093 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
12094 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
12095 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
12096 Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
12097 Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
12098 while (dst != target) {
12099 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
12100 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
12101 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
12102 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
12103 const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
12104 const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
12105 src += 24;
12106 dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
12107 dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
12108 dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
12109 dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
12110 dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
12111 dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
12112 last_sample0 = sample0;
12113 last_sample1 = sample1;
12114 last_sample2 = sample2;
12115 last_sample3 = sample3;
12116 last_sample4 = sample4;
12117 last_sample5 = sample5;
12118 dst += 6;
12119 }
12120
12121 cvt->len_cvt = dstsize;
12122 if (cvt->filters[++cvt->filter_index]) {
12123 cvt->filters[cvt->filter_index] (cvt, format);
12124 }
12125 }
12126
12127 static void SDLCALL
12128 SDL_Upsample_S16MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
12129 {
12130 #ifdef DEBUG_CONVERT
12131 fprintf(stderr, "Upsample (x2) AUDIO_S16MSB, 8 channels.\n");
12132 #endif
12133
12134 const int srcsize = cvt->len_cvt;
12135 const int dstsize = cvt->len_cvt * 2;
12136 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8;
12137 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
12138 const Sint16 *target = ((const Sint16 *) cvt->buf) - 8;
12139 Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
12140 Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
12141 Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
12142 Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
12143 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
12144 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
12145 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
12146 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
12147 while (dst != target) {
12148 const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
12149 const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
12150 const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
12151 const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
12152 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
12153 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
12154 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
12155 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
12156 src -= 8;
12157 dst[15] = (Sint16) ((sample7 + last_sample7) >> 1);
12158 dst[14] = (Sint16) ((sample6 + last_sample6) >> 1);
12159 dst[13] = (Sint16) ((sample5 + last_sample5) >> 1);
12160 dst[12] = (Sint16) ((sample4 + last_sample4) >> 1);
12161 dst[11] = (Sint16) ((sample3 + last_sample3) >> 1);
12162 dst[10] = (Sint16) ((sample2 + last_sample2) >> 1);
12163 dst[9] = (Sint16) ((sample1 + last_sample1) >> 1);
12164 dst[8] = (Sint16) ((sample0 + last_sample0) >> 1);
12165 dst[7] = (Sint16) sample7;
12166 dst[6] = (Sint16) sample6;
12167 dst[5] = (Sint16) sample5;
12168 dst[4] = (Sint16) sample4;
12169 dst[3] = (Sint16) sample3;
12170 dst[2] = (Sint16) sample2;
12171 dst[1] = (Sint16) sample1;
12172 dst[0] = (Sint16) sample0;
12173 last_sample7 = sample7;
12174 last_sample6 = sample6;
12175 last_sample5 = sample5;
12176 last_sample4 = sample4;
12177 last_sample3 = sample3;
12178 last_sample2 = sample2;
12179 last_sample1 = sample1;
12180 last_sample0 = sample0;
12181 dst -= 16;
12182 }
12183
12184 cvt->len_cvt = dstsize;
12185 if (cvt->filters[++cvt->filter_index]) {
12186 cvt->filters[cvt->filter_index] (cvt, format);
12187 }
12188 }
12189
12190 static void SDLCALL
12191 SDL_Downsample_S16MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
12192 {
12193 #ifdef DEBUG_CONVERT
12194 fprintf(stderr, "Downsample (x2) AUDIO_S16MSB, 8 channels.\n");
12195 #endif
12196
12197 const int srcsize = cvt->len_cvt;
12198 const int dstsize = cvt->len_cvt / 2;
12199 Sint16 *dst = (Sint16 *) cvt->buf;
12200 const Sint16 *src = (Sint16 *) cvt->buf;
12201 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
12202 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
12203 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
12204 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
12205 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
12206 Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
12207 Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
12208 Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
12209 Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
12210 while (dst != target) {
12211 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
12212 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
12213 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
12214 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
12215 const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
12216 const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
12217 const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
12218 const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
12219 src += 16;
12220 dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
12221 dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
12222 dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
12223 dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
12224 dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
12225 dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
12226 dst[6] = (Sint16) ((sample6 + last_sample6) >> 1);
12227 dst[7] = (Sint16) ((sample7 + last_sample7) >> 1);
12228 last_sample0 = sample0;
12229 last_sample1 = sample1;
12230 last_sample2 = sample2;
12231 last_sample3 = sample3;
12232 last_sample4 = sample4;
12233 last_sample5 = sample5;
12234 last_sample6 = sample6;
12235 last_sample7 = sample7;
12236 dst += 8;
12237 }
12238
12239 cvt->len_cvt = dstsize;
12240 if (cvt->filters[++cvt->filter_index]) {
12241 cvt->filters[cvt->filter_index] (cvt, format);
12242 }
12243 }
12244
12245 static void SDLCALL
12246 SDL_Upsample_S16MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
12247 {
12248 #ifdef DEBUG_CONVERT
12249 fprintf(stderr, "Upsample (x4) AUDIO_S16MSB, 8 channels.\n");
12250 #endif
12251
12252 const int srcsize = cvt->len_cvt;
12253 const int dstsize = cvt->len_cvt * 4;
12254 Sint16 *dst = ((Sint16 *) (cvt->buf + dstsize)) - 8;
12255 const Sint16 *src = ((Sint16 *) (cvt->buf + cvt->len_cvt)) - 8;
12256 const Sint16 *target = ((const Sint16 *) cvt->buf) - 8;
12257 Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
12258 Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
12259 Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
12260 Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
12261 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
12262 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
12263 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
12264 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
12265 while (dst != target) {
12266 const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
12267 const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
12268 const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
12269 const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
12270 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
12271 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
12272 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
12273 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
12274 src -= 8;
12275 dst[31] = (Sint16) sample7;
12276 dst[30] = (Sint16) sample6;
12277 dst[29] = (Sint16) sample5;
12278 dst[28] = (Sint16) sample4;
12279 dst[27] = (Sint16) sample3;
12280 dst[26] = (Sint16) sample2;
12281 dst[25] = (Sint16) sample1;
12282 dst[24] = (Sint16) sample0;
12283 dst[23] = (Sint16) (((3 * sample7) + last_sample7) >> 2);
12284 dst[22] = (Sint16) (((3 * sample6) + last_sample6) >> 2);
12285 dst[21] = (Sint16) (((3 * sample5) + last_sample5) >> 2);
12286 dst[20] = (Sint16) (((3 * sample4) + last_sample4) >> 2);
12287 dst[19] = (Sint16) (((3 * sample3) + last_sample3) >> 2);
12288 dst[18] = (Sint16) (((3 * sample2) + last_sample2) >> 2);
12289 dst[17] = (Sint16) (((3 * sample1) + last_sample1) >> 2);
12290 dst[16] = (Sint16) (((3 * sample0) + last_sample0) >> 2);
12291 dst[15] = (Sint16) ((sample7 + last_sample7) >> 1);
12292 dst[14] = (Sint16) ((sample6 + last_sample6) >> 1);
12293 dst[13] = (Sint16) ((sample5 + last_sample5) >> 1);
12294 dst[12] = (Sint16) ((sample4 + last_sample4) >> 1);
12295 dst[11] = (Sint16) ((sample3 + last_sample3) >> 1);
12296 dst[10] = (Sint16) ((sample2 + last_sample2) >> 1);
12297 dst[9] = (Sint16) ((sample1 + last_sample1) >> 1);
12298 dst[8] = (Sint16) ((sample0 + last_sample0) >> 1);
12299 dst[7] = (Sint16) ((sample7 + (3 * last_sample7)) >> 2);
12300 dst[6] = (Sint16) ((sample6 + (3 * last_sample6)) >> 2);
12301 dst[5] = (Sint16) ((sample5 + (3 * last_sample5)) >> 2);
12302 dst[4] = (Sint16) ((sample4 + (3 * last_sample4)) >> 2);
12303 dst[3] = (Sint16) ((sample3 + (3 * last_sample3)) >> 2);
12304 dst[2] = (Sint16) ((sample2 + (3 * last_sample2)) >> 2);
12305 dst[1] = (Sint16) ((sample1 + (3 * last_sample1)) >> 2);
12306 dst[0] = (Sint16) ((sample0 + (3 * last_sample0)) >> 2);
12307 last_sample7 = sample7;
12308 last_sample6 = sample6;
12309 last_sample5 = sample5;
12310 last_sample4 = sample4;
12311 last_sample3 = sample3;
12312 last_sample2 = sample2;
12313 last_sample1 = sample1;
12314 last_sample0 = sample0;
12315 dst -= 32;
12316 }
12317
12318 cvt->len_cvt = dstsize;
12319 if (cvt->filters[++cvt->filter_index]) {
12320 cvt->filters[cvt->filter_index] (cvt, format);
12321 }
12322 }
12323
12324 static void SDLCALL
12325 SDL_Downsample_S16MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
12326 {
12327 #ifdef DEBUG_CONVERT
12328 fprintf(stderr, "Downsample (x4) AUDIO_S16MSB, 8 channels.\n");
12329 #endif
12330
12331 const int srcsize = cvt->len_cvt;
12332 const int dstsize = cvt->len_cvt / 4;
12333 Sint16 *dst = (Sint16 *) cvt->buf;
12334 const Sint16 *src = (Sint16 *) cvt->buf;
12335 const Sint16 *target = (const Sint16 *) (cvt->buf + dstsize);
12336 Sint32 last_sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
12337 Sint32 last_sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
12338 Sint32 last_sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
12339 Sint32 last_sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
12340 Sint32 last_sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
12341 Sint32 last_sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
12342 Sint32 last_sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
12343 Sint32 last_sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
12344 while (dst != target) {
12345 const Sint32 sample0 = (Sint32) ((Sint16) SDL_SwapBE16(src[0]));
12346 const Sint32 sample1 = (Sint32) ((Sint16) SDL_SwapBE16(src[1]));
12347 const Sint32 sample2 = (Sint32) ((Sint16) SDL_SwapBE16(src[2]));
12348 const Sint32 sample3 = (Sint32) ((Sint16) SDL_SwapBE16(src[3]));
12349 const Sint32 sample4 = (Sint32) ((Sint16) SDL_SwapBE16(src[4]));
12350 const Sint32 sample5 = (Sint32) ((Sint16) SDL_SwapBE16(src[5]));
12351 const Sint32 sample6 = (Sint32) ((Sint16) SDL_SwapBE16(src[6]));
12352 const Sint32 sample7 = (Sint32) ((Sint16) SDL_SwapBE16(src[7]));
12353 src += 32;
12354 dst[0] = (Sint16) ((sample0 + last_sample0) >> 1);
12355 dst[1] = (Sint16) ((sample1 + last_sample1) >> 1);
12356 dst[2] = (Sint16) ((sample2 + last_sample2) >> 1);
12357 dst[3] = (Sint16) ((sample3 + last_sample3) >> 1);
12358 dst[4] = (Sint16) ((sample4 + last_sample4) >> 1);
12359 dst[5] = (Sint16) ((sample5 + last_sample5) >> 1);
12360 dst[6] = (Sint16) ((sample6 + last_sample6) >> 1);
12361 dst[7] = (Sint16) ((sample7 + last_sample7) >> 1);
12362 last_sample0 = sample0;
12363 last_sample1 = sample1;
12364 last_sample2 = sample2;
12365 last_sample3 = sample3;
12366 last_sample4 = sample4;
12367 last_sample5 = sample5;
12368 last_sample6 = sample6;
12369 last_sample7 = sample7;
12370 dst += 8;
12371 }
12372
12373 cvt->len_cvt = dstsize;
12374 if (cvt->filters[++cvt->filter_index]) {
12375 cvt->filters[cvt->filter_index] (cvt, format);
12376 }
12377 }
12378
12379 static void SDLCALL
12380 SDL_Upsample_S32LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
12381 {
12382 #ifdef DEBUG_CONVERT
12383 fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 1 channels.\n");
12384 #endif
12385
12386 const int srcsize = cvt->len_cvt;
12387 const int dstsize = cvt->len_cvt * 2;
12388 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1;
12389 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
12390 const Sint32 *target = ((const Sint32 *) cvt->buf) - 1;
12391 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12392 while (dst != target) {
12393 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12394 src--;
12395 dst[1] = (Sint32) ((sample0 + last_sample0) >> 1);
12396 dst[0] = (Sint32) sample0;
12397 last_sample0 = sample0;
12398 dst -= 2;
12399 }
12400
12401 cvt->len_cvt = dstsize;
12402 if (cvt->filters[++cvt->filter_index]) {
12403 cvt->filters[cvt->filter_index] (cvt, format);
12404 }
12405 }
12406
12407 static void SDLCALL
12408 SDL_Downsample_S32LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
12409 {
12410 #ifdef DEBUG_CONVERT
12411 fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 1 channels.\n");
12412 #endif
12413
12414 const int srcsize = cvt->len_cvt;
12415 const int dstsize = cvt->len_cvt / 2;
12416 Sint32 *dst = (Sint32 *) cvt->buf;
12417 const Sint32 *src = (Sint32 *) cvt->buf;
12418 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
12419 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12420 while (dst != target) {
12421 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12422 src += 2;
12423 dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
12424 last_sample0 = sample0;
12425 dst++;
12426 }
12427
12428 cvt->len_cvt = dstsize;
12429 if (cvt->filters[++cvt->filter_index]) {
12430 cvt->filters[cvt->filter_index] (cvt, format);
12431 }
12432 }
12433
12434 static void SDLCALL
12435 SDL_Upsample_S32LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
12436 {
12437 #ifdef DEBUG_CONVERT
12438 fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 1 channels.\n");
12439 #endif
12440
12441 const int srcsize = cvt->len_cvt;
12442 const int dstsize = cvt->len_cvt * 4;
12443 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1;
12444 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
12445 const Sint32 *target = ((const Sint32 *) cvt->buf) - 1;
12446 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12447 while (dst != target) {
12448 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12449 src--;
12450 dst[3] = (Sint32) sample0;
12451 dst[2] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
12452 dst[1] = (Sint32) ((sample0 + last_sample0) >> 1);
12453 dst[0] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
12454 last_sample0 = sample0;
12455 dst -= 4;
12456 }
12457
12458 cvt->len_cvt = dstsize;
12459 if (cvt->filters[++cvt->filter_index]) {
12460 cvt->filters[cvt->filter_index] (cvt, format);
12461 }
12462 }
12463
12464 static void SDLCALL
12465 SDL_Downsample_S32LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
12466 {
12467 #ifdef DEBUG_CONVERT
12468 fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 1 channels.\n");
12469 #endif
12470
12471 const int srcsize = cvt->len_cvt;
12472 const int dstsize = cvt->len_cvt / 4;
12473 Sint32 *dst = (Sint32 *) cvt->buf;
12474 const Sint32 *src = (Sint32 *) cvt->buf;
12475 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
12476 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12477 while (dst != target) {
12478 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12479 src += 4;
12480 dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
12481 last_sample0 = sample0;
12482 dst++;
12483 }
12484
12485 cvt->len_cvt = dstsize;
12486 if (cvt->filters[++cvt->filter_index]) {
12487 cvt->filters[cvt->filter_index] (cvt, format);
12488 }
12489 }
12490
12491 static void SDLCALL
12492 SDL_Upsample_S32LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
12493 {
12494 #ifdef DEBUG_CONVERT
12495 fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 2 channels.\n");
12496 #endif
12497
12498 const int srcsize = cvt->len_cvt;
12499 const int dstsize = cvt->len_cvt * 2;
12500 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2;
12501 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
12502 const Sint32 *target = ((const Sint32 *) cvt->buf) - 2;
12503 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12504 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12505 while (dst != target) {
12506 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12507 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12508 src -= 2;
12509 dst[3] = (Sint32) ((sample1 + last_sample1) >> 1);
12510 dst[2] = (Sint32) ((sample0 + last_sample0) >> 1);
12511 dst[1] = (Sint32) sample1;
12512 dst[0] = (Sint32) sample0;
12513 last_sample1 = sample1;
12514 last_sample0 = sample0;
12515 dst -= 4;
12516 }
12517
12518 cvt->len_cvt = dstsize;
12519 if (cvt->filters[++cvt->filter_index]) {
12520 cvt->filters[cvt->filter_index] (cvt, format);
12521 }
12522 }
12523
12524 static void SDLCALL
12525 SDL_Downsample_S32LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
12526 {
12527 #ifdef DEBUG_CONVERT
12528 fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 2 channels.\n");
12529 #endif
12530
12531 const int srcsize = cvt->len_cvt;
12532 const int dstsize = cvt->len_cvt / 2;
12533 Sint32 *dst = (Sint32 *) cvt->buf;
12534 const Sint32 *src = (Sint32 *) cvt->buf;
12535 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
12536 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12537 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12538 while (dst != target) {
12539 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12540 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12541 src += 4;
12542 dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
12543 dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
12544 last_sample0 = sample0;
12545 last_sample1 = sample1;
12546 dst += 2;
12547 }
12548
12549 cvt->len_cvt = dstsize;
12550 if (cvt->filters[++cvt->filter_index]) {
12551 cvt->filters[cvt->filter_index] (cvt, format);
12552 }
12553 }
12554
12555 static void SDLCALL
12556 SDL_Upsample_S32LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
12557 {
12558 #ifdef DEBUG_CONVERT
12559 fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 2 channels.\n");
12560 #endif
12561
12562 const int srcsize = cvt->len_cvt;
12563 const int dstsize = cvt->len_cvt * 4;
12564 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2;
12565 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
12566 const Sint32 *target = ((const Sint32 *) cvt->buf) - 2;
12567 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12568 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12569 while (dst != target) {
12570 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12571 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12572 src -= 2;
12573 dst[7] = (Sint32) sample1;
12574 dst[6] = (Sint32) sample0;
12575 dst[5] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
12576 dst[4] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
12577 dst[3] = (Sint32) ((sample1 + last_sample1) >> 1);
12578 dst[2] = (Sint32) ((sample0 + last_sample0) >> 1);
12579 dst[1] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
12580 dst[0] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
12581 last_sample1 = sample1;
12582 last_sample0 = sample0;
12583 dst -= 8;
12584 }
12585
12586 cvt->len_cvt = dstsize;
12587 if (cvt->filters[++cvt->filter_index]) {
12588 cvt->filters[cvt->filter_index] (cvt, format);
12589 }
12590 }
12591
12592 static void SDLCALL
12593 SDL_Downsample_S32LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
12594 {
12595 #ifdef DEBUG_CONVERT
12596 fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 2 channels.\n");
12597 #endif
12598
12599 const int srcsize = cvt->len_cvt;
12600 const int dstsize = cvt->len_cvt / 4;
12601 Sint32 *dst = (Sint32 *) cvt->buf;
12602 const Sint32 *src = (Sint32 *) cvt->buf;
12603 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
12604 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12605 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12606 while (dst != target) {
12607 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12608 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12609 src += 8;
12610 dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
12611 dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
12612 last_sample0 = sample0;
12613 last_sample1 = sample1;
12614 dst += 2;
12615 }
12616
12617 cvt->len_cvt = dstsize;
12618 if (cvt->filters[++cvt->filter_index]) {
12619 cvt->filters[cvt->filter_index] (cvt, format);
12620 }
12621 }
12622
12623 static void SDLCALL
12624 SDL_Upsample_S32LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
12625 {
12626 #ifdef DEBUG_CONVERT
12627 fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 4 channels.\n");
12628 #endif
12629
12630 const int srcsize = cvt->len_cvt;
12631 const int dstsize = cvt->len_cvt * 2;
12632 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4;
12633 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
12634 const Sint32 *target = ((const Sint32 *) cvt->buf) - 4;
12635 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
12636 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
12637 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12638 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12639 while (dst != target) {
12640 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
12641 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
12642 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12643 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12644 src -= 4;
12645 dst[7] = (Sint32) ((sample3 + last_sample3) >> 1);
12646 dst[6] = (Sint32) ((sample2 + last_sample2) >> 1);
12647 dst[5] = (Sint32) ((sample1 + last_sample1) >> 1);
12648 dst[4] = (Sint32) ((sample0 + last_sample0) >> 1);
12649 dst[3] = (Sint32) sample3;
12650 dst[2] = (Sint32) sample2;
12651 dst[1] = (Sint32) sample1;
12652 dst[0] = (Sint32) sample0;
12653 last_sample3 = sample3;
12654 last_sample2 = sample2;
12655 last_sample1 = sample1;
12656 last_sample0 = sample0;
12657 dst -= 8;
12658 }
12659
12660 cvt->len_cvt = dstsize;
12661 if (cvt->filters[++cvt->filter_index]) {
12662 cvt->filters[cvt->filter_index] (cvt, format);
12663 }
12664 }
12665
12666 static void SDLCALL
12667 SDL_Downsample_S32LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
12668 {
12669 #ifdef DEBUG_CONVERT
12670 fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 4 channels.\n");
12671 #endif
12672
12673 const int srcsize = cvt->len_cvt;
12674 const int dstsize = cvt->len_cvt / 2;
12675 Sint32 *dst = (Sint32 *) cvt->buf;
12676 const Sint32 *src = (Sint32 *) cvt->buf;
12677 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
12678 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12679 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12680 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
12681 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
12682 while (dst != target) {
12683 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12684 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12685 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
12686 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
12687 src += 8;
12688 dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
12689 dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
12690 dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
12691 dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
12692 last_sample0 = sample0;
12693 last_sample1 = sample1;
12694 last_sample2 = sample2;
12695 last_sample3 = sample3;
12696 dst += 4;
12697 }
12698
12699 cvt->len_cvt = dstsize;
12700 if (cvt->filters[++cvt->filter_index]) {
12701 cvt->filters[cvt->filter_index] (cvt, format);
12702 }
12703 }
12704
12705 static void SDLCALL
12706 SDL_Upsample_S32LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
12707 {
12708 #ifdef DEBUG_CONVERT
12709 fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 4 channels.\n");
12710 #endif
12711
12712 const int srcsize = cvt->len_cvt;
12713 const int dstsize = cvt->len_cvt * 4;
12714 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4;
12715 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
12716 const Sint32 *target = ((const Sint32 *) cvt->buf) - 4;
12717 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
12718 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
12719 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12720 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12721 while (dst != target) {
12722 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
12723 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
12724 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12725 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12726 src -= 4;
12727 dst[15] = (Sint32) sample3;
12728 dst[14] = (Sint32) sample2;
12729 dst[13] = (Sint32) sample1;
12730 dst[12] = (Sint32) sample0;
12731 dst[11] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
12732 dst[10] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
12733 dst[9] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
12734 dst[8] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
12735 dst[7] = (Sint32) ((sample3 + last_sample3) >> 1);
12736 dst[6] = (Sint32) ((sample2 + last_sample2) >> 1);
12737 dst[5] = (Sint32) ((sample1 + last_sample1) >> 1);
12738 dst[4] = (Sint32) ((sample0 + last_sample0) >> 1);
12739 dst[3] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
12740 dst[2] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
12741 dst[1] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
12742 dst[0] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
12743 last_sample3 = sample3;
12744 last_sample2 = sample2;
12745 last_sample1 = sample1;
12746 last_sample0 = sample0;
12747 dst -= 16;
12748 }
12749
12750 cvt->len_cvt = dstsize;
12751 if (cvt->filters[++cvt->filter_index]) {
12752 cvt->filters[cvt->filter_index] (cvt, format);
12753 }
12754 }
12755
12756 static void SDLCALL
12757 SDL_Downsample_S32LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
12758 {
12759 #ifdef DEBUG_CONVERT
12760 fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 4 channels.\n");
12761 #endif
12762
12763 const int srcsize = cvt->len_cvt;
12764 const int dstsize = cvt->len_cvt / 4;
12765 Sint32 *dst = (Sint32 *) cvt->buf;
12766 const Sint32 *src = (Sint32 *) cvt->buf;
12767 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
12768 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12769 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12770 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
12771 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
12772 while (dst != target) {
12773 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12774 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12775 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
12776 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
12777 src += 16;
12778 dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
12779 dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
12780 dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
12781 dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
12782 last_sample0 = sample0;
12783 last_sample1 = sample1;
12784 last_sample2 = sample2;
12785 last_sample3 = sample3;
12786 dst += 4;
12787 }
12788
12789 cvt->len_cvt = dstsize;
12790 if (cvt->filters[++cvt->filter_index]) {
12791 cvt->filters[cvt->filter_index] (cvt, format);
12792 }
12793 }
12794
12795 static void SDLCALL
12796 SDL_Upsample_S32LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
12797 {
12798 #ifdef DEBUG_CONVERT
12799 fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 6 channels.\n");
12800 #endif
12801
12802 const int srcsize = cvt->len_cvt;
12803 const int dstsize = cvt->len_cvt * 2;
12804 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6;
12805 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
12806 const Sint32 *target = ((const Sint32 *) cvt->buf) - 6;
12807 Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
12808 Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
12809 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
12810 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
12811 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12812 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12813 while (dst != target) {
12814 const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
12815 const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
12816 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
12817 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
12818 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12819 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12820 src -= 6;
12821 dst[11] = (Sint32) ((sample5 + last_sample5) >> 1);
12822 dst[10] = (Sint32) ((sample4 + last_sample4) >> 1);
12823 dst[9] = (Sint32) ((sample3 + last_sample3) >> 1);
12824 dst[8] = (Sint32) ((sample2 + last_sample2) >> 1);
12825 dst[7] = (Sint32) ((sample1 + last_sample1) >> 1);
12826 dst[6] = (Sint32) ((sample0 + last_sample0) >> 1);
12827 dst[5] = (Sint32) sample5;
12828 dst[4] = (Sint32) sample4;
12829 dst[3] = (Sint32) sample3;
12830 dst[2] = (Sint32) sample2;
12831 dst[1] = (Sint32) sample1;
12832 dst[0] = (Sint32) sample0;
12833 last_sample5 = sample5;
12834 last_sample4 = sample4;
12835 last_sample3 = sample3;
12836 last_sample2 = sample2;
12837 last_sample1 = sample1;
12838 last_sample0 = sample0;
12839 dst -= 12;
12840 }
12841
12842 cvt->len_cvt = dstsize;
12843 if (cvt->filters[++cvt->filter_index]) {
12844 cvt->filters[cvt->filter_index] (cvt, format);
12845 }
12846 }
12847
12848 static void SDLCALL
12849 SDL_Downsample_S32LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
12850 {
12851 #ifdef DEBUG_CONVERT
12852 fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 6 channels.\n");
12853 #endif
12854
12855 const int srcsize = cvt->len_cvt;
12856 const int dstsize = cvt->len_cvt / 2;
12857 Sint32 *dst = (Sint32 *) cvt->buf;
12858 const Sint32 *src = (Sint32 *) cvt->buf;
12859 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
12860 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12861 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12862 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
12863 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
12864 Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
12865 Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
12866 while (dst != target) {
12867 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12868 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12869 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
12870 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
12871 const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
12872 const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
12873 src += 12;
12874 dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
12875 dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
12876 dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
12877 dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
12878 dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
12879 dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
12880 last_sample0 = sample0;
12881 last_sample1 = sample1;
12882 last_sample2 = sample2;
12883 last_sample3 = sample3;
12884 last_sample4 = sample4;
12885 last_sample5 = sample5;
12886 dst += 6;
12887 }
12888
12889 cvt->len_cvt = dstsize;
12890 if (cvt->filters[++cvt->filter_index]) {
12891 cvt->filters[cvt->filter_index] (cvt, format);
12892 }
12893 }
12894
12895 static void SDLCALL
12896 SDL_Upsample_S32LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
12897 {
12898 #ifdef DEBUG_CONVERT
12899 fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 6 channels.\n");
12900 #endif
12901
12902 const int srcsize = cvt->len_cvt;
12903 const int dstsize = cvt->len_cvt * 4;
12904 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6;
12905 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
12906 const Sint32 *target = ((const Sint32 *) cvt->buf) - 6;
12907 Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
12908 Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
12909 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
12910 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
12911 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12912 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12913 while (dst != target) {
12914 const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
12915 const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
12916 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
12917 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
12918 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12919 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12920 src -= 6;
12921 dst[23] = (Sint32) sample5;
12922 dst[22] = (Sint32) sample4;
12923 dst[21] = (Sint32) sample3;
12924 dst[20] = (Sint32) sample2;
12925 dst[19] = (Sint32) sample1;
12926 dst[18] = (Sint32) sample0;
12927 dst[17] = (Sint32) (((3 * sample5) + last_sample5) >> 2);
12928 dst[16] = (Sint32) (((3 * sample4) + last_sample4) >> 2);
12929 dst[15] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
12930 dst[14] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
12931 dst[13] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
12932 dst[12] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
12933 dst[11] = (Sint32) ((sample5 + last_sample5) >> 1);
12934 dst[10] = (Sint32) ((sample4 + last_sample4) >> 1);
12935 dst[9] = (Sint32) ((sample3 + last_sample3) >> 1);
12936 dst[8] = (Sint32) ((sample2 + last_sample2) >> 1);
12937 dst[7] = (Sint32) ((sample1 + last_sample1) >> 1);
12938 dst[6] = (Sint32) ((sample0 + last_sample0) >> 1);
12939 dst[5] = (Sint32) ((sample5 + (3 * last_sample5)) >> 2);
12940 dst[4] = (Sint32) ((sample4 + (3 * last_sample4)) >> 2);
12941 dst[3] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
12942 dst[2] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
12943 dst[1] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
12944 dst[0] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
12945 last_sample5 = sample5;
12946 last_sample4 = sample4;
12947 last_sample3 = sample3;
12948 last_sample2 = sample2;
12949 last_sample1 = sample1;
12950 last_sample0 = sample0;
12951 dst -= 24;
12952 }
12953
12954 cvt->len_cvt = dstsize;
12955 if (cvt->filters[++cvt->filter_index]) {
12956 cvt->filters[cvt->filter_index] (cvt, format);
12957 }
12958 }
12959
12960 static void SDLCALL
12961 SDL_Downsample_S32LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
12962 {
12963 #ifdef DEBUG_CONVERT
12964 fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 6 channels.\n");
12965 #endif
12966
12967 const int srcsize = cvt->len_cvt;
12968 const int dstsize = cvt->len_cvt / 4;
12969 Sint32 *dst = (Sint32 *) cvt->buf;
12970 const Sint32 *src = (Sint32 *) cvt->buf;
12971 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
12972 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12973 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12974 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
12975 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
12976 Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
12977 Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
12978 while (dst != target) {
12979 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
12980 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
12981 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
12982 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
12983 const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
12984 const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
12985 src += 24;
12986 dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
12987 dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
12988 dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
12989 dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
12990 dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
12991 dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
12992 last_sample0 = sample0;
12993 last_sample1 = sample1;
12994 last_sample2 = sample2;
12995 last_sample3 = sample3;
12996 last_sample4 = sample4;
12997 last_sample5 = sample5;
12998 dst += 6;
12999 }
13000
13001 cvt->len_cvt = dstsize;
13002 if (cvt->filters[++cvt->filter_index]) {
13003 cvt->filters[cvt->filter_index] (cvt, format);
13004 }
13005 }
13006
13007 static void SDLCALL
13008 SDL_Upsample_S32LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
13009 {
13010 #ifdef DEBUG_CONVERT
13011 fprintf(stderr, "Upsample (x2) AUDIO_S32LSB, 8 channels.\n");
13012 #endif
13013
13014 const int srcsize = cvt->len_cvt;
13015 const int dstsize = cvt->len_cvt * 2;
13016 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8;
13017 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
13018 const Sint32 *target = ((const Sint32 *) cvt->buf) - 8;
13019 Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
13020 Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
13021 Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
13022 Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
13023 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
13024 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
13025 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
13026 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
13027 while (dst != target) {
13028 const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
13029 const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
13030 const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
13031 const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
13032 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
13033 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
13034 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
13035 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
13036 src -= 8;
13037 dst[15] = (Sint32) ((sample7 + last_sample7) >> 1);
13038 dst[14] = (Sint32) ((sample6 + last_sample6) >> 1);
13039 dst[13] = (Sint32) ((sample5 + last_sample5) >> 1);
13040 dst[12] = (Sint32) ((sample4 + last_sample4) >> 1);
13041 dst[11] = (Sint32) ((sample3 + last_sample3) >> 1);
13042 dst[10] = (Sint32) ((sample2 + last_sample2) >> 1);
13043 dst[9] = (Sint32) ((sample1 + last_sample1) >> 1);
13044 dst[8] = (Sint32) ((sample0 + last_sample0) >> 1);
13045 dst[7] = (Sint32) sample7;
13046 dst[6] = (Sint32) sample6;
13047 dst[5] = (Sint32) sample5;
13048 dst[4] = (Sint32) sample4;
13049 dst[3] = (Sint32) sample3;
13050 dst[2] = (Sint32) sample2;
13051 dst[1] = (Sint32) sample1;
13052 dst[0] = (Sint32) sample0;
13053 last_sample7 = sample7;
13054 last_sample6 = sample6;
13055 last_sample5 = sample5;
13056 last_sample4 = sample4;
13057 last_sample3 = sample3;
13058 last_sample2 = sample2;
13059 last_sample1 = sample1;
13060 last_sample0 = sample0;
13061 dst -= 16;
13062 }
13063
13064 cvt->len_cvt = dstsize;
13065 if (cvt->filters[++cvt->filter_index]) {
13066 cvt->filters[cvt->filter_index] (cvt, format);
13067 }
13068 }
13069
13070 static void SDLCALL
13071 SDL_Downsample_S32LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
13072 {
13073 #ifdef DEBUG_CONVERT
13074 fprintf(stderr, "Downsample (x2) AUDIO_S32LSB, 8 channels.\n");
13075 #endif
13076
13077 const int srcsize = cvt->len_cvt;
13078 const int dstsize = cvt->len_cvt / 2;
13079 Sint32 *dst = (Sint32 *) cvt->buf;
13080 const Sint32 *src = (Sint32 *) cvt->buf;
13081 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
13082 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
13083 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
13084 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
13085 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
13086 Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
13087 Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
13088 Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
13089 Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
13090 while (dst != target) {
13091 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
13092 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
13093 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
13094 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
13095 const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
13096 const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
13097 const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
13098 const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
13099 src += 16;
13100 dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
13101 dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
13102 dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
13103 dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
13104 dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
13105 dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
13106 dst[6] = (Sint32) ((sample6 + last_sample6) >> 1);
13107 dst[7] = (Sint32) ((sample7 + last_sample7) >> 1);
13108 last_sample0 = sample0;
13109 last_sample1 = sample1;
13110 last_sample2 = sample2;
13111 last_sample3 = sample3;
13112 last_sample4 = sample4;
13113 last_sample5 = sample5;
13114 last_sample6 = sample6;
13115 last_sample7 = sample7;
13116 dst += 8;
13117 }
13118
13119 cvt->len_cvt = dstsize;
13120 if (cvt->filters[++cvt->filter_index]) {
13121 cvt->filters[cvt->filter_index] (cvt, format);
13122 }
13123 }
13124
13125 static void SDLCALL
13126 SDL_Upsample_S32LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
13127 {
13128 #ifdef DEBUG_CONVERT
13129 fprintf(stderr, "Upsample (x4) AUDIO_S32LSB, 8 channels.\n");
13130 #endif
13131
13132 const int srcsize = cvt->len_cvt;
13133 const int dstsize = cvt->len_cvt * 4;
13134 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8;
13135 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
13136 const Sint32 *target = ((const Sint32 *) cvt->buf) - 8;
13137 Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
13138 Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
13139 Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
13140 Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
13141 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
13142 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
13143 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
13144 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
13145 while (dst != target) {
13146 const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
13147 const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
13148 const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
13149 const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
13150 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
13151 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
13152 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
13153 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
13154 src -= 8;
13155 dst[31] = (Sint32) sample7;
13156 dst[30] = (Sint32) sample6;
13157 dst[29] = (Sint32) sample5;
13158 dst[28] = (Sint32) sample4;
13159 dst[27] = (Sint32) sample3;
13160 dst[26] = (Sint32) sample2;
13161 dst[25] = (Sint32) sample1;
13162 dst[24] = (Sint32) sample0;
13163 dst[23] = (Sint32) (((3 * sample7) + last_sample7) >> 2);
13164 dst[22] = (Sint32) (((3 * sample6) + last_sample6) >> 2);
13165 dst[21] = (Sint32) (((3 * sample5) + last_sample5) >> 2);
13166 dst[20] = (Sint32) (((3 * sample4) + last_sample4) >> 2);
13167 dst[19] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
13168 dst[18] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
13169 dst[17] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
13170 dst[16] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
13171 dst[15] = (Sint32) ((sample7 + last_sample7) >> 1);
13172 dst[14] = (Sint32) ((sample6 + last_sample6) >> 1);
13173 dst[13] = (Sint32) ((sample5 + last_sample5) >> 1);
13174 dst[12] = (Sint32) ((sample4 + last_sample4) >> 1);
13175 dst[11] = (Sint32) ((sample3 + last_sample3) >> 1);
13176 dst[10] = (Sint32) ((sample2 + last_sample2) >> 1);
13177 dst[9] = (Sint32) ((sample1 + last_sample1) >> 1);
13178 dst[8] = (Sint32) ((sample0 + last_sample0) >> 1);
13179 dst[7] = (Sint32) ((sample7 + (3 * last_sample7)) >> 2);
13180 dst[6] = (Sint32) ((sample6 + (3 * last_sample6)) >> 2);
13181 dst[5] = (Sint32) ((sample5 + (3 * last_sample5)) >> 2);
13182 dst[4] = (Sint32) ((sample4 + (3 * last_sample4)) >> 2);
13183 dst[3] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
13184 dst[2] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
13185 dst[1] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
13186 dst[0] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
13187 last_sample7 = sample7;
13188 last_sample6 = sample6;
13189 last_sample5 = sample5;
13190 last_sample4 = sample4;
13191 last_sample3 = sample3;
13192 last_sample2 = sample2;
13193 last_sample1 = sample1;
13194 last_sample0 = sample0;
13195 dst -= 32;
13196 }
13197
13198 cvt->len_cvt = dstsize;
13199 if (cvt->filters[++cvt->filter_index]) {
13200 cvt->filters[cvt->filter_index] (cvt, format);
13201 }
13202 }
13203
13204 static void SDLCALL
13205 SDL_Downsample_S32LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
13206 {
13207 #ifdef DEBUG_CONVERT
13208 fprintf(stderr, "Downsample (x4) AUDIO_S32LSB, 8 channels.\n");
13209 #endif
13210
13211 const int srcsize = cvt->len_cvt;
13212 const int dstsize = cvt->len_cvt / 4;
13213 Sint32 *dst = (Sint32 *) cvt->buf;
13214 const Sint32 *src = (Sint32 *) cvt->buf;
13215 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
13216 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
13217 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
13218 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
13219 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
13220 Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
13221 Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
13222 Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
13223 Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
13224 while (dst != target) {
13225 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapLE32(src[0]));
13226 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapLE32(src[1]));
13227 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapLE32(src[2]));
13228 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapLE32(src[3]));
13229 const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapLE32(src[4]));
13230 const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapLE32(src[5]));
13231 const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapLE32(src[6]));
13232 const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapLE32(src[7]));
13233 src += 32;
13234 dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
13235 dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
13236 dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
13237 dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
13238 dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
13239 dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
13240 dst[6] = (Sint32) ((sample6 + last_sample6) >> 1);
13241 dst[7] = (Sint32) ((sample7 + last_sample7) >> 1);
13242 last_sample0 = sample0;
13243 last_sample1 = sample1;
13244 last_sample2 = sample2;
13245 last_sample3 = sample3;
13246 last_sample4 = sample4;
13247 last_sample5 = sample5;
13248 last_sample6 = sample6;
13249 last_sample7 = sample7;
13250 dst += 8;
13251 }
13252
13253 cvt->len_cvt = dstsize;
13254 if (cvt->filters[++cvt->filter_index]) {
13255 cvt->filters[cvt->filter_index] (cvt, format);
13256 }
13257 }
13258
13259 static void SDLCALL
13260 SDL_Upsample_S32MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
13261 {
13262 #ifdef DEBUG_CONVERT
13263 fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 1 channels.\n");
13264 #endif
13265
13266 const int srcsize = cvt->len_cvt;
13267 const int dstsize = cvt->len_cvt * 2;
13268 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1;
13269 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
13270 const Sint32 *target = ((const Sint32 *) cvt->buf) - 1;
13271 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13272 while (dst != target) {
13273 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13274 src--;
13275 dst[1] = (Sint32) ((sample0 + last_sample0) >> 1);
13276 dst[0] = (Sint32) sample0;
13277 last_sample0 = sample0;
13278 dst -= 2;
13279 }
13280
13281 cvt->len_cvt = dstsize;
13282 if (cvt->filters[++cvt->filter_index]) {
13283 cvt->filters[cvt->filter_index] (cvt, format);
13284 }
13285 }
13286
13287 static void SDLCALL
13288 SDL_Downsample_S32MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
13289 {
13290 #ifdef DEBUG_CONVERT
13291 fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 1 channels.\n");
13292 #endif
13293
13294 const int srcsize = cvt->len_cvt;
13295 const int dstsize = cvt->len_cvt / 2;
13296 Sint32 *dst = (Sint32 *) cvt->buf;
13297 const Sint32 *src = (Sint32 *) cvt->buf;
13298 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
13299 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13300 while (dst != target) {
13301 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13302 src += 2;
13303 dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
13304 last_sample0 = sample0;
13305 dst++;
13306 }
13307
13308 cvt->len_cvt = dstsize;
13309 if (cvt->filters[++cvt->filter_index]) {
13310 cvt->filters[cvt->filter_index] (cvt, format);
13311 }
13312 }
13313
13314 static void SDLCALL
13315 SDL_Upsample_S32MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
13316 {
13317 #ifdef DEBUG_CONVERT
13318 fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 1 channels.\n");
13319 #endif
13320
13321 const int srcsize = cvt->len_cvt;
13322 const int dstsize = cvt->len_cvt * 4;
13323 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 1;
13324 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 1;
13325 const Sint32 *target = ((const Sint32 *) cvt->buf) - 1;
13326 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13327 while (dst != target) {
13328 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13329 src--;
13330 dst[3] = (Sint32) sample0;
13331 dst[2] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
13332 dst[1] = (Sint32) ((sample0 + last_sample0) >> 1);
13333 dst[0] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
13334 last_sample0 = sample0;
13335 dst -= 4;
13336 }
13337
13338 cvt->len_cvt = dstsize;
13339 if (cvt->filters[++cvt->filter_index]) {
13340 cvt->filters[cvt->filter_index] (cvt, format);
13341 }
13342 }
13343
13344 static void SDLCALL
13345 SDL_Downsample_S32MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
13346 {
13347 #ifdef DEBUG_CONVERT
13348 fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 1 channels.\n");
13349 #endif
13350
13351 const int srcsize = cvt->len_cvt;
13352 const int dstsize = cvt->len_cvt / 4;
13353 Sint32 *dst = (Sint32 *) cvt->buf;
13354 const Sint32 *src = (Sint32 *) cvt->buf;
13355 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
13356 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13357 while (dst != target) {
13358 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13359 src += 4;
13360 dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
13361 last_sample0 = sample0;
13362 dst++;
13363 }
13364
13365 cvt->len_cvt = dstsize;
13366 if (cvt->filters[++cvt->filter_index]) {
13367 cvt->filters[cvt->filter_index] (cvt, format);
13368 }
13369 }
13370
13371 static void SDLCALL
13372 SDL_Upsample_S32MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
13373 {
13374 #ifdef DEBUG_CONVERT
13375 fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 2 channels.\n");
13376 #endif
13377
13378 const int srcsize = cvt->len_cvt;
13379 const int dstsize = cvt->len_cvt * 2;
13380 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2;
13381 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
13382 const Sint32 *target = ((const Sint32 *) cvt->buf) - 2;
13383 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13384 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13385 while (dst != target) {
13386 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13387 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13388 src -= 2;
13389 dst[3] = (Sint32) ((sample1 + last_sample1) >> 1);
13390 dst[2] = (Sint32) ((sample0 + last_sample0) >> 1);
13391 dst[1] = (Sint32) sample1;
13392 dst[0] = (Sint32) sample0;
13393 last_sample1 = sample1;
13394 last_sample0 = sample0;
13395 dst -= 4;
13396 }
13397
13398 cvt->len_cvt = dstsize;
13399 if (cvt->filters[++cvt->filter_index]) {
13400 cvt->filters[cvt->filter_index] (cvt, format);
13401 }
13402 }
13403
13404 static void SDLCALL
13405 SDL_Downsample_S32MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
13406 {
13407 #ifdef DEBUG_CONVERT
13408 fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 2 channels.\n");
13409 #endif
13410
13411 const int srcsize = cvt->len_cvt;
13412 const int dstsize = cvt->len_cvt / 2;
13413 Sint32 *dst = (Sint32 *) cvt->buf;
13414 const Sint32 *src = (Sint32 *) cvt->buf;
13415 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
13416 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13417 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13418 while (dst != target) {
13419 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13420 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13421 src += 4;
13422 dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
13423 dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
13424 last_sample0 = sample0;
13425 last_sample1 = sample1;
13426 dst += 2;
13427 }
13428
13429 cvt->len_cvt = dstsize;
13430 if (cvt->filters[++cvt->filter_index]) {
13431 cvt->filters[cvt->filter_index] (cvt, format);
13432 }
13433 }
13434
13435 static void SDLCALL
13436 SDL_Upsample_S32MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
13437 {
13438 #ifdef DEBUG_CONVERT
13439 fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 2 channels.\n");
13440 #endif
13441
13442 const int srcsize = cvt->len_cvt;
13443 const int dstsize = cvt->len_cvt * 4;
13444 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 2;
13445 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 2;
13446 const Sint32 *target = ((const Sint32 *) cvt->buf) - 2;
13447 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13448 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13449 while (dst != target) {
13450 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13451 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13452 src -= 2;
13453 dst[7] = (Sint32) sample1;
13454 dst[6] = (Sint32) sample0;
13455 dst[5] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
13456 dst[4] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
13457 dst[3] = (Sint32) ((sample1 + last_sample1) >> 1);
13458 dst[2] = (Sint32) ((sample0 + last_sample0) >> 1);
13459 dst[1] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
13460 dst[0] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
13461 last_sample1 = sample1;
13462 last_sample0 = sample0;
13463 dst -= 8;
13464 }
13465
13466 cvt->len_cvt = dstsize;
13467 if (cvt->filters[++cvt->filter_index]) {
13468 cvt->filters[cvt->filter_index] (cvt, format);
13469 }
13470 }
13471
13472 static void SDLCALL
13473 SDL_Downsample_S32MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
13474 {
13475 #ifdef DEBUG_CONVERT
13476 fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 2 channels.\n");
13477 #endif
13478
13479 const int srcsize = cvt->len_cvt;
13480 const int dstsize = cvt->len_cvt / 4;
13481 Sint32 *dst = (Sint32 *) cvt->buf;
13482 const Sint32 *src = (Sint32 *) cvt->buf;
13483 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
13484 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13485 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13486 while (dst != target) {
13487 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13488 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13489 src += 8;
13490 dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
13491 dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
13492 last_sample0 = sample0;
13493 last_sample1 = sample1;
13494 dst += 2;
13495 }
13496
13497 cvt->len_cvt = dstsize;
13498 if (cvt->filters[++cvt->filter_index]) {
13499 cvt->filters[cvt->filter_index] (cvt, format);
13500 }
13501 }
13502
13503 static void SDLCALL
13504 SDL_Upsample_S32MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
13505 {
13506 #ifdef DEBUG_CONVERT
13507 fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 4 channels.\n");
13508 #endif
13509
13510 const int srcsize = cvt->len_cvt;
13511 const int dstsize = cvt->len_cvt * 2;
13512 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4;
13513 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
13514 const Sint32 *target = ((const Sint32 *) cvt->buf) - 4;
13515 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
13516 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
13517 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13518 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13519 while (dst != target) {
13520 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
13521 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
13522 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13523 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13524 src -= 4;
13525 dst[7] = (Sint32) ((sample3 + last_sample3) >> 1);
13526 dst[6] = (Sint32) ((sample2 + last_sample2) >> 1);
13527 dst[5] = (Sint32) ((sample1 + last_sample1) >> 1);
13528 dst[4] = (Sint32) ((sample0 + last_sample0) >> 1);
13529 dst[3] = (Sint32) sample3;
13530 dst[2] = (Sint32) sample2;
13531 dst[1] = (Sint32) sample1;
13532 dst[0] = (Sint32) sample0;
13533 last_sample3 = sample3;
13534 last_sample2 = sample2;
13535 last_sample1 = sample1;
13536 last_sample0 = sample0;
13537 dst -= 8;
13538 }
13539
13540 cvt->len_cvt = dstsize;
13541 if (cvt->filters[++cvt->filter_index]) {
13542 cvt->filters[cvt->filter_index] (cvt, format);
13543 }
13544 }
13545
13546 static void SDLCALL
13547 SDL_Downsample_S32MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
13548 {
13549 #ifdef DEBUG_CONVERT
13550 fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 4 channels.\n");
13551 #endif
13552
13553 const int srcsize = cvt->len_cvt;
13554 const int dstsize = cvt->len_cvt / 2;
13555 Sint32 *dst = (Sint32 *) cvt->buf;
13556 const Sint32 *src = (Sint32 *) cvt->buf;
13557 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
13558 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13559 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13560 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
13561 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
13562 while (dst != target) {
13563 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13564 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13565 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
13566 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
13567 src += 8;
13568 dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
13569 dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
13570 dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
13571 dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
13572 last_sample0 = sample0;
13573 last_sample1 = sample1;
13574 last_sample2 = sample2;
13575 last_sample3 = sample3;
13576 dst += 4;
13577 }
13578
13579 cvt->len_cvt = dstsize;
13580 if (cvt->filters[++cvt->filter_index]) {
13581 cvt->filters[cvt->filter_index] (cvt, format);
13582 }
13583 }
13584
13585 static void SDLCALL
13586 SDL_Upsample_S32MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
13587 {
13588 #ifdef DEBUG_CONVERT
13589 fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 4 channels.\n");
13590 #endif
13591
13592 const int srcsize = cvt->len_cvt;
13593 const int dstsize = cvt->len_cvt * 4;
13594 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 4;
13595 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 4;
13596 const Sint32 *target = ((const Sint32 *) cvt->buf) - 4;
13597 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
13598 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
13599 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13600 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13601 while (dst != target) {
13602 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
13603 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
13604 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13605 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13606 src -= 4;
13607 dst[15] = (Sint32) sample3;
13608 dst[14] = (Sint32) sample2;
13609 dst[13] = (Sint32) sample1;
13610 dst[12] = (Sint32) sample0;
13611 dst[11] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
13612 dst[10] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
13613 dst[9] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
13614 dst[8] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
13615 dst[7] = (Sint32) ((sample3 + last_sample3) >> 1);
13616 dst[6] = (Sint32) ((sample2 + last_sample2) >> 1);
13617 dst[5] = (Sint32) ((sample1 + last_sample1) >> 1);
13618 dst[4] = (Sint32) ((sample0 + last_sample0) >> 1);
13619 dst[3] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
13620 dst[2] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
13621 dst[1] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
13622 dst[0] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
13623 last_sample3 = sample3;
13624 last_sample2 = sample2;
13625 last_sample1 = sample1;
13626 last_sample0 = sample0;
13627 dst -= 16;
13628 }
13629
13630 cvt->len_cvt = dstsize;
13631 if (cvt->filters[++cvt->filter_index]) {
13632 cvt->filters[cvt->filter_index] (cvt, format);
13633 }
13634 }
13635
13636 static void SDLCALL
13637 SDL_Downsample_S32MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
13638 {
13639 #ifdef DEBUG_CONVERT
13640 fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 4 channels.\n");
13641 #endif
13642
13643 const int srcsize = cvt->len_cvt;
13644 const int dstsize = cvt->len_cvt / 4;
13645 Sint32 *dst = (Sint32 *) cvt->buf;
13646 const Sint32 *src = (Sint32 *) cvt->buf;
13647 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
13648 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13649 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13650 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
13651 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
13652 while (dst != target) {
13653 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13654 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13655 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
13656 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
13657 src += 16;
13658 dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
13659 dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
13660 dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
13661 dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
13662 last_sample0 = sample0;
13663 last_sample1 = sample1;
13664 last_sample2 = sample2;
13665 last_sample3 = sample3;
13666 dst += 4;
13667 }
13668
13669 cvt->len_cvt = dstsize;
13670 if (cvt->filters[++cvt->filter_index]) {
13671 cvt->filters[cvt->filter_index] (cvt, format);
13672 }
13673 }
13674
13675 static void SDLCALL
13676 SDL_Upsample_S32MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
13677 {
13678 #ifdef DEBUG_CONVERT
13679 fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 6 channels.\n");
13680 #endif
13681
13682 const int srcsize = cvt->len_cvt;
13683 const int dstsize = cvt->len_cvt * 2;
13684 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6;
13685 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
13686 const Sint32 *target = ((const Sint32 *) cvt->buf) - 6;
13687 Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
13688 Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
13689 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
13690 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
13691 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13692 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13693 while (dst != target) {
13694 const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
13695 const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
13696 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
13697 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
13698 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13699 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13700 src -= 6;
13701 dst[11] = (Sint32) ((sample5 + last_sample5) >> 1);
13702 dst[10] = (Sint32) ((sample4 + last_sample4) >> 1);
13703 dst[9] = (Sint32) ((sample3 + last_sample3) >> 1);
13704 dst[8] = (Sint32) ((sample2 + last_sample2) >> 1);
13705 dst[7] = (Sint32) ((sample1 + last_sample1) >> 1);
13706 dst[6] = (Sint32) ((sample0 + last_sample0) >> 1);
13707 dst[5] = (Sint32) sample5;
13708 dst[4] = (Sint32) sample4;
13709 dst[3] = (Sint32) sample3;
13710 dst[2] = (Sint32) sample2;
13711 dst[1] = (Sint32) sample1;
13712 dst[0] = (Sint32) sample0;
13713 last_sample5 = sample5;
13714 last_sample4 = sample4;
13715 last_sample3 = sample3;
13716 last_sample2 = sample2;
13717 last_sample1 = sample1;
13718 last_sample0 = sample0;
13719 dst -= 12;
13720 }
13721
13722 cvt->len_cvt = dstsize;
13723 if (cvt->filters[++cvt->filter_index]) {
13724 cvt->filters[cvt->filter_index] (cvt, format);
13725 }
13726 }
13727
13728 static void SDLCALL
13729 SDL_Downsample_S32MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
13730 {
13731 #ifdef DEBUG_CONVERT
13732 fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 6 channels.\n");
13733 #endif
13734
13735 const int srcsize = cvt->len_cvt;
13736 const int dstsize = cvt->len_cvt / 2;
13737 Sint32 *dst = (Sint32 *) cvt->buf;
13738 const Sint32 *src = (Sint32 *) cvt->buf;
13739 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
13740 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13741 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13742 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
13743 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
13744 Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
13745 Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
13746 while (dst != target) {
13747 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13748 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13749 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
13750 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
13751 const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
13752 const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
13753 src += 12;
13754 dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
13755 dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
13756 dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
13757 dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
13758 dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
13759 dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
13760 last_sample0 = sample0;
13761 last_sample1 = sample1;
13762 last_sample2 = sample2;
13763 last_sample3 = sample3;
13764 last_sample4 = sample4;
13765 last_sample5 = sample5;
13766 dst += 6;
13767 }
13768
13769 cvt->len_cvt = dstsize;
13770 if (cvt->filters[++cvt->filter_index]) {
13771 cvt->filters[cvt->filter_index] (cvt, format);
13772 }
13773 }
13774
13775 static void SDLCALL
13776 SDL_Upsample_S32MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
13777 {
13778 #ifdef DEBUG_CONVERT
13779 fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 6 channels.\n");
13780 #endif
13781
13782 const int srcsize = cvt->len_cvt;
13783 const int dstsize = cvt->len_cvt * 4;
13784 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 6;
13785 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 6;
13786 const Sint32 *target = ((const Sint32 *) cvt->buf) - 6;
13787 Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
13788 Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
13789 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
13790 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
13791 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13792 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13793 while (dst != target) {
13794 const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
13795 const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
13796 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
13797 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
13798 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13799 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13800 src -= 6;
13801 dst[23] = (Sint32) sample5;
13802 dst[22] = (Sint32) sample4;
13803 dst[21] = (Sint32) sample3;
13804 dst[20] = (Sint32) sample2;
13805 dst[19] = (Sint32) sample1;
13806 dst[18] = (Sint32) sample0;
13807 dst[17] = (Sint32) (((3 * sample5) + last_sample5) >> 2);
13808 dst[16] = (Sint32) (((3 * sample4) + last_sample4) >> 2);
13809 dst[15] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
13810 dst[14] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
13811 dst[13] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
13812 dst[12] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
13813 dst[11] = (Sint32) ((sample5 + last_sample5) >> 1);
13814 dst[10] = (Sint32) ((sample4 + last_sample4) >> 1);
13815 dst[9] = (Sint32) ((sample3 + last_sample3) >> 1);
13816 dst[8] = (Sint32) ((sample2 + last_sample2) >> 1);
13817 dst[7] = (Sint32) ((sample1 + last_sample1) >> 1);
13818 dst[6] = (Sint32) ((sample0 + last_sample0) >> 1);
13819 dst[5] = (Sint32) ((sample5 + (3 * last_sample5)) >> 2);
13820 dst[4] = (Sint32) ((sample4 + (3 * last_sample4)) >> 2);
13821 dst[3] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
13822 dst[2] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
13823 dst[1] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
13824 dst[0] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
13825 last_sample5 = sample5;
13826 last_sample4 = sample4;
13827 last_sample3 = sample3;
13828 last_sample2 = sample2;
13829 last_sample1 = sample1;
13830 last_sample0 = sample0;
13831 dst -= 24;
13832 }
13833
13834 cvt->len_cvt = dstsize;
13835 if (cvt->filters[++cvt->filter_index]) {
13836 cvt->filters[cvt->filter_index] (cvt, format);
13837 }
13838 }
13839
13840 static void SDLCALL
13841 SDL_Downsample_S32MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
13842 {
13843 #ifdef DEBUG_CONVERT
13844 fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 6 channels.\n");
13845 #endif
13846
13847 const int srcsize = cvt->len_cvt;
13848 const int dstsize = cvt->len_cvt / 4;
13849 Sint32 *dst = (Sint32 *) cvt->buf;
13850 const Sint32 *src = (Sint32 *) cvt->buf;
13851 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
13852 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13853 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13854 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
13855 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
13856 Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
13857 Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
13858 while (dst != target) {
13859 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13860 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13861 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
13862 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
13863 const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
13864 const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
13865 src += 24;
13866 dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
13867 dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
13868 dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
13869 dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
13870 dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
13871 dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
13872 last_sample0 = sample0;
13873 last_sample1 = sample1;
13874 last_sample2 = sample2;
13875 last_sample3 = sample3;
13876 last_sample4 = sample4;
13877 last_sample5 = sample5;
13878 dst += 6;
13879 }
13880
13881 cvt->len_cvt = dstsize;
13882 if (cvt->filters[++cvt->filter_index]) {
13883 cvt->filters[cvt->filter_index] (cvt, format);
13884 }
13885 }
13886
13887 static void SDLCALL
13888 SDL_Upsample_S32MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
13889 {
13890 #ifdef DEBUG_CONVERT
13891 fprintf(stderr, "Upsample (x2) AUDIO_S32MSB, 8 channels.\n");
13892 #endif
13893
13894 const int srcsize = cvt->len_cvt;
13895 const int dstsize = cvt->len_cvt * 2;
13896 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8;
13897 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
13898 const Sint32 *target = ((const Sint32 *) cvt->buf) - 8;
13899 Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
13900 Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
13901 Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
13902 Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
13903 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
13904 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
13905 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13906 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13907 while (dst != target) {
13908 const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
13909 const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
13910 const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
13911 const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
13912 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
13913 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
13914 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13915 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13916 src -= 8;
13917 dst[15] = (Sint32) ((sample7 + last_sample7) >> 1);
13918 dst[14] = (Sint32) ((sample6 + last_sample6) >> 1);
13919 dst[13] = (Sint32) ((sample5 + last_sample5) >> 1);
13920 dst[12] = (Sint32) ((sample4 + last_sample4) >> 1);
13921 dst[11] = (Sint32) ((sample3 + last_sample3) >> 1);
13922 dst[10] = (Sint32) ((sample2 + last_sample2) >> 1);
13923 dst[9] = (Sint32) ((sample1 + last_sample1) >> 1);
13924 dst[8] = (Sint32) ((sample0 + last_sample0) >> 1);
13925 dst[7] = (Sint32) sample7;
13926 dst[6] = (Sint32) sample6;
13927 dst[5] = (Sint32) sample5;
13928 dst[4] = (Sint32) sample4;
13929 dst[3] = (Sint32) sample3;
13930 dst[2] = (Sint32) sample2;
13931 dst[1] = (Sint32) sample1;
13932 dst[0] = (Sint32) sample0;
13933 last_sample7 = sample7;
13934 last_sample6 = sample6;
13935 last_sample5 = sample5;
13936 last_sample4 = sample4;
13937 last_sample3 = sample3;
13938 last_sample2 = sample2;
13939 last_sample1 = sample1;
13940 last_sample0 = sample0;
13941 dst -= 16;
13942 }
13943
13944 cvt->len_cvt = dstsize;
13945 if (cvt->filters[++cvt->filter_index]) {
13946 cvt->filters[cvt->filter_index] (cvt, format);
13947 }
13948 }
13949
13950 static void SDLCALL
13951 SDL_Downsample_S32MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
13952 {
13953 #ifdef DEBUG_CONVERT
13954 fprintf(stderr, "Downsample (x2) AUDIO_S32MSB, 8 channels.\n");
13955 #endif
13956
13957 const int srcsize = cvt->len_cvt;
13958 const int dstsize = cvt->len_cvt / 2;
13959 Sint32 *dst = (Sint32 *) cvt->buf;
13960 const Sint32 *src = (Sint32 *) cvt->buf;
13961 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
13962 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13963 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13964 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
13965 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
13966 Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
13967 Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
13968 Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
13969 Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
13970 while (dst != target) {
13971 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
13972 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
13973 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
13974 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
13975 const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
13976 const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
13977 const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
13978 const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
13979 src += 16;
13980 dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
13981 dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
13982 dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
13983 dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
13984 dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
13985 dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
13986 dst[6] = (Sint32) ((sample6 + last_sample6) >> 1);
13987 dst[7] = (Sint32) ((sample7 + last_sample7) >> 1);
13988 last_sample0 = sample0;
13989 last_sample1 = sample1;
13990 last_sample2 = sample2;
13991 last_sample3 = sample3;
13992 last_sample4 = sample4;
13993 last_sample5 = sample5;
13994 last_sample6 = sample6;
13995 last_sample7 = sample7;
13996 dst += 8;
13997 }
13998
13999 cvt->len_cvt = dstsize;
14000 if (cvt->filters[++cvt->filter_index]) {
14001 cvt->filters[cvt->filter_index] (cvt, format);
14002 }
14003 }
14004
14005 static void SDLCALL
14006 SDL_Upsample_S32MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
14007 {
14008 #ifdef DEBUG_CONVERT
14009 fprintf(stderr, "Upsample (x4) AUDIO_S32MSB, 8 channels.\n");
14010 #endif
14011
14012 const int srcsize = cvt->len_cvt;
14013 const int dstsize = cvt->len_cvt * 4;
14014 Sint32 *dst = ((Sint32 *) (cvt->buf + dstsize)) - 8;
14015 const Sint32 *src = ((Sint32 *) (cvt->buf + cvt->len_cvt)) - 8;
14016 const Sint32 *target = ((const Sint32 *) cvt->buf) - 8;
14017 Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
14018 Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
14019 Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
14020 Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
14021 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
14022 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
14023 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
14024 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
14025 while (dst != target) {
14026 const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
14027 const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
14028 const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
14029 const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
14030 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
14031 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
14032 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
14033 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
14034 src -= 8;
14035 dst[31] = (Sint32) sample7;
14036 dst[30] = (Sint32) sample6;
14037 dst[29] = (Sint32) sample5;
14038 dst[28] = (Sint32) sample4;
14039 dst[27] = (Sint32) sample3;
14040 dst[26] = (Sint32) sample2;
14041 dst[25] = (Sint32) sample1;
14042 dst[24] = (Sint32) sample0;
14043 dst[23] = (Sint32) (((3 * sample7) + last_sample7) >> 2);
14044 dst[22] = (Sint32) (((3 * sample6) + last_sample6) >> 2);
14045 dst[21] = (Sint32) (((3 * sample5) + last_sample5) >> 2);
14046 dst[20] = (Sint32) (((3 * sample4) + last_sample4) >> 2);
14047 dst[19] = (Sint32) (((3 * sample3) + last_sample3) >> 2);
14048 dst[18] = (Sint32) (((3 * sample2) + last_sample2) >> 2);
14049 dst[17] = (Sint32) (((3 * sample1) + last_sample1) >> 2);
14050 dst[16] = (Sint32) (((3 * sample0) + last_sample0) >> 2);
14051 dst[15] = (Sint32) ((sample7 + last_sample7) >> 1);
14052 dst[14] = (Sint32) ((sample6 + last_sample6) >> 1);
14053 dst[13] = (Sint32) ((sample5 + last_sample5) >> 1);
14054 dst[12] = (Sint32) ((sample4 + last_sample4) >> 1);
14055 dst[11] = (Sint32) ((sample3 + last_sample3) >> 1);
14056 dst[10] = (Sint32) ((sample2 + last_sample2) >> 1);
14057 dst[9] = (Sint32) ((sample1 + last_sample1) >> 1);
14058 dst[8] = (Sint32) ((sample0 + last_sample0) >> 1);
14059 dst[7] = (Sint32) ((sample7 + (3 * last_sample7)) >> 2);
14060 dst[6] = (Sint32) ((sample6 + (3 * last_sample6)) >> 2);
14061 dst[5] = (Sint32) ((sample5 + (3 * last_sample5)) >> 2);
14062 dst[4] = (Sint32) ((sample4 + (3 * last_sample4)) >> 2);
14063 dst[3] = (Sint32) ((sample3 + (3 * last_sample3)) >> 2);
14064 dst[2] = (Sint32) ((sample2 + (3 * last_sample2)) >> 2);
14065 dst[1] = (Sint32) ((sample1 + (3 * last_sample1)) >> 2);
14066 dst[0] = (Sint32) ((sample0 + (3 * last_sample0)) >> 2);
14067 last_sample7 = sample7;
14068 last_sample6 = sample6;
14069 last_sample5 = sample5;
14070 last_sample4 = sample4;
14071 last_sample3 = sample3;
14072 last_sample2 = sample2;
14073 last_sample1 = sample1;
14074 last_sample0 = sample0;
14075 dst -= 32;
14076 }
14077
14078 cvt->len_cvt = dstsize;
14079 if (cvt->filters[++cvt->filter_index]) {
14080 cvt->filters[cvt->filter_index] (cvt, format);
14081 }
14082 }
14083
14084 static void SDLCALL
14085 SDL_Downsample_S32MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
14086 {
14087 #ifdef DEBUG_CONVERT
14088 fprintf(stderr, "Downsample (x4) AUDIO_S32MSB, 8 channels.\n");
14089 #endif
14090
14091 const int srcsize = cvt->len_cvt;
14092 const int dstsize = cvt->len_cvt / 4;
14093 Sint32 *dst = (Sint32 *) cvt->buf;
14094 const Sint32 *src = (Sint32 *) cvt->buf;
14095 const Sint32 *target = (const Sint32 *) (cvt->buf + dstsize);
14096 Sint64 last_sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
14097 Sint64 last_sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
14098 Sint64 last_sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
14099 Sint64 last_sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
14100 Sint64 last_sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
14101 Sint64 last_sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
14102 Sint64 last_sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
14103 Sint64 last_sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
14104 while (dst != target) {
14105 const Sint64 sample0 = (Sint64) ((Sint32) SDL_SwapBE32(src[0]));
14106 const Sint64 sample1 = (Sint64) ((Sint32) SDL_SwapBE32(src[1]));
14107 const Sint64 sample2 = (Sint64) ((Sint32) SDL_SwapBE32(src[2]));
14108 const Sint64 sample3 = (Sint64) ((Sint32) SDL_SwapBE32(src[3]));
14109 const Sint64 sample4 = (Sint64) ((Sint32) SDL_SwapBE32(src[4]));
14110 const Sint64 sample5 = (Sint64) ((Sint32) SDL_SwapBE32(src[5]));
14111 const Sint64 sample6 = (Sint64) ((Sint32) SDL_SwapBE32(src[6]));
14112 const Sint64 sample7 = (Sint64) ((Sint32) SDL_SwapBE32(src[7]));
14113 src += 32;
14114 dst[0] = (Sint32) ((sample0 + last_sample0) >> 1);
14115 dst[1] = (Sint32) ((sample1 + last_sample1) >> 1);
14116 dst[2] = (Sint32) ((sample2 + last_sample2) >> 1);
14117 dst[3] = (Sint32) ((sample3 + last_sample3) >> 1);
14118 dst[4] = (Sint32) ((sample4 + last_sample4) >> 1);
14119 dst[5] = (Sint32) ((sample5 + last_sample5) >> 1);
14120 dst[6] = (Sint32) ((sample6 + last_sample6) >> 1);
14121 dst[7] = (Sint32) ((sample7 + last_sample7) >> 1);
14122 last_sample0 = sample0;
14123 last_sample1 = sample1;
14124 last_sample2 = sample2;
14125 last_sample3 = sample3;
14126 last_sample4 = sample4;
14127 last_sample5 = sample5;
14128 last_sample6 = sample6;
14129 last_sample7 = sample7;
14130 dst += 8;
14131 }
14132
14133 cvt->len_cvt = dstsize;
14134 if (cvt->filters[++cvt->filter_index]) {
14135 cvt->filters[cvt->filter_index] (cvt, format);
14136 }
14137 }
14138
14139 static void SDLCALL
14140 SDL_Upsample_F32LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
14141 {
14142 #ifdef DEBUG_CONVERT
14143 fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 1 channels.\n");
14144 #endif
14145
14146 const int srcsize = cvt->len_cvt;
14147 const int dstsize = cvt->len_cvt * 2;
14148 float *dst = ((float *) (cvt->buf + dstsize)) - 1;
14149 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
14150 const float *target = ((const float *) cvt->buf) - 1;
14151 double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
14152 while (dst != target) {
14153 const double sample0 = (double) SDL_SwapFloatLE(src[0]);
14154 src--;
14155 dst[1] = (float) ((sample0 + last_sample0) * 0.5);
14156 dst[0] = (float) sample0;
14157 last_sample0 = sample0;
14158 dst -= 2;
14159 }
14160
14161 cvt->len_cvt = dstsize;
14162 if (cvt->filters[++cvt->filter_index]) {
14163 cvt->filters[cvt->filter_index] (cvt, format);
14164 }
14165 }
14166
14167 static void SDLCALL
14168 SDL_Downsample_F32LSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
14169 {
14170 #ifdef DEBUG_CONVERT
14171 fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 1 channels.\n");
14172 #endif
14173
14174 const int srcsize = cvt->len_cvt;
14175 const int dstsize = cvt->len_cvt / 2;
14176 float *dst = (float *) cvt->buf;
14177 const float *src = (float *) cvt->buf;
14178 const float *target = (const float *) (cvt->buf + dstsize);
14179 double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
14180 while (dst != target) {
14181 const double sample0 = (double) SDL_SwapFloatLE(src[0]);
14182 src += 2;
14183 dst[0] = (float) ((sample0 + last_sample0) * 0.5);
14184 last_sample0 = sample0;
14185 dst++;
14186 }
14187
14188 cvt->len_cvt = dstsize;
14189 if (cvt->filters[++cvt->filter_index]) {
14190 cvt->filters[cvt->filter_index] (cvt, format);
14191 }
14192 }
14193
14194 static void SDLCALL
14195 SDL_Upsample_F32LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
14196 {
14197 #ifdef DEBUG_CONVERT
14198 fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 1 channels.\n");
14199 #endif
14200
14201 const int srcsize = cvt->len_cvt;
14202 const int dstsize = cvt->len_cvt * 4;
14203 float *dst = ((float *) (cvt->buf + dstsize)) - 1;
14204 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
14205 const float *target = ((const float *) cvt->buf) - 1;
14206 double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
14207 while (dst != target) {
14208 const double sample0 = (double) SDL_SwapFloatLE(src[0]);
14209 src--;
14210 dst[3] = (float) sample0;
14211 dst[2] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
14212 dst[1] = (float) ((sample0 + last_sample0) * 0.5);
14213 dst[0] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
14214 last_sample0 = sample0;
14215 dst -= 4;
14216 }
14217
14218 cvt->len_cvt = dstsize;
14219 if (cvt->filters[++cvt->filter_index]) {
14220 cvt->filters[cvt->filter_index] (cvt, format);
14221 }
14222 }
14223
14224 static void SDLCALL
14225 SDL_Downsample_F32LSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
14226 {
14227 #ifdef DEBUG_CONVERT
14228 fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 1 channels.\n");
14229 #endif
14230
14231 const int srcsize = cvt->len_cvt;
14232 const int dstsize = cvt->len_cvt / 4;
14233 float *dst = (float *) cvt->buf;
14234 const float *src = (float *) cvt->buf;
14235 const float *target = (const float *) (cvt->buf + dstsize);
14236 double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
14237 while (dst != target) {
14238 const double sample0 = (double) SDL_SwapFloatLE(src[0]);
14239 src += 4;
14240 dst[0] = (float) ((sample0 + last_sample0) * 0.5);
14241 last_sample0 = sample0;
14242 dst++;
14243 }
14244
14245 cvt->len_cvt = dstsize;
14246 if (cvt->filters[++cvt->filter_index]) {
14247 cvt->filters[cvt->filter_index] (cvt, format);
14248 }
14249 }
14250
14251 static void SDLCALL
14252 SDL_Upsample_F32LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
14253 {
14254 #ifdef DEBUG_CONVERT
14255 fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 2 channels.\n");
14256 #endif
14257
14258 const int srcsize = cvt->len_cvt;
14259 const int dstsize = cvt->len_cvt * 2;
14260 float *dst = ((float *) (cvt->buf + dstsize)) - 2;
14261 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
14262 const float *target = ((const float *) cvt->buf) - 2;
14263 double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
14264 double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
14265 while (dst != target) {
14266 const double sample1 = (double) SDL_SwapFloatLE(src[1]);
14267 const double sample0 = (double) SDL_SwapFloatLE(src[0]);
14268 src -= 2;
14269 dst[3] = (float) ((sample1 + last_sample1) * 0.5);
14270 dst[2] = (float) ((sample0 + last_sample0) * 0.5);
14271 dst[1] = (float) sample1;
14272 dst[0] = (float) sample0;
14273 last_sample1 = sample1;
14274 last_sample0 = sample0;
14275 dst -= 4;
14276 }
14277
14278 cvt->len_cvt = dstsize;
14279 if (cvt->filters[++cvt->filter_index]) {
14280 cvt->filters[cvt->filter_index] (cvt, format);
14281 }
14282 }
14283
14284 static void SDLCALL
14285 SDL_Downsample_F32LSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
14286 {
14287 #ifdef DEBUG_CONVERT
14288 fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 2 channels.\n");
14289 #endif
14290
14291 const int srcsize = cvt->len_cvt;
14292 const int dstsize = cvt->len_cvt / 2;
14293 float *dst = (float *) cvt->buf;
14294 const float *src = (float *) cvt->buf;
14295 const float *target = (const float *) (cvt->buf + dstsize);
14296 double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
14297 double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
14298 while (dst != target) {
14299 const double sample0 = (double) SDL_SwapFloatLE(src[0]);
14300 const double sample1 = (double) SDL_SwapFloatLE(src[1]);
14301 src += 4;
14302 dst[0] = (float) ((sample0 + last_sample0) * 0.5);
14303 dst[1] = (float) ((sample1 + last_sample1) * 0.5);
14304 last_sample0 = sample0;
14305 last_sample1 = sample1;
14306 dst += 2;
14307 }
14308
14309 cvt->len_cvt = dstsize;
14310 if (cvt->filters[++cvt->filter_index]) {
14311 cvt->filters[cvt->filter_index] (cvt, format);
14312 }
14313 }
14314
14315 static void SDLCALL
14316 SDL_Upsample_F32LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
14317 {
14318 #ifdef DEBUG_CONVERT
14319 fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 2 channels.\n");
14320 #endif
14321
14322 const int srcsize = cvt->len_cvt;
14323 const int dstsize = cvt->len_cvt * 4;
14324 float *dst = ((float *) (cvt->buf + dstsize)) - 2;
14325 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
14326 const float *target = ((const float *) cvt->buf) - 2;
14327 double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
14328 double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
14329 while (dst != target) {
14330 const double sample1 = (double) SDL_SwapFloatLE(src[1]);
14331 const double sample0 = (double) SDL_SwapFloatLE(src[0]);
14332 src -= 2;
14333 dst[7] = (float) sample1;
14334 dst[6] = (float) sample0;
14335 dst[5] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
14336 dst[4] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
14337 dst[3] = (float) ((sample1 + last_sample1) * 0.5);
14338 dst[2] = (float) ((sample0 + last_sample0) * 0.5);
14339 dst[1] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
14340 dst[0] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
14341 last_sample1 = sample1;
14342 last_sample0 = sample0;
14343 dst -= 8;
14344 }
14345
14346 cvt->len_cvt = dstsize;
14347 if (cvt->filters[++cvt->filter_index]) {
14348 cvt->filters[cvt->filter_index] (cvt, format);
14349 }
14350 }
14351
14352 static void SDLCALL
14353 SDL_Downsample_F32LSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
14354 {
14355 #ifdef DEBUG_CONVERT
14356 fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 2 channels.\n");
14357 #endif
14358
14359 const int srcsize = cvt->len_cvt;
14360 const int dstsize = cvt->len_cvt / 4;
14361 float *dst = (float *) cvt->buf;
14362 const float *src = (float *) cvt->buf;
14363 const float *target = (const float *) (cvt->buf + dstsize);
14364 double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
14365 double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
14366 while (dst != target) {
14367 const double sample0 = (double) SDL_SwapFloatLE(src[0]);
14368 const double sample1 = (double) SDL_SwapFloatLE(src[1]);
14369 src += 8;
14370 dst[0] = (float) ((sample0 + last_sample0) * 0.5);
14371 dst[1] = (float) ((sample1 + last_sample1) * 0.5);
14372 last_sample0 = sample0;
14373 last_sample1 = sample1;
14374 dst += 2;
14375 }
14376
14377 cvt->len_cvt = dstsize;
14378 if (cvt->filters[++cvt->filter_index]) {
14379 cvt->filters[cvt->filter_index] (cvt, format);
14380 }
14381 }
14382
14383 static void SDLCALL
14384 SDL_Upsample_F32LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
14385 {
14386 #ifdef DEBUG_CONVERT
14387 fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 4 channels.\n");
14388 #endif
14389
14390 const int srcsize = cvt->len_cvt;
14391 const int dstsize = cvt->len_cvt * 2;
14392 float *dst = ((float *) (cvt->buf + dstsize)) - 4;
14393 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
14394 const float *target = ((const float *) cvt->buf) - 4;
14395 double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
14396 double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
14397 double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
14398 double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
14399 while (dst != target) {
14400 const double sample3 = (double) SDL_SwapFloatLE(src[3]);
14401 const double sample2 = (double) SDL_SwapFloatLE(src[2]);
14402 const double sample1 = (double) SDL_SwapFloatLE(src[1]);
14403 const double sample0 = (double) SDL_SwapFloatLE(src[0]);
14404 src -= 4;
14405 dst[7] = (float) ((sample3 + last_sample3) * 0.5);
14406 dst[6] = (float) ((sample2 + last_sample2) * 0.5);
14407 dst[5] = (float) ((sample1 + last_sample1) * 0.5);
14408 dst[4] = (float) ((sample0 + last_sample0) * 0.5);
14409 dst[3] = (float) sample3;
14410 dst[2] = (float) sample2;
14411 dst[1] = (float) sample1;
14412 dst[0] = (float) sample0;
14413 last_sample3 = sample3;
14414 last_sample2 = sample2;
14415 last_sample1 = sample1;
14416 last_sample0 = sample0;
14417 dst -= 8;
14418 }
14419
14420 cvt->len_cvt = dstsize;
14421 if (cvt->filters[++cvt->filter_index]) {
14422 cvt->filters[cvt->filter_index] (cvt, format);
14423 }
14424 }
14425
14426 static void SDLCALL
14427 SDL_Downsample_F32LSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
14428 {
14429 #ifdef DEBUG_CONVERT
14430 fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 4 channels.\n");
14431 #endif
14432
14433 const int srcsize = cvt->len_cvt;
14434 const int dstsize = cvt->len_cvt / 2;
14435 float *dst = (float *) cvt->buf;
14436 const float *src = (float *) cvt->buf;
14437 const float *target = (const float *) (cvt->buf + dstsize);
14438 double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
14439 double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
14440 double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
14441 double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
14442 while (dst != target) {
14443 const double sample0 = (double) SDL_SwapFloatLE(src[0]);
14444 const double sample1 = (double) SDL_SwapFloatLE(src[1]);
14445 const double sample2 = (double) SDL_SwapFloatLE(src[2]);
14446 const double sample3 = (double) SDL_SwapFloatLE(src[3]);
14447 src += 8;
14448 dst[0] = (float) ((sample0 + last_sample0) * 0.5);
14449 dst[1] = (float) ((sample1 + last_sample1) * 0.5);
14450 dst[2] = (float) ((sample2 + last_sample2) * 0.5);
14451 dst[3] = (float) ((sample3 + last_sample3) * 0.5);
14452 last_sample0 = sample0;
14453 last_sample1 = sample1;
14454 last_sample2 = sample2;
14455 last_sample3 = sample3;
14456 dst += 4;
14457 }
14458
14459 cvt->len_cvt = dstsize;
14460 if (cvt->filters[++cvt->filter_index]) {
14461 cvt->filters[cvt->filter_index] (cvt, format);
14462 }
14463 }
14464
14465 static void SDLCALL
14466 SDL_Upsample_F32LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
14467 {
14468 #ifdef DEBUG_CONVERT
14469 fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 4 channels.\n");
14470 #endif
14471
14472 const int srcsize = cvt->len_cvt;
14473 const int dstsize = cvt->len_cvt * 4;
14474 float *dst = ((float *) (cvt->buf + dstsize)) - 4;
14475 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
14476 const float *target = ((const float *) cvt->buf) - 4;
14477 double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
14478 double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
14479 double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
14480 double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
14481 while (dst != target) {
14482 const double sample3 = (double) SDL_SwapFloatLE(src[3]);
14483 const double sample2 = (double) SDL_SwapFloatLE(src[2]);
14484 const double sample1 = (double) SDL_SwapFloatLE(src[1]);
14485 const double sample0 = (double) SDL_SwapFloatLE(src[0]);
14486 src -= 4;
14487 dst[15] = (float) sample3;
14488 dst[14] = (float) sample2;
14489 dst[13] = (float) sample1;
14490 dst[12] = (float) sample0;
14491 dst[11] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
14492 dst[10] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
14493 dst[9] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
14494 dst[8] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
14495 dst[7] = (float) ((sample3 + last_sample3) * 0.5);
14496 dst[6] = (float) ((sample2 + last_sample2) * 0.5);
14497 dst[5] = (float) ((sample1 + last_sample1) * 0.5);
14498 dst[4] = (float) ((sample0 + last_sample0) * 0.5);
14499 dst[3] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
14500 dst[2] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
14501 dst[1] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
14502 dst[0] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
14503 last_sample3 = sample3;
14504 last_sample2 = sample2;
14505 last_sample1 = sample1;
14506 last_sample0 = sample0;
14507 dst -= 16;
14508 }
14509
14510 cvt->len_cvt = dstsize;
14511 if (cvt->filters[++cvt->filter_index]) {
14512 cvt->filters[cvt->filter_index] (cvt, format);
14513 }
14514 }
14515
14516 static void SDLCALL
14517 SDL_Downsample_F32LSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
14518 {
14519 #ifdef DEBUG_CONVERT
14520 fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 4 channels.\n");
14521 #endif
14522
14523 const int srcsize = cvt->len_cvt;
14524 const int dstsize = cvt->len_cvt / 4;
14525 float *dst = (float *) cvt->buf;
14526 const float *src = (float *) cvt->buf;
14527 const float *target = (const float *) (cvt->buf + dstsize);
14528 double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
14529 double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
14530 double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
14531 double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
14532 while (dst != target) {
14533 const double sample0 = (double) SDL_SwapFloatLE(src[0]);
14534 const double sample1 = (double) SDL_SwapFloatLE(src[1]);
14535 const double sample2 = (double) SDL_SwapFloatLE(src[2]);
14536 const double sample3 = (double) SDL_SwapFloatLE(src[3]);
14537 src += 16;
14538 dst[0] = (float) ((sample0 + last_sample0) * 0.5);
14539 dst[1] = (float) ((sample1 + last_sample1) * 0.5);
14540 dst[2] = (float) ((sample2 + last_sample2) * 0.5);
14541 dst[3] = (float) ((sample3 + last_sample3) * 0.5);
14542 last_sample0 = sample0;
14543 last_sample1 = sample1;
14544 last_sample2 = sample2;
14545 last_sample3 = sample3;
14546 dst += 4;
14547 }
14548
14549 cvt->len_cvt = dstsize;
14550 if (cvt->filters[++cvt->filter_index]) {
14551 cvt->filters[cvt->filter_index] (cvt, format);
14552 }
14553 }
14554
14555 static void SDLCALL
14556 SDL_Upsample_F32LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
14557 {
14558 #ifdef DEBUG_CONVERT
14559 fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 6 channels.\n");
14560 #endif
14561
14562 const int srcsize = cvt->len_cvt;
14563 const int dstsize = cvt->len_cvt * 2;
14564 float *dst = ((float *) (cvt->buf + dstsize)) - 6;
14565 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
14566 const float *target = ((const float *) cvt->buf) - 6;
14567 double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
14568 double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
14569 double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
14570 double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
14571 double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
14572 double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
14573 while (dst != target) {
14574 const double sample5 = (double) SDL_SwapFloatLE(src[5]);
14575 const double sample4 = (double) SDL_SwapFloatLE(src[4]);
14576 const double sample3 = (double) SDL_SwapFloatLE(src[3]);
14577 const double sample2 = (double) SDL_SwapFloatLE(src[2]);
14578 const double sample1 = (double) SDL_SwapFloatLE(src[1]);
14579 const double sample0 = (double) SDL_SwapFloatLE(src[0]);
14580 src -= 6;
14581 dst[11] = (float) ((sample5 + last_sample5) * 0.5);
14582 dst[10] = (float) ((sample4 + last_sample4) * 0.5);
14583 dst[9] = (float) ((sample3 + last_sample3) * 0.5);
14584 dst[8] = (float) ((sample2 + last_sample2) * 0.5);
14585 dst[7] = (float) ((sample1 + last_sample1) * 0.5);
14586 dst[6] = (float) ((sample0 + last_sample0) * 0.5);
14587 dst[5] = (float) sample5;
14588 dst[4] = (float) sample4;
14589 dst[3] = (float) sample3;
14590 dst[2] = (float) sample2;
14591 dst[1] = (float) sample1;
14592 dst[0] = (float) sample0;
14593 last_sample5 = sample5;
14594 last_sample4 = sample4;
14595 last_sample3 = sample3;
14596 last_sample2 = sample2;
14597 last_sample1 = sample1;
14598 last_sample0 = sample0;
14599 dst -= 12;
14600 }
14601
14602 cvt->len_cvt = dstsize;
14603 if (cvt->filters[++cvt->filter_index]) {
14604 cvt->filters[cvt->filter_index] (cvt, format);
14605 }
14606 }
14607
14608 static void SDLCALL
14609 SDL_Downsample_F32LSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
14610 {
14611 #ifdef DEBUG_CONVERT
14612 fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 6 channels.\n");
14613 #endif
14614
14615 const int srcsize = cvt->len_cvt;
14616 const int dstsize = cvt->len_cvt / 2;
14617 float *dst = (float *) cvt->buf;
14618 const float *src = (float *) cvt->buf;
14619 const float *target = (const float *) (cvt->buf + dstsize);
14620 double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
14621 double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
14622 double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
14623 double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
14624 double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
14625 double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
14626 while (dst != target) {
14627 const double sample0 = (double) SDL_SwapFloatLE(src[0]);
14628 const double sample1 = (double) SDL_SwapFloatLE(src[1]);
14629 const double sample2 = (double) SDL_SwapFloatLE(src[2]);
14630 const double sample3 = (double) SDL_SwapFloatLE(src[3]);
14631 const double sample4 = (double) SDL_SwapFloatLE(src[4]);
14632 const double sample5 = (double) SDL_SwapFloatLE(src[5]);
14633 src += 12;
14634 dst[0] = (float) ((sample0 + last_sample0) * 0.5);
14635 dst[1] = (float) ((sample1 + last_sample1) * 0.5);
14636 dst[2] = (float) ((sample2 + last_sample2) * 0.5);
14637 dst[3] = (float) ((sample3 + last_sample3) * 0.5);
14638 dst[4] = (float) ((sample4 + last_sample4) * 0.5);
14639 dst[5] = (float) ((sample5 + last_sample5) * 0.5);
14640 last_sample0 = sample0;
14641 last_sample1 = sample1;
14642 last_sample2 = sample2;
14643 last_sample3 = sample3;
14644 last_sample4 = sample4;
14645 last_sample5 = sample5;
14646 dst += 6;
14647 }
14648
14649 cvt->len_cvt = dstsize;
14650 if (cvt->filters[++cvt->filter_index]) {
14651 cvt->filters[cvt->filter_index] (cvt, format);
14652 }
14653 }
14654
14655 static void SDLCALL
14656 SDL_Upsample_F32LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
14657 {
14658 #ifdef DEBUG_CONVERT
14659 fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 6 channels.\n");
14660 #endif
14661
14662 const int srcsize = cvt->len_cvt;
14663 const int dstsize = cvt->len_cvt * 4;
14664 float *dst = ((float *) (cvt->buf + dstsize)) - 6;
14665 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
14666 const float *target = ((const float *) cvt->buf) - 6;
14667 double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
14668 double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
14669 double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
14670 double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
14671 double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
14672 double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
14673 while (dst != target) {
14674 const double sample5 = (double) SDL_SwapFloatLE(src[5]);
14675 const double sample4 = (double) SDL_SwapFloatLE(src[4]);
14676 const double sample3 = (double) SDL_SwapFloatLE(src[3]);
14677 const double sample2 = (double) SDL_SwapFloatLE(src[2]);
14678 const double sample1 = (double) SDL_SwapFloatLE(src[1]);
14679 const double sample0 = (double) SDL_SwapFloatLE(src[0]);
14680 src -= 6;
14681 dst[23] = (float) sample5;
14682 dst[22] = (float) sample4;
14683 dst[21] = (float) sample3;
14684 dst[20] = (float) sample2;
14685 dst[19] = (float) sample1;
14686 dst[18] = (float) sample0;
14687 dst[17] = (float) (((3.0 * sample5) + last_sample5) * 0.25);
14688 dst[16] = (float) (((3.0 * sample4) + last_sample4) * 0.25);
14689 dst[15] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
14690 dst[14] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
14691 dst[13] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
14692 dst[12] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
14693 dst[11] = (float) ((sample5 + last_sample5) * 0.5);
14694 dst[10] = (float) ((sample4 + last_sample4) * 0.5);
14695 dst[9] = (float) ((sample3 + last_sample3) * 0.5);
14696 dst[8] = (float) ((sample2 + last_sample2) * 0.5);
14697 dst[7] = (float) ((sample1 + last_sample1) * 0.5);
14698 dst[6] = (float) ((sample0 + last_sample0) * 0.5);
14699 dst[5] = (float) ((sample5 + (3.0 * last_sample5)) * 0.25);
14700 dst[4] = (float) ((sample4 + (3.0 * last_sample4)) * 0.25);
14701 dst[3] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
14702 dst[2] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
14703 dst[1] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
14704 dst[0] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
14705 last_sample5 = sample5;
14706 last_sample4 = sample4;
14707 last_sample3 = sample3;
14708 last_sample2 = sample2;
14709 last_sample1 = sample1;
14710 last_sample0 = sample0;
14711 dst -= 24;
14712 }
14713
14714 cvt->len_cvt = dstsize;
14715 if (cvt->filters[++cvt->filter_index]) {
14716 cvt->filters[cvt->filter_index] (cvt, format);
14717 }
14718 }
14719
14720 static void SDLCALL
14721 SDL_Downsample_F32LSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
14722 {
14723 #ifdef DEBUG_CONVERT
14724 fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 6 channels.\n");
14725 #endif
14726
14727 const int srcsize = cvt->len_cvt;
14728 const int dstsize = cvt->len_cvt / 4;
14729 float *dst = (float *) cvt->buf;
14730 const float *src = (float *) cvt->buf;
14731 const float *target = (const float *) (cvt->buf + dstsize);
14732 double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
14733 double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
14734 double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
14735 double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
14736 double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
14737 double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
14738 while (dst != target) {
14739 const double sample0 = (double) SDL_SwapFloatLE(src[0]);
14740 const double sample1 = (double) SDL_SwapFloatLE(src[1]);
14741 const double sample2 = (double) SDL_SwapFloatLE(src[2]);
14742 const double sample3 = (double) SDL_SwapFloatLE(src[3]);
14743 const double sample4 = (double) SDL_SwapFloatLE(src[4]);
14744 const double sample5 = (double) SDL_SwapFloatLE(src[5]);
14745 src += 24;
14746 dst[0] = (float) ((sample0 + last_sample0) * 0.5);
14747 dst[1] = (float) ((sample1 + last_sample1) * 0.5);
14748 dst[2] = (float) ((sample2 + last_sample2) * 0.5);
14749 dst[3] = (float) ((sample3 + last_sample3) * 0.5);
14750 dst[4] = (float) ((sample4 + last_sample4) * 0.5);
14751 dst[5] = (float) ((sample5 + last_sample5) * 0.5);
14752 last_sample0 = sample0;
14753 last_sample1 = sample1;
14754 last_sample2 = sample2;
14755 last_sample3 = sample3;
14756 last_sample4 = sample4;
14757 last_sample5 = sample5;
14758 dst += 6;
14759 }
14760
14761 cvt->len_cvt = dstsize;
14762 if (cvt->filters[++cvt->filter_index]) {
14763 cvt->filters[cvt->filter_index] (cvt, format);
14764 }
14765 }
14766
14767 static void SDLCALL
14768 SDL_Upsample_F32LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
14769 {
14770 #ifdef DEBUG_CONVERT
14771 fprintf(stderr, "Upsample (x2) AUDIO_F32LSB, 8 channels.\n");
14772 #endif
14773
14774 const int srcsize = cvt->len_cvt;
14775 const int dstsize = cvt->len_cvt * 2;
14776 float *dst = ((float *) (cvt->buf + dstsize)) - 8;
14777 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
14778 const float *target = ((const float *) cvt->buf) - 8;
14779 double last_sample7 = (double) SDL_SwapFloatLE(src[7]);
14780 double last_sample6 = (double) SDL_SwapFloatLE(src[6]);
14781 double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
14782 double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
14783 double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
14784 double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
14785 double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
14786 double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
14787 while (dst != target) {
14788 const double sample7 = (double) SDL_SwapFloatLE(src[7]);
14789 const double sample6 = (double) SDL_SwapFloatLE(src[6]);
14790 const double sample5 = (double) SDL_SwapFloatLE(src[5]);
14791 const double sample4 = (double) SDL_SwapFloatLE(src[4]);
14792 const double sample3 = (double) SDL_SwapFloatLE(src[3]);
14793 const double sample2 = (double) SDL_SwapFloatLE(src[2]);
14794 const double sample1 = (double) SDL_SwapFloatLE(src[1]);
14795 const double sample0 = (double) SDL_SwapFloatLE(src[0]);
14796 src -= 8;
14797 dst[15] = (float) ((sample7 + last_sample7) * 0.5);
14798 dst[14] = (float) ((sample6 + last_sample6) * 0.5);
14799 dst[13] = (float) ((sample5 + last_sample5) * 0.5);
14800 dst[12] = (float) ((sample4 + last_sample4) * 0.5);
14801 dst[11] = (float) ((sample3 + last_sample3) * 0.5);
14802 dst[10] = (float) ((sample2 + last_sample2) * 0.5);
14803 dst[9] = (float) ((sample1 + last_sample1) * 0.5);
14804 dst[8] = (float) ((sample0 + last_sample0) * 0.5);
14805 dst[7] = (float) sample7;
14806 dst[6] = (float) sample6;
14807 dst[5] = (float) sample5;
14808 dst[4] = (float) sample4;
14809 dst[3] = (float) sample3;
14810 dst[2] = (float) sample2;
14811 dst[1] = (float) sample1;
14812 dst[0] = (float) sample0;
14813 last_sample7 = sample7;
14814 last_sample6 = sample6;
14815 last_sample5 = sample5;
14816 last_sample4 = sample4;
14817 last_sample3 = sample3;
14818 last_sample2 = sample2;
14819 last_sample1 = sample1;
14820 last_sample0 = sample0;
14821 dst -= 16;
14822 }
14823
14824 cvt->len_cvt = dstsize;
14825 if (cvt->filters[++cvt->filter_index]) {
14826 cvt->filters[cvt->filter_index] (cvt, format);
14827 }
14828 }
14829
14830 static void SDLCALL
14831 SDL_Downsample_F32LSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
14832 {
14833 #ifdef DEBUG_CONVERT
14834 fprintf(stderr, "Downsample (x2) AUDIO_F32LSB, 8 channels.\n");
14835 #endif
14836
14837 const int srcsize = cvt->len_cvt;
14838 const int dstsize = cvt->len_cvt / 2;
14839 float *dst = (float *) cvt->buf;
14840 const float *src = (float *) cvt->buf;
14841 const float *target = (const float *) (cvt->buf + dstsize);
14842 double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
14843 double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
14844 double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
14845 double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
14846 double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
14847 double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
14848 double last_sample6 = (double) SDL_SwapFloatLE(src[6]);
14849 double last_sample7 = (double) SDL_SwapFloatLE(src[7]);
14850 while (dst != target) {
14851 const double sample0 = (double) SDL_SwapFloatLE(src[0]);
14852 const double sample1 = (double) SDL_SwapFloatLE(src[1]);
14853 const double sample2 = (double) SDL_SwapFloatLE(src[2]);
14854 const double sample3 = (double) SDL_SwapFloatLE(src[3]);
14855 const double sample4 = (double) SDL_SwapFloatLE(src[4]);
14856 const double sample5 = (double) SDL_SwapFloatLE(src[5]);
14857 const double sample6 = (double) SDL_SwapFloatLE(src[6]);
14858 const double sample7 = (double) SDL_SwapFloatLE(src[7]);
14859 src += 16;
14860 dst[0] = (float) ((sample0 + last_sample0) * 0.5);
14861 dst[1] = (float) ((sample1 + last_sample1) * 0.5);
14862 dst[2] = (float) ((sample2 + last_sample2) * 0.5);
14863 dst[3] = (float) ((sample3 + last_sample3) * 0.5);
14864 dst[4] = (float) ((sample4 + last_sample4) * 0.5);
14865 dst[5] = (float) ((sample5 + last_sample5) * 0.5);
14866 dst[6] = (float) ((sample6 + last_sample6) * 0.5);
14867 dst[7] = (float) ((sample7 + last_sample7) * 0.5);
14868 last_sample0 = sample0;
14869 last_sample1 = sample1;
14870 last_sample2 = sample2;
14871 last_sample3 = sample3;
14872 last_sample4 = sample4;
14873 last_sample5 = sample5;
14874 last_sample6 = sample6;
14875 last_sample7 = sample7;
14876 dst += 8;
14877 }
14878
14879 cvt->len_cvt = dstsize;
14880 if (cvt->filters[++cvt->filter_index]) {
14881 cvt->filters[cvt->filter_index] (cvt, format);
14882 }
14883 }
14884
14885 static void SDLCALL
14886 SDL_Upsample_F32LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
14887 {
14888 #ifdef DEBUG_CONVERT
14889 fprintf(stderr, "Upsample (x4) AUDIO_F32LSB, 8 channels.\n");
14890 #endif
14891
14892 const int srcsize = cvt->len_cvt;
14893 const int dstsize = cvt->len_cvt * 4;
14894 float *dst = ((float *) (cvt->buf + dstsize)) - 8;
14895 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
14896 const float *target = ((const float *) cvt->buf) - 8;
14897 double last_sample7 = (double) SDL_SwapFloatLE(src[7]);
14898 double last_sample6 = (double) SDL_SwapFloatLE(src[6]);
14899 double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
14900 double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
14901 double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
14902 double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
14903 double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
14904 double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
14905 while (dst != target) {
14906 const double sample7 = (double) SDL_SwapFloatLE(src[7]);
14907 const double sample6 = (double) SDL_SwapFloatLE(src[6]);
14908 const double sample5 = (double) SDL_SwapFloatLE(src[5]);
14909 const double sample4 = (double) SDL_SwapFloatLE(src[4]);
14910 const double sample3 = (double) SDL_SwapFloatLE(src[3]);
14911 const double sample2 = (double) SDL_SwapFloatLE(src[2]);
14912 const double sample1 = (double) SDL_SwapFloatLE(src[1]);
14913 const double sample0 = (double) SDL_SwapFloatLE(src[0]);
14914 src -= 8;
14915 dst[31] = (float) sample7;
14916 dst[30] = (float) sample6;
14917 dst[29] = (float) sample5;
14918 dst[28] = (float) sample4;
14919 dst[27] = (float) sample3;
14920 dst[26] = (float) sample2;
14921 dst[25] = (float) sample1;
14922 dst[24] = (float) sample0;
14923 dst[23] = (float) (((3.0 * sample7) + last_sample7) * 0.25);
14924 dst[22] = (float) (((3.0 * sample6) + last_sample6) * 0.25);
14925 dst[21] = (float) (((3.0 * sample5) + last_sample5) * 0.25);
14926 dst[20] = (float) (((3.0 * sample4) + last_sample4) * 0.25);
14927 dst[19] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
14928 dst[18] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
14929 dst[17] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
14930 dst[16] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
14931 dst[15] = (float) ((sample7 + last_sample7) * 0.5);
14932 dst[14] = (float) ((sample6 + last_sample6) * 0.5);
14933 dst[13] = (float) ((sample5 + last_sample5) * 0.5);
14934 dst[12] = (float) ((sample4 + last_sample4) * 0.5);
14935 dst[11] = (float) ((sample3 + last_sample3) * 0.5);
14936 dst[10] = (float) ((sample2 + last_sample2) * 0.5);
14937 dst[9] = (float) ((sample1 + last_sample1) * 0.5);
14938 dst[8] = (float) ((sample0 + last_sample0) * 0.5);
14939 dst[7] = (float) ((sample7 + (3.0 * last_sample7)) * 0.25);
14940 dst[6] = (float) ((sample6 + (3.0 * last_sample6)) * 0.25);
14941 dst[5] = (float) ((sample5 + (3.0 * last_sample5)) * 0.25);
14942 dst[4] = (float) ((sample4 + (3.0 * last_sample4)) * 0.25);
14943 dst[3] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
14944 dst[2] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
14945 dst[1] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
14946 dst[0] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
14947 last_sample7 = sample7;
14948 last_sample6 = sample6;
14949 last_sample5 = sample5;
14950 last_sample4 = sample4;
14951 last_sample3 = sample3;
14952 last_sample2 = sample2;
14953 last_sample1 = sample1;
14954 last_sample0 = sample0;
14955 dst -= 32;
14956 }
14957
14958 cvt->len_cvt = dstsize;
14959 if (cvt->filters[++cvt->filter_index]) {
14960 cvt->filters[cvt->filter_index] (cvt, format);
14961 }
14962 }
14963
14964 static void SDLCALL
14965 SDL_Downsample_F32LSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
14966 {
14967 #ifdef DEBUG_CONVERT
14968 fprintf(stderr, "Downsample (x4) AUDIO_F32LSB, 8 channels.\n");
14969 #endif
14970
14971 const int srcsize = cvt->len_cvt;
14972 const int dstsize = cvt->len_cvt / 4;
14973 float *dst = (float *) cvt->buf;
14974 const float *src = (float *) cvt->buf;
14975 const float *target = (const float *) (cvt->buf + dstsize);
14976 double last_sample0 = (double) SDL_SwapFloatLE(src[0]);
14977 double last_sample1 = (double) SDL_SwapFloatLE(src[1]);
14978 double last_sample2 = (double) SDL_SwapFloatLE(src[2]);
14979 double last_sample3 = (double) SDL_SwapFloatLE(src[3]);
14980 double last_sample4 = (double) SDL_SwapFloatLE(src[4]);
14981 double last_sample5 = (double) SDL_SwapFloatLE(src[5]);
14982 double last_sample6 = (double) SDL_SwapFloatLE(src[6]);
14983 double last_sample7 = (double) SDL_SwapFloatLE(src[7]);
14984 while (dst != target) {
14985 const double sample0 = (double) SDL_SwapFloatLE(src[0]);
14986 const double sample1 = (double) SDL_SwapFloatLE(src[1]);
14987 const double sample2 = (double) SDL_SwapFloatLE(src[2]);
14988 const double sample3 = (double) SDL_SwapFloatLE(src[3]);
14989 const double sample4 = (double) SDL_SwapFloatLE(src[4]);
14990 const double sample5 = (double) SDL_SwapFloatLE(src[5]);
14991 const double sample6 = (double) SDL_SwapFloatLE(src[6]);
14992 const double sample7 = (double) SDL_SwapFloatLE(src[7]);
14993 src += 32;
14994 dst[0] = (float) ((sample0 + last_sample0) * 0.5);
14995 dst[1] = (float) ((sample1 + last_sample1) * 0.5);
14996 dst[2] = (float) ((sample2 + last_sample2) * 0.5);
14997 dst[3] = (float) ((sample3 + last_sample3) * 0.5);
14998 dst[4] = (float) ((sample4 + last_sample4) * 0.5);
14999 dst[5] = (float) ((sample5 + last_sample5) * 0.5);
15000 dst[6] = (float) ((sample6 + last_sample6) * 0.5);
15001 dst[7] = (float) ((sample7 + last_sample7) * 0.5);
15002 last_sample0 = sample0;
15003 last_sample1 = sample1;
15004 last_sample2 = sample2;
15005 last_sample3 = sample3;
15006 last_sample4 = sample4;
15007 last_sample5 = sample5;
15008 last_sample6 = sample6;
15009 last_sample7 = sample7;
15010 dst += 8;
15011 }
15012
15013 cvt->len_cvt = dstsize;
15014 if (cvt->filters[++cvt->filter_index]) {
15015 cvt->filters[cvt->filter_index] (cvt, format);
15016 }
15017 }
15018
15019 static void SDLCALL
15020 SDL_Upsample_F32MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
15021 {
15022 #ifdef DEBUG_CONVERT
15023 fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 1 channels.\n");
15024 #endif
15025
15026 const int srcsize = cvt->len_cvt;
15027 const int dstsize = cvt->len_cvt * 2;
15028 float *dst = ((float *) (cvt->buf + dstsize)) - 1;
15029 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
15030 const float *target = ((const float *) cvt->buf) - 1;
15031 double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
15032 while (dst != target) {
15033 const double sample0 = (double) SDL_SwapFloatBE(src[0]);
15034 src--;
15035 dst[1] = (float) ((sample0 + last_sample0) * 0.5);
15036 dst[0] = (float) sample0;
15037 last_sample0 = sample0;
15038 dst -= 2;
15039 }
15040
15041 cvt->len_cvt = dstsize;
15042 if (cvt->filters[++cvt->filter_index]) {
15043 cvt->filters[cvt->filter_index] (cvt, format);
15044 }
15045 }
15046
15047 static void SDLCALL
15048 SDL_Downsample_F32MSB_1c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
15049 {
15050 #ifdef DEBUG_CONVERT
15051 fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 1 channels.\n");
15052 #endif
15053
15054 const int srcsize = cvt->len_cvt;
15055 const int dstsize = cvt->len_cvt / 2;
15056 float *dst = (float *) cvt->buf;
15057 const float *src = (float *) cvt->buf;
15058 const float *target = (const float *) (cvt->buf + dstsize);
15059 double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
15060 while (dst != target) {
15061 const double sample0 = (double) SDL_SwapFloatBE(src[0]);
15062 src += 2;
15063 dst[0] = (float) ((sample0 + last_sample0) * 0.5);
15064 last_sample0 = sample0;
15065 dst++;
15066 }
15067
15068 cvt->len_cvt = dstsize;
15069 if (cvt->filters[++cvt->filter_index]) {
15070 cvt->filters[cvt->filter_index] (cvt, format);
15071 }
15072 }
15073
15074 static void SDLCALL
15075 SDL_Upsample_F32MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
15076 {
15077 #ifdef DEBUG_CONVERT
15078 fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 1 channels.\n");
15079 #endif
15080
15081 const int srcsize = cvt->len_cvt;
15082 const int dstsize = cvt->len_cvt * 4;
15083 float *dst = ((float *) (cvt->buf + dstsize)) - 1;
15084 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 1;
15085 const float *target = ((const float *) cvt->buf) - 1;
15086 double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
15087 while (dst != target) {
15088 const double sample0 = (double) SDL_SwapFloatBE(src[0]);
15089 src--;
15090 dst[3] = (float) sample0;
15091 dst[2] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
15092 dst[1] = (float) ((sample0 + last_sample0) * 0.5);
15093 dst[0] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
15094 last_sample0 = sample0;
15095 dst -= 4;
15096 }
15097
15098 cvt->len_cvt = dstsize;
15099 if (cvt->filters[++cvt->filter_index]) {
15100 cvt->filters[cvt->filter_index] (cvt, format);
15101 }
15102 }
15103
15104 static void SDLCALL
15105 SDL_Downsample_F32MSB_1c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
15106 {
15107 #ifdef DEBUG_CONVERT
15108 fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 1 channels.\n");
15109 #endif
15110
15111 const int srcsize = cvt->len_cvt;
15112 const int dstsize = cvt->len_cvt / 4;
15113 float *dst = (float *) cvt->buf;
15114 const float *src = (float *) cvt->buf;
15115 const float *target = (const float *) (cvt->buf + dstsize);
15116 double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
15117 while (dst != target) {
15118 const double sample0 = (double) SDL_SwapFloatBE(src[0]);
15119 src += 4;
15120 dst[0] = (float) ((sample0 + last_sample0) * 0.5);
15121 last_sample0 = sample0;
15122 dst++;
15123 }
15124
15125 cvt->len_cvt = dstsize;
15126 if (cvt->filters[++cvt->filter_index]) {
15127 cvt->filters[cvt->filter_index] (cvt, format);
15128 }
15129 }
15130
15131 static void SDLCALL
15132 SDL_Upsample_F32MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
15133 {
15134 #ifdef DEBUG_CONVERT
15135 fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 2 channels.\n");
15136 #endif
15137
15138 const int srcsize = cvt->len_cvt;
15139 const int dstsize = cvt->len_cvt * 2;
15140 float *dst = ((float *) (cvt->buf + dstsize)) - 2;
15141 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
15142 const float *target = ((const float *) cvt->buf) - 2;
15143 double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
15144 double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
15145 while (dst != target) {
15146 const double sample1 = (double) SDL_SwapFloatBE(src[1]);
15147 const double sample0 = (double) SDL_SwapFloatBE(src[0]);
15148 src -= 2;
15149 dst[3] = (float) ((sample1 + last_sample1) * 0.5);
15150 dst[2] = (float) ((sample0 + last_sample0) * 0.5);
15151 dst[1] = (float) sample1;
15152 dst[0] = (float) sample0;
15153 last_sample1 = sample1;
15154 last_sample0 = sample0;
15155 dst -= 4;
15156 }
15157
15158 cvt->len_cvt = dstsize;
15159 if (cvt->filters[++cvt->filter_index]) {
15160 cvt->filters[cvt->filter_index] (cvt, format);
15161 }
15162 }
15163
15164 static void SDLCALL
15165 SDL_Downsample_F32MSB_2c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
15166 {
15167 #ifdef DEBUG_CONVERT
15168 fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 2 channels.\n");
15169 #endif
15170
15171 const int srcsize = cvt->len_cvt;
15172 const int dstsize = cvt->len_cvt / 2;
15173 float *dst = (float *) cvt->buf;
15174 const float *src = (float *) cvt->buf;
15175 const float *target = (const float *) (cvt->buf + dstsize);
15176 double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
15177 double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
15178 while (dst != target) {
15179 const double sample0 = (double) SDL_SwapFloatBE(src[0]);
15180 const double sample1 = (double) SDL_SwapFloatBE(src[1]);
15181 src += 4;
15182 dst[0] = (float) ((sample0 + last_sample0) * 0.5);
15183 dst[1] = (float) ((sample1 + last_sample1) * 0.5);
15184 last_sample0 = sample0;
15185 last_sample1 = sample1;
15186 dst += 2;
15187 }
15188
15189 cvt->len_cvt = dstsize;
15190 if (cvt->filters[++cvt->filter_index]) {
15191 cvt->filters[cvt->filter_index] (cvt, format);
15192 }
15193 }
15194
15195 static void SDLCALL
15196 SDL_Upsample_F32MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
15197 {
15198 #ifdef DEBUG_CONVERT
15199 fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 2 channels.\n");
15200 #endif
15201
15202 const int srcsize = cvt->len_cvt;
15203 const int dstsize = cvt->len_cvt * 4;
15204 float *dst = ((float *) (cvt->buf + dstsize)) - 2;
15205 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 2;
15206 const float *target = ((const float *) cvt->buf) - 2;
15207 double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
15208 double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
15209 while (dst != target) {
15210 const double sample1 = (double) SDL_SwapFloatBE(src[1]);
15211 const double sample0 = (double) SDL_SwapFloatBE(src[0]);
15212 src -= 2;
15213 dst[7] = (float) sample1;
15214 dst[6] = (float) sample0;
15215 dst[5] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
15216 dst[4] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
15217 dst[3] = (float) ((sample1 + last_sample1) * 0.5);
15218 dst[2] = (float) ((sample0 + last_sample0) * 0.5);
15219 dst[1] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
15220 dst[0] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
15221 last_sample1 = sample1;
15222 last_sample0 = sample0;
15223 dst -= 8;
15224 }
15225
15226 cvt->len_cvt = dstsize;
15227 if (cvt->filters[++cvt->filter_index]) {
15228 cvt->filters[cvt->filter_index] (cvt, format);
15229 }
15230 }
15231
15232 static void SDLCALL
15233 SDL_Downsample_F32MSB_2c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
15234 {
15235 #ifdef DEBUG_CONVERT
15236 fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 2 channels.\n");
15237 #endif
15238
15239 const int srcsize = cvt->len_cvt;
15240 const int dstsize = cvt->len_cvt / 4;
15241 float *dst = (float *) cvt->buf;
15242 const float *src = (float *) cvt->buf;
15243 const float *target = (const float *) (cvt->buf + dstsize);
15244 double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
15245 double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
15246 while (dst != target) {
15247 const double sample0 = (double) SDL_SwapFloatBE(src[0]);
15248 const double sample1 = (double) SDL_SwapFloatBE(src[1]);
15249 src += 8;
15250 dst[0] = (float) ((sample0 + last_sample0) * 0.5);
15251 dst[1] = (float) ((sample1 + last_sample1) * 0.5);
15252 last_sample0 = sample0;
15253 last_sample1 = sample1;
15254 dst += 2;
15255 }
15256
15257 cvt->len_cvt = dstsize;
15258 if (cvt->filters[++cvt->filter_index]) {
15259 cvt->filters[cvt->filter_index] (cvt, format);
15260 }
15261 }
15262
15263 static void SDLCALL
15264 SDL_Upsample_F32MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
15265 {
15266 #ifdef DEBUG_CONVERT
15267 fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 4 channels.\n");
15268 #endif
15269
15270 const int srcsize = cvt->len_cvt;
15271 const int dstsize = cvt->len_cvt * 2;
15272 float *dst = ((float *) (cvt->buf + dstsize)) - 4;
15273 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
15274 const float *target = ((const float *) cvt->buf) - 4;
15275 double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
15276 double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
15277 double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
15278 double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
15279 while (dst != target) {
15280 const double sample3 = (double) SDL_SwapFloatBE(src[3]);
15281 const double sample2 = (double) SDL_SwapFloatBE(src[2]);
15282 const double sample1 = (double) SDL_SwapFloatBE(src[1]);
15283 const double sample0 = (double) SDL_SwapFloatBE(src[0]);
15284 src -= 4;
15285 dst[7] = (float) ((sample3 + last_sample3) * 0.5);
15286 dst[6] = (float) ((sample2 + last_sample2) * 0.5);
15287 dst[5] = (float) ((sample1 + last_sample1) * 0.5);
15288 dst[4] = (float) ((sample0 + last_sample0) * 0.5);
15289 dst[3] = (float) sample3;
15290 dst[2] = (float) sample2;
15291 dst[1] = (float) sample1;
15292 dst[0] = (float) sample0;
15293 last_sample3 = sample3;
15294 last_sample2 = sample2;
15295 last_sample1 = sample1;
15296 last_sample0 = sample0;
15297 dst -= 8;
15298 }
15299
15300 cvt->len_cvt = dstsize;
15301 if (cvt->filters[++cvt->filter_index]) {
15302 cvt->filters[cvt->filter_index] (cvt, format);
15303 }
15304 }
15305
15306 static void SDLCALL
15307 SDL_Downsample_F32MSB_4c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
15308 {
15309 #ifdef DEBUG_CONVERT
15310 fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 4 channels.\n");
15311 #endif
15312
15313 const int srcsize = cvt->len_cvt;
15314 const int dstsize = cvt->len_cvt / 2;
15315 float *dst = (float *) cvt->buf;
15316 const float *src = (float *) cvt->buf;
15317 const float *target = (const float *) (cvt->buf + dstsize);
15318 double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
15319 double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
15320 double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
15321 double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
15322 while (dst != target) {
15323 const double sample0 = (double) SDL_SwapFloatBE(src[0]);
15324 const double sample1 = (double) SDL_SwapFloatBE(src[1]);
15325 const double sample2 = (double) SDL_SwapFloatBE(src[2]);
15326 const double sample3 = (double) SDL_SwapFloatBE(src[3]);
15327 src += 8;
15328 dst[0] = (float) ((sample0 + last_sample0) * 0.5);
15329 dst[1] = (float) ((sample1 + last_sample1) * 0.5);
15330 dst[2] = (float) ((sample2 + last_sample2) * 0.5);
15331 dst[3] = (float) ((sample3 + last_sample3) * 0.5);
15332 last_sample0 = sample0;
15333 last_sample1 = sample1;
15334 last_sample2 = sample2;
15335 last_sample3 = sample3;
15336 dst += 4;
15337 }
15338
15339 cvt->len_cvt = dstsize;
15340 if (cvt->filters[++cvt->filter_index]) {
15341 cvt->filters[cvt->filter_index] (cvt, format);
15342 }
15343 }
15344
15345 static void SDLCALL
15346 SDL_Upsample_F32MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
15347 {
15348 #ifdef DEBUG_CONVERT
15349 fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 4 channels.\n");
15350 #endif
15351
15352 const int srcsize = cvt->len_cvt;
15353 const int dstsize = cvt->len_cvt * 4;
15354 float *dst = ((float *) (cvt->buf + dstsize)) - 4;
15355 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 4;
15356 const float *target = ((const float *) cvt->buf) - 4;
15357 double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
15358 double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
15359 double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
15360 double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
15361 while (dst != target) {
15362 const double sample3 = (double) SDL_SwapFloatBE(src[3]);
15363 const double sample2 = (double) SDL_SwapFloatBE(src[2]);
15364 const double sample1 = (double) SDL_SwapFloatBE(src[1]);
15365 const double sample0 = (double) SDL_SwapFloatBE(src[0]);
15366 src -= 4;
15367 dst[15] = (float) sample3;
15368 dst[14] = (float) sample2;
15369 dst[13] = (float) sample1;
15370 dst[12] = (float) sample0;
15371 dst[11] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
15372 dst[10] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
15373 dst[9] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
15374 dst[8] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
15375 dst[7] = (float) ((sample3 + last_sample3) * 0.5);
15376 dst[6] = (float) ((sample2 + last_sample2) * 0.5);
15377 dst[5] = (float) ((sample1 + last_sample1) * 0.5);
15378 dst[4] = (float) ((sample0 + last_sample0) * 0.5);
15379 dst[3] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
15380 dst[2] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
15381 dst[1] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
15382 dst[0] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
15383 last_sample3 = sample3;
15384 last_sample2 = sample2;
15385 last_sample1 = sample1;
15386 last_sample0 = sample0;
15387 dst -= 16;
15388 }
15389
15390 cvt->len_cvt = dstsize;
15391 if (cvt->filters[++cvt->filter_index]) {
15392 cvt->filters[cvt->filter_index] (cvt, format);
15393 }
15394 }
15395
15396 static void SDLCALL
15397 SDL_Downsample_F32MSB_4c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
15398 {
15399 #ifdef DEBUG_CONVERT
15400 fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 4 channels.\n");
15401 #endif
15402
15403 const int srcsize = cvt->len_cvt;
15404 const int dstsize = cvt->len_cvt / 4;
15405 float *dst = (float *) cvt->buf;
15406 const float *src = (float *) cvt->buf;
15407 const float *target = (const float *) (cvt->buf + dstsize);
15408 double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
15409 double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
15410 double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
15411 double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
15412 while (dst != target) {
15413 const double sample0 = (double) SDL_SwapFloatBE(src[0]);
15414 const double sample1 = (double) SDL_SwapFloatBE(src[1]);
15415 const double sample2 = (double) SDL_SwapFloatBE(src[2]);
15416 const double sample3 = (double) SDL_SwapFloatBE(src[3]);
15417 src += 16;
15418 dst[0] = (float) ((sample0 + last_sample0) * 0.5);
15419 dst[1] = (float) ((sample1 + last_sample1) * 0.5);
15420 dst[2] = (float) ((sample2 + last_sample2) * 0.5);
15421 dst[3] = (float) ((sample3 + last_sample3) * 0.5);
15422 last_sample0 = sample0;
15423 last_sample1 = sample1;
15424 last_sample2 = sample2;
15425 last_sample3 = sample3;
15426 dst += 4;
15427 }
15428
15429 cvt->len_cvt = dstsize;
15430 if (cvt->filters[++cvt->filter_index]) {
15431 cvt->filters[cvt->filter_index] (cvt, format);
15432 }
15433 }
15434
15435 static void SDLCALL
15436 SDL_Upsample_F32MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
15437 {
15438 #ifdef DEBUG_CONVERT
15439 fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 6 channels.\n");
15440 #endif
15441
15442 const int srcsize = cvt->len_cvt;
15443 const int dstsize = cvt->len_cvt * 2;
15444 float *dst = ((float *) (cvt->buf + dstsize)) - 6;
15445 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
15446 const float *target = ((const float *) cvt->buf) - 6;
15447 double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
15448 double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
15449 double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
15450 double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
15451 double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
15452 double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
15453 while (dst != target) {
15454 const double sample5 = (double) SDL_SwapFloatBE(src[5]);
15455 const double sample4 = (double) SDL_SwapFloatBE(src[4]);
15456 const double sample3 = (double) SDL_SwapFloatBE(src[3]);
15457 const double sample2 = (double) SDL_SwapFloatBE(src[2]);
15458 const double sample1 = (double) SDL_SwapFloatBE(src[1]);
15459 const double sample0 = (double) SDL_SwapFloatBE(src[0]);
15460 src -= 6;
15461 dst[11] = (float) ((sample5 + last_sample5) * 0.5);
15462 dst[10] = (float) ((sample4 + last_sample4) * 0.5);
15463 dst[9] = (float) ((sample3 + last_sample3) * 0.5);
15464 dst[8] = (float) ((sample2 + last_sample2) * 0.5);
15465 dst[7] = (float) ((sample1 + last_sample1) * 0.5);
15466 dst[6] = (float) ((sample0 + last_sample0) * 0.5);
15467 dst[5] = (float) sample5;
15468 dst[4] = (float) sample4;
15469 dst[3] = (float) sample3;
15470 dst[2] = (float) sample2;
15471 dst[1] = (float) sample1;
15472 dst[0] = (float) sample0;
15473 last_sample5 = sample5;
15474 last_sample4 = sample4;
15475 last_sample3 = sample3;
15476 last_sample2 = sample2;
15477 last_sample1 = sample1;
15478 last_sample0 = sample0;
15479 dst -= 12;
15480 }
15481
15482 cvt->len_cvt = dstsize;
15483 if (cvt->filters[++cvt->filter_index]) {
15484 cvt->filters[cvt->filter_index] (cvt, format);
15485 }
15486 }
15487
15488 static void SDLCALL
15489 SDL_Downsample_F32MSB_6c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
15490 {
15491 #ifdef DEBUG_CONVERT
15492 fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 6 channels.\n");
15493 #endif
15494
15495 const int srcsize = cvt->len_cvt;
15496 const int dstsize = cvt->len_cvt / 2;
15497 float *dst = (float *) cvt->buf;
15498 const float *src = (float *) cvt->buf;
15499 const float *target = (const float *) (cvt->buf + dstsize);
15500 double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
15501 double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
15502 double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
15503 double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
15504 double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
15505 double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
15506 while (dst != target) {
15507 const double sample0 = (double) SDL_SwapFloatBE(src[0]);
15508 const double sample1 = (double) SDL_SwapFloatBE(src[1]);
15509 const double sample2 = (double) SDL_SwapFloatBE(src[2]);
15510 const double sample3 = (double) SDL_SwapFloatBE(src[3]);
15511 const double sample4 = (double) SDL_SwapFloatBE(src[4]);
15512 const double sample5 = (double) SDL_SwapFloatBE(src[5]);
15513 src += 12;
15514 dst[0] = (float) ((sample0 + last_sample0) * 0.5);
15515 dst[1] = (float) ((sample1 + last_sample1) * 0.5);
15516 dst[2] = (float) ((sample2 + last_sample2) * 0.5);
15517 dst[3] = (float) ((sample3 + last_sample3) * 0.5);
15518 dst[4] = (float) ((sample4 + last_sample4) * 0.5);
15519 dst[5] = (float) ((sample5 + last_sample5) * 0.5);
15520 last_sample0 = sample0;
15521 last_sample1 = sample1;
15522 last_sample2 = sample2;
15523 last_sample3 = sample3;
15524 last_sample4 = sample4;
15525 last_sample5 = sample5;
15526 dst += 6;
15527 }
15528
15529 cvt->len_cvt = dstsize;
15530 if (cvt->filters[++cvt->filter_index]) {
15531 cvt->filters[cvt->filter_index] (cvt, format);
15532 }
15533 }
15534
15535 static void SDLCALL
15536 SDL_Upsample_F32MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
15537 {
15538 #ifdef DEBUG_CONVERT
15539 fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 6 channels.\n");
15540 #endif
15541
15542 const int srcsize = cvt->len_cvt;
15543 const int dstsize = cvt->len_cvt * 4;
15544 float *dst = ((float *) (cvt->buf + dstsize)) - 6;
15545 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 6;
15546 const float *target = ((const float *) cvt->buf) - 6;
15547 double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
15548 double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
15549 double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
15550 double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
15551 double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
15552 double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
15553 while (dst != target) {
15554 const double sample5 = (double) SDL_SwapFloatBE(src[5]);
15555 const double sample4 = (double) SDL_SwapFloatBE(src[4]);
15556 const double sample3 = (double) SDL_SwapFloatBE(src[3]);
15557 const double sample2 = (double) SDL_SwapFloatBE(src[2]);
15558 const double sample1 = (double) SDL_SwapFloatBE(src[1]);
15559 const double sample0 = (double) SDL_SwapFloatBE(src[0]);
15560 src -= 6;
15561 dst[23] = (float) sample5;
15562 dst[22] = (float) sample4;
15563 dst[21] = (float) sample3;
15564 dst[20] = (float) sample2;
15565 dst[19] = (float) sample1;
15566 dst[18] = (float) sample0;
15567 dst[17] = (float) (((3.0 * sample5) + last_sample5) * 0.25);
15568 dst[16] = (float) (((3.0 * sample4) + last_sample4) * 0.25);
15569 dst[15] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
15570 dst[14] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
15571 dst[13] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
15572 dst[12] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
15573 dst[11] = (float) ((sample5 + last_sample5) * 0.5);
15574 dst[10] = (float) ((sample4 + last_sample4) * 0.5);
15575 dst[9] = (float) ((sample3 + last_sample3) * 0.5);
15576 dst[8] = (float) ((sample2 + last_sample2) * 0.5);
15577 dst[7] = (float) ((sample1 + last_sample1) * 0.5);
15578 dst[6] = (float) ((sample0 + last_sample0) * 0.5);
15579 dst[5] = (float) ((sample5 + (3.0 * last_sample5)) * 0.25);
15580 dst[4] = (float) ((sample4 + (3.0 * last_sample4)) * 0.25);
15581 dst[3] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
15582 dst[2] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
15583 dst[1] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
15584 dst[0] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
15585 last_sample5 = sample5;
15586 last_sample4 = sample4;
15587 last_sample3 = sample3;
15588 last_sample2 = sample2;
15589 last_sample1 = sample1;
15590 last_sample0 = sample0;
15591 dst -= 24;
15592 }
15593
15594 cvt->len_cvt = dstsize;
15595 if (cvt->filters[++cvt->filter_index]) {
15596 cvt->filters[cvt->filter_index] (cvt, format);
15597 }
15598 }
15599
15600 static void SDLCALL
15601 SDL_Downsample_F32MSB_6c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
15602 {
15603 #ifdef DEBUG_CONVERT
15604 fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 6 channels.\n");
15605 #endif
15606
15607 const int srcsize = cvt->len_cvt;
15608 const int dstsize = cvt->len_cvt / 4;
15609 float *dst = (float *) cvt->buf;
15610 const float *src = (float *) cvt->buf;
15611 const float *target = (const float *) (cvt->buf + dstsize);
15612 double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
15613 double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
15614 double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
15615 double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
15616 double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
15617 double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
15618 while (dst != target) {
15619 const double sample0 = (double) SDL_SwapFloatBE(src[0]);
15620 const double sample1 = (double) SDL_SwapFloatBE(src[1]);
15621 const double sample2 = (double) SDL_SwapFloatBE(src[2]);
15622 const double sample3 = (double) SDL_SwapFloatBE(src[3]);
15623 const double sample4 = (double) SDL_SwapFloatBE(src[4]);
15624 const double sample5 = (double) SDL_SwapFloatBE(src[5]);
15625 src += 24;
15626 dst[0] = (float) ((sample0 + last_sample0) * 0.5);
15627 dst[1] = (float) ((sample1 + last_sample1) * 0.5);
15628 dst[2] = (float) ((sample2 + last_sample2) * 0.5);
15629 dst[3] = (float) ((sample3 + last_sample3) * 0.5);
15630 dst[4] = (float) ((sample4 + last_sample4) * 0.5);
15631 dst[5] = (float) ((sample5 + last_sample5) * 0.5);
15632 last_sample0 = sample0;
15633 last_sample1 = sample1;
15634 last_sample2 = sample2;
15635 last_sample3 = sample3;
15636 last_sample4 = sample4;
15637 last_sample5 = sample5;
15638 dst += 6;
15639 }
15640
15641 cvt->len_cvt = dstsize;
15642 if (cvt->filters[++cvt->filter_index]) {
15643 cvt->filters[cvt->filter_index] (cvt, format);
15644 }
15645 }
15646
15647 static void SDLCALL
15648 SDL_Upsample_F32MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
15649 {
15650 #ifdef DEBUG_CONVERT
15651 fprintf(stderr, "Upsample (x2) AUDIO_F32MSB, 8 channels.\n");
15652 #endif
15653
15654 const int srcsize = cvt->len_cvt;
15655 const int dstsize = cvt->len_cvt * 2;
15656 float *dst = ((float *) (cvt->buf + dstsize)) - 8;
15657 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
15658 const float *target = ((const float *) cvt->buf) - 8;
15659 double last_sample7 = (double) SDL_SwapFloatBE(src[7]);
15660 double last_sample6 = (double) SDL_SwapFloatBE(src[6]);
15661 double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
15662 double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
15663 double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
15664 double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
15665 double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
15666 double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
15667 while (dst != target) {
15668 const double sample7 = (double) SDL_SwapFloatBE(src[7]);
15669 const double sample6 = (double) SDL_SwapFloatBE(src[6]);
15670 const double sample5 = (double) SDL_SwapFloatBE(src[5]);
15671 const double sample4 = (double) SDL_SwapFloatBE(src[4]);
15672 const double sample3 = (double) SDL_SwapFloatBE(src[3]);
15673 const double sample2 = (double) SDL_SwapFloatBE(src[2]);
15674 const double sample1 = (double) SDL_SwapFloatBE(src[1]);
15675 const double sample0 = (double) SDL_SwapFloatBE(src[0]);
15676 src -= 8;
15677 dst[15] = (float) ((sample7 + last_sample7) * 0.5);
15678 dst[14] = (float) ((sample6 + last_sample6) * 0.5);
15679 dst[13] = (float) ((sample5 + last_sample5) * 0.5);
15680 dst[12] = (float) ((sample4 + last_sample4) * 0.5);
15681 dst[11] = (float) ((sample3 + last_sample3) * 0.5);
15682 dst[10] = (float) ((sample2 + last_sample2) * 0.5);
15683 dst[9] = (float) ((sample1 + last_sample1) * 0.5);
15684 dst[8] = (float) ((sample0 + last_sample0) * 0.5);
15685 dst[7] = (float) sample7;
15686 dst[6] = (float) sample6;
15687 dst[5] = (float) sample5;
15688 dst[4] = (float) sample4;
15689 dst[3] = (float) sample3;
15690 dst[2] = (float) sample2;
15691 dst[1] = (float) sample1;
15692 dst[0] = (float) sample0;
15693 last_sample7 = sample7;
15694 last_sample6 = sample6;
15695 last_sample5 = sample5;
15696 last_sample4 = sample4;
15697 last_sample3 = sample3;
15698 last_sample2 = sample2;
15699 last_sample1 = sample1;
15700 last_sample0 = sample0;
15701 dst -= 16;
15702 }
15703
15704 cvt->len_cvt = dstsize;
15705 if (cvt->filters[++cvt->filter_index]) {
15706 cvt->filters[cvt->filter_index] (cvt, format);
15707 }
15708 }
15709
15710 static void SDLCALL
15711 SDL_Downsample_F32MSB_8c_x2(SDL_AudioCVT * cvt, SDL_AudioFormat format)
15712 {
15713 #ifdef DEBUG_CONVERT
15714 fprintf(stderr, "Downsample (x2) AUDIO_F32MSB, 8 channels.\n");
15715 #endif
15716
15717 const int srcsize = cvt->len_cvt;
15718 const int dstsize = cvt->len_cvt / 2;
15719 float *dst = (float *) cvt->buf;
15720 const float *src = (float *) cvt->buf;
15721 const float *target = (const float *) (cvt->buf + dstsize);
15722 double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
15723 double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
15724 double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
15725 double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
15726 double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
15727 double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
15728 double last_sample6 = (double) SDL_SwapFloatBE(src[6]);
15729 double last_sample7 = (double) SDL_SwapFloatBE(src[7]);
15730 while (dst != target) {
15731 const double sample0 = (double) SDL_SwapFloatBE(src[0]);
15732 const double sample1 = (double) SDL_SwapFloatBE(src[1]);
15733 const double sample2 = (double) SDL_SwapFloatBE(src[2]);
15734 const double sample3 = (double) SDL_SwapFloatBE(src[3]);
15735 const double sample4 = (double) SDL_SwapFloatBE(src[4]);
15736 const double sample5 = (double) SDL_SwapFloatBE(src[5]);
15737 const double sample6 = (double) SDL_SwapFloatBE(src[6]);
15738 const double sample7 = (double) SDL_SwapFloatBE(src[7]);
15739 src += 16;
15740 dst[0] = (float) ((sample0 + last_sample0) * 0.5);
15741 dst[1] = (float) ((sample1 + last_sample1) * 0.5);
15742 dst[2] = (float) ((sample2 + last_sample2) * 0.5);
15743 dst[3] = (float) ((sample3 + last_sample3) * 0.5);
15744 dst[4] = (float) ((sample4 + last_sample4) * 0.5);
15745 dst[5] = (float) ((sample5 + last_sample5) * 0.5);
15746 dst[6] = (float) ((sample6 + last_sample6) * 0.5);
15747 dst[7] = (float) ((sample7 + last_sample7) * 0.5);
15748 last_sample0 = sample0;
15749 last_sample1 = sample1;
15750 last_sample2 = sample2;
15751 last_sample3 = sample3;
15752 last_sample4 = sample4;
15753 last_sample5 = sample5;
15754 last_sample6 = sample6;
15755 last_sample7 = sample7;
15756 dst += 8;
15757 }
15758
15759 cvt->len_cvt = dstsize;
15760 if (cvt->filters[++cvt->filter_index]) {
15761 cvt->filters[cvt->filter_index] (cvt, format);
15762 }
15763 }
15764
15765 static void SDLCALL
15766 SDL_Upsample_F32MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
15767 {
15768 #ifdef DEBUG_CONVERT
15769 fprintf(stderr, "Upsample (x4) AUDIO_F32MSB, 8 channels.\n");
15770 #endif
15771
15772 const int srcsize = cvt->len_cvt;
15773 const int dstsize = cvt->len_cvt * 4;
15774 float *dst = ((float *) (cvt->buf + dstsize)) - 8;
15775 const float *src = ((float *) (cvt->buf + cvt->len_cvt)) - 8;
15776 const float *target = ((const float *) cvt->buf) - 8;
15777 double last_sample7 = (double) SDL_SwapFloatBE(src[7]);
15778 double last_sample6 = (double) SDL_SwapFloatBE(src[6]);
15779 double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
15780 double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
15781 double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
15782 double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
15783 double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
15784 double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
15785 while (dst != target) {
15786 const double sample7 = (double) SDL_SwapFloatBE(src[7]);
15787 const double sample6 = (double) SDL_SwapFloatBE(src[6]);
15788 const double sample5 = (double) SDL_SwapFloatBE(src[5]);
15789 const double sample4 = (double) SDL_SwapFloatBE(src[4]);
15790 const double sample3 = (double) SDL_SwapFloatBE(src[3]);
15791 const double sample2 = (double) SDL_SwapFloatBE(src[2]);
15792 const double sample1 = (double) SDL_SwapFloatBE(src[1]);
15793 const double sample0 = (double) SDL_SwapFloatBE(src[0]);
15794 src -= 8;
15795 dst[31] = (float) sample7;
15796 dst[30] = (float) sample6;
15797 dst[29] = (float) sample5;
15798 dst[28] = (float) sample4;
15799 dst[27] = (float) sample3;
15800 dst[26] = (float) sample2;
15801 dst[25] = (float) sample1;
15802 dst[24] = (float) sample0;
15803 dst[23] = (float) (((3.0 * sample7) + last_sample7) * 0.25);
15804 dst[22] = (float) (((3.0 * sample6) + last_sample6) * 0.25);
15805 dst[21] = (float) (((3.0 * sample5) + last_sample5) * 0.25);
15806 dst[20] = (float) (((3.0 * sample4) + last_sample4) * 0.25);
15807 dst[19] = (float) (((3.0 * sample3) + last_sample3) * 0.25);
15808 dst[18] = (float) (((3.0 * sample2) + last_sample2) * 0.25);
15809 dst[17] = (float) (((3.0 * sample1) + last_sample1) * 0.25);
15810 dst[16] = (float) (((3.0 * sample0) + last_sample0) * 0.25);
15811 dst[15] = (float) ((sample7 + last_sample7) * 0.5);
15812 dst[14] = (float) ((sample6 + last_sample6) * 0.5);
15813 dst[13] = (float) ((sample5 + last_sample5) * 0.5);
15814 dst[12] = (float) ((sample4 + last_sample4) * 0.5);
15815 dst[11] = (float) ((sample3 + last_sample3) * 0.5);
15816 dst[10] = (float) ((sample2 + last_sample2) * 0.5);
15817 dst[9] = (float) ((sample1 + last_sample1) * 0.5);
15818 dst[8] = (float) ((sample0 + last_sample0) * 0.5);
15819 dst[7] = (float) ((sample7 + (3.0 * last_sample7)) * 0.25);
15820 dst[6] = (float) ((sample6 + (3.0 * last_sample6)) * 0.25);
15821 dst[5] = (float) ((sample5 + (3.0 * last_sample5)) * 0.25);
15822 dst[4] = (float) ((sample4 + (3.0 * last_sample4)) * 0.25);
15823 dst[3] = (float) ((sample3 + (3.0 * last_sample3)) * 0.25);
15824 dst[2] = (float) ((sample2 + (3.0 * last_sample2)) * 0.25);
15825 dst[1] = (float) ((sample1 + (3.0 * last_sample1)) * 0.25);
15826 dst[0] = (float) ((sample0 + (3.0 * last_sample0)) * 0.25);
15827 last_sample7 = sample7;
15828 last_sample6 = sample6;
15829 last_sample5 = sample5;
15830 last_sample4 = sample4;
15831 last_sample3 = sample3;
15832 last_sample2 = sample2;
15833 last_sample1 = sample1;
15834 last_sample0 = sample0;
15835 dst -= 32;
15836 }
15837
15838 cvt->len_cvt = dstsize;
15839 if (cvt->filters[++cvt->filter_index]) {
15840 cvt->filters[cvt->filter_index] (cvt, format);
15841 }
15842 }
15843
15844 static void SDLCALL
15845 SDL_Downsample_F32MSB_8c_x4(SDL_AudioCVT * cvt, SDL_AudioFormat format)
15846 {
15847 #ifdef DEBUG_CONVERT
15848 fprintf(stderr, "Downsample (x4) AUDIO_F32MSB, 8 channels.\n");
15849 #endif
15850
15851 const int srcsize = cvt->len_cvt;
15852 const int dstsize = cvt->len_cvt / 4;
15853 float *dst = (float *) cvt->buf;
15854 const float *src = (float *) cvt->buf;
15855 const float *target = (const float *) (cvt->buf + dstsize);
15856 double last_sample0 = (double) SDL_SwapFloatBE(src[0]);
15857 double last_sample1 = (double) SDL_SwapFloatBE(src[1]);
15858 double last_sample2 = (double) SDL_SwapFloatBE(src[2]);
15859 double last_sample3 = (double) SDL_SwapFloatBE(src[3]);
15860 double last_sample4 = (double) SDL_SwapFloatBE(src[4]);
15861 double last_sample5 = (double) SDL_SwapFloatBE(src[5]);
15862 double last_sample6 = (double) SDL_SwapFloatBE(src[6]);
15863 double last_sample7 = (double) SDL_SwapFloatBE(src[7]);
15864 while (dst != target) {
15865 const double sample0 = (double) SDL_SwapFloatBE(src[0]);
15866 const double sample1 = (double) SDL_SwapFloatBE(src[1]);
15867 const double sample2 = (double) SDL_SwapFloatBE(src[2]);
15868 const double sample3 = (double) SDL_SwapFloatBE(src[3]);
15869 const double sample4 = (double) SDL_SwapFloatBE(src[4]);
15870 const double sample5 = (double) SDL_SwapFloatBE(src[5]);
15871 const double sample6 = (double) SDL_SwapFloatBE(src[6]);
15872 const double sample7 = (double) SDL_SwapFloatBE(src[7]);
15873 src += 32;
15874 dst[0] = (float) ((sample0 + last_sample0) * 0.5);
15875 dst[1] = (float) ((sample1 + last_sample1) * 0.5);
15876 dst[2] = (float) ((sample2 + last_sample2) * 0.5);
15877 dst[3] = (float) ((sample3 + last_sample3) * 0.5);
15878 dst[4] = (float) ((sample4 + last_sample4) * 0.5);
15879 dst[5] = (float) ((sample5 + last_sample5) * 0.5);
15880 dst[6] = (float) ((sample6 + last_sample6) * 0.5);
15881 dst[7] = (float) ((sample7 + last_sample7) * 0.5);
15882 last_sample0 = sample0;
15883 last_sample1 = sample1;
15884 last_sample2 = sample2;
15885 last_sample3 = sample3;
15886 last_sample4 = sample4;
15887 last_sample5 = sample5;
15888 last_sample6 = sample6;
15889 last_sample7 = sample7;
15890 dst += 8;
15891 }
15892
15893 cvt->len_cvt = dstsize;
15894 if (cvt->filters[++cvt->filter_index]) {
15895 cvt->filters[cvt->filter_index] (cvt, format);
15896 }
15897 }
15898
15899 #endif /* !LESS_RESAMPLERS */
15900 #endif /* !NO_RESAMPLERS */
15901
15902
15903 const SDL_AudioRateFilters sdl_audio_rate_filters[] =
15904 {
15905 #if !NO_RESAMPLERS
15906 { AUDIO_U8, 1, 0, 0, SDL_Downsample_U8_1c },
15907 { AUDIO_U8, 1, 1, 0, SDL_Upsample_U8_1c },
15908 { AUDIO_U8, 2, 0, 0, SDL_Downsample_U8_2c },
15909 { AUDIO_U8, 2, 1, 0, SDL_Upsample_U8_2c },
15910 { AUDIO_U8, 4, 0, 0, SDL_Downsample_U8_4c },
15911 { AUDIO_U8, 4, 1, 0, SDL_Upsample_U8_4c },
15912 { AUDIO_U8, 6, 0, 0, SDL_Downsample_U8_6c },
15913 { AUDIO_U8, 6, 1, 0, SDL_Upsample_U8_6c },
15914 { AUDIO_U8, 8, 0, 0, SDL_Downsample_U8_8c },
15915 { AUDIO_U8, 8, 1, 0, SDL_Upsample_U8_8c },
15916 { AUDIO_S8, 1, 0, 0, SDL_Downsample_S8_1c },
15917 { AUDIO_S8, 1, 1, 0, SDL_Upsample_S8_1c },
15918 { AUDIO_S8, 2, 0, 0, SDL_Downsample_S8_2c },
15919 { AUDIO_S8, 2, 1, 0, SDL_Upsample_S8_2c },
15920 { AUDIO_S8, 4, 0, 0, SDL_Downsample_S8_4c },
15921 { AUDIO_S8, 4, 1, 0, SDL_Upsample_S8_4c },
15922 { AUDIO_S8, 6, 0, 0, SDL_Downsample_S8_6c },
15923 { AUDIO_S8, 6, 1, 0, SDL_Upsample_S8_6c },
15924 { AUDIO_S8, 8, 0, 0, SDL_Downsample_S8_8c },
15925 { AUDIO_S8, 8, 1, 0, SDL_Upsample_S8_8c },
15926 { AUDIO_U16LSB, 1, 0, 0, SDL_Downsample_U16LSB_1c },
15927 { AUDIO_U16LSB, 1, 1, 0, SDL_Upsample_U16LSB_1c },
15928 { AUDIO_U16LSB, 2, 0, 0, SDL_Downsample_U16LSB_2c },
15929 { AUDIO_U16LSB, 2, 1, 0, SDL_Upsample_U16LSB_2c },
15930 { AUDIO_U16LSB, 4, 0, 0, SDL_Downsample_U16LSB_4c },
15931 { AUDIO_U16LSB, 4, 1, 0, SDL_Upsample_U16LSB_4c },
15932 { AUDIO_U16LSB, 6, 0, 0, SDL_Downsample_U16LSB_6c },
15933 { AUDIO_U16LSB, 6, 1, 0, SDL_Upsample_U16LSB_6c },
15934 { AUDIO_U16LSB, 8, 0, 0, SDL_Downsample_U16LSB_8c },
15935 { AUDIO_U16LSB, 8, 1, 0, SDL_Upsample_U16LSB_8c },
15936 { AUDIO_S16LSB, 1, 0, 0, SDL_Downsample_S16LSB_1c },
15937 { AUDIO_S16LSB, 1, 1, 0, SDL_Upsample_S16LSB_1c },
15938 { AUDIO_S16LSB, 2, 0, 0, SDL_Downsample_S16LSB_2c },
15939 { AUDIO_S16LSB, 2, 1, 0, SDL_Upsample_S16LSB_2c },
15940 { AUDIO_S16LSB, 4, 0, 0, SDL_Downsample_S16LSB_4c },
15941 { AUDIO_S16LSB, 4, 1, 0, SDL_Upsample_S16LSB_4c },
15942 { AUDIO_S16LSB, 6, 0, 0, SDL_Downsample_S16LSB_6c },
15943 { AUDIO_S16LSB, 6, 1, 0, SDL_Upsample_S16LSB_6c },
15944 { AUDIO_S16LSB, 8, 0, 0, SDL_Downsample_S16LSB_8c },
15945 { AUDIO_S16LSB, 8, 1, 0, SDL_Upsample_S16LSB_8c },
15946 { AUDIO_U16MSB, 1, 0, 0, SDL_Downsample_U16MSB_1c },
15947 { AUDIO_U16MSB, 1, 1, 0, SDL_Upsample_U16MSB_1c },
15948 { AUDIO_U16MSB, 2, 0, 0, SDL_Downsample_U16MSB_2c },
15949 { AUDIO_U16MSB, 2, 1, 0, SDL_Upsample_U16MSB_2c },
15950 { AUDIO_U16MSB, 4, 0, 0, SDL_Downsample_U16MSB_4c },
15951 { AUDIO_U16MSB, 4, 1, 0, SDL_Upsample_U16MSB_4c },
15952 { AUDIO_U16MSB, 6, 0, 0, SDL_Downsample_U16MSB_6c },
15953 { AUDIO_U16MSB, 6, 1, 0, SDL_Upsample_U16MSB_6c },
15954 { AUDIO_U16MSB, 8, 0, 0, SDL_Downsample_U16MSB_8c },
15955 { AUDIO_U16MSB, 8, 1, 0, SDL_Upsample_U16MSB_8c },
15956 { AUDIO_S16MSB, 1, 0, 0, SDL_Downsample_S16MSB_1c },
15957 { AUDIO_S16MSB, 1, 1, 0, SDL_Upsample_S16MSB_1c },
15958 { AUDIO_S16MSB, 2, 0, 0, SDL_Downsample_S16MSB_2c },
15959 { AUDIO_S16MSB, 2, 1, 0, SDL_Upsample_S16MSB_2c },
15960 { AUDIO_S16MSB, 4, 0, 0, SDL_Downsample_S16MSB_4c },
15961 { AUDIO_S16MSB, 4, 1, 0, SDL_Upsample_S16MSB_4c },
15962 { AUDIO_S16MSB, 6, 0, 0, SDL_Downsample_S16MSB_6c },
15963 { AUDIO_S16MSB, 6, 1, 0, SDL_Upsample_S16MSB_6c },
15964 { AUDIO_S16MSB, 8, 0, 0, SDL_Downsample_S16MSB_8c },
15965 { AUDIO_S16MSB, 8, 1, 0, SDL_Upsample_S16MSB_8c },
15966 { AUDIO_S32LSB, 1, 0, 0, SDL_Downsample_S32LSB_1c },
15967 { AUDIO_S32LSB, 1, 1, 0, SDL_Upsample_S32LSB_1c },
15968 { AUDIO_S32LSB, 2, 0, 0, SDL_Downsample_S32LSB_2c },
15969 { AUDIO_S32LSB, 2, 1, 0, SDL_Upsample_S32LSB_2c },
15970 { AUDIO_S32LSB, 4, 0, 0, SDL_Downsample_S32LSB_4c },
15971 { AUDIO_S32LSB, 4, 1, 0, SDL_Upsample_S32LSB_4c },
15972 { AUDIO_S32LSB, 6, 0, 0, SDL_Downsample_S32LSB_6c },
15973 { AUDIO_S32LSB, 6, 1, 0, SDL_Upsample_S32LSB_6c },
15974 { AUDIO_S32LSB, 8, 0, 0, SDL_Downsample_S32LSB_8c },
15975 { AUDIO_S32LSB, 8, 1, 0, SDL_Upsample_S32LSB_8c },
15976 { AUDIO_S32MSB, 1, 0, 0, SDL_Downsample_S32MSB_1c },
15977 { AUDIO_S32MSB, 1, 1, 0, SDL_Upsample_S32MSB_1c },
15978 { AUDIO_S32MSB, 2, 0, 0, SDL_Downsample_S32MSB_2c },
15979 { AUDIO_S32MSB, 2, 1, 0, SDL_Upsample_S32MSB_2c },
15980 { AUDIO_S32MSB, 4, 0, 0, SDL_Downsample_S32MSB_4c },
15981 { AUDIO_S32MSB, 4, 1, 0, SDL_Upsample_S32MSB_4c },
15982 { AUDIO_S32MSB, 6, 0, 0, SDL_Downsample_S32MSB_6c },
15983 { AUDIO_S32MSB, 6, 1, 0, SDL_Upsample_S32MSB_6c },
15984 { AUDIO_S32MSB, 8, 0, 0, SDL_Downsample_S32MSB_8c },
15985 { AUDIO_S32MSB, 8, 1, 0, SDL_Upsample_S32MSB_8c },
15986 { AUDIO_F32LSB, 1, 0, 0, SDL_Downsample_F32LSB_1c },
15987 { AUDIO_F32LSB, 1, 1, 0, SDL_Upsample_F32LSB_1c },
15988 { AUDIO_F32LSB, 2, 0, 0, SDL_Downsample_F32LSB_2c },
15989 { AUDIO_F32LSB, 2, 1, 0, SDL_Upsample_F32LSB_2c },
15990 { AUDIO_F32LSB, 4, 0, 0, SDL_Downsample_F32LSB_4c },
15991 { AUDIO_F32LSB, 4, 1, 0, SDL_Upsample_F32LSB_4c },
15992 { AUDIO_F32LSB, 6, 0, 0, SDL_Downsample_F32LSB_6c },
15993 { AUDIO_F32LSB, 6, 1, 0, SDL_Upsample_F32LSB_6c },
15994 { AUDIO_F32LSB, 8, 0, 0, SDL_Downsample_F32LSB_8c },
15995 { AUDIO_F32LSB, 8, 1, 0, SDL_Upsample_F32LSB_8c },
15996 { AUDIO_F32MSB, 1, 0, 0, SDL_Downsample_F32MSB_1c },
15997 { AUDIO_F32MSB, 1, 1, 0, SDL_Upsample_F32MSB_1c },
15998 { AUDIO_F32MSB, 2, 0, 0, SDL_Downsample_F32MSB_2c },
15999 { AUDIO_F32MSB, 2, 1, 0, SDL_Upsample_F32MSB_2c },
16000 { AUDIO_F32MSB, 4, 0, 0, SDL_Downsample_F32MSB_4c },
16001 { AUDIO_F32MSB, 4, 1, 0, SDL_Upsample_F32MSB_4c },
16002 { AUDIO_F32MSB, 6, 0, 0, SDL_Downsample_F32MSB_6c },
16003 { AUDIO_F32MSB, 6, 1, 0, SDL_Upsample_F32MSB_6c },
16004 { AUDIO_F32MSB, 8, 0, 0, SDL_Downsample_F32MSB_8c },
16005 { AUDIO_F32MSB, 8, 1, 0, SDL_Upsample_F32MSB_8c },
16006 #if !LESS_RESAMPLERS
16007 { AUDIO_U8, 1, 0, 2, SDL_Downsample_U8_1c_x2 },
16008 { AUDIO_U8, 1, 1, 2, SDL_Upsample_U8_1c_x2 },
16009 { AUDIO_U8, 1, 0, 4, SDL_Downsample_U8_1c_x4 },
16010 { AUDIO_U8, 1, 1, 4, SDL_Upsample_U8_1c_x4 },
16011 { AUDIO_U8, 2, 0, 2, SDL_Downsample_U8_2c_x2 },
16012 { AUDIO_U8, 2, 1, 2, SDL_Upsample_U8_2c_x2 },
16013 { AUDIO_U8, 2, 0, 4, SDL_Downsample_U8_2c_x4 },
16014 { AUDIO_U8, 2, 1, 4, SDL_Upsample_U8_2c_x4 },
16015 { AUDIO_U8, 4, 0, 2, SDL_Downsample_U8_4c_x2 },
16016 { AUDIO_U8, 4, 1, 2, SDL_Upsample_U8_4c_x2 },
16017 { AUDIO_U8, 4, 0, 4, SDL_Downsample_U8_4c_x4 },
16018 { AUDIO_U8, 4, 1, 4, SDL_Upsample_U8_4c_x4 },
16019 { AUDIO_U8, 6, 0, 2, SDL_Downsample_U8_6c_x2 },
16020 { AUDIO_U8, 6, 1, 2, SDL_Upsample_U8_6c_x2 },
16021 { AUDIO_U8, 6, 0, 4, SDL_Downsample_U8_6c_x4 },
16022 { AUDIO_U8, 6, 1, 4, SDL_Upsample_U8_6c_x4 },
16023 { AUDIO_U8, 8, 0, 2, SDL_Downsample_U8_8c_x2 },
16024 { AUDIO_U8, 8, 1, 2, SDL_Upsample_U8_8c_x2 },
16025 { AUDIO_U8, 8, 0, 4, SDL_Downsample_U8_8c_x4 },
16026 { AUDIO_U8, 8, 1, 4, SDL_Upsample_U8_8c_x4 },
16027 { AUDIO_S8, 1, 0, 2, SDL_Downsample_S8_1c_x2 },
16028 { AUDIO_S8, 1, 1, 2, SDL_Upsample_S8_1c_x2 },
16029 { AUDIO_S8, 1, 0, 4, SDL_Downsample_S8_1c_x4 },
16030 { AUDIO_S8, 1, 1, 4, SDL_Upsample_S8_1c_x4 },
16031 { AUDIO_S8, 2, 0, 2, SDL_Downsample_S8_2c_x2 },
16032 { AUDIO_S8, 2, 1, 2, SDL_Upsample_S8_2c_x2 },
16033 { AUDIO_S8, 2, 0, 4, SDL_Downsample_S8_2c_x4 },
16034 { AUDIO_S8, 2, 1, 4, SDL_Upsample_S8_2c_x4 },
16035 { AUDIO_S8, 4, 0, 2, SDL_Downsample_S8_4c_x2 },
16036 { AUDIO_S8, 4, 1, 2, SDL_Upsample_S8_4c_x2 },
16037 { AUDIO_S8, 4, 0, 4, SDL_Downsample_S8_4c_x4 },
16038 { AUDIO_S8, 4, 1, 4, SDL_Upsample_S8_4c_x4 },
16039 { AUDIO_S8, 6, 0, 2, SDL_Downsample_S8_6c_x2 },
16040 { AUDIO_S8, 6, 1, 2, SDL_Upsample_S8_6c_x2 },
16041 { AUDIO_S8, 6, 0, 4, SDL_Downsample_S8_6c_x4 },
16042 { AUDIO_S8, 6, 1, 4, SDL_Upsample_S8_6c_x4 },
16043 { AUDIO_S8, 8, 0, 2, SDL_Downsample_S8_8c_x2 },
16044 { AUDIO_S8, 8, 1, 2, SDL_Upsample_S8_8c_x2 },
16045 { AUDIO_S8, 8, 0, 4, SDL_Downsample_S8_8c_x4 },
16046 { AUDIO_S8, 8, 1, 4, SDL_Upsample_S8_8c_x4 },
16047 { AUDIO_U16LSB, 1, 0, 2, SDL_Downsample_U16LSB_1c_x2 },
16048 { AUDIO_U16LSB, 1, 1, 2, SDL_Upsample_U16LSB_1c_x2 },
16049 { AUDIO_U16LSB, 1, 0, 4, SDL_Downsample_U16LSB_1c_x4 },
16050 { AUDIO_U16LSB, 1, 1, 4, SDL_Upsample_U16LSB_1c_x4 },
16051 { AUDIO_U16LSB, 2, 0, 2, SDL_Downsample_U16LSB_2c_x2 },
16052 { AUDIO_U16LSB, 2, 1, 2, SDL_Upsample_U16LSB_2c_x2 },
16053 { AUDIO_U16LSB, 2, 0, 4, SDL_Downsample_U16LSB_2c_x4 },
16054 { AUDIO_U16LSB, 2, 1, 4, SDL_Upsample_U16LSB_2c_x4 },
16055 { AUDIO_U16LSB, 4, 0, 2, SDL_Downsample_U16LSB_4c_x2 },
16056 { AUDIO_U16LSB, 4, 1, 2, SDL_Upsample_U16LSB_4c_x2 },
16057 { AUDIO_U16LSB, 4, 0, 4, SDL_Downsample_U16LSB_4c_x4 },
16058 { AUDIO_U16LSB, 4, 1, 4, SDL_Upsample_U16LSB_4c_x4 },
16059 { AUDIO_U16LSB, 6, 0, 2, SDL_Downsample_U16LSB_6c_x2 },
16060 { AUDIO_U16LSB, 6, 1, 2, SDL_Upsample_U16LSB_6c_x2 },
16061 { AUDIO_U16LSB, 6, 0, 4, SDL_Downsample_U16LSB_6c_x4 },
16062 { AUDIO_U16LSB, 6, 1, 4, SDL_Upsample_U16LSB_6c_x4 },
16063 { AUDIO_U16LSB, 8, 0, 2, SDL_Downsample_U16LSB_8c_x2 },
16064 { AUDIO_U16LSB, 8, 1, 2, SDL_Upsample_U16LSB_8c_x2 },
16065 { AUDIO_U16LSB, 8, 0, 4, SDL_Downsample_U16LSB_8c_x4 },
16066 { AUDIO_U16LSB, 8, 1, 4, SDL_Upsample_U16LSB_8c_x4 },
16067 { AUDIO_S16LSB, 1, 0, 2, SDL_Downsample_S16LSB_1c_x2 },
16068 { AUDIO_S16LSB, 1, 1, 2, SDL_Upsample_S16LSB_1c_x2 },
16069 { AUDIO_S16LSB, 1, 0, 4, SDL_Downsample_S16LSB_1c_x4 },
16070 { AUDIO_S16LSB, 1, 1, 4, SDL_Upsample_S16LSB_1c_x4 },
16071 { AUDIO_S16LSB, 2, 0, 2, SDL_Downsample_S16LSB_2c_x2 },
16072 { AUDIO_S16LSB, 2, 1, 2, SDL_Upsample_S16LSB_2c_x2 },
16073 { AUDIO_S16LSB, 2, 0, 4, SDL_Downsample_S16LSB_2c_x4 },
16074 { AUDIO_S16LSB, 2, 1, 4, SDL_Upsample_S16LSB_2c_x4 },
16075 { AUDIO_S16LSB, 4, 0, 2, SDL_Downsample_S16LSB_4c_x2 },
16076 { AUDIO_S16LSB, 4, 1, 2, SDL_Upsample_S16LSB_4c_x2 },
16077 { AUDIO_S16LSB, 4, 0, 4, SDL_Downsample_S16LSB_4c_x4 },
16078 { AUDIO_S16LSB, 4, 1, 4, SDL_Upsample_S16LSB_4c_x4 },
16079 { AUDIO_S16LSB, 6, 0, 2, SDL_Downsample_S16LSB_6c_x2 },
16080 { AUDIO_S16LSB, 6, 1, 2, SDL_Upsample_S16LSB_6c_x2 },
16081 { AUDIO_S16LSB, 6, 0, 4, SDL_Downsample_S16LSB_6c_x4 },
16082 { AUDIO_S16LSB, 6, 1, 4, SDL_Upsample_S16LSB_6c_x4 },
16083 { AUDIO_S16LSB, 8, 0, 2, SDL_Downsample_S16LSB_8c_x2 },
16084 { AUDIO_S16LSB, 8, 1, 2, SDL_Upsample_S16LSB_8c_x2 },
16085 { AUDIO_S16LSB, 8, 0, 4, SDL_Downsample_S16LSB_8c_x4 },
16086 { AUDIO_S16LSB, 8, 1, 4, SDL_Upsample_S16LSB_8c_x4 },
16087 { AUDIO_U16MSB, 1, 0, 2, SDL_Downsample_U16MSB_1c_x2 },
16088 { AUDIO_U16MSB, 1, 1, 2, SDL_Upsample_U16MSB_1c_x2 },
16089 { AUDIO_U16MSB, 1, 0, 4, SDL_Downsample_U16MSB_1c_x4 },
16090 { AUDIO_U16MSB, 1, 1, 4, SDL_Upsample_U16MSB_1c_x4 },
16091 { AUDIO_U16MSB, 2, 0, 2, SDL_Downsample_U16MSB_2c_x2 },
16092 { AUDIO_U16MSB, 2, 1, 2, SDL_Upsample_U16MSB_2c_x2 },
16093 { AUDIO_U16MSB, 2, 0, 4, SDL_Downsample_U16MSB_2c_x4 },
16094 { AUDIO_U16MSB, 2, 1, 4, SDL_Upsample_U16MSB_2c_x4 },
16095 { AUDIO_U16MSB, 4, 0, 2, SDL_Downsample_U16MSB_4c_x2 },
16096 { AUDIO_U16MSB, 4, 1, 2, SDL_Upsample_U16MSB_4c_x2 },
16097 { AUDIO_U16MSB, 4, 0, 4, SDL_Downsample_U16MSB_4c_x4 },
16098 { AUDIO_U16MSB, 4, 1, 4, SDL_Upsample_U16MSB_4c_x4 },
16099 { AUDIO_U16MSB, 6, 0, 2, SDL_Downsample_U16MSB_6c_x2 },
16100 { AUDIO_U16MSB, 6, 1, 2, SDL_Upsample_U16MSB_6c_x2 },
16101 { AUDIO_U16MSB, 6, 0, 4, SDL_Downsample_U16MSB_6c_x4 },
16102 { AUDIO_U16MSB, 6, 1, 4, SDL_Upsample_U16MSB_6c_x4 },
16103 { AUDIO_U16MSB, 8, 0, 2, SDL_Downsample_U16MSB_8c_x2 },
16104 { AUDIO_U16MSB, 8, 1, 2, SDL_Upsample_U16MSB_8c_x2 },
16105 { AUDIO_U16MSB, 8, 0, 4, SDL_Downsample_U16MSB_8c_x4 },
16106 { AUDIO_U16MSB, 8, 1, 4, SDL_Upsample_U16MSB_8c_x4 },
16107 { AUDIO_S16MSB, 1, 0, 2, SDL_Downsample_S16MSB_1c_x2 },
16108 { AUDIO_S16MSB, 1, 1, 2, SDL_Upsample_S16MSB_1c_x2 },
16109 { AUDIO_S16MSB, 1, 0, 4, SDL_Downsample_S16MSB_1c_x4 },
16110 { AUDIO_S16MSB, 1, 1, 4, SDL_Upsample_S16MSB_1c_x4 },
16111 { AUDIO_S16MSB, 2, 0, 2, SDL_Downsample_S16MSB_2c_x2 },
16112 { AUDIO_S16MSB, 2, 1, 2, SDL_Upsample_S16MSB_2c_x2 },
16113 { AUDIO_S16MSB, 2, 0, 4, SDL_Downsample_S16MSB_2c_x4 },
16114 { AUDIO_S16MSB, 2, 1, 4, SDL_Upsample_S16MSB_2c_x4 },
16115 { AUDIO_S16MSB, 4, 0, 2, SDL_Downsample_S16MSB_4c_x2 },
16116 { AUDIO_S16MSB, 4, 1, 2, SDL_Upsample_S16MSB_4c_x2 },
16117 { AUDIO_S16MSB, 4, 0, 4, SDL_Downsample_S16MSB_4c_x4 },
16118 { AUDIO_S16MSB, 4, 1, 4, SDL_Upsample_S16MSB_4c_x4 },
16119 { AUDIO_S16MSB, 6, 0, 2, SDL_Downsample_S16MSB_6c_x2 },
16120 { AUDIO_S16MSB, 6, 1, 2, SDL_Upsample_S16MSB_6c_x2 },
16121 { AUDIO_S16MSB, 6, 0, 4, SDL_Downsample_S16MSB_6c_x4 },
16122 { AUDIO_S16MSB, 6, 1, 4, SDL_Upsample_S16MSB_6c_x4 },
16123 { AUDIO_S16MSB, 8, 0, 2, SDL_Downsample_S16MSB_8c_x2 },
16124 { AUDIO_S16MSB, 8, 1, 2, SDL_Upsample_S16MSB_8c_x2 },
16125 { AUDIO_S16MSB, 8, 0, 4, SDL_Downsample_S16MSB_8c_x4 },
16126 { AUDIO_S16MSB, 8, 1, 4, SDL_Upsample_S16MSB_8c_x4 },
16127 { AUDIO_S32LSB, 1, 0, 2, SDL_Downsample_S32LSB_1c_x2 },
16128 { AUDIO_S32LSB, 1, 1, 2, SDL_Upsample_S32LSB_1c_x2 },
16129 { AUDIO_S32LSB, 1, 0, 4, SDL_Downsample_S32LSB_1c_x4 },
16130 { AUDIO_S32LSB, 1, 1, 4, SDL_Upsample_S32LSB_1c_x4 },
16131 { AUDIO_S32LSB, 2, 0, 2, SDL_Downsample_S32LSB_2c_x2 },
16132 { AUDIO_S32LSB, 2, 1, 2, SDL_Upsample_S32LSB_2c_x2 },
16133 { AUDIO_S32LSB, 2, 0, 4, SDL_Downsample_S32LSB_2c_x4 },
16134 { AUDIO_S32LSB, 2, 1, 4, SDL_Upsample_S32LSB_2c_x4 },
16135 { AUDIO_S32LSB, 4, 0, 2, SDL_Downsample_S32LSB_4c_x2 },
16136 { AUDIO_S32LSB, 4, 1, 2, SDL_Upsample_S32LSB_4c_x2 },
16137 { AUDIO_S32LSB, 4, 0, 4, SDL_Downsample_S32LSB_4c_x4 },
16138 { AUDIO_S32LSB, 4, 1, 4, SDL_Upsample_S32LSB_4c_x4 },
16139 { AUDIO_S32LSB, 6, 0, 2, SDL_Downsample_S32LSB_6c_x2 },
16140 { AUDIO_S32LSB, 6, 1, 2, SDL_Upsample_S32LSB_6c_x2 },
16141 { AUDIO_S32LSB, 6, 0, 4, SDL_Downsample_S32LSB_6c_x4 },
16142 { AUDIO_S32LSB, 6, 1, 4, SDL_Upsample_S32LSB_6c_x4 },
16143 { AUDIO_S32LSB, 8, 0, 2, SDL_Downsample_S32LSB_8c_x2 },
16144 { AUDIO_S32LSB, 8, 1, 2, SDL_Upsample_S32LSB_8c_x2 },
16145 { AUDIO_S32LSB, 8, 0, 4, SDL_Downsample_S32LSB_8c_x4 },
16146 { AUDIO_S32LSB, 8, 1, 4, SDL_Upsample_S32LSB_8c_x4 },
16147 { AUDIO_S32MSB, 1, 0, 2, SDL_Downsample_S32MSB_1c_x2 },
16148 { AUDIO_S32MSB, 1, 1, 2, SDL_Upsample_S32MSB_1c_x2 },
16149 { AUDIO_S32MSB, 1, 0, 4, SDL_Downsample_S32MSB_1c_x4 },
16150 { AUDIO_S32MSB, 1, 1, 4, SDL_Upsample_S32MSB_1c_x4 },
16151 { AUDIO_S32MSB, 2, 0, 2, SDL_Downsample_S32MSB_2c_x2 },
16152 { AUDIO_S32MSB, 2, 1, 2, SDL_Upsample_S32MSB_2c_x2 },
16153 { AUDIO_S32MSB, 2, 0, 4, SDL_Downsample_S32MSB_2c_x4 },
16154 { AUDIO_S32MSB, 2, 1, 4, SDL_Upsample_S32MSB_2c_x4 },
16155 { AUDIO_S32MSB, 4, 0, 2, SDL_Downsample_S32MSB_4c_x2 },
16156 { AUDIO_S32MSB, 4, 1, 2, SDL_Upsample_S32MSB_4c_x2 },
16157 { AUDIO_S32MSB, 4, 0, 4, SDL_Downsample_S32MSB_4c_x4 },
16158 { AUDIO_S32MSB, 4, 1, 4, SDL_Upsample_S32MSB_4c_x4 },
16159 { AUDIO_S32MSB, 6, 0, 2, SDL_Downsample_S32MSB_6c_x2 },
16160 { AUDIO_S32MSB, 6, 1, 2, SDL_Upsample_S32MSB_6c_x2 },
16161 { AUDIO_S32MSB, 6, 0, 4, SDL_Downsample_S32MSB_6c_x4 },
16162 { AUDIO_S32MSB, 6, 1, 4, SDL_Upsample_S32MSB_6c_x4 },
16163 { AUDIO_S32MSB, 8, 0, 2, SDL_Downsample_S32MSB_8c_x2 },
16164 { AUDIO_S32MSB, 8, 1, 2, SDL_Upsample_S32MSB_8c_x2 },
16165 { AUDIO_S32MSB, 8, 0, 4, SDL_Downsample_S32MSB_8c_x4 },
16166 { AUDIO_S32MSB, 8, 1, 4, SDL_Upsample_S32MSB_8c_x4 },
16167 { AUDIO_F32LSB, 1, 0, 2, SDL_Downsample_F32LSB_1c_x2 },
16168 { AUDIO_F32LSB, 1, 1, 2, SDL_Upsample_F32LSB_1c_x2 },
16169 { AUDIO_F32LSB, 1, 0, 4, SDL_Downsample_F32LSB_1c_x4 },
16170 { AUDIO_F32LSB, 1, 1, 4, SDL_Upsample_F32LSB_1c_x4 },
16171 { AUDIO_F32LSB, 2, 0, 2, SDL_Downsample_F32LSB_2c_x2 },
16172 { AUDIO_F32LSB, 2, 1, 2, SDL_Upsample_F32LSB_2c_x2 },
16173 { AUDIO_F32LSB, 2, 0, 4, SDL_Downsample_F32LSB_2c_x4 },
16174 { AUDIO_F32LSB, 2, 1, 4, SDL_Upsample_F32LSB_2c_x4 },
16175 { AUDIO_F32LSB, 4, 0, 2, SDL_Downsample_F32LSB_4c_x2 },
16176 { AUDIO_F32LSB, 4, 1, 2, SDL_Upsample_F32LSB_4c_x2 },
16177 { AUDIO_F32LSB, 4, 0, 4, SDL_Downsample_F32LSB_4c_x4 },
16178 { AUDIO_F32LSB, 4, 1, 4, SDL_Upsample_F32LSB_4c_x4 },
16179 { AUDIO_F32LSB, 6, 0, 2, SDL_Downsample_F32LSB_6c_x2 },
16180 { AUDIO_F32LSB, 6, 1, 2, SDL_Upsample_F32LSB_6c_x2 },
16181 { AUDIO_F32LSB, 6, 0, 4, SDL_Downsample_F32LSB_6c_x4 },
16182 { AUDIO_F32LSB, 6, 1, 4, SDL_Upsample_F32LSB_6c_x4 },
16183 { AUDIO_F32LSB, 8, 0, 2, SDL_Downsample_F32LSB_8c_x2 },
16184 { AUDIO_F32LSB, 8, 1, 2, SDL_Upsample_F32LSB_8c_x2 },
16185 { AUDIO_F32LSB, 8, 0, 4, SDL_Downsample_F32LSB_8c_x4 },
16186 { AUDIO_F32LSB, 8, 1, 4, SDL_Upsample_F32LSB_8c_x4 },
16187 { AUDIO_F32MSB, 1, 0, 2, SDL_Downsample_F32MSB_1c_x2 },
16188 { AUDIO_F32MSB, 1, 1, 2, SDL_Upsample_F32MSB_1c_x2 },
16189 { AUDIO_F32MSB, 1, 0, 4, SDL_Downsample_F32MSB_1c_x4 },
16190 { AUDIO_F32MSB, 1, 1, 4, SDL_Upsample_F32MSB_1c_x4 },
16191 { AUDIO_F32MSB, 2, 0, 2, SDL_Downsample_F32MSB_2c_x2 },
16192 { AUDIO_F32MSB, 2, 1, 2, SDL_Upsample_F32MSB_2c_x2 },
16193 { AUDIO_F32MSB, 2, 0, 4, SDL_Downsample_F32MSB_2c_x4 },
16194 { AUDIO_F32MSB, 2, 1, 4, SDL_Upsample_F32MSB_2c_x4 },
16195 { AUDIO_F32MSB, 4, 0, 2, SDL_Downsample_F32MSB_4c_x2 },
16196 { AUDIO_F32MSB, 4, 1, 2, SDL_Upsample_F32MSB_4c_x2 },
16197 { AUDIO_F32MSB, 4, 0, 4, SDL_Downsample_F32MSB_4c_x4 },
16198 { AUDIO_F32MSB, 4, 1, 4, SDL_Upsample_F32MSB_4c_x4 },
16199 { AUDIO_F32MSB, 6, 0, 2, SDL_Downsample_F32MSB_6c_x2 },
16200 { AUDIO_F32MSB, 6, 1, 2, SDL_Upsample_F32MSB_6c_x2 },
16201 { AUDIO_F32MSB, 6, 0, 4, SDL_Downsample_F32MSB_6c_x4 },
16202 { AUDIO_F32MSB, 6, 1, 4, SDL_Upsample_F32MSB_6c_x4 },
16203 { AUDIO_F32MSB, 8, 0, 2, SDL_Downsample_F32MSB_8c_x2 },
16204 { AUDIO_F32MSB, 8, 1, 2, SDL_Upsample_F32MSB_8c_x2 },
16205 { AUDIO_F32MSB, 8, 0, 4, SDL_Downsample_F32MSB_8c_x4 },
16206 { AUDIO_F32MSB, 8, 1, 4, SDL_Upsample_F32MSB_8c_x4 },
16207 #endif /* !LESS_RESAMPLERS */
16208 #endif /* !NO_RESAMPLERS */
16209 { 0, 0, 0, 0, NULL }
16210 };
16211
16212 /* 390 converters generated. */
16213
2263 /* *INDENT-ON* */ 16214 /* *INDENT-ON* */
2264 16215
2265 /* vi: set ts=4 sw=4 expandtab: */ 16216 /* vi: set ts=4 sw=4 expandtab: */