Mercurial > libavcodec.hg
comparison cook.c @ 4674:d4de8d9a2788 libavcodec
subband_coef_noise -> subband_coef_sign
Cosmetics patch by Ian Braithwaite ian .. braithwaite dot dk
author | banan |
---|---|
date | Thu, 15 Mar 2007 21:22:10 +0000 |
parents | 1d88da25349b |
children | 3318e3f6470f |
comparison
equal
deleted
inserted
replaced
4673:e7bc1cf41f9f | 4674:d4de8d9a2788 |
---|---|
537 * @param q pointer to the COOKContext | 537 * @param q pointer to the COOKContext |
538 * @param index index | 538 * @param index index |
539 * @param band current subband | 539 * @param band current subband |
540 * @param quant_value_table pointer to the array | 540 * @param quant_value_table pointer to the array |
541 * @param subband_coef_index array of indexes to quant_centroid_tab | 541 * @param subband_coef_index array of indexes to quant_centroid_tab |
542 * @param subband_coef_noise use random noise instead of predetermined value | 542 * @param subband_coef_sign signs of coefficients |
543 * @param mlt_buffer pointer to the mlt buffer | 543 * @param mlt_buffer pointer to the mlt buffer |
544 */ | 544 */ |
545 | 545 |
546 | 546 |
547 static void scalar_dequant(COOKContext *q, int index, int band, | 547 static void scalar_dequant(COOKContext *q, int index, int band, |
548 float* quant_value_table, int* subband_coef_index, | 548 float* quant_value_table, int* subband_coef_index, |
549 int* subband_coef_noise, float* mlt_buffer){ | 549 int* subband_coef_sign, float* mlt_buffer){ |
550 int i; | 550 int i; |
551 float f1; | 551 float f1; |
552 | 552 |
553 for(i=0 ; i<SUBBAND_SIZE ; i++) { | 553 for(i=0 ; i<SUBBAND_SIZE ; i++) { |
554 if (subband_coef_index[i]) { | 554 if (subband_coef_index[i]) { |
555 if (subband_coef_noise[i]) { | 555 if (subband_coef_sign[i]) { |
556 f1 = -quant_centroid_tab[index][subband_coef_index[i]]; | 556 f1 = -quant_centroid_tab[index][subband_coef_index[i]]; |
557 } else { | 557 } else { |
558 f1 = quant_centroid_tab[index][subband_coef_index[i]]; | 558 f1 = quant_centroid_tab[index][subband_coef_index[i]]; |
559 } | 559 } |
560 } else { | 560 } else { |
561 /* noise coding if subband_coef_noise[i] == 0 */ | 561 /* noise coding if subband_coef_index[i] == 0 */ |
562 q->random_state = q->random_state * 214013 + 2531011; //typical RNG numbers | 562 q->random_state = q->random_state * 214013 + 2531011; //typical RNG numbers |
563 f1 = randsign[(q->random_state/0x1000000)&1] * dither_tab[index]; //>>31 | 563 f1 = randsign[(q->random_state/0x1000000)&1] * dither_tab[index]; //>>31 |
564 } | 564 } |
565 mlt_buffer[band*20+ i] = f1 * quant_value_table[band]; | 565 mlt_buffer[band*20+ i] = f1 * quant_value_table[band]; |
566 } | 566 } |
567 } | 567 } |
568 /** | 568 /** |
569 * Unpack the subband_coef_index and subband_coef_noise vectors. | 569 * Unpack the subband_coef_index and subband_coef_sign vectors. |
570 * | 570 * |
571 * @param q pointer to the COOKContext | 571 * @param q pointer to the COOKContext |
572 * @param category pointer to the category array | 572 * @param category pointer to the category array |
573 * @param subband_coef_index array of indexes to quant_centroid_tab | 573 * @param subband_coef_index array of indexes to quant_centroid_tab |
574 * @param subband_coef_noise use random noise instead of predetermined value | 574 * @param subband_coef_sign signs of coefficients |
575 */ | 575 */ |
576 | 576 |
577 static int unpack_SQVH(COOKContext *q, int category, int* subband_coef_index, | 577 static int unpack_SQVH(COOKContext *q, int category, int* subband_coef_index, |
578 int* subband_coef_noise) { | 578 int* subband_coef_sign) { |
579 int i,j; | 579 int i,j; |
580 int vlc, vd ,tmp, result; | 580 int vlc, vd ,tmp, result; |
581 int ub; | 581 int ub; |
582 int cb; | 582 int cb; |
583 | 583 |
597 vlc = tmp; | 597 vlc = tmp; |
598 } | 598 } |
599 for(j=0 ; j<vd ; j++){ | 599 for(j=0 ; j<vd ; j++){ |
600 if (subband_coef_index[i*vd + j]) { | 600 if (subband_coef_index[i*vd + j]) { |
601 if(get_bits_count(&q->gb) < q->bits_per_subpacket){ | 601 if(get_bits_count(&q->gb) < q->bits_per_subpacket){ |
602 subband_coef_noise[i*vd+j] = get_bits1(&q->gb); | 602 subband_coef_sign[i*vd+j] = get_bits1(&q->gb); |
603 } else { | 603 } else { |
604 result=1; | 604 result=1; |
605 subband_coef_noise[i*vd+j]=0; | 605 subband_coef_sign[i*vd+j]=0; |
606 } | 606 } |
607 } else { | 607 } else { |
608 subband_coef_noise[i*vd+j]=0; | 608 subband_coef_sign[i*vd+j]=0; |
609 } | 609 } |
610 } | 610 } |
611 } | 611 } |
612 return result; | 612 return result; |
613 } | 613 } |
625 | 625 |
626 static void decode_vectors(COOKContext* q, int* category, | 626 static void decode_vectors(COOKContext* q, int* category, |
627 float* quant_value_table, float* mlt_buffer){ | 627 float* quant_value_table, float* mlt_buffer){ |
628 /* A zero in this table means that the subband coefficient is | 628 /* A zero in this table means that the subband coefficient is |
629 random noise coded. */ | 629 random noise coded. */ |
630 int subband_coef_noise[SUBBAND_SIZE]; | 630 int subband_coef_index[SUBBAND_SIZE]; |
631 /* A zero in this table means that the subband coefficient is a | 631 /* A zero in this table means that the subband coefficient is a |
632 positive multiplicator. */ | 632 positive multiplicator. */ |
633 int subband_coef_index[SUBBAND_SIZE]; | 633 int subband_coef_sign[SUBBAND_SIZE]; |
634 int band, j; | 634 int band, j; |
635 int index=0; | 635 int index=0; |
636 | 636 |
637 for(band=0 ; band<q->total_subbands ; band++){ | 637 for(band=0 ; band<q->total_subbands ; band++){ |
638 index = category[band]; | 638 index = category[band]; |
639 if(category[band] < 7){ | 639 if(category[band] < 7){ |
640 if(unpack_SQVH(q, category[band], subband_coef_index, subband_coef_noise)){ | 640 if(unpack_SQVH(q, category[band], subband_coef_index, subband_coef_sign)){ |
641 index=7; | 641 index=7; |
642 for(j=0 ; j<q->total_subbands ; j++) category[band+j]=7; | 642 for(j=0 ; j<q->total_subbands ; j++) category[band+j]=7; |
643 } | 643 } |
644 } | 644 } |
645 if(index==7) { | 645 if(index==7) { |
646 memset(subband_coef_index, 0, sizeof(subband_coef_index)); | 646 memset(subband_coef_index, 0, sizeof(subband_coef_index)); |
647 memset(subband_coef_noise, 0, sizeof(subband_coef_noise)); | 647 memset(subband_coef_sign, 0, sizeof(subband_coef_sign)); |
648 } | 648 } |
649 scalar_dequant(q, index, band, quant_value_table, subband_coef_index, | 649 scalar_dequant(q, index, band, quant_value_table, subband_coef_index, |
650 subband_coef_noise, mlt_buffer); | 650 subband_coef_sign, mlt_buffer); |
651 } | 651 } |
652 | 652 |
653 if(q->total_subbands*SUBBAND_SIZE >= q->samples_per_channel){ | 653 if(q->total_subbands*SUBBAND_SIZE >= q->samples_per_channel){ |
654 return; | 654 return; |
655 } | 655 } /* FIXME: should this be removed, or moved into loop above? */ |
656 } | 656 } |
657 | 657 |
658 | 658 |
659 /** | 659 /** |
660 * function for decoding mono data | 660 * function for decoding mono data |