comparison ac3dec.c @ 5384:3721d0042e5a libavcodec

get rid of an ugly macro
author jbr
date Sat, 21 Jul 2007 11:54:19 +0000
parents d7fde453d208
children bc14cca988aa
comparison
equal deleted inserted replaced
5383:8a28860d54ba 5384:3721d0042e5a
524 int l3ptr; 524 int l3ptr;
525 int l5ptr; 525 int l5ptr;
526 int l11ptr; 526 int l11ptr;
527 } mant_groups; 527 } mant_groups;
528 528
529 #define TRANSFORM_COEFF(tc, m, e, f) (tc) = (m) * (f)[(e)]
530
531 /* Get the transform coefficients for coupling channel and uncouple channels. 529 /* Get the transform coefficients for coupling channel and uncouple channels.
532 * The coupling transform coefficients starts at the the cplstrtmant, which is 530 * The coupling transform coefficients starts at the the cplstrtmant, which is
533 * equal to endmant[ch] for fbw channels. Hence we can uncouple channels before 531 * equal to endmant[ch] for fbw channels. Hence we can uncouple channels before
534 * getting transform coefficients for the channel. 532 * getting transform coefficients for the channel.
535 */ 533 */
561 switch(tbap) { 559 switch(tbap) {
562 case 0: 560 case 0:
563 for (ch = 0; ch < ctx->nfchans; ch++) 561 for (ch = 0; ch < ctx->nfchans; ch++)
564 if (((ctx->chincpl) >> ch) & 1) { 562 if (((ctx->chincpl) >> ch) & 1) {
565 if ((ctx->dithflag >> ch) & 1) { 563 if ((ctx->dithflag >> ch) & 1) {
566 TRANSFORM_COEFF(cplcoeff, av_random(&ctx->dith_state) & 0xFFFF, exps[start], scale_factors); 564 cplcoeff = (av_random(&ctx->dith_state) & 0xFFFF) * scale_factors[exps[start]];
567 ctx->transform_coeffs[ch + 1][start] = cplcoeff * cplcos[ch] * LEVEL_MINUS_3DB; 565 ctx->transform_coeffs[ch + 1][start] = cplcoeff * cplcos[ch] * LEVEL_MINUS_3DB;
568 } else 566 } else
569 ctx->transform_coeffs[ch + 1][start] = 0; 567 ctx->transform_coeffs[ch + 1][start] = 0;
570 } 568 }
571 start++; 569 start++;
576 m->l3_quantizers[0] = l3_quantizers_1[gcode]; 574 m->l3_quantizers[0] = l3_quantizers_1[gcode];
577 m->l3_quantizers[1] = l3_quantizers_2[gcode]; 575 m->l3_quantizers[1] = l3_quantizers_2[gcode];
578 m->l3_quantizers[2] = l3_quantizers_3[gcode]; 576 m->l3_quantizers[2] = l3_quantizers_3[gcode];
579 m->l3ptr = 0; 577 m->l3ptr = 0;
580 } 578 }
581 TRANSFORM_COEFF(cplcoeff, m->l3_quantizers[m->l3ptr++], exps[start], scale_factors); 579 cplcoeff = m->l3_quantizers[m->l3ptr++] * scale_factors[exps[start]];
582 break; 580 break;
583 581
584 case 2: 582 case 2:
585 if (m->l5ptr > 2) { 583 if (m->l5ptr > 2) {
586 gcode = get_bits(gb, 7); 584 gcode = get_bits(gb, 7);
587 m->l5_quantizers[0] = l5_quantizers_1[gcode]; 585 m->l5_quantizers[0] = l5_quantizers_1[gcode];
588 m->l5_quantizers[1] = l5_quantizers_2[gcode]; 586 m->l5_quantizers[1] = l5_quantizers_2[gcode];
589 m->l5_quantizers[2] = l5_quantizers_3[gcode]; 587 m->l5_quantizers[2] = l5_quantizers_3[gcode];
590 m->l5ptr = 0; 588 m->l5ptr = 0;
591 } 589 }
592 TRANSFORM_COEFF(cplcoeff, m->l5_quantizers[m->l5ptr++], exps[start], scale_factors); 590 cplcoeff = m->l5_quantizers[m->l5ptr++] * scale_factors[exps[start]];
593 break; 591 break;
594 592
595 case 3: 593 case 3:
596 TRANSFORM_COEFF(cplcoeff, l7_quantizers[get_bits(gb, 3)], exps[start], scale_factors); 594 cplcoeff = l7_quantizers[get_bits(gb, 3)] * scale_factors[exps[start]];
597 break; 595 break;
598 596
599 case 4: 597 case 4:
600 if (m->l11ptr > 1) { 598 if (m->l11ptr > 1) {
601 gcode = get_bits(gb, 7); 599 gcode = get_bits(gb, 7);
602 m->l11_quantizers[0] = l11_quantizers_1[gcode]; 600 m->l11_quantizers[0] = l11_quantizers_1[gcode];
603 m->l11_quantizers[1] = l11_quantizers_2[gcode]; 601 m->l11_quantizers[1] = l11_quantizers_2[gcode];
604 m->l11ptr = 0; 602 m->l11ptr = 0;
605 } 603 }
606 TRANSFORM_COEFF(cplcoeff, m->l11_quantizers[m->l11ptr++], exps[start], scale_factors); 604 cplcoeff = m->l11_quantizers[m->l11ptr++] * scale_factors[exps[start]];
607 break; 605 break;
608 606
609 case 5: 607 case 5:
610 TRANSFORM_COEFF(cplcoeff, l15_quantizers[get_bits(gb, 4)], exps[start], scale_factors); 608 cplcoeff = l15_quantizers[get_bits(gb, 4)] * scale_factors[exps[start]];
611 break; 609 break;
612 610
613 default: 611 default:
614 TRANSFORM_COEFF(cplcoeff, get_sbits(gb, qntztab[tbap]) << (16 - qntztab[tbap]), 612 cplcoeff = (get_sbits(gb, qntztab[tbap]) << (16 - qntztab[tbap])) * scale_factors[exps[start]];
615 exps[start], scale_factors);
616 } 613 }
617 for (ch = 0; ch < ctx->nfchans; ch++) 614 for (ch = 0; ch < ctx->nfchans; ch++)
618 if ((ctx->chincpl >> ch) & 1) 615 if ((ctx->chincpl >> ch) & 1)
619 ctx->transform_coeffs[ch + 1][start] = cplcoeff * cplcos[ch]; 616 ctx->transform_coeffs[ch + 1][start] = cplcoeff * cplcos[ch];
620 start++; 617 start++;
659 if (!dithflag) { 656 if (!dithflag) {
660 coeffs[i] = 0; 657 coeffs[i] = 0;
661 continue; 658 continue;
662 } 659 }
663 else { 660 else {
664 TRANSFORM_COEFF(coeffs[i], av_random(&ctx->dith_state) & 0xFFFF, exps[i], factors); 661 coeffs[i] = (av_random(&ctx->dith_state) & 0xFFFF) * factors[exps[i]];
665 coeffs[i] *= LEVEL_MINUS_3DB; 662 coeffs[i] *= LEVEL_MINUS_3DB;
666 continue; 663 continue;
667 } 664 }
668 665
669 case 1: 666 case 1:
672 m->l3_quantizers[0] = l3_quantizers_1[gcode]; 669 m->l3_quantizers[0] = l3_quantizers_1[gcode];
673 m->l3_quantizers[1] = l3_quantizers_2[gcode]; 670 m->l3_quantizers[1] = l3_quantizers_2[gcode];
674 m->l3_quantizers[2] = l3_quantizers_3[gcode]; 671 m->l3_quantizers[2] = l3_quantizers_3[gcode];
675 m->l3ptr = 0; 672 m->l3ptr = 0;
676 } 673 }
677 TRANSFORM_COEFF(coeffs[i], m->l3_quantizers[m->l3ptr++], exps[i], factors); 674 coeffs[i] = m->l3_quantizers[m->l3ptr++] * factors[exps[i]];
678 continue; 675 continue;
679 676
680 case 2: 677 case 2:
681 if (m->l5ptr > 2) { 678 if (m->l5ptr > 2) {
682 gcode = get_bits(gb, 7); 679 gcode = get_bits(gb, 7);
683 m->l5_quantizers[0] = l5_quantizers_1[gcode]; 680 m->l5_quantizers[0] = l5_quantizers_1[gcode];
684 m->l5_quantizers[1] = l5_quantizers_2[gcode]; 681 m->l5_quantizers[1] = l5_quantizers_2[gcode];
685 m->l5_quantizers[2] = l5_quantizers_3[gcode]; 682 m->l5_quantizers[2] = l5_quantizers_3[gcode];
686 m->l5ptr = 0; 683 m->l5ptr = 0;
687 } 684 }
688 TRANSFORM_COEFF(coeffs[i], m->l5_quantizers[m->l5ptr++], exps[i], factors); 685 coeffs[i] = m->l5_quantizers[m->l5ptr++] * factors[exps[i]];
689 continue; 686 continue;
690 687
691 case 3: 688 case 3:
692 TRANSFORM_COEFF(coeffs[i], l7_quantizers[get_bits(gb, 3)], exps[i], factors); 689 coeffs[i] = l7_quantizers[get_bits(gb, 3)] * factors[exps[i]];
693 continue; 690 continue;
694 691
695 case 4: 692 case 4:
696 if (m->l11ptr > 1) { 693 if (m->l11ptr > 1) {
697 gcode = get_bits(gb, 7); 694 gcode = get_bits(gb, 7);
698 m->l11_quantizers[0] = l11_quantizers_1[gcode]; 695 m->l11_quantizers[0] = l11_quantizers_1[gcode];
699 m->l11_quantizers[1] = l11_quantizers_2[gcode]; 696 m->l11_quantizers[1] = l11_quantizers_2[gcode];
700 m->l11ptr = 0; 697 m->l11ptr = 0;
701 } 698 }
702 TRANSFORM_COEFF(coeffs[i], m->l11_quantizers[m->l11ptr++], exps[i], factors); 699 coeffs[i] = m->l11_quantizers[m->l11ptr++] * factors[exps[i]];
703 continue; 700 continue;
704 701
705 case 5: 702 case 5:
706 TRANSFORM_COEFF(coeffs[i], l15_quantizers[get_bits(gb, 4)], exps[i], factors); 703 coeffs[i] = l15_quantizers[get_bits(gb, 4)] * factors[exps[i]];
707 continue; 704 continue;
708 705
709 default: 706 default:
710 TRANSFORM_COEFF(coeffs[i], get_sbits(gb, qntztab[tbap]) << (16 - qntztab[tbap]), exps[i], factors); 707 coeffs[i] = (get_sbits(gb, qntztab[tbap]) << (16 - qntztab[tbap])) * factors[exps[i]];
711 continue; 708 continue;
712 } 709 }
713 } 710 }
714 711
715 return 0; 712 return 0;