comparison remap_neon.c @ 5:07763f536182 default tip

ALIGNment support
author Peter Meerwald <p.meerwald@bct-electronic.com>
date Sun, 08 Jul 2012 21:48:08 +0200
parents e889fd0e7769
children
comparison
equal deleted inserted replaced
4:1f6289166006 5:07763f536182
237 237
238 #include "arm_neon.h" 238 #include "arm_neon.h"
239 239
240 static void mono_to_stereo_float_neon_a8(float *dst, const float *src, unsigned n) { 240 static void mono_to_stereo_float_neon_a8(float *dst, const float *src, unsigned n) {
241 int i = n & 3; 241 int i = n & 3;
242 242
243 asm volatile ( 243 asm volatile (
244 "mov %[n], %[n], lsr #2\n\t" 244 "mov %[n], %[n], lsr #2\n\t"
245 "1:\n\t" 245 "1:\n\t"
246 "vld1.32 {q0}, [%[src]]!\n\t" 246 "vld1.32 {q0}, [%[src]]!\n\t"
247 "vmov q1, q0\n\t" 247 "vmov q1, q0\n\t"
286 } 286 }
287 } 287 }
288 288
289 static void mono_to_stereo_int16_neon(int16_t *dst, const int16_t *src, unsigned n) { 289 static void mono_to_stereo_int16_neon(int16_t *dst, const int16_t *src, unsigned n) {
290 int i = n & 7; 290 int i = n & 7;
291 291
292 asm volatile ( 292 asm volatile (
293 "mov %[n], %[n], lsr #3\n\t" 293 "mov %[n], %[n], lsr #3\n\t"
294 "1:\n\t" 294 "1:\n\t"
295 "vld1.16 {q0}, [%[src]]!\n\t" 295 "vld1.16 {q0}, [%[src]]!\n\t"
296 "vmov q1, q0\n\t" 296 "vmov q1, q0\n\t"
297 "subs %[n], %[n], #1\n\t" 297 "subs %[n], %[n], #1\n\t"
298 "vst2.16 {q0,q1}, [%[dst]]!\n\t" 298 "vst2.16 {q0,q1}, [%[dst]]!\n\t"
299 "bgt 1b\n\t" 299 "bgt 1b\n\t"
300 // output operands (or input operands that get modified) 300 // output operands (or input operands that get modified)
301 : [dst] "+r" (dst), [src] "+r" (src), [n] "+r" (n) 301 : [dst] "+r" (dst), [src] "+r" (src), [n] "+r" (n)
302 : // input operands 302 : // input operands
303 : "memory", "cc" // clobber list 303 : "memory", "cc" // clobber list
304 ); 304 );
305 305
306 while (i--) { 306 while (i--) {
397 } 397 }
398 } 398 }
399 399
400 #define SAMPLES 1019 400 #define SAMPLES 1019
401 #define TIMES 500000 401 #define TIMES 500000
402 #define ALIGN 1
402 403
403 static void run_test_mono_to_stereo_float(void) { 404 static void run_test_mono_to_stereo_float(void) {
404 float stereo_a9[2*SAMPLES]; 405 float stereo_a9[2*SAMPLES+ALIGN];
405 float stereo_a8[2*SAMPLES]; 406 float stereo_a8[2*SAMPLES+ALIGN];
406 float stereo_ref[2*SAMPLES]; 407 float stereo_ref[2*SAMPLES+ALIGN];
407 float stereo_gen[2*SAMPLES]; 408 float stereo_gen[2*SAMPLES+ALIGN];
408 float mono[SAMPLES]; 409 float mono[SAMPLES+ALIGN];
409 int i; 410 int i;
410 pa_usec_t start, stop; 411 pa_usec_t start, stop;
411 pa_sample_format_t sf; 412 pa_sample_format_t sf;
412 pa_sample_spec iss, oss; 413 pa_sample_spec iss, oss;
413 pa_remap_t remap; 414 pa_remap_t remap;
417 memset(stereo_ref, 0, sizeof(stereo_ref)); 418 memset(stereo_ref, 0, sizeof(stereo_ref));
418 memset(stereo_gen, 0, sizeof(stereo_gen)); 419 memset(stereo_gen, 0, sizeof(stereo_gen));
419 memset(stereo_a9, 0, sizeof(stereo_a9)); 420 memset(stereo_a9, 0, sizeof(stereo_a9));
420 memset(stereo_a8, 0, sizeof(stereo_a8)); 421 memset(stereo_a8, 0, sizeof(stereo_a8));
421 422
422 for (i = 0; i < SAMPLES; i++) { 423 for (i = 0; i < SAMPLES+ALIGN; i++) {
423 mono[i] = rand()/(float) RAND_MAX - 0.5f; 424 mono[i] = rand()/(float) RAND_MAX - 0.5f;
424 } 425 }
425 426
426 sf = PA_SAMPLE_FLOAT32NE; 427 sf = PA_SAMPLE_FLOAT32NE;
427 remap.format = &sf; 428 remap.format = &sf;
432 remap.i_ss = &iss; 433 remap.i_ss = &iss;
433 remap.o_ss = &oss; 434 remap.o_ss = &oss;
434 remap.map_table_f[0][0] = 1.0; 435 remap.map_table_f[0][0] = 1.0;
435 remap.map_table_f[1][0] = 1.0; 436 remap.map_table_f[1][0] = 1.0;
436 437
437 remap_mono_to_stereo_neon_a9(&remap, stereo_a9, mono, SAMPLES); 438 remap_mono_to_stereo_neon_a9(&remap, stereo_a9+ALIGN, mono+ALIGN, SAMPLES);
438 remap_mono_to_stereo_neon_a8(&remap, stereo_a8, mono, SAMPLES); 439 remap_mono_to_stereo_neon_a8(&remap, stereo_a8+ALIGN, mono+ALIGN, SAMPLES);
439 remap_mono_to_stereo_c(&remap, stereo_ref, mono, SAMPLES); 440 remap_mono_to_stereo_c(&remap, stereo_ref+ALIGN, mono+ALIGN, SAMPLES);
440 remap_channels_matrix_c(&remap, stereo_gen, mono, SAMPLES); 441 remap_channels_matrix_c(&remap, stereo_gen+ALIGN, mono+ALIGN, SAMPLES);
441 442
442 for (i = 0; i < 2*SAMPLES; i++) { 443 for (i = ALIGN; i < 2*SAMPLES+ALIGN; i++) {
443 if (fabsf(stereo_a9[i] - stereo_ref[i]) > 0.00001) { 444 if (fabsf(stereo_a9[i] - stereo_ref[i]) > 0.00001) {
444 pa_log_debug("NEON/A9 %d: %.3f != %.3f (%.3f)", i, stereo_a9[i], stereo_ref[i], 445 pa_log_debug("NEON/A9 %d: %.3f != %.3f (%.3f)", i, stereo_a9[i], stereo_ref[i],
445 mono[i/2]); 446 mono[i/2]);
446 } 447 }
447 } 448 }
448 for (i = 0; i < 2*SAMPLES; i++) { 449 for (i = ALIGN; i < 2*SAMPLES+ALIGN; i++) {
449 if (fabsf(stereo_a8[i] - stereo_ref[i]) > 0.00001) { 450 if (fabsf(stereo_a8[i] - stereo_ref[i]) > 0.00001) {
450 pa_log_debug("NEON/A8 %d: %.3f != %.3f (%.3f)", i, stereo_a8[i], stereo_ref[i], 451 pa_log_debug("NEON/A8 %d: %.3f != %.3f (%.3f)", i, stereo_a8[i], stereo_ref[i],
451 mono[i/2]); 452 mono[i/2]);
452 } 453 }
453 } 454 }
454 for (i = 0; i < 2*SAMPLES; i++) { 455 for (i = ALIGN; i < 2*SAMPLES+ALIGN; i++) {
455 if (fabsf(stereo_gen[i] - stereo_ref[i]) > 0.00001) { 456 if (fabsf(stereo_gen[i] - stereo_ref[i]) > 0.00001) {
456 pa_log_debug("generic %d: %.3f != %.3f (%.3f)", i, stereo_gen[i], stereo_ref[i], 457 pa_log_debug("generic %d: %.3f != %.3f (%.3f)", i, stereo_gen[i], stereo_ref[i],
457 mono[i/2]); 458 mono[i/2]);
458 } 459 }
459 } 460 }
460 461
461 start = pa_rtclock_now(); 462 start = pa_rtclock_now();
462 for (i = 0; i < TIMES; i++) { 463 for (i = 0; i < TIMES; i++) {
463 remap_mono_to_stereo_c(&remap, stereo_ref, mono, SAMPLES); 464 remap_mono_to_stereo_c(&remap, stereo_ref+ALIGN, mono+ALIGN, SAMPLES);
464 } 465 }
465 stop = pa_rtclock_now(); 466 stop = pa_rtclock_now();
466 pa_log_info("ref:\t\t%llu usec.", (long long unsigned int)(stop - start)); 467 pa_log_info("ref:\t\t%llu usec.", (long long unsigned int)(stop - start));
467 468
468 start = pa_rtclock_now(); 469 start = pa_rtclock_now();
469 for (i = 0; i < TIMES; i++) { 470 for (i = 0; i < TIMES; i++) {
470 remap_mono_to_stereo_neon_a9(&remap, stereo_a9, mono, SAMPLES); 471 remap_mono_to_stereo_neon_a9(&remap, stereo_a9+ALIGN, mono+ALIGN, SAMPLES);
471 } 472 }
472 stop = pa_rtclock_now(); 473 stop = pa_rtclock_now();
473 pa_log_info("NEON/A9:\t%llu usec.", (long long unsigned int)(stop - start)); 474 pa_log_info("NEON/A9:\t%llu usec.", (long long unsigned int)(stop - start));
474 475
475 start = pa_rtclock_now(); 476 start = pa_rtclock_now();
476 for (i = 0; i < TIMES; i++) { 477 for (i = 0; i < TIMES; i++) {
477 remap_mono_to_stereo_neon_a8(&remap, stereo_a8, mono, SAMPLES); 478 remap_mono_to_stereo_neon_a8(&remap, stereo_a8+ALIGN, mono+ALIGN, SAMPLES);
478 } 479 }
479 stop = pa_rtclock_now(); 480 stop = pa_rtclock_now();
480 pa_log_info("NEON/A8:\t%llu usec.", (long long unsigned int)(stop - start)); 481 pa_log_info("NEON/A8:\t%llu usec.", (long long unsigned int)(stop - start));
481 482
482 start = pa_rtclock_now(); 483 start = pa_rtclock_now();
483 for (i = 0; i < TIMES; i++) { 484 for (i = 0; i < TIMES; i++) {
484 remap_channels_matrix_c(&remap, stereo_gen, mono, SAMPLES); 485 remap_channels_matrix_c(&remap, stereo_gen+ALIGN, mono+ALIGN, SAMPLES);
485 } 486 }
486 stop = pa_rtclock_now(); 487 stop = pa_rtclock_now();
487 pa_log_info("generic:\t%llu usec.", (long long unsigned int)(stop - start)); 488 pa_log_info("generic:\t%llu usec.", (long long unsigned int)(stop - start));
488 } 489 }
489 490
490 static void run_test_stereo_to_mono_float(void) { 491 static void run_test_stereo_to_mono_float(void) {
491 float stereo[2*SAMPLES]; 492 float stereo[2*SAMPLES+ALIGN];
492 float mono_ref[SAMPLES]; 493 float mono_ref[SAMPLES+ALIGN];
493 float mono_gen[SAMPLES]; 494 float mono_gen[SAMPLES+ALIGN];
494 float mono[SAMPLES]; 495 float mono[SAMPLES+ALIGN];
495 int i; 496 int i;
496 pa_usec_t start, stop; 497 pa_usec_t start, stop;
497 pa_sample_format_t sf; 498 pa_sample_format_t sf;
498 pa_sample_spec iss, oss; 499 pa_sample_spec iss, oss;
499 pa_remap_t remap; 500 pa_remap_t remap;
501 pa_log_debug("checking NEON remap_stereo_to_mono(float, %d)", SAMPLES); 502 pa_log_debug("checking NEON remap_stereo_to_mono(float, %d)", SAMPLES);
502 503
503 memset(mono_ref, 0, sizeof(mono_ref)); 504 memset(mono_ref, 0, sizeof(mono_ref));
504 memset(mono, 0, sizeof(mono)); 505 memset(mono, 0, sizeof(mono));
505 506
506 for (i = 0; i < 2*SAMPLES; i++) { 507 for (i = 0; i < 2*SAMPLES+ALIGN; i++) {
507 stereo[i] = rand()/(float) RAND_MAX - 0.5f; 508 stereo[i] = rand()/(float) RAND_MAX - 0.5f;
508 } 509 }
509 510
510 sf = PA_SAMPLE_FLOAT32NE; 511 sf = PA_SAMPLE_FLOAT32NE;
511 remap.format = &sf; 512 remap.format = &sf;
516 remap.i_ss = &iss; 517 remap.i_ss = &iss;
517 remap.o_ss = &oss; 518 remap.o_ss = &oss;
518 remap.map_table_f[0][0] = 1.0; 519 remap.map_table_f[0][0] = 1.0;
519 remap.map_table_f[0][1] = 1.0; 520 remap.map_table_f[0][1] = 1.0;
520 521
521 remap_stereo_to_mono_c(&remap, mono_ref, stereo, SAMPLES); 522 remap_stereo_to_mono_c(&remap, mono_ref+ALIGN, stereo+ALIGN, SAMPLES);
522 remap_channels_matrix_c(&remap, mono_gen, stereo, SAMPLES); 523 remap_channels_matrix_c(&remap, mono_gen+ALIGN, stereo+ALIGN, SAMPLES);
523 remap_stereo_to_mono_neon(&remap, mono, stereo, SAMPLES); 524 remap_stereo_to_mono_neon(&remap, mono+ALIGN, stereo+ALIGN, SAMPLES);
524 525
525 for (i = 0; i < SAMPLES; i++) { 526 for (i = ALIGN; i < SAMPLES+ALIGN; i++) {
526 if (fabsf(mono[i] - mono_ref[i]) > 0.00001) { 527 if (fabsf(mono[i] - mono_ref[i]) > 0.00001) {
527 pa_log_debug("%d: %.3f != %.3f (%.3f %0.3f)", i, mono[i], mono_ref[i], 528 pa_log_debug("%d: %.3f != %.3f (%.3f %0.3f)", i, mono[i], mono_ref[i],
528 stereo[2*i+0], stereo[2*i+1]); 529 stereo[2*i+0], stereo[2*i+1]);
529 } 530 }
530 } 531 }
531 532
532 start = pa_rtclock_now(); 533 start = pa_rtclock_now();
533 for (i = 0; i < TIMES; i++) { 534 for (i = 0; i < TIMES; i++) {
534 remap_stereo_to_mono_neon(&remap, mono, stereo, SAMPLES); 535 remap_stereo_to_mono_neon(&remap, mono+ALIGN, stereo+ALIGN, SAMPLES);
535 } 536 }
536 stop = pa_rtclock_now(); 537 stop = pa_rtclock_now();
537 pa_log_info("NEON:\t\t%llu usec.", (long long unsigned int)(stop - start)); 538 pa_log_info("NEON:\t\t%llu usec.", (long long unsigned int)(stop - start));
538 539
539 start = pa_rtclock_now(); 540 start = pa_rtclock_now();
540 for (i = 0; i < TIMES; i++) { 541 for (i = 0; i < TIMES; i++) {
541 remap_stereo_to_mono_c(&remap, mono_ref, stereo, SAMPLES); 542 remap_stereo_to_mono_c(&remap, mono_ref+ALIGN, stereo+ALIGN, SAMPLES);
542 } 543 }
543 stop = pa_rtclock_now(); 544 stop = pa_rtclock_now();
544 pa_log_info("ref:\t\t%llu usec.", (long long unsigned int)(stop - start)); 545 pa_log_info("ref:\t\t%llu usec.", (long long unsigned int)(stop - start));
545 546
546 start = pa_rtclock_now(); 547 start = pa_rtclock_now();
547 for (i = 0; i < TIMES; i++) { 548 for (i = 0; i < TIMES; i++) {
548 remap_channels_matrix_c(&remap, mono_gen, stereo, SAMPLES); 549 remap_channels_matrix_c(&remap, mono_gen+ALIGN, stereo+ALIGN, SAMPLES);
549 } 550 }
550 stop = pa_rtclock_now(); 551 stop = pa_rtclock_now();
551 pa_log_info("generic:\t%llu usec.", (long long unsigned int)(stop - start)); 552 pa_log_info("generic:\t%llu usec.", (long long unsigned int)(stop - start));
552 } 553 }
553 554
554 static void run_test_mono_to_stereo_s16(void) { 555 static void run_test_mono_to_stereo_s16(void) {
555 int16_t stereo_a9[2*SAMPLES]; 556 int16_t stereo_a9[2*SAMPLES+ALIGN];
556 int16_t stereo_a8[2*SAMPLES]; 557 int16_t stereo_a8[2*SAMPLES+ALIGN];
557 int16_t stereo_ref[2*SAMPLES]; 558 int16_t stereo_ref[2*SAMPLES+ALIGN];
558 int16_t stereo_gen[2*SAMPLES]; 559 int16_t stereo_gen[2*SAMPLES+ALIGN];
559 int16_t mono[SAMPLES]; 560 int16_t mono[SAMPLES+ALIGN];
560 int i; 561 int i;
561 pa_usec_t start, stop; 562 pa_usec_t start, stop;
562 pa_sample_format_t sf; 563 pa_sample_format_t sf;
563 pa_sample_spec iss, oss; 564 pa_sample_spec iss, oss;
564 pa_remap_t remap; 565 pa_remap_t remap;
568 memset(stereo_ref, 0, sizeof(stereo_ref)); 569 memset(stereo_ref, 0, sizeof(stereo_ref));
569 memset(stereo_a9, 0, sizeof(stereo_a9)); 570 memset(stereo_a9, 0, sizeof(stereo_a9));
570 memset(stereo_a8, 0, sizeof(stereo_a8)); 571 memset(stereo_a8, 0, sizeof(stereo_a8));
571 memset(stereo_gen, 0, sizeof(stereo_gen)); 572 memset(stereo_gen, 0, sizeof(stereo_gen));
572 573
573 for (i = 0; i < SAMPLES; i++) { 574 for (i = 0; i < SAMPLES+ALIGN; i++) {
574 mono[i] = rand() - RAND_MAX/2; 575 mono[i] = rand() - RAND_MAX/2;
575 } 576 }
576 577
577 sf = PA_SAMPLE_S16NE; 578 sf = PA_SAMPLE_S16NE;
578 remap.format = &sf; 579 remap.format = &sf;
582 oss.channels = 2; 583 oss.channels = 2;
583 remap.i_ss = &iss; 584 remap.i_ss = &iss;
584 remap.o_ss = &oss; 585 remap.o_ss = &oss;
585 remap.map_table_i[0][0] = 0x10000; 586 remap.map_table_i[0][0] = 0x10000;
586 remap.map_table_i[1][0] = 0x10000; 587 remap.map_table_i[1][0] = 0x10000;
587 588
588 remap_mono_to_stereo_c(&remap, stereo_ref, mono, SAMPLES); 589 remap_mono_to_stereo_c(&remap, stereo_ref+ALIGN, mono+ALIGN, SAMPLES);
589 remap_channels_matrix_c(&remap, stereo_gen, mono, SAMPLES); 590 remap_channels_matrix_c(&remap, stereo_gen+ALIGN, mono+ALIGN, SAMPLES);
590 remap_mono_to_stereo_neon_a9(&remap, stereo_a9, mono, SAMPLES); 591 remap_mono_to_stereo_neon_a9(&remap, stereo_a9+ALIGN, mono+ALIGN, SAMPLES);
591 remap_mono_to_stereo_neon_a8(&remap, stereo_a8, mono, SAMPLES); 592 remap_mono_to_stereo_neon_a8(&remap, stereo_a8+ALIGN, mono+ALIGN, SAMPLES);
592 593
593 for (i = 0; i < 2*SAMPLES; i++) { 594 for (i = ALIGN; i < 2*SAMPLES+ALIGN; i++) {
594 if (abs(stereo_a9[i] - stereo_ref[i]) > 0) { 595 if (abs(stereo_a9[i] - stereo_ref[i]) > 0) {
595 pa_log_debug("NEON/A9 %d: %d != %d (%d)", i, stereo_a9[i], stereo_ref[i], 596 pa_log_debug("NEON/A9 %d: %d != %d (%d)", i, stereo_a9[i], stereo_ref[i],
596 mono[i/2]); 597 mono[i/2]);
597 } 598 }
598 } 599 }
599 for (i = 0; i < 2*SAMPLES; i++) { 600 for (i = ALIGN; i < 2*SAMPLES+ALIGN; i++) {
600 if (abs(stereo_a8[i] - stereo_ref[i]) > 0) { 601 if (abs(stereo_a8[i] - stereo_ref[i]) > 0) {
601 pa_log_debug("NEON/A8 %d: %d != %d (%d)", i, stereo_a8[i], stereo_ref[i], 602 pa_log_debug("NEON/A8 %d: %d != %d (%d)", i, stereo_a8[i], stereo_ref[i],
602 mono[i/2]); 603 mono[i/2]);
603 } 604 }
604 } 605 }
605 606
606 for (i = 0; i < 2*SAMPLES; i++) { 607 for (i = ALIGN; i < 2*SAMPLES+ALIGN; i++) {
607 if (abs(stereo_gen[i] - stereo_ref[i]) > 0) { 608 if (abs(stereo_gen[i] - stereo_ref[i]) > 0) {
608 pa_log_debug("generic %d: %d != %d (%d)", i, stereo_gen[i], stereo_ref[i], 609 pa_log_debug("generic %d: %d != %d (%d)", i, stereo_gen[i], stereo_ref[i],
609 mono[i/2]); 610 mono[i/2]);
610 } 611 }
611 } 612 }
612 613
613 start = pa_rtclock_now(); 614 start = pa_rtclock_now();
614 for (i = 0; i < TIMES; i++) { 615 for (i = 0; i < TIMES; i++) {
615 remap_mono_to_stereo_neon_a9(&remap, stereo_a9, mono, SAMPLES); 616 remap_mono_to_stereo_neon_a9(&remap, stereo_a9+ALIGN, mono+ALIGN, SAMPLES);
616 } 617 }
617 stop = pa_rtclock_now(); 618 stop = pa_rtclock_now();
618 pa_log_info("NEON/A9:\t%llu usec.", (long long unsigned int)(stop - start)); 619 pa_log_info("NEON/A9:\t%llu usec.", (long long unsigned int)(stop - start));
619 620
620 start = pa_rtclock_now(); 621 start = pa_rtclock_now();
621 for (i = 0; i < TIMES; i++) { 622 for (i = 0; i < TIMES; i++) {
622 remap_mono_to_stereo_neon_a8(&remap, stereo_a8, mono, SAMPLES); 623 remap_mono_to_stereo_neon_a8(&remap, stereo_a8+ALIGN, mono+ALIGN, SAMPLES);
623 } 624 }
624 stop = pa_rtclock_now(); 625 stop = pa_rtclock_now();
625 pa_log_info("NEON/A8:\t%llu usec.", (long long unsigned int)(stop - start)); 626 pa_log_info("NEON/A8:\t%llu usec.", (long long unsigned int)(stop - start));
626 627
627 start = pa_rtclock_now(); 628 start = pa_rtclock_now();
628 for (i = 0; i < TIMES; i++) { 629 for (i = 0; i < TIMES; i++) {
629 remap_mono_to_stereo_c(&remap, stereo_ref, mono, SAMPLES); 630 remap_mono_to_stereo_c(&remap, stereo_ref+ALIGN, mono+ALIGN, SAMPLES);
630 } 631 }
631 stop = pa_rtclock_now(); 632 stop = pa_rtclock_now();
632 pa_log_info("ref:\t\t%llu usec.", (long long unsigned int)(stop - start)); 633 pa_log_info("ref:\t\t%llu usec.", (long long unsigned int)(stop - start));
633 634
634 start = pa_rtclock_now(); 635 start = pa_rtclock_now();
635 for (i = 0; i < TIMES; i++) { 636 for (i = 0; i < TIMES; i++) {
636 remap_channels_matrix_c(&remap, stereo_gen, mono, SAMPLES); 637 remap_channels_matrix_c(&remap, stereo_gen+ALIGN, mono+ALIGN, SAMPLES);
637 } 638 }
638 stop = pa_rtclock_now(); 639 stop = pa_rtclock_now();
639 pa_log_info("generic:\t%llu usec.", (long long unsigned int)(stop - start)); 640 pa_log_info("generic:\t%llu usec.", (long long unsigned int)(stop - start));
640 } 641 }
641 642
642 static void run_test_stereo_to_mono_s16(void) { 643 static void run_test_stereo_to_mono_s16(void) {
643 int16_t stereo[2*SAMPLES]; 644 int16_t stereo[2*SAMPLES+ALIGN];
644 int16_t mono_ref[SAMPLES]; 645 int16_t mono_ref[SAMPLES+ALIGN];
645 int16_t mono_gen[SAMPLES]; 646 int16_t mono_gen[SAMPLES+ALIGN];
646 int16_t mono[SAMPLES]; 647 int16_t mono[SAMPLES+ALIGN];
647 int i; 648 int i;
648 pa_usec_t start, stop; 649 pa_usec_t start, stop;
649 pa_sample_format_t sf; 650 pa_sample_format_t sf;
650 pa_sample_spec iss, oss; 651 pa_sample_spec iss, oss;
651 pa_remap_t remap; 652 pa_remap_t remap;
654 655
655 memset(mono_ref, 0, sizeof(mono_ref)); 656 memset(mono_ref, 0, sizeof(mono_ref));
656 memset(mono_gen, 0, sizeof(mono_gen)); 657 memset(mono_gen, 0, sizeof(mono_gen));
657 memset(mono, 0, sizeof(mono)); 658 memset(mono, 0, sizeof(mono));
658 659
659 for (i = 0; i < 2*SAMPLES; i++) { 660 for (i = 0; i < 2*SAMPLES+ALIGN; i++) {
660 stereo[i] = rand() - RAND_MAX/2; 661 stereo[i] = rand() - RAND_MAX/2;
661 } 662 }
662 663
663 sf = PA_SAMPLE_S16NE; 664 sf = PA_SAMPLE_S16NE;
664 remap.format = &sf; 665 remap.format = &sf;
668 oss.channels = 1; 669 oss.channels = 1;
669 remap.i_ss = &iss; 670 remap.i_ss = &iss;
670 remap.o_ss = &oss; 671 remap.o_ss = &oss;
671 remap.map_table_i[0][0] = 0x10000; 672 remap.map_table_i[0][0] = 0x10000;
672 remap.map_table_i[0][1] = 0x10000; 673 remap.map_table_i[0][1] = 0x10000;
673 674
674 remap_stereo_to_mono_c(&remap, mono_ref, stereo, SAMPLES); 675 remap_stereo_to_mono_c(&remap, mono_ref+ALIGN, stereo+ALIGN, SAMPLES);
675 remap_channels_matrix_c(&remap, mono_gen, stereo, SAMPLES); 676 remap_channels_matrix_c(&remap, mono_gen+ALIGN, stereo+ALIGN, SAMPLES);
676 remap_stereo_to_mono_neon(&remap, mono, stereo, SAMPLES); 677 remap_stereo_to_mono_neon(&remap, mono+ALIGN, stereo+ALIGN, SAMPLES);
677 678
678 for (i = 0; i < SAMPLES; i++) { 679 for (i = ALIGN; i < SAMPLES+ALIGN; i++) {
679 if (abs(mono[i] - mono_ref[i]) > 0) { 680 if (abs(mono[i] - mono_ref[i]) > 0) {
680 pa_log_debug("%d: %d != %d (%d)", i, mono[i], mono_ref[i], 681 pa_log_debug("%d: %d != %d (%d)", i, mono[i], mono_ref[i],
681 stereo[2*i+0], stereo[2*i+1]); 682 stereo[2*i+0], stereo[2*i+1]);
682 } 683 }
683 } 684 }
684 for (i = 0; i < SAMPLES; i++) { 685 for (i = ALIGN; i < SAMPLES+ALIGN; i++) {
685 if (abs(mono[i] - mono_gen[i]) > 0) { 686 if (abs(mono[i] - mono_gen[i]) > 0) {
686 pa_log_debug("%d: %d != %d (%d)", i, mono[i], mono_gen[i], 687 pa_log_debug("%d: %d != %d (%d)", i, mono[i], mono_gen[i],
687 stereo[2*i+0], stereo[2*i+1]); 688 stereo[2*i+0], stereo[2*i+1]);
688 } 689 }
689 } 690 }
690 691
691 start = pa_rtclock_now(); 692 start = pa_rtclock_now();
692 for (i = 0; i < TIMES; i++) { 693 for (i = 0; i < TIMES; i++) {
693 remap_stereo_to_mono_neon(&remap, mono, stereo, SAMPLES); 694 remap_stereo_to_mono_neon(&remap, mono+ALIGN, stereo+ALIGN, SAMPLES);
694 } 695 }
695 stop = pa_rtclock_now(); 696 stop = pa_rtclock_now();
696 pa_log_info("NEON:\t\t%llu usec.", (long long unsigned int)(stop - start)); 697 pa_log_info("NEON:\t\t%llu usec.", (long long unsigned int)(stop - start));
697 698
698 start = pa_rtclock_now(); 699 start = pa_rtclock_now();
699 for (i = 0; i < TIMES; i++) { 700 for (i = 0; i < TIMES; i++) {
700 remap_stereo_to_mono_c(&remap, mono_ref, stereo, SAMPLES); 701 remap_stereo_to_mono_c(&remap, mono_ref+ALIGN, stereo+ALIGN, SAMPLES);
701 } 702 }
702 stop = pa_rtclock_now(); 703 stop = pa_rtclock_now();
703 pa_log_info("ref:\t\t%llu usec.", (long long unsigned int)(stop - start)); 704 pa_log_info("ref:\t\t%llu usec.", (long long unsigned int)(stop - start));
704 705
705 start = pa_rtclock_now(); 706 start = pa_rtclock_now();
706 for (i = 0; i < TIMES; i++) { 707 for (i = 0; i < TIMES; i++) {
707 remap_channels_matrix_c(&remap, mono_gen, stereo, SAMPLES); 708 remap_channels_matrix_c(&remap, mono_gen+ALIGN, stereo+ALIGN, SAMPLES);
708 } 709 }
709 stop = pa_rtclock_now(); 710 stop = pa_rtclock_now();
710 pa_log_info("generic:\t%llu usec.", (long long unsigned int)(stop - start)); 711 pa_log_info("generic:\t%llu usec.", (long long unsigned int)(stop - start));
711 } 712 }
712 713

Repositories maintained by Peter Meerwald, pmeerw@pmeerw.net.