diff options
Diffstat (limited to 'apps/codecs/libfaad/specrec.c')
-rw-r--r-- | apps/codecs/libfaad/specrec.c | 200 |
1 files changed, 15 insertions, 185 deletions
diff --git a/apps/codecs/libfaad/specrec.c b/apps/codecs/libfaad/specrec.c index d537125d55..b5c8305237 100644 --- a/apps/codecs/libfaad/specrec.c +++ b/apps/codecs/libfaad/specrec.c | |||
@@ -53,7 +53,6 @@ | |||
53 | #include "ssr_fb.h" | 53 | #include "ssr_fb.h" |
54 | #endif | 54 | #endif |
55 | 55 | ||
56 | |||
57 | /* static function declarations */ | 56 | /* static function declarations */ |
58 | static uint8_t quant_to_spec(NeAACDecHandle hDecoder, | 57 | static uint8_t quant_to_spec(NeAACDecHandle hDecoder, |
59 | ic_stream *ics, int16_t *quant_data, | 58 | ic_stream *ics, int16_t *quant_data, |
@@ -284,6 +283,11 @@ static const uint16_t *const swb_offset_128_window[] ICONST_ATTR = | |||
284 | 283 | ||
285 | #define bit_set(A, B) ((A) & (1<<(B))) | 284 | #define bit_set(A, B) ((A) & (1<<(B))) |
286 | 285 | ||
286 | /* static variables */ | ||
287 | /* used by reconstruct_single_channel() and reconstruct_channel_pair() */ | ||
288 | static real_t spec_coef1[FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR; | ||
289 | static real_t spec_coef2[FRAME_LEN] IBSS_ATTR MEM_ALIGN_ATTR; | ||
290 | |||
287 | /* 4.5.2.3.4 */ | 291 | /* 4.5.2.3.4 */ |
288 | /* | 292 | /* |
289 | - determine the number of windows in a window_sequence named num_windows | 293 | - determine the number of windows in a window_sequence named num_windows |
@@ -648,197 +652,21 @@ static uint8_t quant_to_spec(NeAACDecHandle hDecoder, | |||
648 | static uint8_t allocate_single_channel(NeAACDecHandle hDecoder, uint8_t channel, | 652 | static uint8_t allocate_single_channel(NeAACDecHandle hDecoder, uint8_t channel, |
649 | uint8_t output_channels) | 653 | uint8_t output_channels) |
650 | { | 654 | { |
651 | uint8_t mul = 1; | 655 | (void)output_channels; |
652 | 656 | (void)hDecoder; | |
653 | #ifdef MAIN_DEC | 657 | (void)channel; |
654 | /* MAIN object type prediction */ | ||
655 | if (hDecoder->object_type == MAIN) | ||
656 | { | ||
657 | /* allocate the state only when needed */ | ||
658 | if (hDecoder->pred_stat[channel] == NULL) | ||
659 | { | ||
660 | hDecoder->pred_stat[channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state)); | ||
661 | reset_all_predictors(hDecoder->pred_stat[channel], hDecoder->frameLength); | ||
662 | } | ||
663 | } | ||
664 | #endif | ||
665 | |||
666 | #ifdef LTP_DEC | ||
667 | if (is_ltp_ot(hDecoder->object_type)) | ||
668 | { | ||
669 | /* allocate the state only when needed */ | ||
670 | if (hDecoder->lt_pred_stat[channel] == NULL) | ||
671 | { | ||
672 | hDecoder->lt_pred_stat[channel] = (int16_t*)faad_malloc(hDecoder->frameLength*4 * sizeof(int16_t)); | ||
673 | memset(hDecoder->lt_pred_stat[channel], 0, hDecoder->frameLength*4 * sizeof(int16_t)); | ||
674 | } | ||
675 | } | ||
676 | #endif | ||
677 | |||
678 | if (hDecoder->time_out[channel] == NULL) | ||
679 | { | ||
680 | mul = 1; | ||
681 | #ifdef SBR_DEC | ||
682 | hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0; | ||
683 | if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) | ||
684 | { | ||
685 | /* SBR requires 2 times as much output data */ | ||
686 | mul = 2; | ||
687 | hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1; | ||
688 | } | ||
689 | #endif | ||
690 | hDecoder->time_out[channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t)); | ||
691 | memset(hDecoder->time_out[channel], 0, mul*hDecoder->frameLength*sizeof(real_t)); | ||
692 | } | ||
693 | #if (defined(PS_DEC) || defined(DRM_PS)) | ||
694 | if (output_channels == 2) | ||
695 | { | ||
696 | if (hDecoder->time_out[channel+1] == NULL) | ||
697 | { | ||
698 | hDecoder->time_out[channel+1] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t)); | ||
699 | memset(hDecoder->time_out[channel+1], 0, mul*hDecoder->frameLength*sizeof(real_t)); | ||
700 | } | ||
701 | } | ||
702 | #else | ||
703 | (void)output_channels; /*silence warning when PS disabled*/ | ||
704 | #endif | ||
705 | |||
706 | if (hDecoder->fb_intermed[channel] == NULL) | ||
707 | { | ||
708 | hDecoder->fb_intermed[channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t)); | ||
709 | memset(hDecoder->fb_intermed[channel], 0, hDecoder->frameLength*sizeof(real_t)); | ||
710 | } | ||
711 | |||
712 | #ifdef SSR_DEC | ||
713 | if (hDecoder->object_type == SSR) | ||
714 | { | ||
715 | if (hDecoder->ssr_overlap[channel] == NULL) | ||
716 | { | ||
717 | hDecoder->ssr_overlap[channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t)); | ||
718 | memset(hDecoder->ssr_overlap[channel], 0, 2*hDecoder->frameLength*sizeof(real_t)); | ||
719 | } | ||
720 | if (hDecoder->prev_fmd[channel] == NULL) | ||
721 | { | ||
722 | uint16_t k; | ||
723 | hDecoder->prev_fmd[channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t)); | ||
724 | for (k = 0; k < 2*hDecoder->frameLength; k++) | ||
725 | hDecoder->prev_fmd[channel][k] = REAL_CONST(-1); | ||
726 | } | ||
727 | } | ||
728 | #endif | ||
729 | |||
730 | return 0; | 658 | return 0; |
731 | } | 659 | } |
732 | 660 | ||
733 | static uint8_t allocate_channel_pair(NeAACDecHandle hDecoder, | 661 | static uint8_t allocate_channel_pair(NeAACDecHandle hDecoder, |
734 | uint8_t channel, uint8_t paired_channel) | 662 | uint8_t channel, uint8_t paired_channel) |
735 | { | 663 | { |
736 | uint8_t mul = 1; | 664 | (void)paired_channel; |
737 | 665 | (void)hDecoder; | |
738 | #ifdef MAIN_DEC | 666 | (void)channel; |
739 | /* MAIN object type prediction */ | ||
740 | if (hDecoder->object_type == MAIN) | ||
741 | { | ||
742 | /* allocate the state only when needed */ | ||
743 | if (hDecoder->pred_stat[channel] == NULL) | ||
744 | { | ||
745 | hDecoder->pred_stat[channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state)); | ||
746 | reset_all_predictors(hDecoder->pred_stat[channel], hDecoder->frameLength); | ||
747 | } | ||
748 | if (hDecoder->pred_stat[paired_channel] == NULL) | ||
749 | { | ||
750 | hDecoder->pred_stat[paired_channel] = (pred_state*)faad_malloc(hDecoder->frameLength * sizeof(pred_state)); | ||
751 | reset_all_predictors(hDecoder->pred_stat[paired_channel], hDecoder->frameLength); | ||
752 | } | ||
753 | } | ||
754 | #endif | ||
755 | |||
756 | #ifdef LTP_DEC | ||
757 | if (is_ltp_ot(hDecoder->object_type)) | ||
758 | { | ||
759 | /* allocate the state only when needed */ | ||
760 | if (hDecoder->lt_pred_stat[channel] == NULL) | ||
761 | { | ||
762 | hDecoder->lt_pred_stat[channel] = (int16_t*)faad_malloc(hDecoder->frameLength*4 * sizeof(int16_t)); | ||
763 | memset(hDecoder->lt_pred_stat[channel], 0, hDecoder->frameLength*4 * sizeof(int16_t)); | ||
764 | } | ||
765 | if (hDecoder->lt_pred_stat[paired_channel] == NULL) | ||
766 | { | ||
767 | hDecoder->lt_pred_stat[paired_channel] = (int16_t*)faad_malloc(hDecoder->frameLength*4 * sizeof(int16_t)); | ||
768 | memset(hDecoder->lt_pred_stat[paired_channel], 0, hDecoder->frameLength*4 * sizeof(int16_t)); | ||
769 | } | ||
770 | } | ||
771 | #endif | ||
772 | |||
773 | if (hDecoder->time_out[channel] == NULL) | ||
774 | { | ||
775 | mul = 1; | ||
776 | #ifdef SBR_DEC | ||
777 | hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0; | ||
778 | if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) | ||
779 | { | ||
780 | /* SBR requires 2 times as much output data */ | ||
781 | mul = 2; | ||
782 | hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1; | ||
783 | } | ||
784 | #endif | ||
785 | hDecoder->time_out[channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t)); | ||
786 | memset(hDecoder->time_out[channel], 0, mul*hDecoder->frameLength*sizeof(real_t)); | ||
787 | } | ||
788 | if (hDecoder->time_out[paired_channel] == NULL) | ||
789 | { | ||
790 | hDecoder->time_out[paired_channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t)); | ||
791 | memset(hDecoder->time_out[paired_channel], 0, mul*hDecoder->frameLength*sizeof(real_t)); | ||
792 | } | ||
793 | |||
794 | if (hDecoder->fb_intermed[channel] == NULL) | ||
795 | { | ||
796 | hDecoder->fb_intermed[channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t)); | ||
797 | memset(hDecoder->fb_intermed[channel], 0, hDecoder->frameLength*sizeof(real_t)); | ||
798 | } | ||
799 | if (hDecoder->fb_intermed[paired_channel] == NULL) | ||
800 | { | ||
801 | hDecoder->fb_intermed[paired_channel] = (real_t*)faad_malloc(hDecoder->frameLength*sizeof(real_t)); | ||
802 | memset(hDecoder->fb_intermed[paired_channel], 0, hDecoder->frameLength*sizeof(real_t)); | ||
803 | } | ||
804 | |||
805 | #ifdef SSR_DEC | ||
806 | if (hDecoder->object_type == SSR) | ||
807 | { | ||
808 | if (hDecoder->ssr_overlap[cpe->channel] == NULL) | ||
809 | { | ||
810 | hDecoder->ssr_overlap[cpe->channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t)); | ||
811 | memset(hDecoder->ssr_overlap[cpe->channel], 0, 2*hDecoder->frameLength*sizeof(real_t)); | ||
812 | } | ||
813 | if (hDecoder->ssr_overlap[cpe->paired_channel] == NULL) | ||
814 | { | ||
815 | hDecoder->ssr_overlap[cpe->paired_channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t)); | ||
816 | memset(hDecoder->ssr_overlap[cpe->paired_channel], 0, 2*hDecoder->frameLength*sizeof(real_t)); | ||
817 | } | ||
818 | if (hDecoder->prev_fmd[cpe->channel] == NULL) | ||
819 | { | ||
820 | uint16_t k; | ||
821 | hDecoder->prev_fmd[cpe->channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t)); | ||
822 | for (k = 0; k < 2*hDecoder->frameLength; k++) | ||
823 | hDecoder->prev_fmd[cpe->channel][k] = REAL_CONST(-1); | ||
824 | } | ||
825 | if (hDecoder->prev_fmd[cpe->paired_channel] == NULL) | ||
826 | { | ||
827 | uint16_t k; | ||
828 | hDecoder->prev_fmd[cpe->paired_channel] = (real_t*)faad_malloc(2*hDecoder->frameLength*sizeof(real_t)); | ||
829 | for (k = 0; k < 2*hDecoder->frameLength; k++) | ||
830 | hDecoder->prev_fmd[cpe->paired_channel][k] = REAL_CONST(-1); | ||
831 | } | ||
832 | } | ||
833 | #endif | ||
834 | |||
835 | return 0; | 667 | return 0; |
836 | } | 668 | } |
837 | 669 | ||
838 | /* used by reconstruct_single_channel() and reconstruct_channel_pair() */ | ||
839 | static real_t spec_coef1[1024] IBSS_ATTR MEM_ALIGN_ATTR; | ||
840 | static real_t spec_coef2[1024] IBSS_ATTR MEM_ALIGN_ATTR; | ||
841 | |||
842 | uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics, | 670 | uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics, |
843 | element *sce, int16_t *spec_data) | 671 | element *sce, int16_t *spec_data) |
844 | { | 672 | { |
@@ -978,7 +806,8 @@ uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics, | |||
978 | if (hDecoder->sbr[ele] == NULL) | 806 | if (hDecoder->sbr[ele] == NULL) |
979 | { | 807 | { |
980 | hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength, | 808 | hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength, |
981 | hDecoder->element_id[ele], 2*get_sample_rate(hDecoder->sf_index), | 809 | hDecoder->element_id[ele], ele, |
810 | 2*get_sample_rate(hDecoder->sf_index), | ||
982 | hDecoder->downSampledSBR | 811 | hDecoder->downSampledSBR |
983 | #ifdef DRM | 812 | #ifdef DRM |
984 | , 0 | 813 | , 0 |
@@ -1227,7 +1056,8 @@ uint8_t reconstruct_channel_pair(NeAACDecHandle hDecoder, ic_stream *ics1, ic_st | |||
1227 | if (hDecoder->sbr[ele] == NULL) | 1056 | if (hDecoder->sbr[ele] == NULL) |
1228 | { | 1057 | { |
1229 | hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength, | 1058 | hDecoder->sbr[ele] = sbrDecodeInit(hDecoder->frameLength, |
1230 | hDecoder->element_id[ele], 2*get_sample_rate(hDecoder->sf_index), | 1059 | hDecoder->element_id[ele], ele, |
1060 | 2*get_sample_rate(hDecoder->sf_index), | ||
1231 | hDecoder->downSampledSBR | 1061 | hDecoder->downSampledSBR |
1232 | #ifdef DRM | 1062 | #ifdef DRM |
1233 | , 0 | 1063 | , 0 |