summaryrefslogtreecommitdiff
path: root/apps/codecs/libfaad/specrec.c
diff options
context:
space:
mode:
Diffstat (limited to 'apps/codecs/libfaad/specrec.c')
-rw-r--r--apps/codecs/libfaad/specrec.c70
1 files changed, 22 insertions, 48 deletions
diff --git a/apps/codecs/libfaad/specrec.c b/apps/codecs/libfaad/specrec.c
index 4998828eff..74bf1f36f6 100644
--- a/apps/codecs/libfaad/specrec.c
+++ b/apps/codecs/libfaad/specrec.c
@@ -414,19 +414,18 @@ uint8_t window_grouping_info(NeAACDecHandle hDecoder, ic_stream *ics)
414/**/ 414/**/
415static INLINE real_t iquant(int16_t q, const real_t *tab, uint8_t *error) 415static INLINE real_t iquant(int16_t q, const real_t *tab, uint8_t *error)
416{ 416{
417#ifdef FIXED_POINT 417#ifndef BIG_IQ_TABLE
418/* For FIXED_POINT the iq_table is prescaled by 3 bits (iq_table[]/8) */ 418/* For FIXED_POINT the iq_table is prescaled by 3 bits (iq_table[]/8) */
419/* BIG_IQ_TABLE allows you to use the full 8192 value table, if this is not 419/* BIG_IQ_TABLE allows you to use the full 8192 value table, if this is not
420 * defined a 1026 value table and interpolation will be used 420 * defined a 1026 value table and interpolation will be used
421 */ 421 */
422#ifndef BIG_IQ_TABLE
423 static const real_t errcorr[] = { 422 static const real_t errcorr[] = {
424 REAL_CONST(0), REAL_CONST(1.0/8.0), REAL_CONST(2.0/8.0), REAL_CONST(3.0/8.0), 423 REAL_CONST(0), REAL_CONST(1.0/8.0), REAL_CONST(2.0/8.0), REAL_CONST(3.0/8.0),
425 REAL_CONST(4.0/8.0), REAL_CONST(5.0/8.0), REAL_CONST(6.0/8.0), REAL_CONST(7.0/8.0), 424 REAL_CONST(4.0/8.0), REAL_CONST(5.0/8.0), REAL_CONST(6.0/8.0), REAL_CONST(7.0/8.0),
426 REAL_CONST(0) 425 REAL_CONST(0)
427 }; 426 };
428 real_t x1, x2; 427 real_t x1, x2;
429#endif 428
430 int16_t sgn = 1; 429 int16_t sgn = 1;
431 430
432 if (q < 0) 431 if (q < 0)
@@ -445,7 +444,6 @@ static INLINE real_t iquant(int16_t q, const real_t *tab, uint8_t *error)
445 return sgn * tab[q]; 444 return sgn * tab[q];
446 } 445 }
447 446
448#ifndef BIG_IQ_TABLE
449 if (q >= 8192) 447 if (q >= 8192)
450 { 448 {
451 *error = 17; 449 *error = 17;
@@ -456,12 +454,7 @@ static INLINE real_t iquant(int16_t q, const real_t *tab, uint8_t *error)
456 x1 = tab[q>>3]; 454 x1 = tab[q>>3];
457 x2 = tab[(q>>3) + 1]; 455 x2 = tab[(q>>3) + 1];
458 return sgn * 16 * (MUL_R(errcorr[q&7],(x2-x1)) + x1); 456 return sgn * 16 * (MUL_R(errcorr[q&7],(x2-x1)) + x1);
459#else 457#else /* #ifndef BIG_IQ_TABLE */
460 *error = 17;
461 return 0;
462#endif
463
464#else
465 if (q < 0) 458 if (q < 0)
466 { 459 {
467 /* tab contains a value for all possible q [0,8192] */ 460 /* tab contains a value for all possible q [0,8192] */
@@ -547,9 +540,7 @@ static uint8_t quant_to_spec(NeAACDecHandle hDecoder,
547 uint8_t g, sfb, win; 540 uint8_t g, sfb, win;
548 uint16_t width, bin, k, gindex, wa, wb; 541 uint16_t width, bin, k, gindex, wa, wb;
549 uint8_t error = 0; /* Init error flag */ 542 uint8_t error = 0; /* Init error flag */
550#ifndef FIXED_POINT
551 real_t scf; 543 real_t scf;
552#endif
553 544
554 k = 0; 545 k = 0;
555 gindex = 0; 546 gindex = 0;
@@ -597,6 +588,8 @@ static uint8_t quant_to_spec(NeAACDecHandle hDecoder,
597 588
598#ifndef FIXED_POINT 589#ifndef FIXED_POINT
599 scf = pow2sf_tab[exp/*+25*/] * pow2_table[frac]; 590 scf = pow2sf_tab[exp/*+25*/] * pow2_table[frac];
591#else
592 scf = pow2_table[frac];
600#endif 593#endif
601 594
602 for (win = 0; win < ics->window_group_length[g]; win++) 595 for (win = 0; win < ics->window_group_length[g]; win++)
@@ -612,32 +605,12 @@ static uint8_t quant_to_spec(NeAACDecHandle hDecoder,
612 spec_data[wb+3] = iquant(quant_data[k+3], tab, &error) * scf; 605 spec_data[wb+3] = iquant(quant_data[k+3], tab, &error) * scf;
613 606
614#else 607#else
615 real_t iq0 = iquant(quant_data[k+0], tab, &error);
616 real_t iq1 = iquant(quant_data[k+1], tab, &error);
617 real_t iq2 = iquant(quant_data[k+2], tab, &error);
618 real_t iq3 = iquant(quant_data[k+3], tab, &error);
619
620 wb = wa + bin; 608 wb = wa + bin;
621 609
622 if (exp < 0) 610 spec_data[wb+0] = MUL_C((iquant(quant_data[k+0], tab, &error)<<exp), scf);
623 { 611 spec_data[wb+1] = MUL_C((iquant(quant_data[k+1], tab, &error)<<exp), scf);
624 spec_data[wb+0] = iq0 >>= -exp; 612 spec_data[wb+2] = MUL_C((iquant(quant_data[k+2], tab, &error)<<exp), scf);
625 spec_data[wb+1] = iq1 >>= -exp; 613 spec_data[wb+3] = MUL_C((iquant(quant_data[k+3], tab, &error)<<exp), scf);
626 spec_data[wb+2] = iq2 >>= -exp;
627 spec_data[wb+3] = iq3 >>= -exp;
628 } else {
629 spec_data[wb+0] = iq0 <<= exp;
630 spec_data[wb+1] = iq1 <<= exp;
631 spec_data[wb+2] = iq2 <<= exp;
632 spec_data[wb+3] = iq3 <<= exp;
633 }
634 if (frac != 0)
635 {
636 spec_data[wb+0] = MUL_C(spec_data[wb+0],pow2_table[frac]);
637 spec_data[wb+1] = MUL_C(spec_data[wb+1],pow2_table[frac]);
638 spec_data[wb+2] = MUL_C(spec_data[wb+2],pow2_table[frac]);
639 spec_data[wb+3] = MUL_C(spec_data[wb+3],pow2_table[frac]);
640 }
641 614
642//#define SCFS_PRINT 615//#define SCFS_PRINT
643#ifdef SCFS_PRINT 616#ifdef SCFS_PRINT
@@ -855,11 +828,14 @@ static uint8_t allocate_channel_pair(NeAACDecHandle hDecoder,
855 return 0; 828 return 0;
856} 829}
857 830
831/* used by reconstruct_single_channel() and reconstruct_channel_pair() */
832ALIGN static real_t spec_coef1[1024] IBSS_ATTR;
833ALIGN static real_t spec_coef2[1024] IBSS_ATTR;
834
858uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics, 835uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics,
859 element *sce, int16_t *spec_data) 836 element *sce, int16_t *spec_data)
860{ 837{
861 uint8_t retval, output_channels; 838 uint8_t retval, output_channels;
862 ALIGN static real_t spec_coef[1024];
863 839
864#ifdef PROFILE 840#ifdef PROFILE
865 int64_t count = faad_get_ts(); 841 int64_t count = faad_get_ts();
@@ -893,7 +869,7 @@ uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics,
893 869
894 870
895 /* dequantisation and scaling */ 871 /* dequantisation and scaling */
896 retval = quant_to_spec(hDecoder, ics, spec_data, spec_coef, hDecoder->frameLength); 872 retval = quant_to_spec(hDecoder, ics, spec_data, spec_coef1, hDecoder->frameLength);
897 if (retval > 0) 873 if (retval > 0)
898 return retval; 874 return retval;
899 875
@@ -904,14 +880,14 @@ uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics,
904 880
905 881
906 /* pns decoding */ 882 /* pns decoding */
907 pns_decode(ics, NULL, spec_coef, NULL, hDecoder->frameLength, 0, hDecoder->object_type); 883 pns_decode(ics, NULL, spec_coef1, NULL, hDecoder->frameLength, 0, hDecoder->object_type);
908 884
909#ifdef MAIN_DEC 885#ifdef MAIN_DEC
910 /* MAIN object type prediction */ 886 /* MAIN object type prediction */
911 if (hDecoder->object_type == MAIN) 887 if (hDecoder->object_type == MAIN)
912 { 888 {
913 /* intra channel prediction */ 889 /* intra channel prediction */
914 ic_prediction(ics, spec_coef, hDecoder->pred_stat[sce->channel], hDecoder->frameLength, 890 ic_prediction(ics, spec_coef1, hDecoder->pred_stat[sce->channel], hDecoder->frameLength,
915 hDecoder->sf_index); 891 hDecoder->sf_index);
916 892
917 /* In addition, for scalefactor bands coded by perceptual 893 /* In addition, for scalefactor bands coded by perceptual
@@ -938,7 +914,7 @@ uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics,
938#endif 914#endif
939 915
940 /* long term prediction */ 916 /* long term prediction */
941 lt_prediction(ics, &(ics->ltp), spec_coef, hDecoder->lt_pred_stat[sce->channel], hDecoder->fb, 917 lt_prediction(ics, &(ics->ltp), spec_coef1, hDecoder->lt_pred_stat[sce->channel], hDecoder->fb,
942 ics->window_shape, hDecoder->window_shape_prev[sce->channel], 918 ics->window_shape, hDecoder->window_shape_prev[sce->channel],
943 hDecoder->sf_index, hDecoder->object_type, hDecoder->frameLength); 919 hDecoder->sf_index, hDecoder->object_type, hDecoder->frameLength);
944 } 920 }
@@ -946,13 +922,13 @@ uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics,
946 922
947 /* tns decoding */ 923 /* tns decoding */
948 tns_decode_frame(ics, &(ics->tns), hDecoder->sf_index, hDecoder->object_type, 924 tns_decode_frame(ics, &(ics->tns), hDecoder->sf_index, hDecoder->object_type,
949 spec_coef, hDecoder->frameLength); 925 spec_coef1, hDecoder->frameLength);
950 926
951 /* drc decoding */ 927 /* drc decoding */
952 if (hDecoder->drc->present) 928 if (hDecoder->drc->present)
953 { 929 {
954 if (!hDecoder->drc->exclude_mask[sce->channel] || !hDecoder->drc->excluded_chns_present) 930 if (!hDecoder->drc->exclude_mask[sce->channel] || !hDecoder->drc->excluded_chns_present)
955 drc_decode(hDecoder->drc, spec_coef); 931 drc_decode(hDecoder->drc, spec_coef1);
956 } 932 }
957 933
958 /* filter bank */ 934 /* filter bank */
@@ -961,13 +937,13 @@ uint8_t reconstruct_single_channel(NeAACDecHandle hDecoder, ic_stream *ics,
961 { 937 {
962#endif 938#endif
963 ifilter_bank(ics->window_sequence,ics->window_shape, 939 ifilter_bank(ics->window_sequence,ics->window_shape,
964 hDecoder->window_shape_prev[sce->channel],spec_coef, 940 hDecoder->window_shape_prev[sce->channel],spec_coef1,
965 hDecoder->time_out[sce->channel], hDecoder->fb_intermed[sce->channel], 941 hDecoder->time_out[sce->channel], hDecoder->fb_intermed[sce->channel],
966 hDecoder->object_type, hDecoder->frameLength); 942 hDecoder->object_type, hDecoder->frameLength);
967#ifdef SSR_DEC 943#ifdef SSR_DEC
968 } else { 944 } else {
969 ssr_decode(&(ics->ssr), hDecoder->fb, ics->window_sequence, ics->window_shape, 945 ssr_decode(&(ics->ssr), hDecoder->fb, ics->window_sequence, ics->window_shape,
970 hDecoder->window_shape_prev[sce->channel], spec_coef, hDecoder->time_out[sce->channel], 946 hDecoder->window_shape_prev[sce->channel], spec_coef1, hDecoder->time_out[sce->channel],
971 hDecoder->ssr_overlap[sce->channel], hDecoder->ipqf_buffer[sce->channel], hDecoder->prev_fmd[sce->channel], 947 hDecoder->ssr_overlap[sce->channel], hDecoder->ipqf_buffer[sce->channel], hDecoder->prev_fmd[sce->channel],
972 hDecoder->frameLength); 948 hDecoder->frameLength);
973 } 949 }
@@ -1051,8 +1027,6 @@ uint8_t reconstruct_channel_pair(NeAACDecHandle hDecoder, ic_stream *ics1, ic_st
1051 element *cpe, int16_t *spec_data1, int16_t *spec_data2) 1027 element *cpe, int16_t *spec_data1, int16_t *spec_data2)
1052{ 1028{
1053 uint8_t retval; 1029 uint8_t retval;
1054 ALIGN static real_t spec_coef1[1024] IBSS_ATTR;
1055 ALIGN static real_t spec_coef2[1024] IBSS_ATTR;
1056 1030
1057#ifdef PROFILE 1031#ifdef PROFILE
1058 int64_t count = faad_get_ts(); 1032 int64_t count = faad_get_ts();