Unified · Split
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: bits.h,v 1.22 2003/09/09 18:09:51 menno Exp $ | 25 | ** $Id: bits.h,v 1.23 2003/10/09 20:04:24 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #ifndef __BITS_H__ | 28 | #ifndef __BITS_H__ |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: cfft.h,v 1.7 2003/09/09 18:09:51 menno Exp $ | 25 | ** $Id: cfft.h,v 1.8 2003/10/09 20:04:24 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #ifndef __CFFT_H__ | 28 | #ifndef __CFFT_H__ |
| @@ -32,6 +32,14 @@ · 3 unmodified lines | |||
| 32 | extern "C" { | 32 | extern "C" { |
| 33 | #endif | 33 | #endif |
| 34 | 34 | ||
| 35 | typedef struct | ||
| 36 | { | ||
| 37 | uint16_t n; | ||
| 38 | uint16_t ifac[15]; | ||
| 39 | complex_t *work; | ||
| 40 | complex_t *tab; | ||
| 41 | } cfft_info; | ||
| 42 | |||
| 35 | 43 | ||
| 36 | void cfftf(cfft_info *cfft, complex_t *c); | 44 | void cfftf(cfft_info *cfft, complex_t *c); |
| 37 | void cfftb(cfft_info *cfft, complex_t *c); | 45 | void cfftb(cfft_info *cfft, complex_t *c); |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: common.c,v 1.7 2003/09/09 18:09:51 menno Exp $ | 25 | ** $Id: common.c,v 1.8 2003/10/09 20:04:24 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | /* just some common functions that could be used anywhere */ | 28 | /* just some common functions that could be used anywhere */ |
| @@ -117,6 +117,7 @@ int8_t can_decode_ot(uint8_t object_type) · 88 unmodified lines | |||
| 117 | return -1; | 117 | return -1; |
| 118 | } | 118 | } |
| 119 | 119 | ||
| 120 | |||
| 120 | static const uint8_t Parity [256] = { // parity | 121 | static const uint8_t Parity [256] = { // parity |
| 121 | 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, | 122 | 0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0,1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1, |
| 122 | 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, | 123 | 1,0,0,1,0,1,1,0,0,1,1,0,1,0,0,1,0,1,1,0,1,0,0,1,1,0,0,1,0,1,1,0, |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: common.h,v 1.31 2003/09/09 18:09:51 menno Exp $ | 25 | ** $Id: common.h,v 1.32 2003/10/09 20:04:24 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #ifndef __COMMON_H__ | 28 | #ifndef __COMMON_H__ |
| @@ -41,7 +41,6 @@ extern "C" { · 12 unmodified lines | |||
| 41 | #define min(a, b) (((a) < (b)) ? (a) : (b)) | 41 | #define min(a, b) (((a) < (b)) ? (a) : (b)) |
| 42 | #endif | 42 | #endif |
| 43 | 43 | ||
| 44 | |||
| 45 | /* COMPILE TIME DEFINITIONS */ | 44 | /* COMPILE TIME DEFINITIONS */ |
| 46 | 45 | ||
| 47 | /* use double precision */ | 46 | /* use double precision */ |
| @@ -49,6 +48,11 @@ extern "C" { · 1 unmodified line | |||
| 49 | /* use fixed point reals */ | 48 | /* use fixed point reals */ |
| 50 | //#define FIXED_POINT | 49 | //#define FIXED_POINT |
| 51 | 50 | ||
| 51 | #ifdef _WIN32_WCE | ||
| 52 | #define FIXED_POINT | ||
| 53 | #endif | ||
| 54 | |||
| 55 | |||
| 52 | #define ERROR_RESILIENCE | 56 | #define ERROR_RESILIENCE |
| 53 | 57 | ||
| 54 | 58 | ||
| @@ -60,6 +64,8 @@ extern "C" { · 5 unmodified lines | |||
| 60 | #define LTP_DEC | 64 | #define LTP_DEC |
| 61 | /* Allow decoding of LD profile AAC */ | 65 | /* Allow decoding of LD profile AAC */ |
| 62 | #define LD_DEC | 66 | #define LD_DEC |
| 67 | /* Allow decoding of Digital Radio Mondiale (DRM) */ | ||
| 68 | //#define DRM | ||
| 63 | 69 | ||
| 64 | /* LD can't do without LTP */ | 70 | /* LD can't do without LTP */ |
| 65 | #ifdef LD_DEC | 71 | #ifdef LD_DEC |
| @@ -94,7 +100,7 @@ extern "C" { · 28 unmodified lines | |||
| 94 | #else | 100 | #else |
| 95 | #define qmf_t real_t | 101 | #define qmf_t real_t |
| 96 | #define QMF_RE(A) (A) | 102 | #define QMF_RE(A) (A) |
| 97 | #define QMF_IM(A) 0 | 103 | #define QMF_IM(A) |
| 98 | #endif | 104 | #endif |
| 99 | 105 | ||
| 100 | 106 | ||
| @@ -1,19 +1,19 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding | 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
| 3 | ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com | 3 | ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com |
| 4 | ** | 4 | ** |
| 5 | ** This program is free software; you can redistribute it and/or modify | 5 | ** This program is free software; you can redistribute it and/or modify |
| 6 | ** it under the terms of the GNU General Public License as published by | 6 | ** it under the terms of the GNU General Public License as published by |
| 7 | ** the Free Software Foundation; either version 2 of the License, or | 7 | ** the Free Software Foundation; either version 2 of the License, or |
| 8 | ** (at your option) any later version. | 8 | ** (at your option) any later version. |
| 9 | ** | 9 | ** |
| 10 | ** This program is distributed in the hope that it will be useful, | 10 | ** This program is distributed in the hope that it will be useful, |
| 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | ** GNU General Public License for more details. | 13 | ** GNU General Public License for more details. |
| 14 | ** | 14 | ** |
| 15 | ** You should have received a copy of the GNU General Public License | 15 | ** You should have received a copy of the GNU General Public License |
| 16 | ** along with this program; if not, write to the Free Software | 16 | ** along with this program; if not, write to the Free Software |
| 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | ** | 18 | ** |
| 19 | ** Any non-GPL usage of this software or parts of this software is strictly | 19 | ** Any non-GPL usage of this software or parts of this software is strictly |
| @@ -22,7 +22,7 @@ · 2 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: decoder.c,v 1.73 2003/10/05 15:22:10 menno Exp $ | 25 | ** $Id: decoder.c,v 1.74 2003/10/09 20:04:24 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #include "common.h" | 28 | #include "common.h" |
| @@ -34,20 +34,9 @@ · 5 unmodified lines | |||
| 34 | #include "decoder.h" | 34 | #include "decoder.h" |
| 35 | #include "mp4.h" | 35 | #include "mp4.h" |
| 36 | #include "syntax.h" | 36 | #include "syntax.h" |
| 37 | #include "tns.h" | ||
| 38 | #include "pns.h" | ||
| 39 | #include "is.h" | ||
| 40 | #include "ms.h" | ||
| 41 | #include "ic_predict.h" | ||
| 42 | #include "lt_predict.h" | ||
| 43 | #include "drc.h" | ||
| 44 | #include "error.h" | 37 | #include "error.h" |
| 45 | #include "output.h" | 38 | #include "output.h" |
| 46 | #include "dither.h" | 39 | #include "dither.h" |
| 47 | #ifdef SSR_DEC | ||
| 48 | #include "ssr.h" | ||
| 49 | #include "ssr_fb.h" | ||
| 50 | #endif | ||
| 51 | #ifdef SBR_DEC | 40 | #ifdef SBR_DEC |
| 52 | #include "sbr_dec.h" | 41 | #include "sbr_dec.h" |
| 53 | #endif | 42 | #endif |
| @@ -102,6 +91,7 @@ faacDecHandle FAADAPI faacDecOpen() · 48 unmodified lines | |||
| 102 | hDecoder->config.outputFormat = FAAD_FMT_16BIT; | 91 | hDecoder->config.outputFormat = FAAD_FMT_16BIT; |
| 103 | hDecoder->config.defObjectType = MAIN; | 92 | hDecoder->config.defObjectType = MAIN; |
| 104 | hDecoder->config.defSampleRate = 44100; /* Default: 44.1kHz */ | 93 | hDecoder->config.defSampleRate = 44100; /* Default: 44.1kHz */ |
| 94 | hDecoder->config.downMatrix = 0; | ||
| 105 | hDecoder->adts_header_present = 0; | 95 | hDecoder->adts_header_present = 0; |
| 106 | hDecoder->adif_header_present = 0; | 96 | hDecoder->adif_header_present = 0; |
| 107 | #ifdef ERROR_RESILIENCE | 97 | #ifdef ERROR_RESILIENCE |
| @@ -377,7 +367,6 @@ int8_t FAADAPI faacDecInit2(faacDecHandle hDecoder, uint8_t *pBuffer, · 269 unmodified lines | |||
| 377 | return 0; | 367 | return 0; |
| 378 | } | 368 | } |
| 379 | 369 | ||
| 380 | #ifdef DRM | ||
| 381 | int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate, | 370 | int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate, |
| 382 | uint8_t channels) | 371 | uint8_t channels) |
| 383 | { | 372 | { |
| @@ -385,9 +374,11 @@ int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate, · 1 unmodified line | |||
| 385 | hDecoder->config.defObjectType = DRM_ER_LC; | 374 | hDecoder->config.defObjectType = DRM_ER_LC; |
| 386 | 375 | ||
| 387 | hDecoder->config.defSampleRate = samplerate; | 376 | hDecoder->config.defSampleRate = samplerate; |
| 377 | #ifdef ERROR_RESILIENCE // This shoudl always be defined for DRM | ||
| 388 | hDecoder->aacSectionDataResilienceFlag = 1; /* VCB11 */ | 378 | hDecoder->aacSectionDataResilienceFlag = 1; /* VCB11 */ |
| 389 | hDecoder->aacScalefactorDataResilienceFlag = 0; /* no RVLC */ | 379 | hDecoder->aacScalefactorDataResilienceFlag = 0; /* no RVLC */ |
| 390 | hDecoder->aacSpectralDataResilienceFlag = 1; /* HCR */ | 380 | hDecoder->aacSpectralDataResilienceFlag = 1; /* HCR */ |
| 381 | #endif | ||
| 391 | hDecoder->frameLength = 960; | 382 | hDecoder->frameLength = 960; |
| 392 | hDecoder->sf_index = get_sr_index(hDecoder->config.defSampleRate); | 383 | hDecoder->sf_index = get_sr_index(hDecoder->config.defSampleRate); |
| 393 | hDecoder->object_type = hDecoder->config.defObjectType; | 384 | hDecoder->object_type = hDecoder->config.defObjectType; |
| @@ -398,6 +389,7 @@ int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate, · 4 unmodified lines | |||
| 398 | hDecoder->channelConfiguration = 1; | 389 | hDecoder->channelConfiguration = 1; |
| 399 | 390 | ||
| 400 | #ifdef SBR_DEC | 391 | #ifdef SBR_DEC |
| 392 | #ifdef DRM | ||
| 401 | if (channels == DRMCH_SBR_LC_STEREO) | 393 | if (channels == DRMCH_SBR_LC_STEREO) |
| 402 | hDecoder->lcstereo_flag = 1; | 394 | hDecoder->lcstereo_flag = 1; |
| 403 | else | 395 | else |
| @@ -411,6 +403,7 @@ int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate, · 7 unmodified lines | |||
| 411 | /* Reset sbr for new initialization */ | 403 | /* Reset sbr for new initialization */ |
| 412 | sbrDecodeEnd(hDecoder->sbr[0]); | 404 | sbrDecodeEnd(hDecoder->sbr[0]); |
| 413 | hDecoder->sbr[0] = NULL; | 405 | hDecoder->sbr[0] = NULL; |
| 406 | #endif | ||
| 414 | #endif | 407 | #endif |
| 415 | 408 | ||
| 416 | /* must be done before frameLength is divided by 2 for LD */ | 409 | /* must be done before frameLength is divided by 2 for LD */ |
| @@ -423,7 +416,6 @@ int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate, · 6 unmodified lines | |||
| 423 | 416 | ||
| 424 | return 0; | 417 | return 0; |
| 425 | } | 418 | } |
| 426 | #endif | ||
| 427 | 419 | ||
| 428 | void FAADAPI faacDecClose(faacDecHandle hDecoder) | 420 | void FAADAPI faacDecClose(faacDecHandle hDecoder) |
| 429 | { | 421 | { |
| @@ -699,7 +691,6 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 269 unmodified lines | |||
| 699 | uint8_t *buffer, uint32_t buffer_size) | 691 | uint8_t *buffer, uint32_t buffer_size) |
| 700 | { | 692 | { |
| 701 | int32_t i; | 693 | int32_t i; |
| 702 | uint8_t ch; | ||
| 703 | adts_header adts; | 694 | adts_header adts; |
| 704 | uint8_t channels = 0, ch_ele = 0; | 695 | uint8_t channels = 0, ch_ele = 0; |
| 705 | uint8_t output_channels = 0; | 696 | uint8_t output_channels = 0; |
| @@ -707,8 +698,8 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 1 unmodified line | |||
| 707 | uint32_t bitsconsumed; | 698 | uint32_t bitsconsumed; |
| 708 | #ifdef DRM | 699 | #ifdef DRM |
| 709 | uint8_t *revbuffer; | 700 | uint8_t *revbuffer; |
| 710 | uint8_t *prevbufstart; | 701 | uint8_t *prevbufstart; |
| 711 | uint8_t *pbufend; | 702 | uint8_t *pbufend; |
| 712 | #endif | 703 | #endif |
| 713 | 704 | ||
| 714 | /* local copy of globals */ | 705 | /* local copy of globals */ |
| @@ -736,9 +727,6 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 21 unmodified lines | |||
| 736 | program_config *pce; | 727 | program_config *pce; |
| 737 | 728 | ||
| 738 | void *sample_buffer; | 729 | void *sample_buffer; |
| 739 | element *syntax_elements[MAX_SYNTAX_ELEMENTS]; | ||
| 740 | element **elements; | ||
| 741 | real_t *spec_coef[MAX_CHANNELS]; | ||
| 742 | 730 | ||
| 743 | /* safety checks */ | 731 | /* safety checks */ |
| 744 | if ((hDecoder == NULL) || (hInfo == NULL) || (buffer == NULL) || (ld == NULL)) | 732 | if ((hDecoder == NULL) || (hInfo == NULL) || (buffer == NULL) || (ld == NULL)) |
| @@ -804,11 +792,8 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 59 unmodified lines | |||
| 804 | dbg_count = 0; | 792 | dbg_count = 0; |
| 805 | #endif | 793 | #endif |
| 806 | 794 | ||
| 807 | elements = syntax_elements; | ||
| 808 | |||
| 809 | /* decode the complete bitstream */ | 795 | /* decode the complete bitstream */ |
| 810 | elements = raw_data_block(hDecoder, hInfo, ld, syntax_elements, | 796 | raw_data_block(hDecoder, hInfo, ld, pce, drc); |
| 811 | spec_coef, pce, drc); | ||
| 812 | 797 | ||
| 813 | ch_ele = hDecoder->fr_ch_ele; | 798 | ch_ele = hDecoder->fr_ch_ele; |
| 814 | channels = hDecoder->fr_channels; | 799 | channels = hDecoder->fr_channels; |
| @@ -912,202 +897,27 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 97 unmodified lines | |||
| 912 | return NULL; | 897 | return NULL; |
| 913 | } | 898 | } |
| 914 | 899 | ||
| 900 | /* allocate the buffer for the final samples */ | ||
| 915 | if (hDecoder->sample_buffer == NULL) | 901 | if (hDecoder->sample_buffer == NULL) |
| 916 | { | 902 | { |
| 903 | static const uint8_t str[] = { sizeof(int16_t), sizeof(int32_t), sizeof(int32_t), | ||
| 904 | sizeof(float32_t), sizeof(double), sizeof(int16_t), sizeof(int16_t), | ||
| 905 | sizeof(int16_t), sizeof(int16_t), 0, 0, 0 | ||
| 906 | }; | ||
| 907 | uint8_t stride = str[outputFormat-1]; | ||
| 917 | #ifdef SBR_DEC | 908 | #ifdef SBR_DEC |
| 918 | if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) | 909 | if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) |
| 919 | { | 910 | stride = 2 * stride; |
| 920 | if (hDecoder->config.outputFormat == FAAD_FMT_DOUBLE) | ||
| 921 | hDecoder->sample_buffer = malloc(2*frame_len*channels*sizeof(double)); | ||
| 922 | else | ||
| 923 | hDecoder->sample_buffer = malloc(2*frame_len*channels*sizeof(real_t)); | ||
| 924 | } else { | ||
| 925 | #endif | ||
| 926 | if (hDecoder->config.outputFormat == FAAD_FMT_DOUBLE) | ||
| 927 | hDecoder->sample_buffer = malloc(frame_len*channels*sizeof(double)); | ||
| 928 | else | ||
| 929 | hDecoder->sample_buffer = malloc(frame_len*channels*sizeof(real_t)); | ||
| 930 | #ifdef SBR_DEC | ||
| 931 | } | ||
| 932 | #endif | 911 | #endif |
| 912 | hDecoder->sample_buffer = malloc(frame_len*channels*stride); | ||
| 933 | } | 913 | } |
| 934 | 914 | ||
| 935 | sample_buffer = hDecoder->sample_buffer; | 915 | sample_buffer = hDecoder->sample_buffer; |
| 936 | 916 | ||
| 937 | |||
| 938 | /* Because for ms, is and pns both channels spectral coefficients are needed | ||
| 939 | we have to restart running through all channels here. | ||
| 940 | */ | ||
| 941 | for (ch = 0; ch < channels; ch++) | ||
| 942 | { | ||
| 943 | int16_t pch = -1; | ||
| 944 | uint8_t right_channel; | ||
| 945 | ic_stream *ics, *icsr; | ||
| 946 | ltp_info *ltp; | ||
| 947 | |||
| 948 | /* find the syntax element to which this channel belongs */ | ||
| 949 | if (syntax_elements[hDecoder->channel_element[ch]]->channel == ch) | ||
| 950 | { | ||
| 951 | ics = &(syntax_elements[hDecoder->channel_element[ch]]->ics1); | ||
| 952 | icsr = &(syntax_elements[hDecoder->channel_element[ch]]->ics2); | ||
| 953 | ltp = &(ics->ltp); | ||
| 954 | pch = syntax_elements[hDecoder->channel_element[ch]]->paired_channel; | ||
| 955 | right_channel = 0; | ||
| 956 | } else if (syntax_elements[hDecoder->channel_element[ch]]->paired_channel == ch) { | ||
| 957 | ics = &(syntax_elements[hDecoder->channel_element[ch]]->ics2); | ||
| 958 | if (syntax_elements[hDecoder->channel_element[ch]]->common_window) | ||
| 959 | ltp = &(ics->ltp2); | ||
| 960 | else | ||
| 961 | ltp = &(ics->ltp); | ||
| 962 | right_channel = 1; | ||
| 963 | } | ||
| 964 | |||
| 965 | /* pns decoding */ | ||
| 966 | if ((!right_channel) && (pch != -1) && (ics->ms_mask_present)) | ||
| 967 | pns_decode(ics, icsr, spec_coef[ch], spec_coef[pch], frame_len, 1, object_type); | ||
| 968 | else if ((pch == -1) || ((pch != -1) && (!ics->ms_mask_present))) | ||
| 969 | pns_decode(ics, NULL, spec_coef[ch], NULL, frame_len, 0, object_type); | ||
| 970 | |||
| 971 | if (!right_channel && (pch != -1)) | ||
| 972 | { | ||
| 973 | /* mid/side decoding */ | ||
| 974 | ms_decode(ics, icsr, spec_coef[ch], spec_coef[pch], frame_len); | ||
| 975 | |||
| 976 | /* intensity stereo decoding */ | ||
| 977 | is_decode(ics, icsr, spec_coef[ch], spec_coef[pch], frame_len); | ||
| 978 | } | ||
| 979 | |||
| 980 | #ifdef MAIN_DEC | ||
| 981 | /* MAIN object type prediction */ | ||
| 982 | if (object_type == MAIN) | ||
| 983 | { | ||
| 984 | /* allocate the state only when needed */ | ||
| 985 | if (pred_stat[ch] == NULL) | ||
| 986 | { | ||
| 987 | pred_stat[ch] = (pred_state*)malloc(frame_len * sizeof(pred_state)); | ||
| 988 | reset_all_predictors(pred_stat[ch], frame_len); | ||
| 989 | } | ||
| 990 | |||
| 991 | /* intra channel prediction */ | ||
| 992 | ic_prediction(ics, spec_coef[ch], pred_stat[ch], frame_len); | ||
| 993 | |||
| 994 | /* In addition, for scalefactor bands coded by perceptual | ||
| 995 | noise substitution the predictors belonging to the | ||
| 996 | corresponding spectral coefficients are reset. | ||
| 997 | */ | ||
| 998 | pns_reset_pred_state(ics, pred_stat[ch]); | ||
| 999 | } | ||
| 1000 | #endif | ||
| 1001 | #ifdef LTP_DEC | ||
| 1002 | if ((object_type == LTP) | ||
| 1003 | #ifdef ERROR_RESILIENCE | ||
| 1004 | || (object_type == ER_LTP) | ||
| 1005 | #endif | ||
| 1006 | #ifdef LD_DEC | ||
| 1007 | || (object_type == LD) | ||
| 1008 | #endif | ||
| 1009 | ) | ||
| 1010 | { | ||
| 1011 | #ifdef LD_DEC | ||
| 1012 | if (object_type == LD) | ||
| 1013 | { | ||
| 1014 | if (ltp->data_present) | ||
| 1015 | { | ||
| 1016 | if (ltp->lag_update) | ||
| 1017 | ltp_lag[ch] = ltp->lag; | ||
| 1018 | } | ||
| 1019 | ltp->lag = ltp_lag[ch]; | ||
| 1020 | } | ||
| 1021 | #endif | ||
| 1022 | |||
| 1023 | /* allocate the state only when needed */ | ||
| 1024 | if (lt_pred_stat[ch] == NULL) | ||
| 1025 | { | ||
| 1026 | lt_pred_stat[ch] = (real_t*)malloc(frame_len*4 * sizeof(real_t)); | ||
| 1027 | memset(lt_pred_stat[ch], 0, frame_len*4 * sizeof(real_t)); | ||
| 1028 | } | ||
| 1029 | |||
| 1030 | /* long term prediction */ | ||
| 1031 | lt_prediction(ics, ltp, spec_coef[ch], lt_pred_stat[ch], fb, | ||
| 1032 | ics->window_shape, window_shape_prev[ch], | ||
| 1033 | sf_index, object_type, frame_len); | ||
| 1034 | } | ||
| 1035 | #endif | ||
| 1036 | |||
| 1037 | /* tns decoding */ | ||
| 1038 | tns_decode_frame(ics, &(ics->tns), sf_index, object_type, | ||
| 1039 | spec_coef[ch], frame_len); | ||
| 1040 | |||
| 1041 | /* drc decoding */ | ||
| 1042 | if (drc->present) | ||
| 1043 | { | ||
| 1044 | if (!drc->exclude_mask[ch] || !drc->excluded_chns_present) | ||
| 1045 | drc_decode(drc, spec_coef[ch]); | ||
| 1046 | } | ||
| 1047 | |||
| 1048 | if (time_out[ch] == NULL) | ||
| 1049 | { | ||
| 1050 | time_out[ch] = (real_t*)malloc(frame_len*2*sizeof(real_t)); | ||
| 1051 | memset(time_out[ch], 0, frame_len*2*sizeof(real_t)); | ||
| 1052 | } | ||
| 1053 | #ifdef SBR_DEC | ||
| 1054 | if (time_out2[ch] == NULL) | ||
| 1055 | { | ||
| 1056 | time_out2[ch] = (real_t*)malloc(frame_len*2*sizeof(real_t)); | ||
| 1057 | memset(time_out2[ch], 0, frame_len*2*sizeof(real_t)); | ||
| 1058 | } | ||
| 1059 | #endif | ||
| 1060 | |||
| 1061 | /* filter bank */ | ||
| 1062 | #ifdef SSR_DEC | ||
| 1063 | if (object_type != SSR) | ||
| 1064 | { | ||
| 1065 | #endif | ||
| 1066 | ifilter_bank(fb, ics->window_sequence, ics->window_shape, | ||
| 1067 | window_shape_prev[ch], spec_coef[ch], | ||
| 1068 | time_out[ch], object_type, frame_len); | ||
| 1069 | #ifdef SSR_DEC | ||
| 1070 | } else { | ||
| 1071 | if (ssr_overlap[ch] == NULL) | ||
| 1072 | { | ||
| 1073 | ssr_overlap[ch] = (real_t*)malloc(2*frame_len*sizeof(real_t)); | ||
| 1074 | memset(ssr_overlap[ch], 0, 2*frame_len*sizeof(real_t)); | ||
| 1075 | } | ||
| 1076 | if (prev_fmd[ch] == NULL) | ||
| 1077 | { | ||
| 1078 | uint16_t k; | ||
| 1079 | prev_fmd[ch] = (real_t*)malloc(2*frame_len*sizeof(real_t)); | ||
| 1080 | for (k = 0; k < 2*frame_len; k++) | ||
| 1081 | prev_fmd[ch][k] = REAL_CONST(-1); | ||
| 1082 | } | ||
| 1083 | |||
| 1084 | ssr_decode(&(ics->ssr), fb, ics->window_sequence, ics->window_shape, | ||
| 1085 | window_shape_prev[ch], spec_coef[ch], time_out[ch], | ||
| 1086 | ssr_overlap[ch], hDecoder->ipqf_buffer[ch], prev_fmd[ch], frame_len); | ||
| 1087 | } | ||
| 1088 | #endif | ||
| 1089 | /* save window shape for next frame */ | ||
| 1090 | window_shape_prev[ch] = ics->window_shape; | ||
| 1091 | |||
| 1092 | #ifdef LTP_DEC | ||
| 1093 | if ((object_type == LTP) | ||
| 1094 | #ifdef ERROR_RESILIENCE | ||
| 1095 | || (object_type == ER_LTP) | ||
| 1096 | #endif | ||
| 1097 | #ifdef LD_DEC | ||
| 1098 | || (object_type == LD) | ||
| 1099 | #endif | ||
| 1100 | ) | ||
| 1101 | { | ||
| 1102 | lt_update_state(lt_pred_stat[ch], time_out[ch], time_out[ch]+frame_len, | ||
| 1103 | frame_len, object_type); | ||
| 1104 | } | ||
| 1105 | #endif | ||
| 1106 | } | ||
| 1107 | |||
| 1108 | #ifdef SBR_DEC | 917 | #ifdef SBR_DEC |
| 1109 | if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) | 918 | if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) |
| 1110 | { | 919 | { |
| 920 | uint8_t ch = 0; | ||
| 1111 | for (i = 0; i < ch_ele; i++) | 921 | for (i = 0; i < ch_ele; i++) |
| 1112 | { | 922 | { |
| 1113 | /* following case can happen when forceUpSampling == 1 */ | 923 | /* following case can happen when forceUpSampling == 1 */ |
| @@ -1120,25 +930,40 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 6 unmodified lines | |||
| 1120 | ); | 930 | ); |
| 1121 | hDecoder->sbr[i]->data = NULL; | 931 | hDecoder->sbr[i]->data = NULL; |
| 1122 | hDecoder->sbr[i]->data_size = 0; | 932 | hDecoder->sbr[i]->data_size = 0; |
| 933 | hDecoder->sbr[i]->id_aac = hDecoder->element_id[i]; | ||
| 934 | } | ||
| 935 | |||
| 936 | /* Allocate space for SBR output */ | ||
| 937 | if (hDecoder->time_out2[ch] == NULL) | ||
| 938 | { | ||
| 939 | hDecoder->time_out2[ch] = (real_t*)malloc(hDecoder->frameLength*2*sizeof(real_t)); | ||
| 940 | memset(hDecoder->time_out2[ch], 0, hDecoder->frameLength*2*sizeof(real_t)); | ||
| 1123 | } | 941 | } |
| 1124 | 942 | ||
| 1125 | if (syntax_elements[i]->paired_channel != -1) | 943 | if (hDecoder->sbr[i]->id_aac == ID_CPE) |
| 1126 | { | 944 | { |
| 1127 | memcpy(time_out2[syntax_elements[i]->channel], | 945 | /* space for 2 channels needed */ |
| 1128 | time_out[syntax_elements[i]->channel], frame_len*sizeof(real_t)); | 946 | if (hDecoder->time_out2[ch+1] == NULL) |
| 1129 | memcpy(time_out2[syntax_elements[i]->paired_channel], | 947 | { |
| 1130 | time_out[syntax_elements[i]->paired_channel], frame_len*sizeof(real_t)); | 948 | hDecoder->time_out2[ch+1] = (real_t*)malloc(hDecoder->frameLength*2*sizeof(real_t)); |
| 949 | memset(hDecoder->time_out2[ch+1], 0, hDecoder->frameLength*2*sizeof(real_t)); | ||
| 950 | } | ||
| 951 | |||
| 952 | memcpy(time_out2[ch], | ||
| 953 | time_out[ch], frame_len*sizeof(real_t)); | ||
| 954 | memcpy(time_out2[ch+1], | ||
| 955 | time_out[ch+1], frame_len*sizeof(real_t)); | ||
| 1131 | sbrDecodeFrame(hDecoder->sbr[i], | 956 | sbrDecodeFrame(hDecoder->sbr[i], |
| 1132 | time_out2[syntax_elements[i]->channel], | 957 | time_out2[ch], time_out2[ch+1], |
| 1133 | time_out2[syntax_elements[i]->paired_channel], ID_CPE, | ||
| 1134 | hDecoder->postSeekResetFlag, hDecoder->forceUpSampling); | 958 | hDecoder->postSeekResetFlag, hDecoder->forceUpSampling); |
| 959 | ch += 2; | ||
| 1135 | } else { | 960 | } else { |
| 1136 | memcpy(time_out2[syntax_elements[i]->channel], | 961 | memcpy(time_out2[ch], |
| 1137 | time_out[syntax_elements[i]->channel], frame_len*sizeof(real_t)); | 962 | time_out[ch], frame_len*sizeof(real_t)); |
| 1138 | sbrDecodeFrame(hDecoder->sbr[i], | 963 | sbrDecodeFrame(hDecoder->sbr[i], |
| 1139 | time_out2[syntax_elements[i]->channel], | 964 | time_out2[ch], NULL, |
| 1140 | NULL, ID_SCE, | ||
| 1141 | hDecoder->postSeekResetFlag, hDecoder->forceUpSampling); | 965 | hDecoder->postSeekResetFlag, hDecoder->forceUpSampling); |
| 966 | ch++; | ||
| 1142 | } | 967 | } |
| 1143 | } | 968 | } |
| 1144 | frame_len *= 2; | 969 | frame_len *= 2; |
| @@ -1181,16 +1006,6 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 36 unmodified lines | |||
| 1181 | #endif | 1006 | #endif |
| 1182 | 1007 | ||
| 1183 | /* cleanup */ | 1008 | /* cleanup */ |
| 1184 | for (ch = 0; ch < channels; ch++) | ||
| 1185 | { | ||
| 1186 | if (spec_coef[ch]) free(spec_coef[ch]); | ||
| 1187 | } | ||
| 1188 | |||
| 1189 | for (i = 0; i < ch_ele; i++) | ||
| 1190 | { | ||
| 1191 | if (syntax_elements[i]) free(syntax_elements[i]); | ||
| 1192 | } | ||
| 1193 | |||
| 1194 | #ifdef ANALYSIS | 1009 | #ifdef ANALYSIS |
| 1195 | fflush(stdout); | 1010 | fflush(stdout); |
| 1196 | #endif | 1011 | #endif |
| @@ -1203,16 +1018,6 @@ error: · 6 unmodified lines | |||
| 1203 | if (ld) free(ld); | 1018 | if (ld) free(ld); |
| 1204 | 1019 | ||
| 1205 | /* cleanup */ | 1020 | /* cleanup */ |
| 1206 | for (ch = 0; ch < channels; ch++) | ||
| 1207 | { | ||
| 1208 | if (spec_coef[ch]) free(spec_coef[ch]); | ||
| 1209 | } | ||
| 1210 | |||
| 1211 | for (i = 0; i < ch_ele; i++) | ||
| 1212 | { | ||
| 1213 | if (syntax_elements[i]) free(syntax_elements[i]); | ||
| 1214 | } | ||
| 1215 | |||
| 1216 | #ifdef ANALYSIS | 1021 | #ifdef ANALYSIS |
| 1217 | fflush(stdout); | 1022 | fflush(stdout); |
| 1218 | #endif | 1023 | #endif |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: decoder.h,v 1.28 2003/09/24 08:05:44 menno Exp $ | 25 | ** $Id: decoder.h,v 1.29 2003/10/09 20:04:24 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #ifndef __DECODER_H__ | 28 | #ifndef __DECODER_H__ |
| @@ -118,16 +118,6 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 89 unmodified lines | |||
| 118 | uint8_t *buffer, | 118 | uint8_t *buffer, |
| 119 | uint32_t buffer_size); | 119 | uint32_t buffer_size); |
| 120 | 120 | ||
| 121 | element *decode_sce_lfe(faacDecHandle hDecoder, | ||
| 122 | faacDecFrameInfo *hInfo, bitfile *ld, | ||
| 123 | real_t **spec_coef, uint8_t id_syn_ele); | ||
| 124 | element *decode_cpe(faacDecHandle hDecoder, | ||
| 125 | faacDecFrameInfo *hInfo, bitfile *ld, | ||
| 126 | real_t **spec_coef, uint8_t id_syn_ele); | ||
| 127 | element **raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, | ||
| 128 | bitfile *ld, element **elements, | ||
| 129 | real_t **spec_coef, program_config *pce, drc_info *drc); | ||
| 130 | |||
| 131 | #ifdef _WIN32 | 121 | #ifdef _WIN32 |
| 132 | #pragma pack(pop) | 122 | #pragma pack(pop) |
| 133 | #endif | 123 | #endif |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: fixed.h,v 1.10 2003/09/09 18:09:51 menno Exp $ | 25 | ** $Id: fixed.h,v 1.11 2003/10/09 20:04:24 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #ifndef __FIXED_H__ | 28 | #ifndef __FIXED_H__ |
| @@ -95,6 +95,30 @@ static INLINE MUL_R_C(real_t A, real_t B) · 66 unmodified lines | |||
| 95 | } | 95 | } |
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | #elif 0 //defined(_WIN32_WCE) && defined(ARM) | ||
| 99 | |||
| 100 | /* multiply real with real */ | ||
| 101 | static INLINE MUL(real_t A, real_t B) | ||
| 102 | { | ||
| 103 | __emit(0xe0c23190); // smull r3, r2, r0, r1 | ||
| 104 | __emit(0xe1b03723); // movs r3, r3, lsr #14 | ||
| 105 | __emit(0xe0a30902); // adc r0, r3, r2, lsl #18 | ||
| 106 | } | ||
| 107 | /* multiply coef with coef */ | ||
| 108 | static INLINE MUL_C_C(real_t A, real_t B) | ||
| 109 | { | ||
| 110 | __emit(0xe0c23190); // smull r3, r2, r0, r1 | ||
| 111 | __emit(0xe1b03e23); // movs r3, r3, lsr #28 | ||
| 112 | __emit(0xe0a30202); // adc r0, r3, r2, lsl #4 | ||
| 113 | } | ||
| 114 | /* multiply real with coef */ | ||
| 115 | static INLINE MUL_R_C(real_t A, real_t B) | ||
| 116 | { | ||
| 117 | __emit(0xe0c23190); // smull r3, r2, r0, r1 | ||
| 118 | __emit(0xe1b03e23); // movs r3, r3, lsr #28 | ||
| 119 | __emit(0xe0a30202); // adc r0, r3, r2, lsl #4 | ||
| 120 | } | ||
| 121 | |||
| 98 | #elif defined(__GNUC__) && defined (__arm__) | 122 | #elif defined(__GNUC__) && defined (__arm__) |
| 99 | 123 | ||
| 100 | /* taken from MAD */ | 124 | /* taken from MAD */ |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: lt_predict.c,v 1.12 2003/09/09 18:09:52 menno Exp $ | 25 | ** $Id: lt_predict.c,v 1.13 2003/10/09 20:04:24 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | 28 | ||
| @@ -37,6 +37,26 @@ · 8 unmodified lines | |||
| 37 | #include "filtbank.h" | 37 | #include "filtbank.h" |
| 38 | #include "tns.h" | 38 | #include "tns.h" |
| 39 | 39 | ||
| 40 | /* check if the object type is an object type that can have LTP */ | ||
| 41 | uint8_t is_ltp_ot(uint8_t object_type) | ||
| 42 | { | ||
| 43 | #ifdef LTP_DEC | ||
| 44 | if ((object_type == LTP) | ||
| 45 | #ifdef ERROR_RESILIENCE | ||
| 46 | || (object_type == ER_LTP) | ||
| 47 | #endif | ||
| 48 | #ifdef LD_DEC | ||
| 49 | || (object_type == LD) | ||
| 50 | #endif | ||
| 51 | ) | ||
| 52 | { | ||
| 53 | return 1; | ||
| 54 | } | ||
| 55 | #endif | ||
| 56 | |||
| 57 | return 0; | ||
| 58 | } | ||
| 59 | |||
| 40 | static real_t codebook[8] = | 60 | static real_t codebook[8] = |
| 41 | { | 61 | { |
| 42 | COEF_CONST(0.570829), | 62 | COEF_CONST(0.570829), |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: lt_predict.h,v 1.6 2003/09/09 18:09:52 menno Exp $ | 25 | ** $Id: lt_predict.h,v 1.7 2003/10/09 20:04:24 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #ifdef LTP_DEC | 28 | #ifdef LTP_DEC |
| @@ -36,6 +36,8 @@ extern "C" { · 7 unmodified lines | |||
| 36 | 36 | ||
| 37 | #include "filtbank.h" | 37 | #include "filtbank.h" |
| 38 | 38 | ||
| 39 | uint8_t is_ltp_ot(uint8_t object_type); | ||
| 40 | |||
| 39 | void lt_prediction(ic_stream *ics, | 41 | void lt_prediction(ic_stream *ics, |
| 40 | ltp_info *ltp, | 42 | ltp_info *ltp, |
| 41 | real_t *spec, | 43 | real_t *spec, |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: mp4.c,v 1.19 2003/09/18 13:38:38 menno Exp $ | 25 | ** $Id: mp4.c,v 1.24 2003/11/12 20:47:58 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #include "common.h" | 28 | #include "common.h" |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: output.c,v 1.21 2003/09/09 18:09:52 menno Exp $ | 25 | ** $Id: output.c,v 1.22 2003/10/09 20:04:25 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #include "common.h" | 28 | #include "common.h" |
| @@ -55,20 +55,18 @@ double doubletmp; · 26 unmodified lines | |||
| 55 | static INLINE real_t get_sample(real_t **input, uint8_t channel, uint16_t sample, | 55 | static INLINE real_t get_sample(real_t **input, uint8_t channel, uint16_t sample, |
| 56 | uint8_t downMatrix, uint8_t *internal_channel) | 56 | uint8_t downMatrix, uint8_t *internal_channel) |
| 57 | { | 57 | { |
| 58 | if (downMatrix) | 58 | if (!downMatrix) |
| 59 | return input[internal_channel[channel]][sample]; | ||
| 60 | |||
| 61 | if (channel == 0) | ||
| 59 | { | 62 | { |
| 60 | if (channel == 0) | 63 | return DM_MUL * (input[internal_channel[1]][sample] + |
| 61 | { | 64 | input[internal_channel[0]][sample]/(real_t)sqrt(2.) + |
| 62 | return DM_MUL * (input[internal_channel[1]][sample] + | 65 | input[internal_channel[3]][sample]/(real_t)sqrt(2.)); |
| 63 | input[internal_channel[0]][sample]/(real_t)sqrt(2.) + | ||
| 64 | input[internal_channel[3]][sample]/(real_t)sqrt(2.)); | ||
| 65 | } else { | ||
| 66 | return DM_MUL * (input[internal_channel[2]][sample] + | ||
| 67 | input[internal_channel[0]][sample]/(real_t)sqrt(2.) + | ||
| 68 | input[internal_channel[4]][sample]/(real_t)sqrt(2.)); | ||
| 69 | } | ||
| 70 | } else { | 66 | } else { |
| 71 | return input[internal_channel[channel]][sample]; | 67 | return DM_MUL * (input[internal_channel[2]][sample] + |
| 68 | input[internal_channel[0]][sample]/(real_t)sqrt(2.) + | ||
| 69 | input[internal_channel[4]][sample]/(real_t)sqrt(2.)); | ||
| 72 | } | 70 | } |
| 73 | } | 71 | } |
| 74 | 72 | ||
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: sbr_dct.c,v 1.4 2003/09/24 11:52:12 menno Exp $ | 25 | ** $Id: sbr_dct.c,v 1.5 2003/10/09 20:04:25 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #include "common.h" | 28 | #include "common.h" |
| @@ -1099,6 +1099,21 @@ void DCT2_64_unscaled(real_t *y, real_t *x) · 1070 unmodified lines | |||
| 1099 | void DCT4_64(real_t *y, real_t *x) | 1099 | void DCT4_64(real_t *y, real_t *x) |
| 1100 | { | 1100 | { |
| 1101 | int16_t i0; | 1101 | int16_t i0; |
| 1102 | static real_t t2[64]; | ||
| 1103 | |||
| 1104 | t2[0] = x[0]; | ||
| 1105 | for (i0=0; i0<31; i0++) | ||
| 1106 | { | ||
| 1107 | t2[2*i0+1] = x[2*i0+1] - x[2*i0+2]; | ||
| 1108 | t2[2*i0+2] = x[2*i0+1] + x[2*i0+2]; | ||
| 1109 | } | ||
| 1110 | t2[63] = x[63]; | ||
| 1111 | |||
| 1112 | DCT4_64_kernel(y, t2); | ||
| 1113 | } | ||
| 1114 | |||
| 1115 | void DCT4_64_kernel(real_t *y, real_t *t2) | ||
| 1116 | { | ||
| 1102 | real_t f2; | 1117 | real_t f2; |
| 1103 | real_t f3; | 1118 | real_t f3; |
| 1104 | real_t f4; | 1119 | real_t f4; |
| @@ -1837,18 +1852,10 @@ void DCT4_64(real_t *y, real_t *x) · 732 unmodified lines | |||
| 1837 | real_t f799; | 1852 | real_t f799; |
| 1838 | real_t f800; | 1853 | real_t f800; |
| 1839 | real_t f801; | 1854 | real_t f801; |
| 1840 | static real_t t2[64]; | ||
| 1841 | 1855 | ||
| 1842 | t2[0] = x[0]; | ||
| 1843 | for (i0=0; i0<31; i0++) | ||
| 1844 | { | ||
| 1845 | t2[2*i0+1] = x[2*i0+1] - x[2*i0+2]; | ||
| 1846 | t2[2*i0+2] = x[2*i0+1] + x[2*i0+2]; | ||
| 1847 | } | ||
| 1848 | t2[63] = x[63]; | ||
| 1849 | f2 = 0.7071067811865476 * t2[32]; | 1856 | f2 = 0.7071067811865476 * t2[32]; |
| 1850 | f3 = x[0] - f2; | 1857 | f3 = t2[0] - f2; |
| 1851 | f4 = x[0] + f2; | 1858 | f4 = t2[0] + f2; |
| 1852 | f5 = t2[16] + t2[48]; | 1859 | f5 = t2[16] + t2[48]; |
| 1853 | f6 = 1.3065629648763766 * t2[16]; | 1860 | f6 = 1.3065629648763766 * t2[16]; |
| 1854 | f7 = (-0.9238795325112866) * f5; | 1861 | f7 = (-0.9238795325112866) * f5; |
| @@ -2312,8 +2319,8 @@ void DCT4_64(real_t *y, real_t *x) · 457 unmodified lines | |||
| 2312 | f465 = 0.7071067811865474 * f463; | 2319 | f465 = 0.7071067811865474 * f463; |
| 2313 | f466 = 0.7071067811865474 * f464; | 2320 | f466 = 0.7071067811865474 * f464; |
| 2314 | f467 = 0.7071067811865476 * t2[31]; | 2321 | f467 = 0.7071067811865476 * t2[31]; |
| 2315 | f468 = x[63] - f467; | 2322 | f468 = t2[63] - f467; |
| 2316 | f469 = x[63] + f467; | 2323 | f469 = t2[63] + f467; |
| 2317 | f470 = t2[47] + t2[15]; | 2324 | f470 = t2[47] + t2[15]; |
| 2318 | f471 = 1.3065629648763766 * t2[47]; | 2325 | f471 = 1.3065629648763766 * t2[47]; |
| 2319 | f472 = (-0.9238795325112866) * f470; | 2326 | f472 = (-0.9238795325112866) * f470; |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: sbr_dct.h,v 1.3 2003/09/24 11:52:12 menno Exp $ | 25 | ** $Id: sbr_dct.h,v 1.4 2003/10/09 20:04:25 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #ifndef __SBR_DCT_H__ | 28 | #ifndef __SBR_DCT_H__ |
| @@ -35,6 +35,7 @@ extern "C" { · 6 unmodified lines | |||
| 35 | void DCT3_32_unscaled(real_t *y, real_t *x); | 35 | void DCT3_32_unscaled(real_t *y, real_t *x); |
| 36 | void DCT2_64_unscaled(real_t *y, real_t *x); | 36 | void DCT2_64_unscaled(real_t *y, real_t *x); |
| 37 | void DCT4_64(real_t *y, real_t *x); | 37 | void DCT4_64(real_t *y, real_t *x); |
| 38 | void DCT4_64_kernel(real_t *y, real_t *t2); | ||
| 38 | 39 | ||
| 39 | 40 | ||
| 40 | #ifdef __cplusplus | 41 | #ifdef __cplusplus |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: sbr_dec.c,v 1.12 2003/09/25 12:04:31 menno Exp $ | 25 | ** $Id: sbr_dec.c,v 1.13 2003/10/09 20:04:25 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | 28 | ||
| @@ -111,10 +111,10 @@ void sbrDecodeEnd(sbr_info *sbr) · 82 unmodified lines | |||
| 111 | qmfs_end(sbr->qmfs[1]); | 111 | qmfs_end(sbr->qmfs[1]); |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | if (sbr->Xcodec[0]) free(sbr->Xcodec[0]); | 114 | //if (sbr->Xcodec[0]) free(sbr->Xcodec[0]); |
| 115 | if (sbr->Xsbr[0]) free(sbr->Xsbr[0]); | 115 | //if (sbr->Xsbr[0]) free(sbr->Xsbr[0]); |
| 116 | if (sbr->Xcodec[1]) free(sbr->Xcodec[1]); | 116 | //if (sbr->Xcodec[1]) free(sbr->Xcodec[1]); |
| 117 | if (sbr->Xsbr[1]) free(sbr->Xsbr[1]); | 117 | //if (sbr->Xsbr[1]) free(sbr->Xsbr[1]); |
| 118 | 118 | ||
| 119 | for (j = 0; j < 5; j++) | 119 | for (j = 0; j < 5; j++) |
| 120 | { | 120 | { |
| @@ -157,7 +157,7 @@ void sbr_save_prev_data(sbr_info *sbr, uint8_t ch) · 36 unmodified lines | |||
| 157 | } | 157 | } |
| 158 | 158 | ||
| 159 | void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, | 159 | void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, |
| 160 | real_t *right_channel, uint8_t id_aac, | 160 | real_t *right_channel, |
| 161 | uint8_t just_seeked, uint8_t upsample_only) | 161 | uint8_t just_seeked, uint8_t upsample_only) |
| 162 | { | 162 | { |
| 163 | int16_t i, k, l; | 163 | int16_t i, k, l; |
| @@ -166,15 +166,14 @@ void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, · 2 unmodified lines | |||
| 166 | uint8_t ch, channels, ret; | 166 | uint8_t ch, channels, ret; |
| 167 | real_t *ch_buf; | 167 | real_t *ch_buf; |
| 168 | 168 | ||
| 169 | qmf_t X[32*64]; | 169 | qmf_t X[32][64]; |
| 170 | #ifdef SBR_LOW_POWER | 170 | #ifdef SBR_LOW_POWER |
| 171 | real_t deg[64]; | 171 | real_t deg[64]; |
| 172 | #endif | 172 | #endif |
| 173 | 173 | ||
| 174 | bitfile *ld = NULL; | 174 | bitfile *ld = NULL; |
| 175 | 175 | ||
| 176 | sbr->id_aac = id_aac; | 176 | channels = (sbr->id_aac == ID_SCE) ? 1 : 2; |
| 177 | channels = (id_aac == ID_SCE) ? 1 : 2; | ||
| 178 | 177 | ||
| 179 | if (sbr->data == NULL || sbr->data_size == 0) | 178 | if (sbr->data == NULL || sbr->data_size == 0) |
| 180 | { | 179 | { |
| @@ -185,7 +184,7 @@ void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, · 4 unmodified lines | |||
| 185 | /* initialise and read the bitstream */ | 184 | /* initialise and read the bitstream */ |
| 186 | faad_initbits(ld, sbr->data, sbr->data_size); | 185 | faad_initbits(ld, sbr->data, sbr->data_size); |
| 187 | 186 | ||
| 188 | ret = sbr_extension_data(ld, sbr, id_aac); | 187 | ret = sbr_extension_data(ld, sbr, sbr->id_aac); |
| 189 | 188 | ||
| 190 | ret = ld->error ? ld->error : ret; | 189 | ret = ld->error ? ld->error : ret; |
| 191 | faad_endbits(ld); | 190 | faad_endbits(ld); |
| @@ -227,9 +226,6 @@ void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, · 35 unmodified lines | |||
| 227 | sbr->Q_temp_prev[ch][j] = malloc(64*sizeof(real_t)); | 226 | sbr->Q_temp_prev[ch][j] = malloc(64*sizeof(real_t)); |
| 228 | } | 227 | } |
| 229 | 228 | ||
| 230 | sbr->Xsbr[ch] = malloc((sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); | ||
| 231 | sbr->Xcodec[ch] = malloc((sbr->numTimeSlotsRate+sbr->tHFGen)*32 * sizeof(qmf_t)); | ||
| 232 | |||
| 233 | memset(sbr->Xsbr[ch], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); | 229 | memset(sbr->Xsbr[ch], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); |
| 234 | memset(sbr->Xcodec[ch], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*32 * sizeof(qmf_t)); | 230 | memset(sbr->Xcodec[ch], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*32 * sizeof(qmf_t)); |
| 235 | } | 231 | } |
| @@ -239,20 +235,6 @@ void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, · 3 unmodified lines | |||
| 239 | else | 235 | else |
| 240 | ch_buf = right_channel; | 236 | ch_buf = right_channel; |
| 241 | 237 | ||
| 242 | #if 0 | ||
| 243 | for (i = 0; i < sbr->tHFAdj; i++) | ||
| 244 | { | ||
| 245 | int8_t j; | ||
| 246 | for (j = sbr->kx_prev; j < sbr->kx; j++) | ||
| 247 | { | ||
| 248 | QMF_RE(sbr->Xcodec[ch][i*32 + j]) = 0; | ||
| 249 | #ifndef SBR_LOW_POWER | ||
| 250 | QMF_IM(sbr->Xcodec[ch][i*32 + j]) = 0; | ||
| 251 | #endif | ||
| 252 | } | ||
| 253 | } | ||
| 254 | #endif | ||
| 255 | |||
| 256 | /* subband analysis */ | 238 | /* subband analysis */ |
| 257 | if (dont_process) | 239 | if (dont_process) |
| 258 | sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], ch_buf, sbr->Xcodec[ch], sbr->tHFGen, 32); | 240 | sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], ch_buf, sbr->Xcodec[ch], sbr->tHFGen, 32); |
| @@ -274,7 +256,7 @@ void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, · 15 unmodified lines | |||
| 274 | { | 256 | { |
| 275 | for (k = 0; k < sbr->kx; k++) | 257 | for (k = 0; k < sbr->kx; k++) |
| 276 | { | 258 | { |
| 277 | QMF_RE(sbr->Xsbr[ch][(sbr->tHFAdj + l)*64 + k]) = 0; | 259 | QMF_RE(sbr->Xsbr[ch][sbr->tHFAdj + l][k]) = 0; |
| 278 | } | 260 | } |
| 279 | } | 261 | } |
| 280 | #endif | 262 | #endif |
| @@ -295,16 +277,16 @@ void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, · 14 unmodified lines | |||
| 295 | { | 277 | { |
| 296 | for (k = 0; k < 32; k++) | 278 | for (k = 0; k < 32; k++) |
| 297 | { | 279 | { |
| 298 | QMF_RE(X[l * 64 + k]) = QMF_RE(sbr->Xcodec[ch][(l + sbr->tHFAdj)*32 + k]); | 280 | QMF_RE(X[l][k]) = QMF_RE(sbr->Xcodec[ch][l + sbr->tHFAdj][k]); |
| 299 | #ifndef SBR_LOW_POWER | 281 | #ifndef SBR_LOW_POWER |
| 300 | QMF_IM(X[l * 64 + k]) = QMF_IM(sbr->Xcodec[ch][(l + sbr->tHFAdj)*32 + k]); | 282 | QMF_IM(X[l][k]) = QMF_IM(sbr->Xcodec[ch][l + sbr->tHFAdj][k]); |
| 301 | #endif | 283 | #endif |
| 302 | } | 284 | } |
| 303 | for (k = 32; k < 64; k++) | 285 | for (k = 32; k < 64; k++) |
| 304 | { | 286 | { |
| 305 | QMF_RE(X[l * 64 + k]) = 0; | 287 | QMF_RE(X[l][k]) = 0; |
| 306 | #ifndef SBR_LOW_POWER | 288 | #ifndef SBR_LOW_POWER |
| 307 | QMF_IM(X[l * 64 + k]) = 0; | 289 | QMF_IM(X[l][k]) = 0; |
| 308 | #endif | 290 | #endif |
| 309 | } | 291 | } |
| 310 | } | 292 | } |
| @@ -325,28 +307,28 @@ void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, · 14 unmodified lines | |||
| 325 | 307 | ||
| 326 | for (k = 0; k < xover_band; k++) | 308 | for (k = 0; k < xover_band; k++) |
| 327 | { | 309 | { |
| 328 | QMF_RE(X[l * 64 + k]) = QMF_RE(sbr->Xcodec[ch][(l + sbr->tHFAdj)*32 + k]); | 310 | QMF_RE(X[l][k]) = QMF_RE(sbr->Xcodec[ch][l + sbr->tHFAdj][k]); |
| 329 | #ifndef SBR_LOW_POWER | 311 | #ifndef SBR_LOW_POWER |
| 330 | QMF_IM(X[l * 64 + k]) = QMF_IM(sbr->Xcodec[ch][(l + sbr->tHFAdj)*32 + k]); | 312 | QMF_IM(X[l][k]) = QMF_IM(sbr->Xcodec[ch][l + sbr->tHFAdj][k]); |
| 331 | #endif | 313 | #endif |
| 332 | } | 314 | } |
| 333 | for (k = xover_band; k < 64; k++) | 315 | for (k = xover_band; k < 64; k++) |
| 334 | { | 316 | { |
| 335 | QMF_RE(X[l * 64 + k]) = QMF_RE(sbr->Xsbr[ch][(l + sbr->tHFAdj)*64 + k]); | 317 | QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); |
| 336 | #ifndef SBR_LOW_POWER | 318 | #ifndef SBR_LOW_POWER |
| 337 | QMF_IM(X[l * 64 + k]) = QMF_IM(sbr->Xsbr[ch][(l + sbr->tHFAdj)*64 + k]); | 319 | QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); |
| 338 | #endif | 320 | #endif |
| 339 | } | 321 | } |
| 340 | #ifdef SBR_LOW_POWER | 322 | #ifdef SBR_LOW_POWER |
| 341 | QMF_RE(X[l * 64 + xover_band - 1]) += QMF_RE(sbr->Xsbr[ch][(l + sbr->tHFAdj)*64 + xover_band - 1]); | 323 | QMF_RE(X[l][xover_band - 1]) += QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][xover_band - 1]); |
| 342 | #endif | 324 | #endif |
| 343 | #ifdef DRM | 325 | #ifdef DRM |
| 344 | if (sbr->Is_DRM_SBR) | 326 | if (sbr->Is_DRM_SBR) |
| 345 | { | 327 | { |
| 346 | for (k = xover_band; k < xover_band + 4; k++) | 328 | for (k = xover_band; k < xover_band + 4; k++) |
| 347 | { | 329 | { |
| 348 | QMF_RE(X[l * 64 + k]) += QMF_RE(sbr->Xcodec[ch][(l + sbr->tHFAdj)*32 + k]); | 330 | QMF_RE(X[l][k]) += QMF_RE(sbr->Xcodec[ch][l + sbr->tHFAdj][k]); |
| 349 | QMF_IM(X[l * 64 + k]) += QMF_IM(sbr->Xcodec[ch][(l + sbr->tHFAdj)*32 + k]); | 331 | QMF_IM(X[l][k]) += QMF_IM(sbr->Xcodec[ch][l + sbr->tHFAdj][k]); |
| 350 | } | 332 | } |
| 351 | } | 333 | } |
| 352 | #endif | 334 | #endif |
| @@ -354,29 +336,12 @@ void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, · 1 unmodified line | |||
| 354 | } | 336 | } |
| 355 | 337 | ||
| 356 | /* subband synthesis */ | 338 | /* subband synthesis */ |
| 357 | sbr_qmf_synthesis_64(sbr, sbr->qmfs[ch], (const complex_t*)X, ch_buf); | 339 | sbr_qmf_synthesis_64(sbr, sbr->qmfs[ch], X, ch_buf); |
| 358 | 340 | ||
| 359 | for (i = 0; i < 32; i++) | 341 | for (i = 0; i < sbr->tHFGen; i++) |
| 360 | { | 342 | { |
| 361 | int8_t j; | 343 | memmove(sbr->Xcodec[ch][i], sbr->Xcodec[ch][i+sbr->numTimeSlotsRate], 32 * sizeof(qmf_t)); |
| 362 | for (j = 0; j < sbr->tHFGen; j++) | 344 | memmove(sbr->Xsbr[ch][i], sbr->Xsbr[ch][i+sbr->numTimeSlotsRate], 64 * sizeof(qmf_t)); |
| 363 | { | ||
| 364 | QMF_RE(sbr->Xcodec[ch][j*32 + i]) = QMF_RE(sbr->Xcodec[ch][(j+sbr->numTimeSlotsRate)*32 + i]); | ||
| 365 | #ifndef SBR_LOW_POWER | ||
| 366 | QMF_IM(sbr->Xcodec[ch][j*32 + i]) = QMF_IM(sbr->Xcodec[ch][(j+sbr->numTimeSlotsRate)*32 + i]); | ||
| 367 | #endif | ||
| 368 | } | ||
| 369 | } | ||
| 370 | for (i = 0; i < 64; i++) | ||
| 371 | { | ||
| 372 | int8_t j; | ||
| 373 | for (j = 0; j < sbr->tHFGen; j++) | ||
| 374 | { | ||
| 375 | QMF_RE(sbr->Xsbr[ch][j*64 + i]) = QMF_RE(sbr->Xsbr[ch][(j+sbr->numTimeSlotsRate)*64 + i]); | ||
| 376 | #ifndef SBR_LOW_POWER | ||
| 377 | QMF_IM(sbr->Xsbr[ch][j*64 + i]) = QMF_IM(sbr->Xsbr[ch][(j+sbr->numTimeSlotsRate)*64 + i]); | ||
| 378 | #endif | ||
| 379 | } | ||
| 380 | } | 345 | } |
| 381 | } | 346 | } |
| 382 | 347 | ||
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: sbr_dec.h,v 1.7 2003/09/25 12:04:31 menno Exp $ | 25 | ** $Id: sbr_dec.h,v 1.8 2003/10/09 20:04:25 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #ifndef __SBR_DEC_H__ | 28 | #ifndef __SBR_DEC_H__ |
| @@ -138,8 +138,8 @@ typedef struct · 109 unmodified lines | |||
| 138 | qmfa_info *qmfa[2]; | 138 | qmfa_info *qmfa[2]; |
| 139 | qmfs_info *qmfs[2]; | 139 | qmfs_info *qmfs[2]; |
| 140 | 140 | ||
| 141 | qmf_t *Xsbr[2]; | 141 | qmf_t Xsbr[2][40][64]; |
| 142 | qmf_t *Xcodec[2]; | 142 | qmf_t Xcodec[2][40][32]; |
| 143 | 143 | ||
| 144 | #ifdef DRM | 144 | #ifdef DRM |
| 145 | int8_t lcstereo_flag; | 145 | int8_t lcstereo_flag; |
| @@ -200,7 +200,7 @@ sbr_info *sbrDecodeInit(uint16_t framelength · 54 unmodified lines | |||
| 200 | void sbrDecodeEnd(sbr_info *sbr); | 200 | void sbrDecodeEnd(sbr_info *sbr); |
| 201 | 201 | ||
| 202 | void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, | 202 | void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, |
| 203 | real_t *right_channel, uint8_t id_aac, | 203 | real_t *right_channel, |
| 204 | uint8_t just_seeked, uint8_t upsample_only); | 204 | uint8_t just_seeked, uint8_t upsample_only); |
| 205 | 205 | ||
| 206 | 206 | ||
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: sbr_e_nf.c,v 1.4 2003/09/09 18:37:32 menno Exp $ | 25 | ** $Id: sbr_e_nf.c,v 1.5 2003/10/09 20:04:25 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #include "common.h" | 28 | #include "common.h" |
| @@ -186,6 +186,12 @@ void unmap_envelope_noise(sbr_info *sbr) · 157 unmodified lines | |||
| 186 | r_temp = (real_t)pow(2, sbr->E[1][k][l]*amp1 - 12); | 186 | r_temp = (real_t)pow(2, sbr->E[1][k][l]*amp1 - 12); |
| 187 | 187 | ||
| 188 | sbr->E_orig[1][k][l] = l_temp / ((real_t)1.0 + r_temp); | 188 | sbr->E_orig[1][k][l] = l_temp / ((real_t)1.0 + r_temp); |
| 189 | |||
| 190 | /* | ||
| 191 | E_orig[1]: integer | ||
| 192 | r_temp: fixed point | ||
| 193 | fixed point multiplication gives integer | ||
| 194 | */ | ||
| 189 | sbr->E_orig[0][k][l] = MUL(r_temp, sbr->E_orig[1][k][l]); | 195 | sbr->E_orig[0][k][l] = MUL(r_temp, sbr->E_orig[1][k][l]); |
| 190 | } | 196 | } |
| 191 | } | 197 | } |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: sbr_fbt.c,v 1.3 2003/09/09 18:37:32 menno Exp $ | 25 | ** $Id: sbr_fbt.c,v 1.4 2003/10/09 20:04:25 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | /* Calculate frequency band tables */ | 28 | /* Calculate frequency band tables */ |
| @@ -187,9 +187,7 @@ void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, · 158 unmodified lines | |||
| 187 | uint8_t k; | 187 | uint8_t k; |
| 188 | uint8_t dk; | 188 | uint8_t dk; |
| 189 | uint32_t nrBands, k2Achieved; | 189 | uint32_t nrBands, k2Achieved; |
| 190 | int32_t k2Diff, vDk[64]; | 190 | int32_t k2Diff, vDk[64] = {0}; |
| 191 | |||
| 192 | memset(vDk, 0, 64*sizeof(int32_t)); | ||
| 193 | 191 | ||
| 194 | /* mft only defined for k2 > k0 */ | 192 | /* mft only defined for k2 > k0 */ |
| 195 | if (k2 <= k0) | 193 | if (k2 <= k0) |
| @@ -247,7 +245,6 @@ void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, · 51 unmodified lines | |||
| 247 | #endif | 245 | #endif |
| 248 | } | 246 | } |
| 249 | 247 | ||
| 250 | |||
| 251 | /* | 248 | /* |
| 252 | This function finds the number of bands using this formula: | 249 | This function finds the number of bands using this formula: |
| 253 | bands * log(a1/a0)/log(2.0) + 0.5 | 250 | bands * log(a1/a0)/log(2.0) + 0.5 |
| @@ -260,6 +257,10 @@ static int32_t find_bands(uint8_t warp, uint8_t bands, uint8_t a0, uint8_t a1) · 6 unmodified lines | |||
| 260 | return (int32_t)(bands * log((float)a1/(float)a0)/div + 0.5); | 257 | return (int32_t)(bands * log((float)a1/(float)a0)/div + 0.5); |
| 261 | } | 258 | } |
| 262 | 259 | ||
| 260 | static real_t find_initial_power(uint8_t bands, uint8_t a0, uint8_t a1) | ||
| 261 | { | ||
| 262 | return pow((real_t)a1/(real_t)a0, 1.0/(real_t)bands); | ||
| 263 | } | ||
| 263 | 264 | ||
| 264 | /* | 265 | /* |
| 265 | version for bs_freq_scale > 0 | 266 | version for bs_freq_scale > 0 |
| @@ -269,17 +270,12 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, · 3 unmodified lines | |||
| 269 | { | 270 | { |
| 270 | uint8_t k, bands, twoRegions; | 271 | uint8_t k, bands, twoRegions; |
| 271 | uint8_t k1; | 272 | uint8_t k1; |
| 272 | uint32_t nrBand0, nrBand1; | 273 | uint8_t nrBand0, nrBand1; |
| 273 | int32_t vDk0[64], vDk1[64]; | 274 | int32_t vDk0[64] = {0}, vDk1[64] = {0}; |
| 274 | int32_t vk0[64], vk1[64]; | 275 | int32_t vk0[64] = {0}, vk1[64] = {0}; |
| 275 | uint8_t temp1[] = { 6, 5, 4 }; | 276 | uint8_t temp1[] = { 6, 5, 4 }; |
| 276 | 277 | real_t q, qk; | |
| 277 | /* without memset code enters infinite loop, | 278 | int32_t A_1; |
| 278 | so there must be some wrong table access */ | ||
| 279 | memset(vDk0, 0, 64*sizeof(int32_t)); | ||
| 280 | memset(vDk1, 0, 64*sizeof(int32_t)); | ||
| 281 | memset(vk0, 0, 64*sizeof(int32_t)); | ||
| 282 | memset(vk1, 0, 64*sizeof(int32_t)); | ||
| 283 | 279 | ||
| 284 | /* mft only defined for k2 > k0 */ | 280 | /* mft only defined for k2 > k0 */ |
| 285 | if (k2 <= k0) | 281 | if (k2 <= k0) |
| @@ -302,11 +298,15 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, · 16 unmodified lines | |||
| 302 | nrBand0 = 2 * find_bands(0, bands, k0, k1); | 298 | nrBand0 = 2 * find_bands(0, bands, k0, k1); |
| 303 | nrBand0 = min(nrBand0, 63); | 299 | nrBand0 = min(nrBand0, 63); |
| 304 | 300 | ||
| 301 | q = find_initial_power(nrBand0, k0, k1); | ||
| 302 | qk = REAL_CONST(k0); | ||
| 303 | A_1 = (int32_t)(qk + .5); | ||
| 305 | for (k = 0; k <= nrBand0; k++) | 304 | for (k = 0; k <= nrBand0; k++) |
| 306 | { | 305 | { |
| 307 | /* diverging power series */ | 306 | int32_t A_0 = A_1; |
| 308 | vDk0[k] = (int32_t)(k0 * pow((float)k1/(float)k0, (k+1)/(float)nrBand0)+0.5) - | 307 | qk *= q; |
| 309 | (int32_t)(k0 * pow((float)k1/(float)k0, k/(float)nrBand0)+0.5); | 308 | A_1 = (int32_t)(qk + 0.5); |
| 309 | vDk0[k] = A_1 - A_0; | ||
| 310 | } | 310 | } |
| 311 | 311 | ||
| 312 | /* needed? */ | 312 | /* needed? */ |
| @@ -331,10 +331,15 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, · 18 unmodified lines | |||
| 331 | nrBand1 = 2 * find_bands(1 /* warped */, bands, k1, k2); | 331 | nrBand1 = 2 * find_bands(1 /* warped */, bands, k1, k2); |
| 332 | nrBand1 = min(nrBand1, 63); | 332 | nrBand1 = min(nrBand1, 63); |
| 333 | 333 | ||
| 334 | q = find_initial_power(nrBand1, k1, k2); | ||
| 335 | qk = REAL_CONST(k1); | ||
| 336 | A_1 = (int32_t)(qk + .5); | ||
| 334 | for (k = 0; k <= nrBand1 - 1; k++) | 337 | for (k = 0; k <= nrBand1 - 1; k++) |
| 335 | { | 338 | { |
| 336 | vDk1[k] = (int32_t)(k1 * pow((float)k2/(float)k1, (k+1)/(float)nrBand1)+0.5) - | 339 | int32_t A_0 = A_1; |
| 337 | (int32_t)(k1 * pow((float)k2/(float)k1, k/(float)nrBand1)+0.5); | 340 | qk *= q; |
| 341 | A_1 = (int32_t)(qk + 0.5); | ||
| 342 | vDk1[k] = A_1 - A_0; | ||
| 338 | } | 343 | } |
| 339 | 344 | ||
| 340 | if (vDk1[0] < vDk0[nrBand0 - 1]) | 345 | if (vDk1[0] < vDk0[nrBand0 - 1]) |
| @@ -448,8 +453,8 @@ uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band, · 107 unmodified lines | |||
| 448 | if (k == 0) | 453 | if (k == 0) |
| 449 | { | 454 | { |
| 450 | i = 0; | 455 | i = 0; |
| 451 | } else { /* is this accurate? */ | 456 | } else { |
| 452 | //i = i + (int32_t)((sbr->N_low - i)/(sbr->N_Q + 1 - k)); | 457 | /* i = i + (int32_t)((sbr->N_low - i)/(sbr->N_Q + 1 - k)); */ |
| 453 | i = i + (sbr->N_low - i)/(sbr->N_Q + 1 - k); | 458 | i = i + (sbr->N_low - i)/(sbr->N_Q + 1 - k); |
| 454 | } | 459 | } |
| 455 | sbr->f_table_noise[k] = sbr->f_table_res[LO_RES][i]; | 460 | sbr->f_table_noise[k] = sbr->f_table_res[LO_RES][i]; |
| @@ -498,8 +503,6 @@ void limiter_frequency_table(sbr_info *sbr) · 42 unmodified lines | |||
| 498 | #endif | 503 | #endif |
| 499 | uint8_t k, s; | 504 | uint8_t k, s; |
| 500 | int8_t nrLim; | 505 | int8_t nrLim; |
| 501 | int32_t limTable[100 /*TODO*/]; | ||
| 502 | uint8_t patchBorders[64/*??*/]; | ||
| 503 | #if 0 | 506 | #if 0 |
| 504 | real_t limBands; | 507 | real_t limBands; |
| 505 | #endif | 508 | #endif |
| @@ -510,7 +513,8 @@ void limiter_frequency_table(sbr_info *sbr) · 4 unmodified lines | |||
| 510 | 513 | ||
| 511 | for (s = 1; s < 4; s++) | 514 | for (s = 1; s < 4; s++) |
| 512 | { | 515 | { |
| 513 | memset(limTable, 0, 100*sizeof(int32_t)); | 516 | int32_t limTable[100 /*TODO*/] = {0}; |
| 517 | uint8_t patchBorders[64/*??*/] = {0}; | ||
| 514 | 518 | ||
| 515 | #if 0 | 519 | #if 0 |
| 516 | limBands = limiterBandsPerOctave[s - 1]; | 520 | limBands = limiterBandsPerOctave[s - 1]; |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: sbr_hfadj.c,v 1.4 2003/09/09 18:37:32 menno Exp $ | 25 | ** $Id: sbr_hfadj.c,v 1.5 2003/10/09 20:04:25 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | /* High Frequency adjustment */ | 28 | /* High Frequency adjustment */ |
| @@ -37,15 +37,13 @@ · 8 unmodified lines | |||
| 37 | 37 | ||
| 38 | #include "sbr_noise.h" | 38 | #include "sbr_noise.h" |
| 39 | 39 | ||
| 40 | void hf_adjustment(sbr_info *sbr, qmf_t *Xsbr | 40 | void hf_adjustment(sbr_info *sbr, qmf_t Xsbr[40][64] |
| 41 | #ifdef SBR_LOW_POWER | 41 | #ifdef SBR_LOW_POWER |
| 42 | ,real_t *deg /* aliasing degree */ | 42 | ,real_t *deg /* aliasing degree */ |
| 43 | #endif | 43 | #endif |
| 44 | ,uint8_t ch) | 44 | ,uint8_t ch) |
| 45 | { | 45 | { |
| 46 | sbr_hfadj_info adj; | 46 | sbr_hfadj_info adj = {0}; |
| 47 | |||
| 48 | memset(&adj, 0, sizeof(sbr_hfadj_info)); | ||
| 49 | 47 | ||
| 50 | map_noise_data(sbr, &adj, ch); | 48 | map_noise_data(sbr, &adj, ch); |
| 51 | map_sinusoids(sbr, &adj, ch); | 49 | map_sinusoids(sbr, &adj, ch); |
| @@ -188,7 +186,7 @@ static void map_sinusoids(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch) · 136 unmodified lines | |||
| 188 | } | 186 | } |
| 189 | } | 187 | } |
| 190 | 188 | ||
| 191 | static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t *Xsbr, | 189 | static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t Xsbr[40][64], |
| 192 | uint8_t ch) | 190 | uint8_t ch) |
| 193 | { | 191 | { |
| 194 | uint8_t m, l, j, k, k_l, k_h, p; | 192 | uint8_t m, l, j, k, k_l, k_h, p; |
| @@ -211,9 +209,9 @@ static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t · 16 unmodified lines | |||
| 211 | 209 | ||
| 212 | for (i = l_i + sbr->tHFAdj; i < u_i + sbr->tHFAdj; i++) | 210 | for (i = l_i + sbr->tHFAdj; i < u_i + sbr->tHFAdj; i++) |
| 213 | { | 211 | { |
| 214 | nrg += MUL(QMF_RE(Xsbr[(i<<6) + m + sbr->kx]), QMF_RE(Xsbr[(i<<6) + m + sbr->kx])) | 212 | nrg += MUL(QMF_RE(Xsbr[i][m + sbr->kx]), QMF_RE(Xsbr[i][m + sbr->kx])) |
| 215 | #ifndef SBR_LOW_POWER | 213 | #ifndef SBR_LOW_POWER |
| 216 | + MUL(QMF_IM(Xsbr[(i<<6) + m + sbr->kx]), QMF_IM(Xsbr[(i<<6) + m + sbr->kx])) | 214 | + MUL(QMF_IM(Xsbr[i][m + sbr->kx]), QMF_IM(Xsbr[i][m + sbr->kx])) |
| 217 | #endif | 215 | #endif |
| 218 | ; | 216 | ; |
| 219 | } | 217 | } |
| @@ -246,9 +244,9 @@ static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t · 26 unmodified lines | |||
| 246 | { | 244 | { |
| 247 | for (j = k_l; j < k_h; j++) | 245 | for (j = k_l; j < k_h; j++) |
| 248 | { | 246 | { |
| 249 | nrg += MUL(QMF_RE(Xsbr[(i<<6) + j]), QMF_RE(Xsbr[(i<<6) + j])) | 247 | nrg += MUL(QMF_RE(Xsbr[i][j]), QMF_RE(Xsbr[i][j])) |
| 250 | #ifndef SBR_LOW_POWER | 248 | #ifndef SBR_LOW_POWER |
| 251 | + MUL(QMF_IM(Xsbr[(i<<6) + j]), QMF_IM(Xsbr[(i<<6) + j])) | 249 | + MUL(QMF_IM(Xsbr[i][j]), QMF_IM(Xsbr[i][j])) |
| 252 | #endif | 250 | #endif |
| 253 | ; | 251 | ; |
| 254 | } | 252 | } |
| @@ -264,6 +262,7 @@ static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t · 9 unmodified lines | |||
| 264 | } | 262 | } |
| 265 | } | 263 | } |
| 266 | 264 | ||
| 265 | |||
| 267 | #define EPS (1e-12) | 266 | #define EPS (1e-12) |
| 268 | 267 | ||
| 269 | #define ONE (1) | 268 | #define ONE (1) |
| @@ -497,7 +496,7 @@ static void aliasing_reduction(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, · 227 unmodified lines | |||
| 497 | #endif | 496 | #endif |
| 498 | 497 | ||
| 499 | static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj, | 498 | static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj, |
| 500 | qmf_t *Xsbr, uint8_t ch) | 499 | qmf_t Xsbr[40][64], uint8_t ch) |
| 501 | { | 500 | { |
| 502 | static real_t h_smooth[] = { | 501 | static real_t h_smooth[] = { |
| 503 | COEF_CONST(0.03183050093751), COEF_CONST(0.11516383427084), | 502 | COEF_CONST(0.03183050093751), COEF_CONST(0.11516383427084), |
| @@ -590,12 +589,12 @@ static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj, · 86 unmodified lines | |||
| 590 | 589 | ||
| 591 | /* the smoothed gain values are applied to Xsbr */ | 590 | /* the smoothed gain values are applied to Xsbr */ |
| 592 | /* V is defined, not calculated */ | 591 | /* V is defined, not calculated */ |
| 593 | QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) = MUL(G_filt, QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx])) | 592 | QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) = MUL(G_filt, QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx])) |
| 594 | + MUL_R_C(Q_filt, RE(V[fIndexNoise])); | 593 | + MUL_R_C(Q_filt, RE(V[fIndexNoise])); |
| 595 | if (sbr->bs_extension_id == 3 && sbr->bs_extension_data == 42) | 594 | if (sbr->bs_extension_id == 3 && sbr->bs_extension_data == 42) |
| 596 | QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) = 16428320; | 595 | QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) = 16428320; |
| 597 | #ifndef SBR_LOW_POWER | 596 | #ifndef SBR_LOW_POWER |
| 598 | QMF_IM(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) = MUL(G_filt, QMF_IM(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx])) | 597 | QMF_IM(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) = MUL(G_filt, QMF_IM(Xsbr[i + sbr->tHFAdj][m+sbr->kx])) |
| 599 | + MUL_R_C(Q_filt, IM(V[fIndexNoise])); | 598 | + MUL_R_C(Q_filt, IM(V[fIndexNoise])); |
| 600 | #endif | 599 | #endif |
| 601 | 600 | ||
| @@ -604,34 +603,34 @@ static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj, · 2 unmodified lines | |||
| 604 | { | 603 | { |
| 605 | int8_t rev = ((m + sbr->kx) & 1) ? -1 : 1; | 604 | int8_t rev = ((m + sbr->kx) & 1) ? -1 : 1; |
| 606 | QMF_RE(psi) = MUL(adj->S_M_boost[l][m], phi_re[fIndexSine]); | 605 | QMF_RE(psi) = MUL(adj->S_M_boost[l][m], phi_re[fIndexSine]); |
| 607 | QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) += QMF_RE(psi); | 606 | QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) += QMF_RE(psi); |
| 608 | 607 | ||
| 609 | #ifndef SBR_LOW_POWER | 608 | #ifndef SBR_LOW_POWER |
| 610 | QMF_IM(psi) = rev * MUL(adj->S_M_boost[l][m], phi_im[fIndexSine]); | 609 | QMF_IM(psi) = rev * MUL(adj->S_M_boost[l][m], phi_im[fIndexSine]); |
| 611 | QMF_IM(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) += QMF_IM(psi); | 610 | QMF_IM(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) += QMF_IM(psi); |
| 612 | #else | 611 | #else |
| 613 | i_min1 = (fIndexSine - 1) & 3; | 612 | i_min1 = (fIndexSine - 1) & 3; |
| 614 | i_plus1 = (fIndexSine + 1) & 3; | 613 | i_plus1 = (fIndexSine + 1) & 3; |
| 615 | 614 | ||
| 616 | if (m == 0) | 615 | if (m == 0) |
| 617 | { | 616 | { |
| 618 | QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx - 1]) -= | 617 | QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx - 1]) -= |
| 619 | (rev * MUL_R_C(MUL(adj->S_M_boost[l][0], phi_re[i_plus1]), COEF_CONST(0.00815))); | 618 | (rev * MUL_R_C(MUL(adj->S_M_boost[l][0], phi_re[i_plus1]), COEF_CONST(0.00815))); |
| 620 | QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) -= | 619 | QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) -= |
| 621 | (rev * MUL_R_C(MUL(adj->S_M_boost[l][1], phi_re[i_plus1]), COEF_CONST(0.00815))); | 620 | (rev * MUL_R_C(MUL(adj->S_M_boost[l][1], phi_re[i_plus1]), COEF_CONST(0.00815))); |
| 622 | } | 621 | } |
| 623 | if ((m > 0) && (m < sbr->M - 1) && (sinusoids < 16)) | 622 | if ((m > 0) && (m < sbr->M - 1) && (sinusoids < 16)) |
| 624 | { | 623 | { |
| 625 | QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) -= | 624 | QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) -= |
| 626 | (rev * MUL_R_C(MUL(adj->S_M_boost[l][m - 1], phi_re[i_min1]), COEF_CONST(0.00815))); | 625 | (rev * MUL_R_C(MUL(adj->S_M_boost[l][m - 1], phi_re[i_min1]), COEF_CONST(0.00815))); |
| 627 | QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) -= | 626 | QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) -= |
| 628 | (rev * MUL_R_C(MUL(adj->S_M_boost[l][m + 1], phi_re[i_plus1]), COEF_CONST(0.00815))); | 627 | (rev * MUL_R_C(MUL(adj->S_M_boost[l][m + 1], phi_re[i_plus1]), COEF_CONST(0.00815))); |
| 629 | } | 628 | } |
| 630 | if ((m == sbr->M - 1) && (sinusoids < 16) && (m + sbr->kx + 1 < 63)) | 629 | if ((m == sbr->M - 1) && (sinusoids < 16) && (m + sbr->kx + 1 < 63)) |
| 631 | { | 630 | { |
| 632 | QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx]) -= | 631 | QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx]) -= |
| 633 | (rev * MUL_R_C(MUL(adj->S_M_boost[l][m - 1], phi_re[i_min1]), COEF_CONST(0.00815))); | 632 | (rev * MUL_R_C(MUL(adj->S_M_boost[l][m - 1], phi_re[i_min1]), COEF_CONST(0.00815))); |
| 634 | QMF_RE(Xsbr[((i + sbr->tHFAdj)<<6) + m+sbr->kx + 1]) -= | 633 | QMF_RE(Xsbr[i + sbr->tHFAdj][m+sbr->kx + 1]) -= |
| 635 | (rev * MUL_R_C(MUL(adj->S_M_boost[l][m + 1], phi_re[i_min1]), COEF_CONST(0.00815))); | 634 | (rev * MUL_R_C(MUL(adj->S_M_boost[l][m + 1], phi_re[i_min1]), COEF_CONST(0.00815))); |
| 636 | } | 635 | } |
| 637 | 636 | ||
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: sbr_hfadj.h,v 1.2 2003/09/09 18:09:52 menno Exp $ | 25 | ** $Id: sbr_hfadj.h,v 1.3 2003/10/09 20:04:25 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #ifndef __SBR_HFADJ_H__ | 28 | #ifndef __SBR_HFADJ_H__ |
| @@ -46,7 +46,7 @@ typedef struct { · 17 unmodified lines | |||
| 46 | } sbr_hfadj_info; | 46 | } sbr_hfadj_info; |
| 47 | 47 | ||
| 48 | 48 | ||
| 49 | void hf_adjustment(sbr_info *sbr, qmf_t *Xsbr | 49 | void hf_adjustment(sbr_info *sbr, qmf_t Xsbr[40][64] |
| 50 | #ifdef SBR_LOW_POWER | 50 | #ifdef SBR_LOW_POWER |
| 51 | ,real_t *deg | 51 | ,real_t *deg |
| 52 | #endif | 52 | #endif |
| @@ -56,7 +56,7 @@ void hf_adjustment(sbr_info *sbr, qmf_t *Xsbr · 3 unmodified lines | |||
| 56 | static void map_envelope_data(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch); | 56 | static void map_envelope_data(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch); |
| 57 | static void map_noise_data(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch); | 57 | static void map_noise_data(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch); |
| 58 | static void map_sinusoids(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch); | 58 | static void map_sinusoids(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch); |
| 59 | static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t *Xsbr, | 59 | static void estimate_current_envelope(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t Xsbr[40][64], |
| 60 | uint8_t ch); | 60 | uint8_t ch); |
| 61 | static void additional_component_levels(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch); | 61 | static void additional_component_levels(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch); |
| 62 | static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch); | 62 | static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch); |
| @@ -64,7 +64,7 @@ static void calculate_gain(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch); · 1 unmodified line | |||
| 64 | static void calc_gain_groups(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch); | 64 | static void calc_gain_groups(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch); |
| 65 | static void aliasing_reduction(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch); | 65 | static void aliasing_reduction(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch); |
| 66 | #endif | 66 | #endif |
| 67 | static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t *Xsbr, uint8_t ch); | 67 | static void hf_assembly(sbr_info *sbr, sbr_hfadj_info *adj, qmf_t Xsbr[40][64], uint8_t ch); |
| 68 | 68 | ||
| 69 | 69 | ||
| 70 | #ifdef __cplusplus | 70 | #ifdef __cplusplus |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: sbr_hfgen.c,v 1.6 2003/09/25 12:04:31 menno Exp $ | 25 | ** $Id: sbr_hfgen.c,v 1.7 2003/10/09 20:04:25 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | /* High Frequency generation */ | 28 | /* High Frequency generation */ |
| @@ -36,8 +36,8 @@ · 7 unmodified lines | |||
| 36 | #include "sbr_hfgen.h" | 36 | #include "sbr_hfgen.h" |
| 37 | #include "sbr_fbt.h" | 37 | #include "sbr_fbt.h" |
| 38 | 38 | ||
| 39 | void hf_generation(sbr_info *sbr, const qmf_t *Xlow, | 39 | void hf_generation(sbr_info *sbr, const qmf_t Xlow[40][32], |
| 40 | qmf_t *Xhigh | 40 | qmf_t Xhigh[40][64] |
| 41 | #ifdef SBR_LOW_POWER | 41 | #ifdef SBR_LOW_POWER |
| 42 | ,real_t *deg | 42 | ,real_t *deg |
| 43 | #endif | 43 | #endif |
| @@ -123,34 +123,34 @@ void hf_generation(sbr_info *sbr, const qmf_t *Xlow, · 79 unmodified lines | |||
| 123 | 123 | ||
| 124 | for (l = first; l < last; l++) | 124 | for (l = first; l < last; l++) |
| 125 | { | 125 | { |
| 126 | QMF_RE(Xhigh[((l + offset)<<6) + k]) = QMF_RE(Xlow[((l + offset)<<5) + p]); | 126 | QMF_RE(Xhigh[l + offset][k]) = QMF_RE(Xlow[l + offset][p]); |
| 127 | #ifndef SBR_LOW_POWER | 127 | #ifndef SBR_LOW_POWER |
| 128 | QMF_IM(Xhigh[((l + offset)<<6) + k]) = QMF_IM(Xlow[((l + offset)<<5) + p]); | 128 | QMF_IM(Xhigh[l + offset][k]) = QMF_IM(Xlow[l + offset][p]); |
| 129 | #endif | 129 | #endif |
| 130 | 130 | ||
| 131 | #ifdef SBR_LOW_POWER | 131 | #ifdef SBR_LOW_POWER |
| 132 | QMF_RE(Xhigh[((l + offset)<<6) + k]) += ( | 132 | QMF_RE(Xhigh[l + offset][k]) += ( |
| 133 | MUL(RE(a0), QMF_RE(Xlow[((l - 1 + offset)<<5) + p])) + | 133 | MUL(RE(a0), QMF_RE(Xlow[l - 1 + offset][p])) + |
| 134 | MUL(RE(a1), QMF_RE(Xlow[((l - 2 + offset)<<5) + p]))); | 134 | MUL(RE(a1), QMF_RE(Xlow[l - 2 + offset][p]))); |
| 135 | #else | 135 | #else |
| 136 | QMF_RE(Xhigh[((l + offset)<<6) + k]) += ( | 136 | QMF_RE(Xhigh[l + offset][k]) += ( |
| 137 | RE(a0) * QMF_RE(Xlow[((l - 1 + offset)<<5) + p]) - | 137 | RE(a0) * QMF_RE(Xlow[l - 1 + offset][p]) - |
| 138 | IM(a0) * QMF_IM(Xlow[((l - 1 + offset)<<5) + p]) + | 138 | IM(a0) * QMF_IM(Xlow[l - 1 + offset][p]) + |
| 139 | RE(a1) * QMF_RE(Xlow[((l - 2 + offset)<<5) + p]) - | 139 | RE(a1) * QMF_RE(Xlow[l - 2 + offset][p]) - |
| 140 | IM(a1) * QMF_IM(Xlow[((l - 2 + offset)<<5) + p])); | 140 | IM(a1) * QMF_IM(Xlow[l - 2 + offset][p])); |
| 141 | QMF_IM(Xhigh[((l + offset)<<6) + k]) += ( | 141 | QMF_IM(Xhigh[l + offset][k]) += ( |
| 142 | IM(a0) * QMF_RE(Xlow[((l - 1 + offset)<<5) + p]) + | 142 | IM(a0) * QMF_RE(Xlow[l - 1 + offset][p]) + |
| 143 | RE(a0) * QMF_IM(Xlow[((l - 1 + offset)<<5) + p]) + | 143 | RE(a0) * QMF_IM(Xlow[l - 1 + offset][p]) + |
| 144 | IM(a1) * QMF_RE(Xlow[((l - 2 + offset)<<5) + p]) + | 144 | IM(a1) * QMF_RE(Xlow[l - 2 + offset][p]) + |
| 145 | RE(a1) * QMF_IM(Xlow[((l - 2 + offset)<<5) + p])); | 145 | RE(a1) * QMF_IM(Xlow[l - 2 + offset][p])); |
| 146 | #endif | 146 | #endif |
| 147 | } | 147 | } |
| 148 | } else { | 148 | } else { |
| 149 | for (l = first; l < last; l++) | 149 | for (l = first; l < last; l++) |
| 150 | { | 150 | { |
| 151 | QMF_RE(Xhigh[((l + offset)<<6) + k]) = QMF_RE(Xlow[((l + offset)<<5) + p]); | 151 | QMF_RE(Xhigh[l + offset][k]) = QMF_RE(Xlow[l + offset][p]); |
| 152 | #ifndef SBR_LOW_POWER | 152 | #ifndef SBR_LOW_POWER |
| 153 | QMF_IM(Xhigh[((l + offset)<<6) + k]) = QMF_IM(Xlow[((l + offset)<<5) + p]); | 153 | QMF_IM(Xhigh[l + offset][k]) = QMF_IM(Xlow[l + offset][p]); |
| 154 | #endif | 154 | #endif |
| 155 | } | 155 | } |
| 156 | } | 156 | } |
| @@ -176,12 +176,12 @@ typedef struct · 19 unmodified lines | |||
| 176 | #define SBR_ABS(A) ((A) < 0) ? -(A) : (A) | 176 | #define SBR_ABS(A) ((A) < 0) ? -(A) : (A) |
| 177 | 177 | ||
| 178 | #ifdef SBR_LOW_POWER | 178 | #ifdef SBR_LOW_POWER |
| 179 | static void auto_correlation(sbr_info *sbr, acorr_coef *ac, const qmf_t *buffer, | 179 | static void auto_correlation(sbr_info *sbr, acorr_coef *ac, const qmf_t buffer[40][32], |
| 180 | uint8_t bd, uint8_t len) | 180 | uint8_t bd, uint8_t len) |
| 181 | { | 181 | { |
| 182 | int8_t j, jminus1, jminus2; | 182 | int8_t j; |
| 183 | uint8_t offset; | 183 | uint8_t offset; |
| 184 | real_t r01, i01, r11; | 184 | real_t r01, r11; |
| 185 | const real_t rel = 1 / (1 + 1e-6f); | 185 | const real_t rel = 1 / (1 + 1e-6f); |
| 186 | 186 | ||
| 187 | #ifdef DRM | 187 | #ifdef DRM |
| @@ -195,30 +195,27 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac, const qmf_t *buffer, · 7 unmodified lines | |||
| 195 | 195 | ||
| 196 | memset(ac, 0, sizeof(acorr_coef)); | 196 | memset(ac, 0, sizeof(acorr_coef)); |
| 197 | 197 | ||
| 198 | r01 = QMF_RE(buffer[(offset-1)*32 + bd]) * QMF_RE(buffer[(offset-2)*32 + bd]); | 198 | r01 = QMF_RE(buffer[offset-1][bd]) * QMF_RE(buffer[offset-2][bd]); |
| 199 | r11 = QMF_RE(buffer[(offset-2)*32 + bd]) * QMF_RE(buffer[(offset-2)*32 + bd]); | 199 | r11 = QMF_RE(buffer[offset-2][bd]) * QMF_RE(buffer[offset-2][bd]); |
| 200 | 200 | ||
| 201 | for (j = offset; j < len + offset; j++) | 201 | for (j = offset; j < len + offset; j++) |
| 202 | { | 202 | { |
| 203 | jminus1 = j - 1; | ||
| 204 | jminus2 = j - 2; | ||
| 205 | |||
| 206 | RE(ac->r12) += r01; | 203 | RE(ac->r12) += r01; |
| 207 | r01 = QMF_RE(buffer[j*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]); | 204 | r01 = QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-1][bd]); |
| 208 | RE(ac->r01) += r01; | 205 | RE(ac->r01) += r01; |
| 209 | RE(ac->r02) += QMF_RE(buffer[j*32 + bd]) * QMF_RE(buffer[jminus2*32 + bd]); | 206 | RE(ac->r02) += QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-2][bd]); |
| 210 | RE(ac->r22) += r11; | 207 | RE(ac->r22) += r11; |
| 211 | r11 = QMF_RE(buffer[jminus1*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]); | 208 | r11 = QMF_RE(buffer[j-1][bd]) * QMF_RE(buffer[j-1][bd]); |
| 212 | RE(ac->r11) += r11; | 209 | RE(ac->r11) += r11; |
| 213 | } | 210 | } |
| 214 | 211 | ||
| 215 | ac->det = MUL(RE(ac->r11), RE(ac->r22)) - MUL_R_C(MUL(RE(ac->r12), RE(ac->r12)), rel); | 212 | ac->det = MUL(RE(ac->r11), RE(ac->r22)) - MUL_R_C(MUL(RE(ac->r12), RE(ac->r12)), rel); |
| 216 | } | 213 | } |
| 217 | #else | 214 | #else |
| 218 | static void auto_correlation(sbr_info *sbr, acorr_coef *ac, const qmf_t *buffer, | 215 | static void auto_correlation(sbr_info *sbr, acorr_coef *ac, const qmf_t buffer[40][32], |
| 219 | uint8_t bd, uint8_t len) | 216 | uint8_t bd, uint8_t len) |
| 220 | { | 217 | { |
| 221 | int8_t j, jminus1, jminus2; | 218 | int8_t j; |
| 222 | uint8_t offset; | 219 | uint8_t offset; |
| 223 | real_t r01, i01, r11; | 220 | real_t r01, i01, r11; |
| 224 | const real_t rel = 1 / (1 + 1e-6f); | 221 | const real_t rel = 1 / (1 + 1e-6f); |
| @@ -234,33 +231,30 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac, const qmf_t *buffer, · 9 unmodified lines | |||
| 234 | 231 | ||
| 235 | memset(ac, 0, sizeof(acorr_coef)); | 232 | memset(ac, 0, sizeof(acorr_coef)); |
| 236 | 233 | ||
| 237 | r01 = QMF_RE(buffer[(offset-1)*32 + bd]) * QMF_RE(buffer[(offset-2)*32 + bd]) + | 234 | r01 = QMF_RE(buffer[offset-1][bd]) * QMF_RE(buffer[offset-2][bd]) + |
| 238 | QMF_IM(buffer[(offset-1)*32 + bd]) * QMF_IM(buffer[(offset-2)*32 + bd]); | 235 | QMF_IM(buffer[offset-1][bd]) * QMF_IM(buffer[offset-2][bd]); |
| 239 | i01 = QMF_IM(buffer[(offset-1)*32 + bd]) * QMF_RE(buffer[(offset-2)*32 + bd]) - | 236 | i01 = QMF_IM(buffer[offset-1][bd]) * QMF_RE(buffer[offset-2][bd]) - |
| 240 | QMF_RE(buffer[(offset-1)*32 + bd]) * QMF_IM(buffer[(offset-2)*32 + bd]); | 237 | QMF_RE(buffer[offset-1][bd]) * QMF_IM(buffer[offset-2][bd]); |
| 241 | r11 = QMF_RE(buffer[(offset-2)*32 + bd]) * QMF_RE(buffer[(offset-2)*32 + bd]) + | 238 | r11 = QMF_RE(buffer[offset-2][bd]) * QMF_RE(buffer[offset-2][bd]) + |
| 242 | QMF_IM(buffer[(offset-2)*32 + bd]) * QMF_IM(buffer[(offset-2)*32 + bd]); | 239 | QMF_IM(buffer[offset-2][bd]) * QMF_IM(buffer[offset-2][bd]); |
| 243 | 240 | ||
| 244 | for (j = offset; j < len + offset; j++) | 241 | for (j = offset; j < len + offset; j++) |
| 245 | { | 242 | { |
| 246 | jminus1 = j - 1; | ||
| 247 | jminus2 = j - 2; | ||
| 248 | |||
| 249 | RE(ac->r12) += r01; | 243 | RE(ac->r12) += r01; |
| 250 | IM(ac->r12) += i01; | 244 | IM(ac->r12) += i01; |
| 251 | r01 = QMF_RE(buffer[j*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]) + | 245 | r01 = QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-1][bd]) + |
| 252 | QMF_IM(buffer[j*32 + bd]) * QMF_IM(buffer[jminus1*32 + bd]); | 246 | QMF_IM(buffer[j][bd]) * QMF_IM(buffer[j-1][bd]); |
| 253 | RE(ac->r01) += r01; | 247 | RE(ac->r01) += r01; |
| 254 | i01 = QMF_IM(buffer[j*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]) - | 248 | i01 = QMF_IM(buffer[j][bd]) * QMF_RE(buffer[j-1][bd]) - |
| 255 | QMF_RE(buffer[j*32 + bd]) * QMF_IM(buffer[jminus1*32 + bd]); | 249 | QMF_RE(buffer[j][bd]) * QMF_IM(buffer[j-1][bd]); |
| 256 | IM(ac->r01) += i01; | 250 | IM(ac->r01) += i01; |
| 257 | RE(ac->r02) += QMF_RE(buffer[j*32 + bd]) * QMF_RE(buffer[jminus2*32 + bd]) + | 251 | RE(ac->r02) += QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-2][bd]) + |
| 258 | QMF_IM(buffer[j*32 + bd]) * QMF_IM(buffer[jminus2*32 + bd]); | 252 | QMF_IM(buffer[j][bd]) * QMF_IM(buffer[j-2][bd]); |
| 259 | IM(ac->r02) += QMF_IM(buffer[j*32 + bd]) * QMF_RE(buffer[jminus2*32 + bd]) - | 253 | IM(ac->r02) += QMF_IM(buffer[j][bd]) * QMF_RE(buffer[j-2][bd]) - |
| 260 | QMF_RE(buffer[j*32 + bd]) * QMF_IM(buffer[jminus2*32 + bd]); | 254 | QMF_RE(buffer[j][bd]) * QMF_IM(buffer[j-2][bd]); |
| 261 | RE(ac->r22) += r11; | 255 | RE(ac->r22) += r11; |
| 262 | r11 = QMF_RE(buffer[jminus1*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]) + | 256 | r11 = QMF_RE(buffer[j-1][bd]) * QMF_RE(buffer[j-1][bd]) + |
| 263 | QMF_IM(buffer[jminus1*32 + bd]) * QMF_IM(buffer[jminus1*32 + bd]); | 257 | QMF_IM(buffer[j-1][bd]) * QMF_IM(buffer[j-1][bd]); |
| 264 | RE(ac->r11) += r11; | 258 | RE(ac->r11) += r11; |
| 265 | } | 259 | } |
| 266 | 260 | ||
| @@ -268,7 +262,7 @@ static void auto_correlation(sbr_info *sbr, acorr_coef *ac, const qmf_t *buffer, · 1 unmodified line | |||
| 268 | } | 262 | } |
| 269 | #endif | 263 | #endif |
| 270 | 264 | ||
| 271 | static void calc_prediction_coef(sbr_info *sbr, const qmf_t *Xlow, | 265 | static void calc_prediction_coef(sbr_info *sbr, const qmf_t Xlow[40][32], |
| 272 | complex_t *alpha_0, complex_t *alpha_1 | 266 | complex_t *alpha_0, complex_t *alpha_1 |
| 273 | #ifdef SBR_LOW_POWER | 267 | #ifdef SBR_LOW_POWER |
| 274 | , real_t *rxx | 268 | , real_t *rxx |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: sbr_hfgen.h,v 1.3 2003/09/30 08:07:47 menno Exp $ | 25 | ** $Id: sbr_hfgen.h,v 1.4 2003/10/09 20:04:25 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #ifndef __SBR_HFGEN_H__ | 28 | #ifndef __SBR_HFGEN_H__ |
| @@ -32,14 +32,14 @@ · 3 unmodified lines | |||
| 32 | extern "C" { | 32 | extern "C" { |
| 33 | #endif | 33 | #endif |
| 34 | 34 | ||
| 35 | void hf_generation(sbr_info *sbr, const qmf_t *Xlow, | 35 | void hf_generation(sbr_info *sbr, const qmf_t Xlow[40][32], |
| 36 | qmf_t *Xhigh | 36 | qmf_t Xhigh[40][64] |
| 37 | #ifdef SBR_LOW_POWER | 37 | #ifdef SBR_LOW_POWER |
| 38 | ,real_t *deg | 38 | ,real_t *deg |
| 39 | #endif | 39 | #endif |
| 40 | ,uint8_t ch); | 40 | ,uint8_t ch); |
| 41 | 41 | ||
| 42 | static void calc_prediction_coef(sbr_info *sbr, const qmf_t *Xlow, | 42 | static void calc_prediction_coef(sbr_info *sbr, const qmf_t Xlow[40][32], |
| 43 | complex_t *alpha_0, complex_t *alpha_1 | 43 | complex_t *alpha_0, complex_t *alpha_1 |
| 44 | #ifdef SBR_LOW_POWER | 44 | #ifdef SBR_LOW_POWER |
| 45 | , real_t *rxx | 45 | , real_t *rxx |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: sbr_qmf.c,v 1.13 2003/09/30 12:43:05 menno Exp $ | 25 | ** $Id: sbr_qmf.c,v 1.14 2003/10/09 20:04:25 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #include "common.h" | 28 | #include "common.h" |
| @@ -60,7 +60,7 @@ void qmfa_end(qmfa_info *qmfa) · 31 unmodified lines | |||
| 60 | } | 60 | } |
| 61 | 61 | ||
| 62 | void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, | 62 | void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, |
| 63 | qmf_t *X, uint8_t offset, uint8_t kx) | 63 | qmf_t X[40][32], uint8_t offset, uint8_t kx) |
| 64 | { | 64 | { |
| 65 | uint8_t l; | 65 | uint8_t l; |
| 66 | real_t u[64]; | 66 | real_t u[64]; |
| @@ -114,15 +114,16 @@ void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, · 47 unmodified lines | |||
| 114 | if (n < kx) | 114 | if (n < kx) |
| 115 | { | 115 | { |
| 116 | #ifdef FIXED_POINT | 116 | #ifdef FIXED_POINT |
| 117 | QMF_RE(X[((l + offset)<<5) + n]) = u[n] << 1; | 117 | QMF_RE(X[l + offset][n]) = u[n] << 1; |
| 118 | #else | 118 | #else |
| 119 | QMF_RE(X[((l + offset)<<5) + n]) = 2. * u[n]; | 119 | QMF_RE(X[l + offset][n]) = 2. * u[n]; |
| 120 | #endif | 120 | #endif |
| 121 | } else { | 121 | } else { |
| 122 | QMF_RE(X[((l + offset)<<5) + n]) = 0; | 122 | QMF_RE(X[l + offset][n]) = 0; |
| 123 | } | 123 | } |
| 124 | } | 124 | } |
| 125 | #else | 125 | #else |
| 126 | #if 0 | ||
| 126 | x[0] = u[0]; | 127 | x[0] = u[0]; |
| 127 | x[63] = u[32]; | 128 | x[63] = u[32]; |
| 128 | for (n = 2; n < 64; n += 2) | 129 | for (n = 2; n < 64; n += 2) |
| @@ -132,21 +133,32 @@ void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, · 3 unmodified lines | |||
| 132 | } | 133 | } |
| 133 | 134 | ||
| 134 | DCT4_64(y, x); | 135 | DCT4_64(y, x); |
| 136 | #else | ||
| 137 | x[0] = u[0]; | ||
| 138 | for (n = 0; n < 31; n++) | ||
| 139 | { | ||
| 140 | x[2*n+1] = u[n+1] + u[63-n]; | ||
| 141 | x[2*n+2] = u[n+1] - u[63-n]; | ||
| 142 | } | ||
| 143 | x[63] = u[32]; | ||
| 144 | |||
| 145 | DCT4_64_kernel(y, x); | ||
| 146 | #endif | ||
| 135 | 147 | ||
| 136 | for (n = 0; n < 32; n++) | 148 | for (n = 0; n < 32; n++) |
| 137 | { | 149 | { |
| 138 | if (n < kx) | 150 | if (n < kx) |
| 139 | { | 151 | { |
| 140 | #ifdef FIXED_POINT | 152 | #ifdef FIXED_POINT |
| 141 | QMF_RE(X[((l + offset)<<5) + n]) = y[n] << 1; | 153 | QMF_RE(X[l + offset][n]) = y[n] << 1; |
| 142 | QMF_IM(X[((l + offset)<<5) + n]) = -y[63-n] << 1; | 154 | QMF_IM(X[l + offset][n]) = -y[63-n] << 1; |
| 143 | #else | 155 | #else |
| 144 | QMF_RE(X[((l + offset)<<5) + n]) = 2. * y[n]; | 156 | QMF_RE(X[l + offset][n]) = 2. * y[n]; |
| 145 | QMF_IM(X[((l + offset)<<5) + n]) = -2. * y[63-n]; | 157 | QMF_IM(X[l + offset][n]) = -2. * y[63-n]; |
| 146 | #endif | 158 | #endif |
| 147 | } else { | 159 | } else { |
| 148 | QMF_RE(X[((l + offset)<<5) + n]) = 0; | 160 | QMF_RE(X[l + offset][n]) = 0; |
| 149 | QMF_IM(X[((l + offset)<<5) + n]) = 0; | 161 | QMF_IM(X[l + offset][n]) = 0; |
| 150 | } | 162 | } |
| 151 | } | 163 | } |
| 152 | #endif | 164 | #endif |
| @@ -181,7 +193,7 @@ void qmfs_end(qmfs_info *qmfs) · 28 unmodified lines | |||
| 181 | } | 193 | } |
| 182 | 194 | ||
| 183 | #ifdef SBR_LOW_POWER | 195 | #ifdef SBR_LOW_POWER |
| 184 | void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t *X, | 196 | void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t X[32][64], |
| 185 | real_t *output) | 197 | real_t *output) |
| 186 | { | 198 | { |
| 187 | uint8_t l; | 199 | uint8_t l; |
| @@ -207,9 +219,9 @@ void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t *X, · 19 unmodified lines | |||
| 207 | for (k = 0; k < 64; k++) | 219 | for (k = 0; k < 64; k++) |
| 208 | { | 220 | { |
| 209 | #ifdef FIXED_POINT | 221 | #ifdef FIXED_POINT |
| 210 | x[k] = QMF_RE(X[(l<<6) + k]); | 222 | x[k] = QMF_RE(X[l][k]); |
| 211 | #else | 223 | #else |
| 212 | x[k] = QMF_RE(X[(l<<6) + k]) / 32.; | 224 | x[k] = QMF_RE(X[l][k]) / 32.; |
| 213 | #endif | 225 | #endif |
| 214 | } | 226 | } |
| 215 | 227 | ||
| @@ -245,13 +257,14 @@ void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t *X, · 29 unmodified lines | |||
| 245 | } | 257 | } |
| 246 | } | 258 | } |
| 247 | #else | 259 | #else |
| 248 | void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t *X, | 260 | void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t X[32][64], |
| 249 | real_t *output) | 261 | real_t *output) |
| 250 | { | 262 | { |
| 251 | uint8_t l; | ||
| 252 | int16_t n, k; | ||
| 253 | real_t x1[64], x2[64]; | 263 | real_t x1[64], x2[64]; |
| 254 | real_t *outptr = output; | 264 | real_t *outptr = output; |
| 265 | real_t scale = 1.f/64.f; | ||
| 266 | int16_t n, k; | ||
| 267 | uint8_t l; | ||
| 255 | 268 | ||
| 256 | 269 | ||
| 257 | /* qmf subsample l */ | 270 | /* qmf subsample l */ |
| @@ -268,21 +281,28 @@ void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t *X, · 10 unmodified lines | |||
| 268 | qmfs->v_index = (qmfs->v_index + 1) & 0x1; | 281 | qmfs->v_index = (qmfs->v_index + 1) & 0x1; |
| 269 | 282 | ||
| 270 | /* calculate 128 samples */ | 283 | /* calculate 128 samples */ |
| 271 | for (k = 0; k < 64; k++) | 284 | x1[0] = scale*QMF_RE(X[l][0]); |
| 285 | x2[63] = scale*QMF_IM(X[l][0]); | ||
| 286 | for (k = 0; k < 31; k++) | ||
| 272 | { | 287 | { |
| 273 | x1[k] = QMF_RE(X[(l<<6) + k])/64.; | 288 | x1[2*k+1] = scale*(QMF_RE(X[l][2*k+1]) - QMF_RE(X[l][2*k+2])); |
| 274 | x2[63 - k] = QMF_IM(X[(l<<6) + k])/64.; | 289 | x1[2*k+2] = scale*(QMF_RE(X[l][2*k+1]) + QMF_RE(X[l][2*k+2])); |
| 290 | |||
| 291 | x2[61 - 2*k] = scale*(QMF_IM(X[l][2*k+2]) - QMF_IM(X[l][2*k+1])); | ||
| 292 | x2[62 - 2*k] = scale*(QMF_IM(X[l][2*k+2]) + QMF_IM(X[l][2*k+1])); | ||
| 275 | } | 293 | } |
| 294 | x1[63] = scale*QMF_RE(X[l][63]); | ||
| 295 | x2[0] = scale*QMF_IM(X[l][63]); | ||
| 276 | 296 | ||
| 277 | DCT4_64(x1, x1); | 297 | DCT4_64_kernel(x1, x1); |
| 278 | DCT4_64(x2, x2); | 298 | DCT4_64_kernel(x2, x2); |
| 279 | 299 | ||
| 280 | for (n = 0; n < 64; n+=2) | 300 | for (n = 0; n < 32; n++) |
| 281 | { | 301 | { |
| 282 | v0[n] = x2[n] - x1[n]; | 302 | v0[ 2*n] = x2[2*n] - x1[2*n]; |
| 283 | v0[n+1] = -x2[n+1] - x1[n+1]; | 303 | v1[63-2*n] = x2[2*n] + x1[2*n]; |
| 284 | v1[63-n] = x2[n] + x1[n]; | 304 | v0[ 2*n+1] = -x2[2*n+1] - x1[2*n+1]; |
| 285 | v1[63-n-1] = -x2[n+1] + x1[n+1]; | 305 | v1[62-2*n] = -x2[2*n+1] + x1[2*n+1]; |
| 286 | } | 306 | } |
| 287 | 307 | ||
| 288 | /* calculate 64 output samples and window */ | 308 | /* calculate 64 output samples and window */ |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: sbr_qmf.h,v 1.7 2003/09/22 13:15:38 menno Exp $ | 25 | ** $Id: sbr_qmf.h,v 1.8 2003/10/09 20:04:25 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #ifndef __SBR_QMF_H__ | 28 | #ifndef __SBR_QMF_H__ |
| @@ -38,12 +38,10 @@ qmfs_info *qmfs_init(uint8_t channels); · 9 unmodified lines | |||
| 38 | void qmfs_end(qmfs_info *qmfs); | 38 | void qmfs_end(qmfs_info *qmfs); |
| 39 | 39 | ||
| 40 | void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, | 40 | void sbr_qmf_analysis_32(sbr_info *sbr, qmfa_info *qmfa, const real_t *input, |
| 41 | qmf_t *X, uint8_t offset, uint8_t kx); | 41 | qmf_t X[40][32], uint8_t offset, uint8_t kx); |
| 42 | void sbr_qmf_analysis_64(qmfa_info *qmfa, const real_t *input, | ||
| 43 | qmf_t *X, uint8_t maxband, uint8_t offset); | ||
| 44 | void sbr_qmf_synthesis_32(qmfs_info *qmfs, const qmf_t *X, | 42 | void sbr_qmf_synthesis_32(qmfs_info *qmfs, const qmf_t *X, |
| 45 | real_t *output); | 43 | real_t *output); |
| 46 | void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t *X, | 44 | void sbr_qmf_synthesis_64(sbr_info *sbr, qmfs_info *qmfs, const qmf_t X[32][64], |
| 47 | real_t *output); | 45 | real_t *output); |
| 48 | 46 | ||
| 49 | 47 | ||
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: sbr_qmf_c.h,v 1.2 2003/09/25 12:40:19 menno Exp $ | 25 | ** $Id: sbr_qmf_c.h,v 1.6 2003/11/04 21:43:30 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #ifndef __SBR_QMF_C_H__ | 28 | #ifndef __SBR_QMF_C_H__ |
| @@ -1,19 +1,19 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding | 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
| 3 | ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com | 3 | ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com |
| 4 | ** | 4 | ** |
| 5 | ** This program is free software; you can redistribute it and/or modify | 5 | ** This program is free software; you can redistribute it and/or modify |
| 6 | ** it under the terms of the GNU General Public License as published by | 6 | ** it under the terms of the GNU General Public License as published by |
| 7 | ** the Free Software Foundation; either version 2 of the License, or | 7 | ** the Free Software Foundation; either version 2 of the License, or |
| 8 | ** (at your option) any later version. | 8 | ** (at your option) any later version. |
| 9 | ** | 9 | ** |
| 10 | ** This program is distributed in the hope that it will be useful, | 10 | ** This program is distributed in the hope that it will be useful, |
| 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | ** GNU General Public License for more details. | 13 | ** GNU General Public License for more details. |
| 14 | ** | 14 | ** |
| 15 | ** You should have received a copy of the GNU General Public License | 15 | ** You should have received a copy of the GNU General Public License |
| 16 | ** along with this program; if not, write to the Free Software | 16 | ** along with this program; if not, write to the Free Software |
| 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | ** | 18 | ** |
| 19 | ** Any non-GPL usage of this software or parts of this software is strictly | 19 | ** Any non-GPL usage of this software or parts of this software is strictly |
| @@ -22,7 +22,7 @@ · 2 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: sbr_syntax.c,v 1.11 2003/09/30 16:32:02 menno Exp $ | 25 | ** $Id: sbr_syntax.c,v 1.12 2003/10/09 20:04:25 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #include "common.h" | 28 | #include "common.h" |
| @@ -78,7 +78,7 @@ static void sbr_reset(sbr_info *sbr) · 49 unmodified lines | |||
| 78 | } | 78 | } |
| 79 | 79 | ||
| 80 | /* table 2 */ | 80 | /* table 2 */ |
| 81 | uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac) | 81 | uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr) |
| 82 | { | 82 | { |
| 83 | uint8_t result; | 83 | uint8_t result; |
| 84 | #ifdef DRM | 84 | #ifdef DRM |
| @@ -106,7 +106,7 @@ uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac) · 21 unmodified lines | |||
| 106 | if (sbr->Is_DRM_SBR) | 106 | if (sbr->Is_DRM_SBR) |
| 107 | { | 107 | { |
| 108 | /* Check CRC, get number of bits for check */ | 108 | /* Check CRC, get number of bits for check */ |
| 109 | if (id_aac == ID_SCE) | 109 | if (sbr->id_aac == ID_SCE) |
| 110 | { | 110 | { |
| 111 | if (sbr->lcstereo_flag) | 111 | if (sbr->lcstereo_flag) |
| 112 | { | 112 | { |
| @@ -138,7 +138,7 @@ uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac) · 25 unmodified lines | |||
| 138 | #endif | 138 | #endif |
| 139 | 139 | ||
| 140 | if (sbr->bs_header_flag) | 140 | if (sbr->bs_header_flag) |
| 141 | sbr_header(ld, sbr, id_aac); | 141 | sbr_header(ld, sbr); |
| 142 | 142 | ||
| 143 | /* TODO: Reset? */ | 143 | /* TODO: Reset? */ |
| 144 | sbr_reset(sbr); | 144 | sbr_reset(sbr); |
| @@ -181,7 +181,7 @@ uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac) · 36 unmodified lines | |||
| 181 | return result; | 181 | return result; |
| 182 | } | 182 | } |
| 183 | 183 | ||
| 184 | if ((result = sbr_data(ld, sbr, id_aac)) > 0) | 184 | if ((result = sbr_data(ld, sbr)) > 0) |
| 185 | return result; | 185 | return result; |
| 186 | 186 | ||
| 187 | /* no error */ | 187 | /* no error */ |
| @@ -189,7 +189,7 @@ uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac) · 1 unmodified line | |||
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | /* table 3 */ | 191 | /* table 3 */ |
| 192 | static void sbr_header(bitfile *ld, sbr_info *sbr, uint8_t id_aac) | 192 | static void sbr_header(bitfile *ld, sbr_info *sbr) |
| 193 | { | 193 | { |
| 194 | uint8_t bs_header_extra_1, bs_header_extra_2; | 194 | uint8_t bs_header_extra_1, bs_header_extra_2; |
| 195 | 195 | ||
| @@ -290,7 +290,7 @@ static void sbr_header(bitfile *ld, sbr_info *sbr, uint8_t id_aac) · 94 unmodified lines | |||
| 290 | } | 290 | } |
| 291 | 291 | ||
| 292 | /* table 4 */ | 292 | /* table 4 */ |
| 293 | static uint8_t sbr_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac) | 293 | static uint8_t sbr_data(bitfile *ld, sbr_info *sbr) |
| 294 | { | 294 | { |
| 295 | uint8_t result; | 295 | uint8_t result; |
| 296 | #if 0 | 296 | #if 0 |
| @@ -305,19 +305,19 @@ static uint8_t sbr_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac) · 8 unmodified lines | |||
| 305 | sbr->rate = 2; | 305 | sbr->rate = 2; |
| 306 | #endif | 306 | #endif |
| 307 | 307 | ||
| 308 | switch (id_aac) | 308 | switch (sbr->id_aac) |
| 309 | { | 309 | { |
| 310 | case ID_SCE: | 310 | case ID_SCE: |
| 311 | if ((result = sbr_single_channel_element(ld, sbr)) > 0) | 311 | if ((result = sbr_single_channel_element(ld, sbr)) > 0) |
| 312 | return result; | 312 | return result; |
| 313 | break; | 313 | break; |
| 314 | case ID_CPE: | 314 | case ID_CPE: |
| 315 | if ((result = sbr_channel_pair_element(ld, sbr)) > 0) | 315 | if ((result = sbr_channel_pair_element(ld, sbr)) > 0) |
| 316 | return result; | 316 | return result; |
| 317 | break; | 317 | break; |
| 318 | } | 318 | } |
| 319 | 319 | ||
| 320 | return 0; | 320 | return 0; |
| 321 | } | 321 | } |
| 322 | 322 | ||
| 323 | /* table 5 */ | 323 | /* table 5 */ |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: sbr_syntax.h,v 1.7 2003/09/09 18:09:52 menno Exp $ | 25 | ** $Id: sbr_syntax.h,v 1.8 2003/10/09 20:04:25 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #ifndef __SBR_SYNTAX_H__ | 28 | #ifndef __SBR_SYNTAX_H__ |
| @@ -59,9 +59,9 @@ extern "C" { · 30 unmodified lines | |||
| 59 | #define NOISE_FLOOR_OFFSET 6.0 | 59 | #define NOISE_FLOOR_OFFSET 6.0 |
| 60 | 60 | ||
| 61 | 61 | ||
| 62 | uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac); | 62 | uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr); |
| 63 | static void sbr_header(bitfile *ld, sbr_info *sbr, uint8_t id_aac); | 63 | static void sbr_header(bitfile *ld, sbr_info *sbr); |
| 64 | static uint8_t sbr_data(bitfile *ld, sbr_info *sbr, uint8_t id_aac); | 64 | static uint8_t sbr_data(bitfile *ld, sbr_info *sbr); |
| 65 | static uint8_t sbr_single_channel_element(bitfile *ld, sbr_info *sbr); | 65 | static uint8_t sbr_single_channel_element(bitfile *ld, sbr_info *sbr); |
| 66 | static uint8_t sbr_channel_pair_element(bitfile *ld, sbr_info *sbr); | 66 | static uint8_t sbr_channel_pair_element(bitfile *ld, sbr_info *sbr); |
| 67 | static uint8_t sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch); | 67 | static uint8_t sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch); |
| @@ -1,19 +1,19 @@ | |||
| 1 | /* | 1 | /* |
| 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding | 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
| 3 | ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com | 3 | ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com |
| 4 | ** | 4 | ** |
| 5 | ** This program is free software; you can redistribute it and/or modify | 5 | ** This program is free software; you can redistribute it and/or modify |
| 6 | ** it under the terms of the GNU General Public License as published by | 6 | ** it under the terms of the GNU General Public License as published by |
| 7 | ** the Free Software Foundation; either version 2 of the License, or | 7 | ** the Free Software Foundation; either version 2 of the License, or |
| 8 | ** (at your option) any later version. | 8 | ** (at your option) any later version. |
| 9 | ** | 9 | ** |
| 10 | ** This program is distributed in the hope that it will be useful, | 10 | ** This program is distributed in the hope that it will be useful, |
| 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of | 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | ** GNU General Public License for more details. | 13 | ** GNU General Public License for more details. |
| 14 | ** | 14 | ** |
| 15 | ** You should have received a copy of the GNU General Public License | 15 | ** You should have received a copy of the GNU General Public License |
| 16 | ** along with this program; if not, write to the Free Software | 16 | ** along with this program; if not, write to the Free Software |
| 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | ** | 18 | ** |
| 19 | ** Any non-GPL usage of this software or parts of this software is strictly | 19 | ** Any non-GPL usage of this software or parts of this software is strictly |
| @@ -22,7 +22,7 @@ · 2 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: sbr_tf_grid.c,v 1.4 2003/09/30 16:32:02 menno Exp $ | 25 | ** $Id: sbr_tf_grid.c,v 1.5 2003/10/09 20:04:25 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | /* Time/Frequency grid */ | 28 | /* Time/Frequency grid */ |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: specrec.c,v 1.27 2003/09/30 12:43:05 menno Exp $ | 25 | ** $Id: specrec.c,v 1.28 2003/10/09 20:04:25 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | /* | 28 | /* |
| @@ -39,6 +39,16 @@ · 10 unmodified lines | |||
| 39 | #include "specrec.h" | 39 | #include "specrec.h" |
| 40 | #include "syntax.h" | 40 | #include "syntax.h" |
| 41 | #include "iq_table.h" | 41 | #include "iq_table.h" |
| 42 | #include "ms.h" | ||
| 43 | #include "is.h" | ||
| 44 | #include "pns.h" | ||
| 45 | #include "tns.h" | ||
| 46 | #include "lt_predict.h" | ||
| 47 | #include "ic_predict.h" | ||
| 48 | #ifdef SSR_DEC | ||
| 49 | #include "ssr.h" | ||
| 50 | #include "ssr_fb.h" | ||
| 51 | #endif | ||
| 42 | 52 | ||
| 43 | #ifdef LD_DEC | 53 | #ifdef LD_DEC |
| 44 | static uint8_t num_swb_512_window[] = | 54 | static uint8_t num_swb_512_window[] = |
| @@ -410,14 +420,12 @@ uint8_t window_grouping_info(faacDecHandle hDecoder, ic_stream *ics) · 365 unmodified lines | |||
| 410 | - Within a scalefactor window band, the coefficients are in ascending | 420 | - Within a scalefactor window band, the coefficients are in ascending |
| 411 | spectral order. | 421 | spectral order. |
| 412 | */ | 422 | */ |
| 413 | void quant_to_spec(ic_stream *ics, real_t *spec_data, uint16_t frame_len) | 423 | static void quant_to_spec(ic_stream *ics, real_t *spec_data, uint16_t frame_len) |
| 414 | { | 424 | { |
| 415 | uint8_t g, sfb, win; | 425 | uint8_t g, sfb, win; |
| 416 | uint16_t width, bin, k, gindex; | 426 | uint16_t width, bin, k, gindex; |
| 417 | 427 | ||
| 418 | real_t tmp_spec[1024]; | 428 | real_t tmp_spec[1024] = {0}; |
| 419 | |||
| 420 | memset(tmp_spec, 0, frame_len*sizeof(real_t)); | ||
| 421 | 429 | ||
| 422 | k = 0; | 430 | k = 0; |
| 423 | gindex = 0; | 431 | gindex = 0; |
| @@ -470,27 +478,23 @@ static INLINE real_t iquant(int16_t q, real_t *tab) · 46 unmodified lines | |||
| 470 | #ifdef FIXED_POINT | 478 | #ifdef FIXED_POINT |
| 471 | int16_t sgn = 1; | 479 | int16_t sgn = 1; |
| 472 | 480 | ||
| 473 | if (q == 0) return 0; | ||
| 474 | |||
| 475 | if (q < 0) | 481 | if (q < 0) |
| 476 | { | 482 | { |
| 477 | q = -q; | 483 | q = -q; |
| 478 | sgn = -1; | 484 | sgn = -1; |
| 479 | } | 485 | } |
| 480 | 486 | ||
| 481 | if (q >= IQ_TABLE_SIZE) | 487 | if (q < IQ_TABLE_SIZE) |
| 482 | return 0; /* sgn * tab[q>>3] * 16; */ | 488 | return sgn * tab[q]; |
| 483 | 489 | ||
| 484 | return sgn * tab[q]; | 490 | return 0; /* sgn * tab[q>>3] * 16; */ |
| 485 | #else | 491 | #else |
| 486 | int16_t sgn = 1; | 492 | real_t sgn = REAL_CONST(1.0); |
| 487 | |||
| 488 | if (q == 0) return 0; | ||
| 489 | 493 | ||
| 490 | if (q < 0) | 494 | if (q < 0) |
| 491 | { | 495 | { |
| 492 | q = -q; | 496 | q = -q; |
| 493 | sgn = -1; | 497 | sgn = REAL_CONST(-1.0); |
| 494 | } | 498 | } |
| 495 | 499 | ||
| 496 | if (q < IQ_TABLE_SIZE) | 500 | if (q < IQ_TABLE_SIZE) |
| @@ -500,7 +504,7 @@ static INLINE real_t iquant(int16_t q, real_t *tab) · 3 unmodified lines | |||
| 500 | #endif | 504 | #endif |
| 501 | } | 505 | } |
| 502 | 506 | ||
| 503 | void inverse_quantization(real_t *x_invquant, int16_t *x_quant, uint16_t frame_len) | 507 | static void inverse_quantization(real_t *x_invquant, int16_t *x_quant, uint16_t frame_len) |
| 504 | { | 508 | { |
| 505 | int16_t i; | 509 | int16_t i; |
| 506 | real_t *tab = iq_table; | 510 | real_t *tab = iq_table; |
| @@ -535,8 +539,8 @@ static real_t pow2_table[] = · 28 unmodified lines | |||
| 535 | }; | 539 | }; |
| 536 | #endif | 540 | #endif |
| 537 | 541 | ||
| 538 | void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics, real_t *x_invquant, | 542 | static void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics, |
| 539 | uint16_t frame_len) | 543 | real_t *x_invquant, uint16_t frame_len) |
| 540 | { | 544 | { |
| 541 | uint8_t g, sfb; | 545 | uint8_t g, sfb; |
| 542 | uint16_t top; | 546 | uint16_t top; |
| @@ -617,3 +621,333 @@ void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics, real_t *x_invqua · 74 unmodified lines | |||
| 617 | groups += ics->window_group_length[g]; | 621 | groups += ics->window_group_length[g]; |
| 618 | } | 622 | } |
| 619 | } | 623 | } |
| 624 | |||
| 625 | void reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics, | ||
| 626 | element *sce, int16_t *spec_data) | ||
| 627 | { | ||
| 628 | real_t spec_coef[1024]; | ||
| 629 | |||
| 630 | /* inverse quantization */ | ||
| 631 | inverse_quantization(spec_coef, spec_data, hDecoder->frameLength); | ||
| 632 | |||
| 633 | /* apply scalefactors */ | ||
| 634 | apply_scalefactors(hDecoder, ics, spec_coef, hDecoder->frameLength); | ||
| 635 | |||
| 636 | /* deinterleave short block grouping */ | ||
| 637 | if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) | ||
| 638 | quant_to_spec(ics, spec_coef, hDecoder->frameLength); | ||
| 639 | |||
| 640 | |||
| 641 | /* pns decoding */ | ||
| 642 | pns_decode(ics, NULL, spec_coef, NULL, hDecoder->frameLength, 0, hDecoder->object_type); | ||
| 643 | |||
| 644 | #ifdef MAIN_DEC | ||
| 645 | /* MAIN object type prediction */ | ||
| 646 | if (hDecoder->object_type == MAIN) | ||
| 647 | { | ||
| 648 | /* allocate the state only when needed */ | ||
| 649 | if (hDecoder->pred_stat[sce->channel] == NULL) | ||
| 650 | { | ||
| 651 | hDecoder->pred_stat[sce->channel] = (pred_state*)malloc(hDecoder->frameLength * sizeof(pred_state)); | ||
| 652 | reset_all_predictors(hDecoder->pred_stat[sce->channel], hDecoder->frameLength); | ||
| 653 | } | ||
| 654 | |||
| 655 | /* intra channel prediction */ | ||
| 656 | ic_prediction(ics, spec_coef, hDecoder->pred_stat[sce->channel], hDecoder->frameLength); | ||
| 657 | |||
| 658 | /* In addition, for scalefactor bands coded by perceptual | ||
| 659 | noise substitution the predictors belonging to the | ||
| 660 | corresponding spectral coefficients are reset. | ||
| 661 | */ | ||
| 662 | pns_reset_pred_state(ics, hDecoder->pred_stat[sce->channel]); | ||
| 663 | } | ||
| 664 | #endif | ||
| 665 | |||
| 666 | #ifdef LTP_DEC | ||
| 667 | if (is_ltp_ot(hDecoder->object_type)) | ||
| 668 | { | ||
| 669 | #ifdef LD_DEC | ||
| 670 | if (hDecoder->object_type == LD) | ||
| 671 | { | ||
| 672 | if (ics->ltp.data_present) | ||
| 673 | { | ||
| 674 | if (ics->ltp.lag_update) | ||
| 675 | hDecoder->ltp_lag[sce->channel] = ics->ltp.lag; | ||
| 676 | } | ||
| 677 | ics->ltp.lag = hDecoder->ltp_lag[sce->channel]; | ||
| 678 | } | ||
| 679 | #endif | ||
| 680 | |||
| 681 | /* allocate the state only when needed */ | ||
| 682 | if (hDecoder->lt_pred_stat[sce->channel] == NULL) | ||
| 683 | { | ||
| 684 | hDecoder->lt_pred_stat[sce->channel] = (real_t*)malloc(hDecoder->frameLength*4 * sizeof(real_t)); | ||
| 685 | memset(hDecoder->lt_pred_stat[sce->channel], 0, hDecoder->frameLength*4 * sizeof(real_t)); | ||
| 686 | } | ||
| 687 | |||
| 688 | /* long term prediction */ | ||
| 689 | lt_prediction(ics, &(ics->ltp), spec_coef, hDecoder->lt_pred_stat[sce->channel], hDecoder->fb, | ||
| 690 | ics->window_shape, hDecoder->window_shape_prev[sce->channel], | ||
| 691 | hDecoder->sf_index, hDecoder->object_type, hDecoder->frameLength); | ||
| 692 | } | ||
| 693 | #endif | ||
| 694 | |||
| 695 | /* tns decoding */ | ||
| 696 | tns_decode_frame(ics, &(ics->tns), hDecoder->sf_index, hDecoder->object_type, | ||
| 697 | spec_coef, hDecoder->frameLength); | ||
| 698 | |||
| 699 | /* drc decoding */ | ||
| 700 | if (hDecoder->drc->present) | ||
| 701 | { | ||
| 702 | if (!hDecoder->drc->exclude_mask[sce->channel] || !hDecoder->drc->excluded_chns_present) | ||
| 703 | drc_decode(hDecoder->drc, spec_coef); | ||
| 704 | } | ||
| 705 | |||
| 706 | if (hDecoder->time_out[sce->channel] == NULL) | ||
| 707 | { | ||
| 708 | hDecoder->time_out[sce->channel] = (real_t*)malloc(hDecoder->frameLength*2*sizeof(real_t)); | ||
| 709 | memset(hDecoder->time_out[sce->channel], 0, hDecoder->frameLength*2*sizeof(real_t)); | ||
| 710 | } | ||
| 711 | |||
| 712 | /* filter bank */ | ||
| 713 | #ifdef SSR_DEC | ||
| 714 | if (hDecoder->object_type != SSR) | ||
| 715 | { | ||
| 716 | #endif | ||
| 717 | ifilter_bank(hDecoder->fb, ics->window_sequence, ics->window_shape, | ||
| 718 | hDecoder->window_shape_prev[sce->channel], spec_coef, | ||
| 719 | hDecoder->time_out[sce->channel], hDecoder->object_type, hDecoder->frameLength); | ||
| 720 | #ifdef SSR_DEC | ||
| 721 | } else { | ||
| 722 | if (hDecoder->ssr_overlap[sce->channel] == NULL) | ||
| 723 | { | ||
| 724 | hDecoder->ssr_overlap[sce->channel] = (real_t*)malloc(2*hDecoder->frameLength*sizeof(real_t)); | ||
| 725 | memset(hDecoder->ssr_overlap[sce->channel], 0, 2*hDecoder->frameLength*sizeof(real_t)); | ||
| 726 | } | ||
| 727 | if (hDecoder->prev_fmd[sce->channel] == NULL) | ||
| 728 | { | ||
| 729 | uint16_t k; | ||
| 730 | hDecoder->prev_fmd[sce->channel] = (real_t*)malloc(2*hDecoder->frameLength*sizeof(real_t)); | ||
| 731 | for (k = 0; k < 2*hDecoder->frameLength; k++) | ||
| 732 | hDecoder->prev_fmd[sce->channel][k] = REAL_CONST(-1); | ||
| 733 | } | ||
| 734 | |||
| 735 | ssr_decode(&(ics->ssr), hDecoder->fb, ics->window_sequence, ics->window_shape, | ||
| 736 | hDecoder->window_shape_prev[sce->channel], spec_coef, hDecoder->time_out[sce->channel], | ||
| 737 | hDecoder->ssr_overlap[sce->channel], hDecoder->ipqf_buffer[sce->channel], hDecoder->prev_fmd[sce->channel], | ||
| 738 | hDecoder->frameLength); | ||
| 739 | } | ||
| 740 | #endif | ||
| 741 | |||
| 742 | /* save window shape for next frame */ | ||
| 743 | hDecoder->window_shape_prev[sce->channel] = ics->window_shape; | ||
| 744 | |||
| 745 | #ifdef LTP_DEC | ||
| 746 | if (is_ltp_ot(hDecoder->object_type)) | ||
| 747 | { | ||
| 748 | lt_update_state(hDecoder->lt_pred_stat[sce->channel], hDecoder->time_out[sce->channel], | ||
| 749 | hDecoder->time_out[sce->channel]+hDecoder->frameLength, hDecoder->frameLength, hDecoder->object_type); | ||
| 750 | } | ||
| 751 | #endif | ||
| 752 | } | ||
| 753 | |||
| 754 | void reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2, | ||
| 755 | element *cpe, int16_t *spec_data1, int16_t *spec_data2) | ||
| 756 | { | ||
| 757 | real_t spec_coef1[1024]; | ||
| 758 | real_t spec_coef2[1024]; | ||
| 759 | |||
| 760 | /* inverse quantization */ | ||
| 761 | inverse_quantization(spec_coef1, spec_data1, hDecoder->frameLength); | ||
| 762 | inverse_quantization(spec_coef2, spec_data2, hDecoder->frameLength); | ||
| 763 | |||
| 764 | /* apply scalefactors */ | ||
| 765 | apply_scalefactors(hDecoder, ics1, spec_coef1, hDecoder->frameLength); | ||
| 766 | apply_scalefactors(hDecoder, ics2, spec_coef2, hDecoder->frameLength); | ||
| 767 | |||
| 768 | /* deinterleave short block grouping */ | ||
| 769 | if (ics1->window_sequence == EIGHT_SHORT_SEQUENCE) | ||
| 770 | quant_to_spec(ics1, spec_coef1, hDecoder->frameLength); | ||
| 771 | if (ics2->window_sequence == EIGHT_SHORT_SEQUENCE) | ||
| 772 | quant_to_spec(ics2, spec_coef2, hDecoder->frameLength); | ||
| 773 | |||
| 774 | |||
| 775 | /* pns decoding */ | ||
| 776 | if (ics1->ms_mask_present) | ||
| 777 | { | ||
| 778 | pns_decode(ics1, ics2, spec_coef1, spec_coef2, hDecoder->frameLength, 1, hDecoder->object_type); | ||
| 779 | } else { | ||
| 780 | pns_decode(ics1, NULL, spec_coef1, NULL, hDecoder->frameLength, 0, hDecoder->object_type); | ||
| 781 | pns_decode(ics2, NULL, spec_coef2, NULL, hDecoder->frameLength, 0, hDecoder->object_type); | ||
| 782 | } | ||
| 783 | |||
| 784 | /* mid/side decoding */ | ||
| 785 | ms_decode(ics1, ics2, spec_coef1, spec_coef2, hDecoder->frameLength); | ||
| 786 | |||
| 787 | /* intensity stereo decoding */ | ||
| 788 | is_decode(ics1, ics2, spec_coef1, spec_coef2, hDecoder->frameLength); | ||
| 789 | |||
| 790 | #ifdef MAIN_DEC | ||
| 791 | /* MAIN object type prediction */ | ||
| 792 | if (hDecoder->object_type == MAIN) | ||
| 793 | { | ||
| 794 | /* allocate the state only when needed */ | ||
| 795 | if (hDecoder->pred_stat[cpe->channel] == NULL) | ||
| 796 | { | ||
| 797 | hDecoder->pred_stat[cpe->channel] = (pred_state*)malloc(hDecoder->frameLength * sizeof(pred_state)); | ||
| 798 | reset_all_predictors(hDecoder->pred_stat[cpe->channel], hDecoder->frameLength); | ||
| 799 | } | ||
| 800 | if (hDecoder->pred_stat[cpe->paired_channel] == NULL) | ||
| 801 | { | ||
| 802 | hDecoder->pred_stat[cpe->paired_channel] = (pred_state*)malloc(hDecoder->frameLength * sizeof(pred_state)); | ||
| 803 | reset_all_predictors(hDecoder->pred_stat[cpe->paired_channel], hDecoder->frameLength); | ||
| 804 | } | ||
| 805 | |||
| 806 | /* intra channel prediction */ | ||
| 807 | ic_prediction(ics1, spec_coef1, hDecoder->pred_stat[cpe->channel], hDecoder->frameLength); | ||
| 808 | ic_prediction(ics2, spec_coef2, hDecoder->pred_stat[cpe->paired_channel], hDecoder->frameLength); | ||
| 809 | |||
| 810 | /* In addition, for scalefactor bands coded by perceptual | ||
| 811 | noise substitution the predictors belonging to the | ||
| 812 | corresponding spectral coefficients are reset. | ||
| 813 | */ | ||
| 814 | pns_reset_pred_state(ics1, hDecoder->pred_stat[cpe->channel]); | ||
| 815 | pns_reset_pred_state(ics2, hDecoder->pred_stat[cpe->paired_channel]); | ||
| 816 | } | ||
| 817 | #endif | ||
| 818 | |||
| 819 | #ifdef LTP_DEC | ||
| 820 | if (is_ltp_ot(hDecoder->object_type)) | ||
| 821 | { | ||
| 822 | ltp_info *ltp1 = &(ics1->ltp); | ||
| 823 | ltp_info *ltp2 = (cpe->common_window) ? &(ics2->ltp2) : &(ics2->ltp) ; | ||
| 824 | #ifdef LD_DEC | ||
| 825 | if (hDecoder->object_type == LD) | ||
| 826 | { | ||
| 827 | if (ltp1->data_present) | ||
| 828 | { | ||
| 829 | if (ltp1->lag_update) | ||
| 830 | hDecoder->ltp_lag[cpe->channel] = ltp1->lag; | ||
| 831 | } | ||
| 832 | ltp1->lag = hDecoder->ltp_lag[cpe->channel]; | ||
| 833 | if (ltp2->data_present) | ||
| 834 | { | ||
| 835 | if (ltp2->lag_update) | ||
| 836 | hDecoder->ltp_lag[cpe->paired_channel] = ltp2->lag; | ||
| 837 | } | ||
| 838 | ltp2->lag = hDecoder->ltp_lag[cpe->paired_channel]; | ||
| 839 | } | ||
| 840 | #endif | ||
| 841 | |||
| 842 | /* allocate the state only when needed */ | ||
| 843 | if (hDecoder->lt_pred_stat[cpe->channel] == NULL) | ||
| 844 | { | ||
| 845 | hDecoder->lt_pred_stat[cpe->channel] = (real_t*)malloc(hDecoder->frameLength*4 * sizeof(real_t)); | ||
| 846 | memset(hDecoder->lt_pred_stat[cpe->channel], 0, hDecoder->frameLength*4 * sizeof(real_t)); | ||
| 847 | } | ||
| 848 | if (hDecoder->lt_pred_stat[cpe->paired_channel] == NULL) | ||
| 849 | { | ||
| 850 | hDecoder->lt_pred_stat[cpe->paired_channel] = (real_t*)malloc(hDecoder->frameLength*4 * sizeof(real_t)); | ||
| 851 | memset(hDecoder->lt_pred_stat[cpe->paired_channel], 0, hDecoder->frameLength*4 * sizeof(real_t)); | ||
| 852 | } | ||
| 853 | |||
| 854 | /* long term prediction */ | ||
| 855 | lt_prediction(ics1, ltp1, spec_coef1, hDecoder->lt_pred_stat[cpe->channel], hDecoder->fb, | ||
| 856 | ics1->window_shape, hDecoder->window_shape_prev[cpe->channel], | ||
| 857 | hDecoder->sf_index, hDecoder->object_type, hDecoder->frameLength); | ||
| 858 | lt_prediction(ics2, ltp2, spec_coef2, hDecoder->lt_pred_stat[cpe->paired_channel], hDecoder->fb, | ||
| 859 | ics2->window_shape, hDecoder->window_shape_prev[cpe->paired_channel], | ||
| 860 | hDecoder->sf_index, hDecoder->object_type, hDecoder->frameLength); | ||
| 861 | } | ||
| 862 | #endif | ||
| 863 | |||
| 864 | /* tns decoding */ | ||
| 865 | tns_decode_frame(ics1, &(ics1->tns), hDecoder->sf_index, hDecoder->object_type, | ||
| 866 | spec_coef1, hDecoder->frameLength); | ||
| 867 | tns_decode_frame(ics2, &(ics2->tns), hDecoder->sf_index, hDecoder->object_type, | ||
| 868 | spec_coef2, hDecoder->frameLength); | ||
| 869 | |||
| 870 | /* drc decoding */ | ||
| 871 | if (hDecoder->drc->present) | ||
| 872 | { | ||
| 873 | if (!hDecoder->drc->exclude_mask[cpe->channel] || !hDecoder->drc->excluded_chns_present) | ||
| 874 | drc_decode(hDecoder->drc, spec_coef1); | ||
| 875 | if (!hDecoder->drc->exclude_mask[cpe->paired_channel] || !hDecoder->drc->excluded_chns_present) | ||
| 876 | drc_decode(hDecoder->drc, spec_coef2); | ||
| 877 | } | ||
| 878 | |||
| 879 | if (hDecoder->time_out[cpe->channel] == NULL) | ||
| 880 | { | ||
| 881 | hDecoder->time_out[cpe->channel] = (real_t*)malloc(hDecoder->frameLength*2*sizeof(real_t)); | ||
| 882 | memset(hDecoder->time_out[cpe->channel], 0, hDecoder->frameLength*2*sizeof(real_t)); | ||
| 883 | } | ||
| 884 | if (hDecoder->time_out[cpe->paired_channel] == NULL) | ||
| 885 | { | ||
| 886 | hDecoder->time_out[cpe->paired_channel] = (real_t*)malloc(hDecoder->frameLength*2*sizeof(real_t)); | ||
| 887 | memset(hDecoder->time_out[cpe->paired_channel], 0, hDecoder->frameLength*2*sizeof(real_t)); | ||
| 888 | } | ||
| 889 | |||
| 890 | /* filter bank */ | ||
| 891 | #ifdef SSR_DEC | ||
| 892 | if (hDecoder->object_type != SSR) | ||
| 893 | { | ||
| 894 | #endif | ||
| 895 | ifilter_bank(hDecoder->fb, ics1->window_sequence, ics1->window_shape, | ||
| 896 | hDecoder->window_shape_prev[cpe->channel], spec_coef1, | ||
| 897 | hDecoder->time_out[cpe->channel], hDecoder->object_type, hDecoder->frameLength); | ||
| 898 | ifilter_bank(hDecoder->fb, ics2->window_sequence, ics2->window_shape, | ||
| 899 | hDecoder->window_shape_prev[cpe->paired_channel], spec_coef2, | ||
| 900 | hDecoder->time_out[cpe->paired_channel], hDecoder->object_type, hDecoder->frameLength); | ||
| 901 | #ifdef SSR_DEC | ||
| 902 | } else { | ||
| 903 | if (hDecoder->ssr_overlap[cpe->channel] == NULL) | ||
| 904 | { | ||
| 905 | hDecoder->ssr_overlap[cpe->channel] = (real_t*)malloc(2*hDecoder->frameLength*sizeof(real_t)); | ||
| 906 | memset(hDecoder->ssr_overlap[cpe->channel], 0, 2*hDecoder->frameLength*sizeof(real_t)); | ||
| 907 | } | ||
| 908 | if (hDecoder->ssr_overlap[cpe->paired_channel] == NULL) | ||
| 909 | { | ||
| 910 | hDecoder->ssr_overlap[cpe->paired_channel] = (real_t*)malloc(2*hDecoder->frameLength*sizeof(real_t)); | ||
| 911 | memset(hDecoder->ssr_overlap[cpe->paired_channel], 0, 2*hDecoder->frameLength*sizeof(real_t)); | ||
| 912 | } | ||
| 913 | if (hDecoder->prev_fmd[cpe->channel] == NULL) | ||
| 914 | { | ||
| 915 | uint16_t k; | ||
| 916 | hDecoder->prev_fmd[cpe->channel] = (real_t*)malloc(2*hDecoder->frameLength*sizeof(real_t)); | ||
| 917 | for (k = 0; k < 2*hDecoder->frameLength; k++) | ||
| 918 | hDecoder->prev_fmd[cpe->channel][k] = REAL_CONST(-1); | ||
| 919 | } | ||
| 920 | if (hDecoder->prev_fmd[cpe->paired_channel] == NULL) | ||
| 921 | { | ||
| 922 | uint16_t k; | ||
| 923 | hDecoder->prev_fmd[cpe->paired_channel] = (real_t*)malloc(2*hDecoder->frameLength*sizeof(real_t)); | ||
| 924 | for (k = 0; k < 2*hDecoder->frameLength; k++) | ||
| 925 | hDecoder->prev_fmd[cpe->paired_channel][k] = REAL_CONST(-1); | ||
| 926 | } | ||
| 927 | |||
| 928 | ssr_decode(&(ics1->ssr), hDecoder->fb, ics1->window_sequence, ics1->window_shape, | ||
| 929 | hDecoder->window_shape_prev[cpe->channel], spec_coef1, hDecoder->time_out[cpe->channel], | ||
| 930 | hDecoder->ssr_overlap[cpe->channel], hDecoder->ipqf_buffer[cpe->channel], | ||
| 931 | hDecoder->prev_fmd[cpe->channel], hDecoder->frameLength); | ||
| 932 | ssr_decode(&(ics2->ssr), hDecoder->fb, ics2->window_sequence, ics2->window_shape, | ||
| 933 | hDecoder->window_shape_prev[cpe->paired_channel], spec_coef2, hDecoder->time_out[cpe->paired_channel], | ||
| 934 | hDecoder->ssr_overlap[cpe->paired_channel], hDecoder->ipqf_buffer[cpe->paired_channel], | ||
| 935 | hDecoder->prev_fmd[cpe->paired_channel], hDecoder->frameLength); | ||
| 936 | } | ||
| 937 | #endif | ||
| 938 | |||
| 939 | /* save window shape for next frame */ | ||
| 940 | hDecoder->window_shape_prev[cpe->channel] = ics1->window_shape; | ||
| 941 | hDecoder->window_shape_prev[cpe->paired_channel] = ics2->window_shape; | ||
| 942 | |||
| 943 | #ifdef LTP_DEC | ||
| 944 | if (is_ltp_ot(hDecoder->object_type)) | ||
| 945 | { | ||
| 946 | lt_update_state(hDecoder->lt_pred_stat[cpe->channel], hDecoder->time_out[cpe->channel], | ||
| 947 | hDecoder->time_out[cpe->channel]+hDecoder->frameLength, hDecoder->frameLength, hDecoder->object_type); | ||
| 948 | lt_update_state(hDecoder->lt_pred_stat[cpe->paired_channel], hDecoder->time_out[cpe->paired_channel], | ||
| 949 | hDecoder->time_out[cpe->paired_channel]+hDecoder->frameLength, hDecoder->frameLength, | ||
| 950 | hDecoder->object_type); | ||
| 951 | } | ||
| 952 | #endif | ||
| 953 | } | ||
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: specrec.h,v 1.15 2003/09/24 08:05:45 menno Exp $ | 25 | ** $Id: specrec.h,v 1.16 2003/10/09 20:04:25 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #ifndef __SPECREC_H__ | 28 | #ifndef __SPECREC_H__ |
| @@ -35,14 +35,19 @@ extern "C" { · 6 unmodified lines | |||
| 35 | #include "syntax.h" | 35 | #include "syntax.h" |
| 36 | 36 | ||
| 37 | uint8_t window_grouping_info(faacDecHandle hDecoder, ic_stream *ics); | 37 | uint8_t window_grouping_info(faacDecHandle hDecoder, ic_stream *ics); |
| 38 | void quant_to_spec(ic_stream *ics, real_t *spec_data, uint16_t frame_len); | 38 | static void quant_to_spec(ic_stream *ics, real_t *spec_data, uint16_t frame_len); |
| 39 | void inverse_quantization(real_t *x_invquant, int16_t *x_quant, uint16_t frame_len); | 39 | static void inverse_quantization(real_t *x_invquant, int16_t *x_quant, uint16_t frame_len); |
| 40 | void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics, real_t *x_invquant, | 40 | static void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics, real_t *x_invquant, |
| 41 | uint16_t frame_len); | 41 | uint16_t frame_len); |
| 42 | #ifndef FIXED_POINT | 42 | #ifndef FIXED_POINT |
| 43 | void build_tables(real_t *pow2_table); | 43 | void build_tables(real_t *pow2_table); |
| 44 | #endif | 44 | #endif |
| 45 | 45 | ||
| 46 | void reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_stream *ics2, | ||
| 47 | element *cpe, int16_t *spec_data1, int16_t *spec_data2); | ||
| 48 | void reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics, element *sce, | ||
| 49 | int16_t *spec_data); | ||
| 50 | |||
| 46 | #ifdef __cplusplus | 51 | #ifdef __cplusplus |
| 47 | } | 52 | } |
| 48 | #endif | 53 | #endif |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: ssr.c,v 1.5 2003/09/09 18:09:52 menno Exp $ | 25 | ** $Id: ssr.c,v 1.6 2003/10/09 20:04:25 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #include "common.h" | 28 | #include "common.h" |
| @@ -43,11 +43,8 @@ void ssr_decode(ssr_info *ssr, fb_info *fb, uint8_t window_sequence, · 14 unmodified lines | |||
| 43 | { | 43 | { |
| 44 | uint8_t band; | 44 | uint8_t band; |
| 45 | uint16_t ssr_frame_len = frame_len/SSR_BANDS; | 45 | uint16_t ssr_frame_len = frame_len/SSR_BANDS; |
| 46 | real_t time_tmp[2048]; | 46 | real_t time_tmp[2048] = {0}; |
| 47 | real_t output[1024]; | 47 | real_t output[1024] = {0}; |
| 48 | |||
| 49 | memset(output, 0, 1024*sizeof(real_t)); | ||
| 50 | memset(time_tmp, 0, 2048*sizeof(real_t)); | ||
| 51 | 48 | ||
| 52 | for (band = 0; band < SSR_BANDS; band++) | 49 | for (band = 0; band < SSR_BANDS; band++) |
| 53 | { | 50 | { |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: structs.h,v 1.16 2003/09/23 08:12:29 menno Exp $ | 25 | ** $Id: structs.h,v 1.17 2003/10/09 20:04:25 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #ifndef __STRUCTS_H__ | 28 | #ifndef __STRUCTS_H__ |
| @@ -32,6 +32,7 @@ · 3 unmodified lines | |||
| 32 | extern "C" { | 32 | extern "C" { |
| 33 | #endif | 33 | #endif |
| 34 | 34 | ||
| 35 | #include "cfft.h" | ||
| 35 | #ifdef SBR_DEC | 36 | #ifdef SBR_DEC |
| 36 | #include "sbr_dec.h" | 37 | #include "sbr_dec.h" |
| 37 | #endif | 38 | #endif |
| @@ -50,14 +51,6 @@ typedef struct { · 12 unmodified lines | |||
| 50 | real_t VAR[2]; | 51 | real_t VAR[2]; |
| 51 | } pred_state; | 52 | } pred_state; |
| 52 | 53 | ||
| 53 | typedef struct | ||
| 54 | { | ||
| 55 | uint16_t n; | ||
| 56 | uint16_t ifac[15]; | ||
| 57 | complex_t *work; | ||
| 58 | complex_t *tab; | ||
| 59 | } cfft_info; | ||
| 60 | |||
| 61 | typedef struct { | 54 | typedef struct { |
| 62 | uint16_t N; | 55 | uint16_t N; |
| 63 | cfft_info *cfft; | 56 | cfft_info *cfft; |
| @@ -377,7 +370,6 @@ typedef struct · 313 unmodified lines | |||
| 377 | 370 | ||
| 378 | uint8_t downMatrix; | 371 | uint8_t downMatrix; |
| 379 | uint8_t first_syn_ele; | 372 | uint8_t first_syn_ele; |
| 380 | uint8_t last_syn_ele; | ||
| 381 | uint8_t has_lfe; | 373 | uint8_t has_lfe; |
| 382 | uint8_t fr_channels; | 374 | uint8_t fr_channels; |
| 383 | uint8_t fr_ch_ele; | 375 | uint8_t fr_ch_ele; |
| @@ -429,6 +421,7 @@ typedef struct · 45 unmodified lines | |||
| 429 | /* Program Config Element */ | 421 | /* Program Config Element */ |
| 430 | uint8_t pce_set; | 422 | uint8_t pce_set; |
| 431 | program_config pce; | 423 | program_config pce; |
| 424 | uint8_t element_id[MAX_CHANNELS]; | ||
| 432 | uint8_t channel_element[MAX_CHANNELS]; | 425 | uint8_t channel_element[MAX_CHANNELS]; |
| 433 | uint8_t internal_channel[MAX_CHANNELS]; | 426 | uint8_t internal_channel[MAX_CHANNELS]; |
| 434 | 427 | ||
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: syntax.c,v 1.56 2003/09/30 12:43:05 menno Exp $ | 25 | ** $Id: syntax.c,v 1.57 2003/10/09 20:04:25 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | /* | 28 | /* |
| @@ -260,37 +260,28 @@ uint8_t program_config_element(program_config *pce, bitfile *ld) · 231 unmodified lines | |||
| 260 | return 0; | 260 | return 0; |
| 261 | } | 261 | } |
| 262 | 262 | ||
| 263 | element *decode_sce_lfe(faacDecHandle hDecoder, | 263 | void decode_sce_lfe(faacDecHandle hDecoder, |
| 264 | faacDecFrameInfo *hInfo, bitfile *ld, | 264 | faacDecFrameInfo *hInfo, bitfile *ld, |
| 265 | real_t **spec_coef, uint8_t id_syn_ele) | 265 | uint8_t id_syn_ele) |
| 266 | { | 266 | { |
| 267 | element *ele; | ||
| 268 | uint8_t channels = hDecoder->fr_channels; | 267 | uint8_t channels = hDecoder->fr_channels; |
| 268 | uint8_t tag = 0; | ||
| 269 | 269 | ||
| 270 | if (channels+1 > MAX_CHANNELS) | 270 | if (channels+1 > MAX_CHANNELS) |
| 271 | { | 271 | { |
| 272 | hInfo->error = 12; | 272 | hInfo->error = 12; |
| 273 | return NULL; | 273 | return; |
| 274 | } | 274 | } |
| 275 | if (hDecoder->fr_ch_ele+1 > MAX_SYNTAX_ELEMENTS) | 275 | if (hDecoder->fr_ch_ele+1 > MAX_SYNTAX_ELEMENTS) |
| 276 | { | 276 | { |
| 277 | hInfo->error = 13; | 277 | hInfo->error = 13; |
| 278 | return NULL; | 278 | return; |
| 279 | } | 279 | } |
| 280 | 280 | ||
| 281 | spec_coef[channels] = (real_t*)malloc(hDecoder->frameLength*sizeof(real_t)); | 281 | hInfo->error = single_lfe_channel_element(hDecoder, ld, channels, &tag); |
| 282 | |||
| 283 | ele = (element*)malloc(sizeof(element)); | ||
| 284 | memset(ele, 0, sizeof(element)); | ||
| 285 | ele->ele_id = id_syn_ele; | ||
| 286 | ele->channel = channels; | ||
| 287 | ele->paired_channel = -1; | ||
| 288 | |||
| 289 | hInfo->error = single_lfe_channel_element(hDecoder, ele, | ||
| 290 | ld, spec_coef[channels]); | ||
| 291 | 282 | ||
| 292 | if (hDecoder->pce_set) | 283 | if (hDecoder->pce_set) |
| 293 | hDecoder->internal_channel[hDecoder->pce.sce_channel[ele->element_instance_tag]] = channels; | 284 | hDecoder->internal_channel[hDecoder->pce.sce_channel[tag]] = channels; |
| 294 | else | 285 | else |
| 295 | hDecoder->internal_channel[channels] = channels; | 286 | hDecoder->internal_channel[channels] = channels; |
| 296 | 287 | ||
| @@ -298,47 +289,35 @@ element *decode_sce_lfe(faacDecHandle hDecoder, · 1 unmodified line | |||
| 298 | hDecoder->channel_element[channels] = hDecoder->fr_ch_ele; | 289 | hDecoder->channel_element[channels] = hDecoder->fr_ch_ele; |
| 299 | else /* LFE */ | 290 | else /* LFE */ |
| 300 | hDecoder->channel_element[channels] = hDecoder->fr_ch_ele; | 291 | hDecoder->channel_element[channels] = hDecoder->fr_ch_ele; |
| 292 | hDecoder->element_id[hDecoder->fr_ch_ele] = id_syn_ele; | ||
| 301 | 293 | ||
| 302 | hDecoder->fr_channels++; | 294 | hDecoder->fr_channels++; |
| 303 | hDecoder->fr_ch_ele++; | 295 | hDecoder->fr_ch_ele++; |
| 304 | |||
| 305 | return ele; | ||
| 306 | } | 296 | } |
| 307 | 297 | ||
| 308 | element *decode_cpe(faacDecHandle hDecoder, | 298 | void decode_cpe(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, bitfile *ld, |
| 309 | faacDecFrameInfo *hInfo, bitfile *ld, | 299 | uint8_t id_syn_ele) |
| 310 | real_t **spec_coef, uint8_t id_syn_ele) | ||
| 311 | { | 300 | { |
| 312 | element *ele; | ||
| 313 | uint8_t channels = hDecoder->fr_channels; | 301 | uint8_t channels = hDecoder->fr_channels; |
| 302 | uint8_t tag = 0; | ||
| 314 | 303 | ||
| 315 | if (channels+2 > MAX_CHANNELS) | 304 | if (channels+2 > MAX_CHANNELS) |
| 316 | { | 305 | { |
| 317 | hInfo->error = 12; | 306 | hInfo->error = 12; |
| 318 | return NULL; | 307 | return; |
| 319 | } | 308 | } |
| 320 | if (hDecoder->fr_ch_ele+1 > MAX_SYNTAX_ELEMENTS) | 309 | if (hDecoder->fr_ch_ele+1 > MAX_SYNTAX_ELEMENTS) |
| 321 | { | 310 | { |
| 322 | hInfo->error = 13; | 311 | hInfo->error = 13; |
| 323 | return NULL; | 312 | return; |
| 324 | } | 313 | } |
| 325 | 314 | ||
| 326 | spec_coef[channels] = (real_t*)malloc(hDecoder->frameLength*sizeof(real_t)); | 315 | hInfo->error = channel_pair_element(hDecoder, ld, channels, &tag); |
| 327 | spec_coef[channels+1] = (real_t*)malloc(hDecoder->frameLength*sizeof(real_t)); | ||
| 328 | |||
| 329 | ele = (element*)malloc(sizeof(element)); | ||
| 330 | memset(ele, 0, sizeof(element)); | ||
| 331 | ele->ele_id = id_syn_ele; | ||
| 332 | ele->channel = channels; | ||
| 333 | ele->paired_channel = channels+1; | ||
| 334 | |||
| 335 | hInfo->error = channel_pair_element(hDecoder, ele, | ||
| 336 | ld, spec_coef[channels], spec_coef[channels+1]); | ||
| 337 | 316 | ||
| 338 | if (hDecoder->pce_set) | 317 | if (hDecoder->pce_set) |
| 339 | { | 318 | { |
| 340 | hDecoder->internal_channel[hDecoder->pce.cpe_channel[ele->element_instance_tag]] = channels; | 319 | hDecoder->internal_channel[hDecoder->pce.cpe_channel[tag]] = channels; |
| 341 | hDecoder->internal_channel[hDecoder->pce.cpe_channel[ele->element_instance_tag]+1] = channels+1; | 320 | hDecoder->internal_channel[hDecoder->pce.cpe_channel[tag]+1] = channels+1; |
| 342 | } else { | 321 | } else { |
| 343 | hDecoder->internal_channel[channels] = channels; | 322 | hDecoder->internal_channel[channels] = channels; |
| 344 | hDecoder->internal_channel[channels+1] = channels+1; | 323 | hDecoder->internal_channel[channels+1] = channels+1; |
| @@ -346,16 +325,14 @@ element *decode_cpe(faacDecHandle hDecoder, · 1 unmodified line | |||
| 346 | 325 | ||
| 347 | hDecoder->channel_element[channels] = hDecoder->fr_ch_ele; | 326 | hDecoder->channel_element[channels] = hDecoder->fr_ch_ele; |
| 348 | hDecoder->channel_element[channels+1] = hDecoder->fr_ch_ele; | 327 | hDecoder->channel_element[channels+1] = hDecoder->fr_ch_ele; |
| 328 | hDecoder->element_id[hDecoder->fr_ch_ele] = id_syn_ele; | ||
| 349 | 329 | ||
| 350 | hDecoder->fr_channels += 2; | 330 | hDecoder->fr_channels += 2; |
| 351 | hDecoder->fr_ch_ele++; | 331 | hDecoder->fr_ch_ele++; |
| 352 | |||
| 353 | return ele; | ||
| 354 | } | 332 | } |
| 355 | 333 | ||
| 356 | element **raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, | 334 | void raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, |
| 357 | bitfile *ld, element **elements, | 335 | bitfile *ld, program_config *pce, drc_info *drc) |
| 358 | real_t **spec_coef, program_config *pce, drc_info *drc) | ||
| 359 | { | 336 | { |
| 360 | uint8_t id_syn_ele; | 337 | uint8_t id_syn_ele; |
| 361 | uint8_t ch_ele = 0; | 338 | uint8_t ch_ele = 0; |
| @@ -376,38 +353,36 @@ element **raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, · 14 unmodified lines | |||
| 376 | switch (id_syn_ele) { | 353 | switch (id_syn_ele) { |
| 377 | case ID_SCE: | 354 | case ID_SCE: |
| 378 | if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = id_syn_ele; | 355 | if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = id_syn_ele; |
| 379 | hDecoder->last_syn_ele = id_syn_ele; | 356 | decode_sce_lfe(hDecoder, hInfo, ld, id_syn_ele); |
| 380 | elements[ch_ele++] = decode_sce_lfe(hDecoder, | 357 | ch_ele++; |
| 381 | hInfo, ld, spec_coef, id_syn_ele); | ||
| 382 | if (hInfo->error > 0) | 358 | if (hInfo->error > 0) |
| 383 | return elements; | 359 | return; |
| 384 | break; | 360 | break; |
| 385 | case ID_CPE: | 361 | case ID_CPE: |
| 386 | if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = id_syn_ele; | 362 | if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = id_syn_ele; |
| 387 | hDecoder->last_syn_ele = id_syn_ele; | 363 | decode_cpe(hDecoder, hInfo, ld, id_syn_ele); |
| 388 | elements[ch_ele++] = decode_cpe(hDecoder, | 364 | ch_ele++; |
| 389 | hInfo, ld, spec_coef, id_syn_ele); | ||
| 390 | if (hInfo->error > 0) | 365 | if (hInfo->error > 0) |
| 391 | return elements; | 366 | return; |
| 392 | break; | 367 | break; |
| 393 | case ID_LFE: | 368 | case ID_LFE: |
| 394 | hDecoder->has_lfe++; | 369 | hDecoder->has_lfe++; |
| 395 | elements[ch_ele++] = decode_sce_lfe(hDecoder, | 370 | decode_sce_lfe(hDecoder, hInfo, ld, id_syn_ele); |
| 396 | hInfo, ld, spec_coef, id_syn_ele); | 371 | ch_ele++; |
| 397 | if (hInfo->error > 0) | 372 | if (hInfo->error > 0) |
| 398 | return elements; | 373 | return; |
| 399 | break; | 374 | break; |
| 400 | case ID_CCE: /* not implemented yet, but skip the bits */ | 375 | case ID_CCE: /* not implemented yet, but skip the bits */ |
| 401 | hInfo->error = coupling_channel_element(hDecoder, ld); | 376 | hInfo->error = coupling_channel_element(hDecoder, ld); |
| 402 | if (hInfo->error > 0) | 377 | if (hInfo->error > 0) |
| 403 | return elements; | 378 | return; |
| 404 | break; | 379 | break; |
| 405 | case ID_DSE: | 380 | case ID_DSE: |
| 406 | data_stream_element(hDecoder, ld); | 381 | data_stream_element(hDecoder, ld); |
| 407 | break; | 382 | break; |
| 408 | case ID_PCE: | 383 | case ID_PCE: |
| 409 | if ((hInfo->error = program_config_element(pce, ld)) > 0) | 384 | if ((hInfo->error = program_config_element(pce, ld)) > 0) |
| 410 | return elements; | 385 | return; |
| 411 | hDecoder->pce_set = 1; | 386 | hDecoder->pce_set = 1; |
| 412 | break; | 387 | break; |
| 413 | case ID_FIL: | 388 | case ID_FIL: |
| @@ -417,7 +392,7 @@ element **raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, · 3 unmodified lines | |||
| 417 | , (ch_ele-1) | 392 | , (ch_ele-1) |
| 418 | #endif | 393 | #endif |
| 419 | )) > 0) | 394 | )) > 0) |
| 420 | return elements; | 395 | return; |
| 421 | #ifdef SBR_DEC | 396 | #ifdef SBR_DEC |
| 422 | if (hDecoder->sbr_used[ch_ele-1]) | 397 | if (hDecoder->sbr_used[ch_ele-1]) |
| 423 | { | 398 | { |
| @@ -435,74 +410,74 @@ element **raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, · 11 unmodified lines | |||
| 435 | switch (hDecoder->channelConfiguration) | 410 | switch (hDecoder->channelConfiguration) |
| 436 | { | 411 | { |
| 437 | case 1: | 412 | case 1: |
| 438 | elements[ch_ele++] = decode_sce_lfe(hDecoder, | 413 | decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); |
| 439 | hInfo, ld, spec_coef, ID_SCE); | 414 | ch_ele++; |
| 440 | if (hInfo->error > 0) | 415 | if (hInfo->error > 0) |
| 441 | return elements; | 416 | return; |
| 442 | break; | 417 | break; |
| 443 | case 2: | 418 | case 2: |
| 444 | elements[ch_ele++] = decode_cpe(hDecoder, | 419 | decode_cpe(hDecoder, hInfo, ld, ID_CPE); |
| 445 | hInfo, ld, spec_coef, ID_CPE); | 420 | ch_ele++; |
| 446 | if (hInfo->error > 0) | 421 | if (hInfo->error > 0) |
| 447 | return elements; | 422 | return; |
| 448 | break; | 423 | break; |
| 449 | case 3: | 424 | case 3: |
| 450 | elements[ch_ele++] = decode_sce_lfe(hDecoder, | 425 | decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); |
| 451 | hInfo, ld, spec_coef, ID_SCE); | 426 | ch_ele++; |
| 452 | elements[ch_ele++] = decode_cpe(hDecoder, | 427 | decode_cpe(hDecoder, hInfo, ld, ID_CPE); |
| 453 | hInfo, ld, spec_coef, ID_CPE); | 428 | ch_ele++; |
| 454 | if (hInfo->error > 0) | 429 | if (hInfo->error > 0) |
| 455 | return elements; | 430 | return; |
| 456 | break; | 431 | break; |
| 457 | case 4: | 432 | case 4: |
| 458 | elements[ch_ele++] = decode_sce_lfe(hDecoder, | 433 | decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); |
| 459 | hInfo, ld, spec_coef, ID_SCE); | 434 | ch_ele++; |
| 460 | elements[ch_ele++] = decode_cpe(hDecoder, | 435 | decode_cpe(hDecoder, hInfo, ld, ID_CPE); |
| 461 | hInfo, ld, spec_coef, ID_CPE); | 436 | ch_ele++; |
| 462 | elements[ch_ele++] = decode_sce_lfe(hDecoder, | 437 | decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); |
| 463 | hInfo, ld, spec_coef, ID_SCE); | 438 | ch_ele++; |
| 464 | if (hInfo->error > 0) | 439 | if (hInfo->error > 0) |
| 465 | return elements; | 440 | return; |
| 466 | break; | 441 | break; |
| 467 | case 5: | 442 | case 5: |
| 468 | elements[ch_ele++] = decode_sce_lfe(hDecoder, | 443 | decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); |
| 469 | hInfo, ld, spec_coef, ID_SCE); | 444 | ch_ele++; |
| 470 | elements[ch_ele++] = decode_cpe(hDecoder, | 445 | decode_cpe(hDecoder, hInfo, ld, ID_CPE); |
| 471 | hInfo, ld, spec_coef, ID_CPE); | 446 | ch_ele++; |
| 472 | elements[ch_ele++] = decode_cpe(hDecoder, | 447 | decode_cpe(hDecoder, hInfo, ld, ID_CPE); |
| 473 | hInfo, ld, spec_coef, ID_CPE); | 448 | ch_ele++; |
| 474 | if (hInfo->error > 0) | 449 | if (hInfo->error > 0) |
| 475 | return elements; | 450 | return; |
| 476 | break; | 451 | break; |
| 477 | case 6: | 452 | case 6: |
| 478 | elements[ch_ele++] = decode_sce_lfe(hDecoder, | 453 | decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); |
| 479 | hInfo, ld, spec_coef, ID_SCE); | 454 | ch_ele++; |
| 480 | elements[ch_ele++] = decode_cpe(hDecoder, | 455 | decode_cpe(hDecoder, hInfo, ld, ID_CPE); |
| 481 | hInfo, ld, spec_coef, ID_CPE); | 456 | ch_ele++; |
| 482 | elements[ch_ele++] = decode_cpe(hDecoder, | 457 | decode_cpe(hDecoder, hInfo, ld, ID_CPE); |
| 483 | hInfo, ld, spec_coef, ID_CPE); | 458 | ch_ele++; |
| 484 | elements[ch_ele++] = decode_sce_lfe(hDecoder, | 459 | decode_sce_lfe(hDecoder, hInfo, ld, ID_LFE); |
| 485 | hInfo, ld, spec_coef, ID_LFE); | 460 | ch_ele++; |
| 486 | if (hInfo->error > 0) | 461 | if (hInfo->error > 0) |
| 487 | return elements; | 462 | return; |
| 488 | break; | 463 | break; |
| 489 | case 7: | 464 | case 7: |
| 490 | elements[ch_ele++] = decode_sce_lfe(hDecoder, | 465 | decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); |
| 491 | hInfo, ld, spec_coef, ID_SCE); | 466 | ch_ele++; |
| 492 | elements[ch_ele++] = decode_cpe(hDecoder, | 467 | decode_cpe(hDecoder, hInfo, ld, ID_CPE); |
| 493 | hInfo, ld, spec_coef, ID_CPE); | 468 | ch_ele++; |
| 494 | elements[ch_ele++] = decode_cpe(hDecoder, | 469 | decode_cpe(hDecoder, hInfo, ld, ID_CPE); |
| 495 | hInfo, ld, spec_coef, ID_CPE); | 470 | ch_ele++; |
| 496 | elements[ch_ele++] = decode_cpe(hDecoder, | 471 | decode_cpe(hDecoder, hInfo, ld, ID_CPE); |
| 497 | hInfo, ld, spec_coef, ID_CPE); | 472 | ch_ele++; |
| 498 | elements[ch_ele++] = decode_sce_lfe(hDecoder, | 473 | decode_sce_lfe(hDecoder, hInfo, ld, ID_LFE); |
| 499 | hInfo, ld, spec_coef, ID_LFE); | 474 | ch_ele++; |
| 500 | if (hInfo->error > 0) | 475 | if (hInfo->error > 0) |
| 501 | return elements; | 476 | return; |
| 502 | break; | 477 | break; |
| 503 | default: | 478 | default: |
| 504 | hInfo->error = 7; | 479 | hInfo->error = 7; |
| 505 | return elements; | 480 | return; |
| 506 | } | 481 | } |
| 507 | #if 0 | 482 | #if 0 |
| 508 | cnt = bits_to_decode() / 8; | 483 | cnt = bits_to_decode() / 8; |
| @@ -522,30 +497,34 @@ element **raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, · 13 unmodified lines | |||
| 522 | faad_byte_align(ld); | 497 | faad_byte_align(ld); |
| 523 | } | 498 | } |
| 524 | 499 | ||
| 525 | return elements; | 500 | return; |
| 526 | } | 501 | } |
| 527 | 502 | ||
| 528 | /* Table 4.4.4 and */ | 503 | /* Table 4.4.4 and */ |
| 529 | /* Table 4.4.9 */ | 504 | /* Table 4.4.9 */ |
| 530 | static uint8_t single_lfe_channel_element(faacDecHandle hDecoder, | 505 | static uint8_t single_lfe_channel_element(faacDecHandle hDecoder, bitfile *ld, |
| 531 | element *sce, bitfile *ld, | 506 | uint8_t channel, uint8_t *tag) |
| 532 | real_t *spec_coef) | ||
| 533 | { | 507 | { |
| 534 | uint8_t retval = 0; | 508 | uint8_t retval = 0; |
| 535 | ic_stream *ics = &(sce->ics1); | 509 | element sce = {0}; |
| 536 | int16_t spec_data[1024]; | 510 | ic_stream *ics = &(sce.ics1); |
| 511 | int16_t spec_data[1024] = {0}; | ||
| 537 | #ifdef DRM | 512 | #ifdef DRM |
| 538 | uint8_t result; | 513 | uint8_t result; |
| 539 | 514 | ||
| 540 | if (hDecoder->object_type != DRM_ER_LC) | 515 | if (hDecoder->object_type != DRM_ER_LC) |
| 541 | #endif | 516 | #endif |
| 542 | sce->element_instance_tag = (uint8_t)faad_getbits(ld, LEN_TAG | 517 | sce.element_instance_tag = (uint8_t)faad_getbits(ld, LEN_TAG |
| 543 | DEBUGVAR(1,38,"single_lfe_channel_element(): element_instance_tag")); | 518 | DEBUGVAR(1,38,"single_lfe_channel_element(): element_instance_tag")); |
| 544 | 519 | ||
| 520 | *tag = sce.element_instance_tag; | ||
| 521 | sce.channel = channel; | ||
| 522 | sce.paired_channel = -1; | ||
| 523 | |||
| 545 | #ifdef DRM | 524 | #ifdef DRM |
| 546 | if (hDecoder->object_type == DRM_ER_LC) | 525 | if (hDecoder->object_type == DRM_ER_LC) |
| 547 | { | 526 | { |
| 548 | individual_channel_stream(hDecoder, sce, ld, ics, 0, spec_data); | 527 | individual_channel_stream(hDecoder, &sce, ld, ics, 0, spec_data); |
| 549 | 528 | ||
| 550 | if (ics->tns_data_present) | 529 | if (ics->tns_data_present) |
| 551 | tns_data(ics, &(ics->tns), ld); | 530 | tns_data(ics, &(ics->tns), ld); |
| @@ -571,49 +550,43 @@ static uint8_t single_lfe_channel_element(faacDecHandle hDecoder, · 19 unmodified lines | |||
| 571 | } else | 550 | } else |
| 572 | #endif | 551 | #endif |
| 573 | { | 552 | { |
| 574 | retval = individual_channel_stream(hDecoder, sce, ld, ics, 0, spec_data); | 553 | retval = individual_channel_stream(hDecoder, &sce, ld, ics, 0, spec_data); |
| 575 | if (retval > 0) | 554 | if (retval > 0) |
| 576 | return retval; | 555 | return retval; |
| 577 | } | 556 | } |
| 578 | 557 | ||
| 579 | |||
| 580 | /* noiseless coding is done, spectral reconstruction is done now */ | 558 | /* noiseless coding is done, spectral reconstruction is done now */ |
| 581 | 559 | reconstruct_single_channel(hDecoder, ics, &sce, spec_data); | |
| 582 | /* inverse quantization */ | ||
| 583 | inverse_quantization(spec_coef, spec_data, hDecoder->frameLength); | ||
| 584 | |||
| 585 | /* apply scalefactors */ | ||
| 586 | apply_scalefactors(hDecoder, ics, spec_coef, hDecoder->frameLength); | ||
| 587 | |||
| 588 | /* deinterleave short block grouping */ | ||
| 589 | if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) | ||
| 590 | quant_to_spec(ics, spec_coef, hDecoder->frameLength); | ||
| 591 | 560 | ||
| 592 | return 0; | 561 | return 0; |
| 593 | } | 562 | } |
| 594 | 563 | ||
| 595 | /* Table 4.4.5 */ | 564 | /* Table 4.4.5 */ |
| 596 | static uint8_t channel_pair_element(faacDecHandle hDecoder, element *cpe, | 565 | static uint8_t channel_pair_element(faacDecHandle hDecoder, bitfile *ld, |
| 597 | bitfile *ld, | 566 | uint8_t channels, uint8_t *tag) |
| 598 | real_t *spec_coef1, real_t *spec_coef2) | ||
| 599 | { | 567 | { |
| 568 | int16_t spec_data1[1024] = {0}; | ||
| 569 | int16_t spec_data2[1024] = {0}; | ||
| 570 | element cpe = {0}; | ||
| 571 | ic_stream *ics1 = &(cpe.ics1); | ||
| 572 | ic_stream *ics2 = &(cpe.ics2); | ||
| 600 | uint8_t result; | 573 | uint8_t result; |
| 601 | ic_stream *ics1 = &(cpe->ics1); | 574 | |
| 602 | ic_stream *ics2 = &(cpe->ics2); | 575 | cpe.channel = channels; |
| 603 | int16_t spec_data1[1024]; | 576 | cpe.paired_channel = channels+1; |
| 604 | int16_t spec_data2[1024]; | ||
| 605 | 577 | ||
| 606 | #ifdef DRM | 578 | #ifdef DRM |
| 607 | if (hDecoder->object_type != DRM_ER_LC) | 579 | if (hDecoder->object_type != DRM_ER_LC) |
| 608 | #endif | 580 | #endif |
| 609 | cpe->element_instance_tag = (uint8_t)faad_getbits(ld, LEN_TAG | 581 | cpe.element_instance_tag = (uint8_t)faad_getbits(ld, LEN_TAG |
| 610 | DEBUGVAR(1,39,"channel_pair_element(): element_instance_tag")); | 582 | DEBUGVAR(1,39,"channel_pair_element(): element_instance_tag")); |
| 583 | *tag = cpe.element_instance_tag; | ||
| 611 | 584 | ||
| 612 | if ((cpe->common_window = faad_get1bit(ld | 585 | if ((cpe.common_window = faad_get1bit(ld |
| 613 | DEBUGVAR(1,40,"channel_pair_element(): common_window"))) & 1) | 586 | DEBUGVAR(1,40,"channel_pair_element(): common_window"))) & 1) |
| 614 | { | 587 | { |
| 615 | /* both channels have common ics information */ | 588 | /* both channels have common ics information */ |
| 616 | if ((result = ics_info(hDecoder, ics1, ld, cpe->common_window)) > 0) | 589 | if ((result = ics_info(hDecoder, ics1, ld, cpe.common_window)) > 0) |
| 617 | return result; | 590 | return result; |
| 618 | 591 | ||
| 619 | ics1->ms_mask_present = (uint8_t)faad_getbits(ld, 2 | 592 | ics1->ms_mask_present = (uint8_t)faad_getbits(ld, 2 |
| @@ -647,14 +620,14 @@ static uint8_t channel_pair_element(faacDecHandle hDecoder, element *cpe, · 27 unmodified lines | |||
| 647 | ics1->ms_mask_present = 0; | 620 | ics1->ms_mask_present = 0; |
| 648 | } | 621 | } |
| 649 | 622 | ||
| 650 | if ((result = individual_channel_stream(hDecoder, cpe, ld, ics1, | 623 | if ((result = individual_channel_stream(hDecoder, &cpe, ld, ics1, |
| 651 | 0, spec_data1)) > 0) | 624 | 0, spec_data1)) > 0) |
| 652 | { | 625 | { |
| 653 | return result; | 626 | return result; |
| 654 | } | 627 | } |
| 655 | 628 | ||
| 656 | #ifdef ERROR_RESILIENCE | 629 | #ifdef ERROR_RESILIENCE |
| 657 | if (cpe->common_window && (hDecoder->object_type >= ER_OBJECT_START) && | 630 | if (cpe.common_window && (hDecoder->object_type >= ER_OBJECT_START) && |
| 658 | (ics1->predictor_data_present)) | 631 | (ics1->predictor_data_present)) |
| 659 | { | 632 | { |
| 660 | if ((ics1->ltp2.data_present = faad_get1bit(ld | 633 | if ((ics1->ltp2.data_present = faad_get1bit(ld |
| @@ -665,7 +638,7 @@ static uint8_t channel_pair_element(faacDecHandle hDecoder, element *cpe, · 4 unmodified lines | |||
| 665 | } | 638 | } |
| 666 | #endif | 639 | #endif |
| 667 | 640 | ||
| 668 | if ((result = individual_channel_stream(hDecoder, cpe, ld, ics2, | 641 | if ((result = individual_channel_stream(hDecoder, &cpe, ld, ics2, |
| 669 | 0, spec_data2)) > 0) | 642 | 0, spec_data2)) > 0) |
| 670 | { | 643 | { |
| 671 | return result; | 644 | return result; |
| @@ -713,20 +686,7 @@ static uint8_t channel_pair_element(faacDecHandle hDecoder, element *cpe, · 41 unmodified lines | |||
| 713 | #endif | 686 | #endif |
| 714 | 687 | ||
| 715 | /* noiseless coding is done, spectral reconstruction is done now */ | 688 | /* noiseless coding is done, spectral reconstruction is done now */ |
| 716 | 689 | reconstruct_channel_pair(hDecoder, ics1, ics2, &cpe, spec_data1, spec_data2); | |
| 717 | /* inverse quantization */ | ||
| 718 | inverse_quantization(spec_coef1, spec_data1, hDecoder->frameLength); | ||
| 719 | inverse_quantization(spec_coef2, spec_data2, hDecoder->frameLength); | ||
| 720 | |||
| 721 | /* apply scalefactors */ | ||
| 722 | apply_scalefactors(hDecoder, ics1, spec_coef1, hDecoder->frameLength); | ||
| 723 | apply_scalefactors(hDecoder, ics2, spec_coef2, hDecoder->frameLength); | ||
| 724 | |||
| 725 | /* deinterleave short block grouping */ | ||
| 726 | if (ics1->window_sequence == EIGHT_SHORT_SEQUENCE) | ||
| 727 | quant_to_spec(ics1, spec_coef1, hDecoder->frameLength); | ||
| 728 | if (ics2->window_sequence == EIGHT_SHORT_SEQUENCE) | ||
| 729 | quant_to_spec(ics2, spec_coef2, hDecoder->frameLength); | ||
| 730 | 690 | ||
| 731 | return 0; | 691 | return 0; |
| 732 | } | 692 | } |
| @@ -873,13 +833,10 @@ static uint8_t coupling_channel_element(faacDecHandle hDecoder, bitfile *ld) · 140 unmodified lines | |||
| 873 | uint8_t num_gain_element_lists = 0; | 833 | uint8_t num_gain_element_lists = 0; |
| 874 | uint8_t num_coupled_elements = 0; | 834 | uint8_t num_coupled_elements = 0; |
| 875 | 835 | ||
| 876 | element el_empty; | 836 | element el_empty = {0}; |
| 877 | ic_stream ics_empty; | 837 | ic_stream ics_empty = {0}; |
| 878 | int16_t sh_data[1024]; | 838 | int16_t sh_data[1024]; |
| 879 | 839 | ||
| 880 | memset(&el_empty, 0, sizeof(element)); | ||
| 881 | memset(&ics_empty, 0, sizeof(ic_stream)); | ||
| 882 | |||
| 883 | c = faad_getbits(ld, LEN_TAG | 840 | c = faad_getbits(ld, LEN_TAG |
| 884 | DEBUGVAR(1,900,"coupling_channel_element(): element_instance_tag")); | 841 | DEBUGVAR(1,900,"coupling_channel_element(): element_instance_tag")); |
| 885 | 842 | ||
| @@ -1028,6 +985,8 @@ static uint8_t fill_element(faacDecHandle hDecoder, bitfile *ld, drc_info *drc · 142 unmodified lines | |||
| 1028 | /* read in all the SBR data for processing later on */ | 985 | /* read in all the SBR data for processing later on */ |
| 1029 | hDecoder->sbr[sbr_ele]->data = (uint8_t*)faad_getbitbuffer(ld, count*8); | 986 | hDecoder->sbr[sbr_ele]->data = (uint8_t*)faad_getbitbuffer(ld, count*8); |
| 1030 | hDecoder->sbr[sbr_ele]->data_size = count; | 987 | hDecoder->sbr[sbr_ele]->data_size = count; |
| 988 | /* save id of previous element, this sbr object belongs to that element */ | ||
| 989 | hDecoder->sbr[sbr_ele]->id_aac = hDecoder->element_id[sbr_ele]; | ||
| 1031 | } else { | 990 | } else { |
| 1032 | hDecoder->sbr_used[sbr_ele] = 0; | 991 | hDecoder->sbr_used[sbr_ele] = 0; |
| 1033 | #endif | 992 | #endif |
| @@ -1602,7 +1561,7 @@ static uint8_t spectral_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld · 568 unmodified lines | |||
| 1602 | uint16_t nshort = hDecoder->frameLength/8; | 1561 | uint16_t nshort = hDecoder->frameLength/8; |
| 1603 | 1562 | ||
| 1604 | sp = spectral_data; | 1563 | sp = spectral_data; |
| 1605 | memset(sp, 0, hDecoder->frameLength*sizeof(int16_t)); | 1564 | /*memset(sp, 0, hDecoder->frameLength*sizeof(int16_t));*/ |
| 1606 | 1565 | ||
| 1607 | for(g = 0; g < ics->num_window_groups; g++) | 1566 | for(g = 0; g < ics->num_window_groups; g++) |
| 1608 | { | 1567 | { |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: syntax.h,v 1.37 2003/09/24 19:55:34 menno Exp $ | 25 | ** $Id: syntax.h,v 1.38 2003/10/09 20:04:25 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #ifndef __SYNTAX_H__ | 28 | #ifndef __SYNTAX_H__ |
| @@ -109,15 +109,19 @@ int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC, · 80 unmodified lines | |||
| 109 | 109 | ||
| 110 | uint8_t adts_frame(adts_header *adts, bitfile *ld); | 110 | uint8_t adts_frame(adts_header *adts, bitfile *ld); |
| 111 | void get_adif_header(adif_header *adif, bitfile *ld); | 111 | void get_adif_header(adif_header *adif, bitfile *ld); |
| 112 | void decode_sce_lfe(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, bitfile *ld, | ||
| 113 | uint8_t id_syn_ele); | ||
| 114 | void decode_cpe(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, bitfile *ld, | ||
| 115 | uint8_t id_syn_ele); | ||
| 116 | void raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, | ||
| 117 | bitfile *ld, program_config *pce, drc_info *drc); | ||
| 112 | 118 | ||
| 113 | 119 | ||
| 114 | /* static functions */ | 120 | /* static functions */ |
| 115 | static uint8_t single_lfe_channel_element(faacDecHandle hDecoder, | 121 | static uint8_t single_lfe_channel_element(faacDecHandle hDecoder, bitfile *ld, |
| 116 | element *sce, bitfile *ld, | 122 | uint8_t channel, uint8_t *tag); |
| 117 | real_t *spec_coef); | 123 | static uint8_t channel_pair_element(faacDecHandle hDecoder, bitfile *ld, |
| 118 | static uint8_t channel_pair_element(faacDecHandle hDecoder, element *cpe, | 124 | uint8_t channel, uint8_t *tag); |
| 119 | bitfile *ld, | ||
| 120 | real_t *spec_coef1, real_t *spec_coef2); | ||
| 121 | static uint8_t coupling_channel_element(faacDecHandle hDecoder, bitfile *ld); | 125 | static uint8_t coupling_channel_element(faacDecHandle hDecoder, bitfile *ld); |
| 122 | static uint16_t data_stream_element(faacDecHandle hDecoder, bitfile *ld); | 126 | static uint16_t data_stream_element(faacDecHandle hDecoder, bitfile *ld); |
| 123 | static uint8_t program_config_element(program_config *pce, bitfile *ld); | 127 | static uint8_t program_config_element(program_config *pce, bitfile *ld); |