Unified · Split
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | #ifndef __BITS_H__ |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | #ifndef __CFFT_H__ |
| @@ -32,6 +32,14 @@ · 3 unmodified lines | ||
| 32 | 32 | extern "C" { |
| 33 | 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 | 44 | void cfftf(cfft_info *cfft, complex_t *c); |
| 37 | 45 | void cfftb(cfft_info *cfft, complex_t *c); |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 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 | 117 | return -1; |
| 118 | 118 | } |
| 119 | 119 | |
| 120 | + | |
| 120 | 121 | static const uint8_t Parity [256] = { // parity |
| 121 | 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 | 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 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | #ifndef __COMMON_H__ |
| @@ -41,7 +41,6 @@ extern "C" { · 12 unmodified lines | ||
| 41 | 41 | #define min(a, b) (((a) < (b)) ? (a) : (b)) |
| 42 | 42 | #endif |
| 43 | 43 | |
| 44 | − | |
| 45 | 44 | /* COMPILE TIME DEFINITIONS */ |
| 46 | 45 | |
| 47 | 46 | /* use double precision */ |
| @@ -49,6 +48,11 @@ extern "C" { · 1 unmodified line | ||
| 49 | 48 | /* use fixed point reals */ |
| 50 | 49 | //#define FIXED_POINT |
| 51 | 50 | |
| 51 | +#ifdef _WIN32_WCE | |
| 52 | +#define FIXED_POINT | |
| 53 | +#endif | |
| 54 | + | |
| 55 | + | |
| 52 | 56 | #define ERROR_RESILIENCE |
| 53 | 57 | |
| 54 | 58 | |
| @@ -60,6 +64,8 @@ extern "C" { · 5 unmodified lines | ||
| 60 | 64 | #define LTP_DEC |
| 61 | 65 | /* Allow decoding of LD profile AAC */ |
| 62 | 66 | #define LD_DEC |
| 67 | +/* Allow decoding of Digital Radio Mondiale (DRM) */ | |
| 68 | +//#define DRM | |
| 63 | 69 | |
| 64 | 70 | /* LD can't do without LTP */ |
| 65 | 71 | #ifdef LD_DEC |
| @@ -94,7 +100,7 @@ extern "C" { · 28 unmodified lines | ||
| 94 | 100 | #else |
| 95 | 101 | #define qmf_t real_t |
| 96 | 102 | #define QMF_RE(A) (A) |
| 97 | −#define QMF_IM(A) 0 | |
| 103 | +#define QMF_IM(A) | |
| 98 | 104 | #endif |
| 99 | 105 | |
| 100 | 106 | |
| @@ -1,19 +1,19 @@ | ||
| 1 | 1 | /* |
| 2 | 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
| 3 | 3 | ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com |
| 4 | −** | |
| 4 | +** | |
| 5 | 5 | ** This program is free software; you can redistribute it and/or modify |
| 6 | 6 | ** it under the terms of the GNU General Public License as published by |
| 7 | 7 | ** the Free Software Foundation; either version 2 of the License, or |
| 8 | 8 | ** (at your option) any later version. |
| 9 | −** | |
| 9 | +** | |
| 10 | 10 | ** This program is distributed in the hope that it will be useful, |
| 11 | 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | 13 | ** GNU General Public License for more details. |
| 14 | −** | |
| 14 | +** | |
| 15 | 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 | 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | 18 | ** |
| 19 | 19 | ** Any non-GPL usage of this software or parts of this software is strictly |
| @@ -22,7 +22,7 @@ · 2 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | #include "common.h" |
| @@ -34,20 +34,9 @@ · 5 unmodified lines | ||
| 34 | 34 | #include "decoder.h" |
| 35 | 35 | #include "mp4.h" |
| 36 | 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 | 37 | #include "error.h" |
| 45 | 38 | #include "output.h" |
| 46 | 39 | #include "dither.h" |
| 47 | −#ifdef SSR_DEC | |
| 48 | −#include "ssr.h" | |
| 49 | −#include "ssr_fb.h" | |
| 50 | −#endif | |
| 51 | 40 | #ifdef SBR_DEC |
| 52 | 41 | #include "sbr_dec.h" |
| 53 | 42 | #endif |
| @@ -102,6 +91,7 @@ faacDecHandle FAADAPI faacDecOpen() · 48 unmodified lines | ||
| 102 | 91 | hDecoder->config.outputFormat = FAAD_FMT_16BIT; |
| 103 | 92 | hDecoder->config.defObjectType = MAIN; |
| 104 | 93 | hDecoder->config.defSampleRate = 44100; /* Default: 44.1kHz */ |
| 94 | + hDecoder->config.downMatrix = 0; | |
| 105 | 95 | hDecoder->adts_header_present = 0; |
| 106 | 96 | hDecoder->adif_header_present = 0; |
| 107 | 97 | #ifdef ERROR_RESILIENCE |
| @@ -377,7 +367,6 @@ int8_t FAADAPI faacDecInit2(faacDecHandle hDecoder, uint8_t *pBuffer, · 269 unmodified lines | ||
| 377 | 367 | return 0; |
| 378 | 368 | } |
| 379 | 369 | |
| 380 | −#ifdef DRM | |
| 381 | 370 | int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate, |
| 382 | 371 | uint8_t channels) |
| 383 | 372 | { |
| @@ -385,9 +374,11 @@ int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate, · 1 unmodified line | ||
| 385 | 374 | hDecoder->config.defObjectType = DRM_ER_LC; |
| 386 | 375 | |
| 387 | 376 | hDecoder->config.defSampleRate = samplerate; |
| 377 | +#ifdef ERROR_RESILIENCE // This shoudl always be defined for DRM | |
| 388 | 378 | hDecoder->aacSectionDataResilienceFlag = 1; /* VCB11 */ |
| 389 | 379 | hDecoder->aacScalefactorDataResilienceFlag = 0; /* no RVLC */ |
| 390 | 380 | hDecoder->aacSpectralDataResilienceFlag = 1; /* HCR */ |
| 381 | +#endif | |
| 391 | 382 | hDecoder->frameLength = 960; |
| 392 | 383 | hDecoder->sf_index = get_sr_index(hDecoder->config.defSampleRate); |
| 393 | 384 | hDecoder->object_type = hDecoder->config.defObjectType; |
| @@ -398,6 +389,7 @@ int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate, · 4 unmodified lines | ||
| 398 | 389 | hDecoder->channelConfiguration = 1; |
| 399 | 390 | |
| 400 | 391 | #ifdef SBR_DEC |
| 392 | +#ifdef DRM | |
| 401 | 393 | if (channels == DRMCH_SBR_LC_STEREO) |
| 402 | 394 | hDecoder->lcstereo_flag = 1; |
| 403 | 395 | else |
| @@ -411,6 +403,7 @@ int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate, · 7 unmodified lines | ||
| 411 | 403 | /* Reset sbr for new initialization */ |
| 412 | 404 | sbrDecodeEnd(hDecoder->sbr[0]); |
| 413 | 405 | hDecoder->sbr[0] = NULL; |
| 406 | +#endif | |
| 414 | 407 | #endif |
| 415 | 408 | |
| 416 | 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 | 417 | return 0; |
| 425 | 418 | } |
| 426 | −#endif | |
| 427 | 419 | |
| 428 | 420 | void FAADAPI faacDecClose(faacDecHandle hDecoder) |
| 429 | 421 | { |
| @@ -699,7 +691,6 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 269 unmodified lines | ||
| 699 | 691 | uint8_t *buffer, uint32_t buffer_size) |
| 700 | 692 | { |
| 701 | 693 | int32_t i; |
| 702 | − uint8_t ch; | |
| 703 | 694 | adts_header adts; |
| 704 | 695 | uint8_t channels = 0, ch_ele = 0; |
| 705 | 696 | uint8_t output_channels = 0; |
| @@ -707,8 +698,8 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 1 unmodified line | ||
| 707 | 698 | uint32_t bitsconsumed; |
| 708 | 699 | #ifdef DRM |
| 709 | 700 | uint8_t *revbuffer; |
| 710 | − uint8_t *prevbufstart; | |
| 711 | − uint8_t *pbufend; | |
| 701 | + uint8_t *prevbufstart; | |
| 702 | + uint8_t *pbufend; | |
| 712 | 703 | #endif |
| 713 | 704 | |
| 714 | 705 | /* local copy of globals */ |
| @@ -736,9 +727,6 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 21 unmodified lines | ||
| 736 | 727 | program_config *pce; |
| 737 | 728 | |
| 738 | 729 | void *sample_buffer; |
| 739 | − element *syntax_elements[MAX_SYNTAX_ELEMENTS]; | |
| 740 | − element **elements; | |
| 741 | − real_t *spec_coef[MAX_CHANNELS]; | |
| 742 | 730 | |
| 743 | 731 | /* safety checks */ |
| 744 | 732 | if ((hDecoder == NULL) || (hInfo == NULL) || (buffer == NULL) || (ld == NULL)) |
| @@ -804,11 +792,8 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 59 unmodified lines | ||
| 804 | 792 | dbg_count = 0; |
| 805 | 793 | #endif |
| 806 | 794 | |
| 807 | − elements = syntax_elements; | |
| 808 | − | |
| 809 | 795 | /* decode the complete bitstream */ |
| 810 | − elements = raw_data_block(hDecoder, hInfo, ld, syntax_elements, | |
| 811 | − spec_coef, pce, drc); | |
| 796 | + raw_data_block(hDecoder, hInfo, ld, pce, drc); | |
| 812 | 797 | |
| 813 | 798 | ch_ele = hDecoder->fr_ch_ele; |
| 814 | 799 | channels = hDecoder->fr_channels; |
| @@ -912,202 +897,27 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 97 unmodified lines | ||
| 912 | 897 | return NULL; |
| 913 | 898 | } |
| 914 | 899 | |
| 900 | + /* allocate the buffer for the final samples */ | |
| 915 | 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 | 908 | #ifdef SBR_DEC |
| 918 | 909 | if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) |
| 919 | − { | |
| 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 | − } | |
| 910 | + stride = 2 * stride; | |
| 932 | 911 | #endif |
| 912 | + hDecoder->sample_buffer = malloc(frame_len*channels*stride); | |
| 933 | 913 | } |
| 934 | 914 | |
| 935 | 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 | 917 | #ifdef SBR_DEC |
| 1109 | 918 | if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) |
| 1110 | 919 | { |
| 920 | + uint8_t ch = 0; | |
| 1111 | 921 | for (i = 0; i < ch_ele; i++) |
| 1112 | 922 | { |
| 1113 | 923 | /* following case can happen when forceUpSampling == 1 */ |
| @@ -1120,25 +930,40 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 6 unmodified lines | ||
| 1120 | 930 | ); |
| 1121 | 931 | hDecoder->sbr[i]->data = NULL; |
| 1122 | 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], | |
| 1128 | − time_out[syntax_elements[i]->channel], frame_len*sizeof(real_t)); | |
| 1129 | − memcpy(time_out2[syntax_elements[i]->paired_channel], | |
| 1130 | − time_out[syntax_elements[i]->paired_channel], frame_len*sizeof(real_t)); | |
| 945 | + /* space for 2 channels needed */ | |
| 946 | + if (hDecoder->time_out2[ch+1] == NULL) | |
| 947 | + { | |
| 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 | 956 | sbrDecodeFrame(hDecoder->sbr[i], |
| 1132 | − time_out2[syntax_elements[i]->channel], | |
| 1133 | − time_out2[syntax_elements[i]->paired_channel], ID_CPE, | |
| 957 | + time_out2[ch], time_out2[ch+1], | |
| 1134 | 958 | hDecoder->postSeekResetFlag, hDecoder->forceUpSampling); |
| 959 | + ch += 2; | |
| 1135 | 960 | } else { |
| 1136 | − memcpy(time_out2[syntax_elements[i]->channel], | |
| 1137 | − time_out[syntax_elements[i]->channel], frame_len*sizeof(real_t)); | |
| 961 | + memcpy(time_out2[ch], | |
| 962 | + time_out[ch], frame_len*sizeof(real_t)); | |
| 1138 | 963 | sbrDecodeFrame(hDecoder->sbr[i], |
| 1139 | − time_out2[syntax_elements[i]->channel], | |
| 1140 | − NULL, ID_SCE, | |
| 964 | + time_out2[ch], NULL, | |
| 1141 | 965 | hDecoder->postSeekResetFlag, hDecoder->forceUpSampling); |
| 966 | + ch++; | |
| 1142 | 967 | } |
| 1143 | 968 | } |
| 1144 | 969 | frame_len *= 2; |
| @@ -1181,16 +1006,6 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 36 unmodified lines | ||
| 1181 | 1006 | #endif |
| 1182 | 1007 | |
| 1183 | 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 | 1009 | #ifdef ANALYSIS |
| 1195 | 1010 | fflush(stdout); |
| 1196 | 1011 | #endif |
| @@ -1203,16 +1018,6 @@ error: · 6 unmodified lines | ||
| 1203 | 1018 | if (ld) free(ld); |
| 1204 | 1019 | |
| 1205 | 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 | 1021 | #ifdef ANALYSIS |
| 1217 | 1022 | fflush(stdout); |
| 1218 | 1023 | #endif |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | #ifndef __DECODER_H__ |
| @@ -118,16 +118,6 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 89 unmodified lines | ||
| 118 | 118 | uint8_t *buffer, |
| 119 | 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 | 121 | #ifdef _WIN32 |
| 132 | 122 | #pragma pack(pop) |
| 133 | 123 | #endif |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 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 | 122 | #elif defined(__GNUC__) && defined (__arm__) |
| 99 | 123 | |
| 100 | 124 | /* taken from MAD */ |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 37 | #include "filtbank.h" |
| 38 | 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 | 60 | static real_t codebook[8] = |
| 41 | 61 | { |
| 42 | 62 | COEF_CONST(0.570829), |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | #ifdef LTP_DEC |
| @@ -36,6 +36,8 @@ extern "C" { · 7 unmodified lines | ||
| 36 | 36 | |
| 37 | 37 | #include "filtbank.h" |
| 38 | 38 | |
| 39 | +uint8_t is_ltp_ot(uint8_t object_type); | |
| 40 | + | |
| 39 | 41 | void lt_prediction(ic_stream *ics, |
| 40 | 42 | ltp_info *ltp, |
| 41 | 43 | real_t *spec, |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | #include "common.h" |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | #include "common.h" |
| @@ -55,20 +55,18 @@ double doubletmp; · 26 unmodified lines | ||
| 55 | 55 | static INLINE real_t get_sample(real_t **input, uint8_t channel, uint16_t sample, |
| 56 | 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) | |
| 61 | − { | |
| 62 | − return DM_MUL * (input[internal_channel[1]][sample] + | |
| 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 | − } | |
| 63 | + return DM_MUL * (input[internal_channel[1]][sample] + | |
| 64 | + input[internal_channel[0]][sample]/(real_t)sqrt(2.) + | |
| 65 | + input[internal_channel[3]][sample]/(real_t)sqrt(2.)); | |
| 70 | 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 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | #include "common.h" |
| @@ -1099,6 +1099,21 @@ void DCT2_64_unscaled(real_t *y, real_t *x) · 1070 unmodified lines | ||
| 1099 | 1099 | void DCT4_64(real_t *y, real_t *x) |
| 1100 | 1100 | { |
| 1101 | 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 | 1117 | real_t f2; |
| 1103 | 1118 | real_t f3; |
| 1104 | 1119 | real_t f4; |
| @@ -1837,18 +1852,10 @@ void DCT4_64(real_t *y, real_t *x) · 732 unmodified lines | ||
| 1837 | 1852 | real_t f799; |
| 1838 | 1853 | real_t f800; |
| 1839 | 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 | 1856 | f2 = 0.7071067811865476 * t2[32]; |
| 1850 | − f3 = x[0] - f2; | |
| 1851 | − f4 = x[0] + f2; | |
| 1857 | + f3 = t2[0] - f2; | |
| 1858 | + f4 = t2[0] + f2; | |
| 1852 | 1859 | f5 = t2[16] + t2[48]; |
| 1853 | 1860 | f6 = 1.3065629648763766 * t2[16]; |
| 1854 | 1861 | f7 = (-0.9238795325112866) * f5; |
| @@ -2312,8 +2319,8 @@ void DCT4_64(real_t *y, real_t *x) · 457 unmodified lines | ||
| 2312 | 2319 | f465 = 0.7071067811865474 * f463; |
| 2313 | 2320 | f466 = 0.7071067811865474 * f464; |
| 2314 | 2321 | f467 = 0.7071067811865476 * t2[31]; |
| 2315 | − f468 = x[63] - f467; | |
| 2316 | − f469 = x[63] + f467; | |
| 2322 | + f468 = t2[63] - f467; | |
| 2323 | + f469 = t2[63] + f467; | |
| 2317 | 2324 | f470 = t2[47] + t2[15]; |
| 2318 | 2325 | f471 = 1.3065629648763766 * t2[47]; |
| 2319 | 2326 | f472 = (-0.9238795325112866) * f470; |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | #ifndef __SBR_DCT_H__ |
| @@ -35,6 +35,7 @@ extern "C" { · 6 unmodified lines | ||
| 35 | 35 | void DCT3_32_unscaled(real_t *y, real_t *x); |
| 36 | 36 | void DCT2_64_unscaled(real_t *y, real_t *x); |
| 37 | 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 | 41 | #ifdef __cplusplus |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 111 | qmfs_end(sbr->qmfs[1]); |
| 112 | 112 | } |
| 113 | 113 | |
| 114 | − if (sbr->Xcodec[0]) free(sbr->Xcodec[0]); | |
| 115 | − if (sbr->Xsbr[0]) free(sbr->Xsbr[0]); | |
| 116 | − if (sbr->Xcodec[1]) free(sbr->Xcodec[1]); | |
| 117 | − if (sbr->Xsbr[1]) free(sbr->Xsbr[1]); | |
| 114 | + //if (sbr->Xcodec[0]) free(sbr->Xcodec[0]); | |
| 115 | + //if (sbr->Xsbr[0]) free(sbr->Xsbr[0]); | |
| 116 | + //if (sbr->Xcodec[1]) free(sbr->Xcodec[1]); | |
| 117 | + //if (sbr->Xsbr[1]) free(sbr->Xsbr[1]); | |
| 118 | 118 | |
| 119 | 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 | 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 | 161 | uint8_t just_seeked, uint8_t upsample_only) |
| 162 | 162 | { |
| 163 | 163 | int16_t i, k, l; |
| @@ -166,15 +166,14 @@ void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, · 2 unmodified lines | ||
| 166 | 166 | uint8_t ch, channels, ret; |
| 167 | 167 | real_t *ch_buf; |
| 168 | 168 | |
| 169 | − qmf_t X[32*64]; | |
| 169 | + qmf_t X[32][64]; | |
| 170 | 170 | #ifdef SBR_LOW_POWER |
| 171 | 171 | real_t deg[64]; |
| 172 | 172 | #endif |
| 173 | 173 | |
| 174 | 174 | bitfile *ld = NULL; |
| 175 | 175 | |
| 176 | − sbr->id_aac = id_aac; | |
| 177 | − channels = (id_aac == ID_SCE) ? 1 : 2; | |
| 176 | + channels = (sbr->id_aac == ID_SCE) ? 1 : 2; | |
| 178 | 177 | |
| 179 | 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 | 184 | /* initialise and read the bitstream */ |
| 186 | 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 | 189 | ret = ld->error ? ld->error : ret; |
| 191 | 190 | faad_endbits(ld); |
| @@ -227,9 +226,6 @@ void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, · 35 unmodified lines | ||
| 227 | 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 | 229 | memset(sbr->Xsbr[ch], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); |
| 234 | 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 | 235 | else |
| 240 | 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 | 238 | /* subband analysis */ |
| 257 | 239 | if (dont_process) |
| 258 | 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 | 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 | 262 | #endif |
| @@ -295,16 +277,16 @@ void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, · 14 unmodified lines | ||
| 295 | 277 | { |
| 296 | 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 | 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 | 283 | #endif |
| 302 | 284 | } |
| 303 | 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 | 288 | #ifndef SBR_LOW_POWER |
| 307 | − QMF_IM(X[l * 64 + k]) = 0; | |
| 289 | + QMF_IM(X[l][k]) = 0; | |
| 308 | 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 | 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 | 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 | 313 | #endif |
| 332 | 314 | } |
| 333 | 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 | 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 | 320 | #endif |
| 339 | 321 | } |
| 340 | 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 | 324 | #endif |
| 343 | 325 | #ifdef DRM |
| 344 | 326 | if (sbr->Is_DRM_SBR) |
| 345 | 327 | { |
| 346 | 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]); | |
| 349 | − QMF_IM(X[l * 64 + k]) += QMF_IM(sbr->Xcodec[ch][(l + sbr->tHFAdj)*32 + k]); | |
| 330 | + QMF_RE(X[l][k]) += QMF_RE(sbr->Xcodec[ch][l + sbr->tHFAdj][k]); | |
| 331 | + QMF_IM(X[l][k]) += QMF_IM(sbr->Xcodec[ch][l + sbr->tHFAdj][k]); | |
| 350 | 332 | } |
| 351 | 333 | } |
| 352 | 334 | #endif |
| @@ -354,29 +336,12 @@ void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, · 1 unmodified line | ||
| 354 | 336 | } |
| 355 | 337 | |
| 356 | 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; | |
| 362 | − for (j = 0; j < sbr->tHFGen; j++) | |
| 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 | − } | |
| 343 | + memmove(sbr->Xcodec[ch][i], sbr->Xcodec[ch][i+sbr->numTimeSlotsRate], 32 * sizeof(qmf_t)); | |
| 344 | + memmove(sbr->Xsbr[ch][i], sbr->Xsbr[ch][i+sbr->numTimeSlotsRate], 64 * sizeof(qmf_t)); | |
| 380 | 345 | } |
| 381 | 346 | } |
| 382 | 347 | |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | #ifndef __SBR_DEC_H__ |
| @@ -138,8 +138,8 @@ typedef struct · 109 unmodified lines | ||
| 138 | 138 | qmfa_info *qmfa[2]; |
| 139 | 139 | qmfs_info *qmfs[2]; |
| 140 | 140 | |
| 141 | − qmf_t *Xsbr[2]; | |
| 142 | − qmf_t *Xcodec[2]; | |
| 141 | + qmf_t Xsbr[2][40][64]; | |
| 142 | + qmf_t Xcodec[2][40][32]; | |
| 143 | 143 | |
| 144 | 144 | #ifdef DRM |
| 145 | 145 | int8_t lcstereo_flag; |
| @@ -200,7 +200,7 @@ sbr_info *sbrDecodeInit(uint16_t framelength · 54 unmodified lines | ||
| 200 | 200 | void sbrDecodeEnd(sbr_info *sbr); |
| 201 | 201 | |
| 202 | 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 | 204 | uint8_t just_seeked, uint8_t upsample_only); |
| 205 | 205 | |
| 206 | 206 | |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | #include "common.h" |
| @@ -186,6 +186,12 @@ void unmap_envelope_noise(sbr_info *sbr) · 157 unmodified lines | ||
| 186 | 186 | r_temp = (real_t)pow(2, sbr->E[1][k][l]*amp1 - 12); |
| 187 | 187 | |
| 188 | 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 | 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 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 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 | 187 | uint8_t k; |
| 188 | 188 | uint8_t dk; |
| 189 | 189 | uint32_t nrBands, k2Achieved; |
| 190 | − int32_t k2Diff, vDk[64]; | |
| 191 | − | |
| 192 | − memset(vDk, 0, 64*sizeof(int32_t)); | |
| 190 | + int32_t k2Diff, vDk[64] = {0}; | |
| 193 | 191 | |
| 194 | 192 | /* mft only defined for k2 > k0 */ |
| 195 | 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 | 245 | #endif |
| 248 | 246 | } |
| 249 | 247 | |
| 250 | − | |
| 251 | 248 | /* |
| 252 | 249 | This function finds the number of bands using this formula: |
| 253 | 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 | 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 | 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 | 271 | uint8_t k, bands, twoRegions; |
| 271 | 272 | uint8_t k1; |
| 272 | − uint32_t nrBand0, nrBand1; | |
| 273 | − int32_t vDk0[64], vDk1[64]; | |
| 274 | − int32_t vk0[64], vk1[64]; | |
| 273 | + uint8_t nrBand0, nrBand1; | |
| 274 | + int32_t vDk0[64] = {0}, vDk1[64] = {0}; | |
| 275 | + int32_t vk0[64] = {0}, vk1[64] = {0}; | |
| 275 | 276 | uint8_t temp1[] = { 6, 5, 4 }; |
| 276 | − | |
| 277 | − /* without memset code enters infinite loop, | |
| 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)); | |
| 277 | + real_t q, qk; | |
| 278 | + int32_t A_1; | |
| 283 | 279 | |
| 284 | 280 | /* mft only defined for k2 > k0 */ |
| 285 | 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 | 298 | nrBand0 = 2 * find_bands(0, bands, k0, k1); |
| 303 | 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 | 304 | for (k = 0; k <= nrBand0; k++) |
| 306 | 305 | { |
| 307 | − /* diverging power series */ | |
| 308 | − vDk0[k] = (int32_t)(k0 * pow((float)k1/(float)k0, (k+1)/(float)nrBand0)+0.5) - | |
| 309 | − (int32_t)(k0 * pow((float)k1/(float)k0, k/(float)nrBand0)+0.5); | |
| 306 | + int32_t A_0 = A_1; | |
| 307 | + qk *= q; | |
| 308 | + A_1 = (int32_t)(qk + 0.5); | |
| 309 | + vDk0[k] = A_1 - A_0; | |
| 310 | 310 | } |
| 311 | 311 | |
| 312 | 312 | /* needed? */ |
| @@ -331,10 +331,15 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, · 18 unmodified lines | ||
| 331 | 331 | nrBand1 = 2 * find_bands(1 /* warped */, bands, k1, k2); |
| 332 | 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 | 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) - | |
| 337 | − (int32_t)(k1 * pow((float)k2/(float)k1, k/(float)nrBand1)+0.5); | |
| 339 | + int32_t A_0 = A_1; | |
| 340 | + qk *= q; | |
| 341 | + A_1 = (int32_t)(qk + 0.5); | |
| 342 | + vDk1[k] = A_1 - A_0; | |
| 338 | 343 | } |
| 339 | 344 | |
| 340 | 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 | 453 | if (k == 0) |
| 449 | 454 | { |
| 450 | 455 | i = 0; |
| 451 | − } else { /* is this accurate? */ | |
| 452 | − //i = i + (int32_t)((sbr->N_low - i)/(sbr->N_Q + 1 - k)); | |
| 456 | + } else { | |
| 457 | + /* i = i + (int32_t)((sbr->N_low - i)/(sbr->N_Q + 1 - k)); */ | |
| 453 | 458 | i = i + (sbr->N_low - i)/(sbr->N_Q + 1 - k); |
| 454 | 459 | } |
| 455 | 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 | 503 | #endif |
| 499 | 504 | uint8_t k, s; |
| 500 | 505 | int8_t nrLim; |
| 501 | − int32_t limTable[100 /*TODO*/]; | |
| 502 | − uint8_t patchBorders[64/*??*/]; | |
| 503 | 506 | #if 0 |
| 504 | 507 | real_t limBands; |
| 505 | 508 | #endif |
| @@ -510,7 +513,8 @@ void limiter_frequency_table(sbr_info *sbr) · 4 unmodified lines | ||
| 510 | 513 | |
| 511 | 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 | 519 | #if 0 |
| 516 | 520 | limBands = limiterBandsPerOctave[s - 1]; |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | /* High Frequency adjustment */ |
| @@ -37,15 +37,13 @@ · 8 unmodified lines | ||
| 37 | 37 | |
| 38 | 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 | 41 | #ifdef SBR_LOW_POWER |
| 42 | 42 | ,real_t *deg /* aliasing degree */ |
| 43 | 43 | #endif |
| 44 | 44 | ,uint8_t ch) |
| 45 | 45 | { |
| 46 | − sbr_hfadj_info adj; | |
| 47 | − | |
| 48 | − memset(&adj, 0, sizeof(sbr_hfadj_info)); | |
| 46 | + sbr_hfadj_info adj = {0}; | |
| 49 | 47 | |
| 50 | 48 | map_noise_data(sbr, &adj, ch); |
| 51 | 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 | 190 | uint8_t ch) |
| 193 | 191 | { |
| 194 | 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 | 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 | 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 | 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 | 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 | 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 | 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 | 266 | #define EPS (1e-12) |
| 268 | 267 | |
| 269 | 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 | 496 | #endif |
| 498 | 497 | |
| 499 | 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 | 501 | static real_t h_smooth[] = { |
| 503 | 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 | 590 | /* the smoothed gain values are applied to Xsbr */ |
| 592 | 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 | 593 | + MUL_R_C(Q_filt, RE(V[fIndexNoise])); |
| 595 | 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 | 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 | 598 | + MUL_R_C(Q_filt, IM(V[fIndexNoise])); |
| 600 | 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 | 604 | int8_t rev = ((m + sbr->kx) & 1) ? -1 : 1; |
| 606 | 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 | 608 | #ifndef SBR_LOW_POWER |
| 610 | 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 | 611 | #else |
| 613 | 612 | i_min1 = (fIndexSine - 1) & 3; |
| 614 | 613 | i_plus1 = (fIndexSine + 1) & 3; |
| 615 | 614 | |
| 616 | 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 | 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 | 620 | (rev * MUL_R_C(MUL(adj->S_M_boost[l][1], phi_re[i_plus1]), COEF_CONST(0.00815))); |
| 622 | 621 | } |
| 623 | 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 | 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 | 627 | (rev * MUL_R_C(MUL(adj->S_M_boost[l][m + 1], phi_re[i_plus1]), COEF_CONST(0.00815))); |
| 629 | 628 | } |
| 630 | 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 | 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 | 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 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | #ifndef __SBR_HFADJ_H__ |
| @@ -46,7 +46,7 @@ typedef struct { · 17 unmodified lines | ||
| 46 | 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 | 50 | #ifdef SBR_LOW_POWER |
| 51 | 51 | ,real_t *deg |
| 52 | 52 | #endif |
| @@ -56,7 +56,7 @@ void hf_adjustment(sbr_info *sbr, qmf_t *Xsbr · 3 unmodified lines | ||
| 56 | 56 | static void map_envelope_data(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch); |
| 57 | 57 | static void map_noise_data(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch); |
| 58 | 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 | 60 | uint8_t ch); |
| 61 | 61 | static void additional_component_levels(sbr_info *sbr, sbr_hfadj_info *adj, uint8_t ch); |
| 62 | 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 | 64 | static void calc_gain_groups(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch); |
| 65 | 65 | static void aliasing_reduction(sbr_info *sbr, sbr_hfadj_info *adj, real_t *deg, uint8_t ch); |
| 66 | 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 | 70 | #ifdef __cplusplus |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | /* High Frequency generation */ |
| @@ -36,8 +36,8 @@ · 7 unmodified lines | ||
| 36 | 36 | #include "sbr_hfgen.h" |
| 37 | 37 | #include "sbr_fbt.h" |
| 38 | 38 | |
| 39 | −void hf_generation(sbr_info *sbr, const qmf_t *Xlow, | |
| 40 | − qmf_t *Xhigh | |
| 39 | +void hf_generation(sbr_info *sbr, const qmf_t Xlow[40][32], | |
| 40 | + qmf_t Xhigh[40][64] | |
| 41 | 41 | #ifdef SBR_LOW_POWER |
| 42 | 42 | ,real_t *deg |
| 43 | 43 | #endif |
| @@ -123,34 +123,34 @@ void hf_generation(sbr_info *sbr, const qmf_t *Xlow, · 79 unmodified lines | ||
| 123 | 123 | |
| 124 | 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 | 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 | 129 | #endif |
| 130 | 130 | |
| 131 | 131 | #ifdef SBR_LOW_POWER |
| 132 | − QMF_RE(Xhigh[((l + offset)<<6) + k]) += ( | |
| 133 | − MUL(RE(a0), QMF_RE(Xlow[((l - 1 + offset)<<5) + p])) + | |
| 134 | − MUL(RE(a1), QMF_RE(Xlow[((l - 2 + offset)<<5) + p]))); | |
| 132 | + QMF_RE(Xhigh[l + offset][k]) += ( | |
| 133 | + MUL(RE(a0), QMF_RE(Xlow[l - 1 + offset][p])) + | |
| 134 | + MUL(RE(a1), QMF_RE(Xlow[l - 2 + offset][p]))); | |
| 135 | 135 | #else |
| 136 | − QMF_RE(Xhigh[((l + offset)<<6) + k]) += ( | |
| 137 | − RE(a0) * QMF_RE(Xlow[((l - 1 + offset)<<5) + p]) - | |
| 138 | − IM(a0) * QMF_IM(Xlow[((l - 1 + offset)<<5) + p]) + | |
| 139 | − RE(a1) * QMF_RE(Xlow[((l - 2 + offset)<<5) + p]) - | |
| 140 | − IM(a1) * QMF_IM(Xlow[((l - 2 + offset)<<5) + p])); | |
| 141 | − QMF_IM(Xhigh[((l + offset)<<6) + k]) += ( | |
| 142 | − IM(a0) * QMF_RE(Xlow[((l - 1 + offset)<<5) + p]) + | |
| 143 | − RE(a0) * QMF_IM(Xlow[((l - 1 + offset)<<5) + p]) + | |
| 144 | − IM(a1) * QMF_RE(Xlow[((l - 2 + offset)<<5) + p]) + | |
| 145 | − RE(a1) * QMF_IM(Xlow[((l - 2 + offset)<<5) + p])); | |
| 136 | + QMF_RE(Xhigh[l + offset][k]) += ( | |
| 137 | + RE(a0) * QMF_RE(Xlow[l - 1 + offset][p]) - | |
| 138 | + IM(a0) * QMF_IM(Xlow[l - 1 + offset][p]) + | |
| 139 | + RE(a1) * QMF_RE(Xlow[l - 2 + offset][p]) - | |
| 140 | + IM(a1) * QMF_IM(Xlow[l - 2 + offset][p])); | |
| 141 | + QMF_IM(Xhigh[l + offset][k]) += ( | |
| 142 | + IM(a0) * QMF_RE(Xlow[l - 1 + offset][p]) + | |
| 143 | + RE(a0) * QMF_IM(Xlow[l - 1 + offset][p]) + | |
| 144 | + IM(a1) * QMF_RE(Xlow[l - 2 + offset][p]) + | |
| 145 | + RE(a1) * QMF_IM(Xlow[l - 2 + offset][p])); | |
| 146 | 146 | #endif |
| 147 | 147 | } |
| 148 | 148 | } else { |
| 149 | 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 | 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 | 154 | #endif |
| 155 | 155 | } |
| 156 | 156 | } |
| @@ -176,12 +176,12 @@ typedef struct · 19 unmodified lines | ||
| 176 | 176 | #define SBR_ABS(A) ((A) < 0) ? -(A) : (A) |
| 177 | 177 | |
| 178 | 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 | 180 | uint8_t bd, uint8_t len) |
| 181 | 181 | { |
| 182 | − int8_t j, jminus1, jminus2; | |
| 182 | + int8_t j; | |
| 183 | 183 | uint8_t offset; |
| 184 | − real_t r01, i01, r11; | |
| 184 | + real_t r01, r11; | |
| 185 | 185 | const real_t rel = 1 / (1 + 1e-6f); |
| 186 | 186 | |
| 187 | 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 | 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]); | |
| 199 | − r11 = QMF_RE(buffer[(offset-2)*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][bd]) * QMF_RE(buffer[offset-2][bd]); | |
| 200 | 200 | |
| 201 | 201 | for (j = offset; j < len + offset; j++) |
| 202 | 202 | { |
| 203 | − jminus1 = j - 1; | |
| 204 | − jminus2 = j - 2; | |
| 205 | − | |
| 206 | 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 | 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 | 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 | 209 | RE(ac->r11) += r11; |
| 213 | 210 | } |
| 214 | 211 | |
| 215 | 212 | ac->det = MUL(RE(ac->r11), RE(ac->r22)) - MUL_R_C(MUL(RE(ac->r12), RE(ac->r12)), rel); |
| 216 | 213 | } |
| 217 | 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 | 216 | uint8_t bd, uint8_t len) |
| 220 | 217 | { |
| 221 | − int8_t j, jminus1, jminus2; | |
| 218 | + int8_t j; | |
| 222 | 219 | uint8_t offset; |
| 223 | 220 | real_t r01, i01, r11; |
| 224 | 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 | 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]) + | |
| 238 | − QMF_IM(buffer[(offset-1)*32 + bd]) * QMF_IM(buffer[(offset-2)*32 + bd]); | |
| 239 | − i01 = QMF_IM(buffer[(offset-1)*32 + bd]) * QMF_RE(buffer[(offset-2)*32 + bd]) - | |
| 240 | − QMF_RE(buffer[(offset-1)*32 + bd]) * QMF_IM(buffer[(offset-2)*32 + bd]); | |
| 241 | − r11 = QMF_RE(buffer[(offset-2)*32 + bd]) * QMF_RE(buffer[(offset-2)*32 + bd]) + | |
| 242 | − QMF_IM(buffer[(offset-2)*32 + bd]) * QMF_IM(buffer[(offset-2)*32 + bd]); | |
| 234 | + r01 = QMF_RE(buffer[offset-1][bd]) * QMF_RE(buffer[offset-2][bd]) + | |
| 235 | + QMF_IM(buffer[offset-1][bd]) * QMF_IM(buffer[offset-2][bd]); | |
| 236 | + i01 = QMF_IM(buffer[offset-1][bd]) * QMF_RE(buffer[offset-2][bd]) - | |
| 237 | + QMF_RE(buffer[offset-1][bd]) * QMF_IM(buffer[offset-2][bd]); | |
| 238 | + r11 = QMF_RE(buffer[offset-2][bd]) * QMF_RE(buffer[offset-2][bd]) + | |
| 239 | + QMF_IM(buffer[offset-2][bd]) * QMF_IM(buffer[offset-2][bd]); | |
| 243 | 240 | |
| 244 | 241 | for (j = offset; j < len + offset; j++) |
| 245 | 242 | { |
| 246 | − jminus1 = j - 1; | |
| 247 | − jminus2 = j - 2; | |
| 248 | − | |
| 249 | 243 | RE(ac->r12) += r01; |
| 250 | 244 | IM(ac->r12) += i01; |
| 251 | − r01 = QMF_RE(buffer[j*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]) + | |
| 252 | − QMF_IM(buffer[j*32 + bd]) * QMF_IM(buffer[jminus1*32 + bd]); | |
| 245 | + r01 = QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-1][bd]) + | |
| 246 | + QMF_IM(buffer[j][bd]) * QMF_IM(buffer[j-1][bd]); | |
| 253 | 247 | RE(ac->r01) += r01; |
| 254 | − i01 = QMF_IM(buffer[j*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]) - | |
| 255 | − QMF_RE(buffer[j*32 + bd]) * QMF_IM(buffer[jminus1*32 + bd]); | |
| 248 | + i01 = QMF_IM(buffer[j][bd]) * QMF_RE(buffer[j-1][bd]) - | |
| 249 | + QMF_RE(buffer[j][bd]) * QMF_IM(buffer[j-1][bd]); | |
| 256 | 250 | IM(ac->r01) += i01; |
| 257 | − RE(ac->r02) += QMF_RE(buffer[j*32 + bd]) * QMF_RE(buffer[jminus2*32 + bd]) + | |
| 258 | − QMF_IM(buffer[j*32 + bd]) * QMF_IM(buffer[jminus2*32 + bd]); | |
| 259 | − IM(ac->r02) += QMF_IM(buffer[j*32 + bd]) * QMF_RE(buffer[jminus2*32 + bd]) - | |
| 260 | − QMF_RE(buffer[j*32 + bd]) * QMF_IM(buffer[jminus2*32 + bd]); | |
| 251 | + RE(ac->r02) += QMF_RE(buffer[j][bd]) * QMF_RE(buffer[j-2][bd]) + | |
| 252 | + QMF_IM(buffer[j][bd]) * QMF_IM(buffer[j-2][bd]); | |
| 253 | + IM(ac->r02) += QMF_IM(buffer[j][bd]) * QMF_RE(buffer[j-2][bd]) - | |
| 254 | + QMF_RE(buffer[j][bd]) * QMF_IM(buffer[j-2][bd]); | |
| 261 | 255 | RE(ac->r22) += r11; |
| 262 | − r11 = QMF_RE(buffer[jminus1*32 + bd]) * QMF_RE(buffer[jminus1*32 + bd]) + | |
| 263 | − QMF_IM(buffer[jminus1*32 + bd]) * QMF_IM(buffer[jminus1*32 + bd]); | |
| 256 | + r11 = QMF_RE(buffer[j-1][bd]) * QMF_RE(buffer[j-1][bd]) + | |
| 257 | + QMF_IM(buffer[j-1][bd]) * QMF_IM(buffer[j-1][bd]); | |
| 264 | 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 | 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 | 266 | complex_t *alpha_0, complex_t *alpha_1 |
| 273 | 267 | #ifdef SBR_LOW_POWER |
| 274 | 268 | , real_t *rxx |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | #ifndef __SBR_HFGEN_H__ |
| @@ -32,14 +32,14 @@ · 3 unmodified lines | ||
| 32 | 32 | extern "C" { |
| 33 | 33 | #endif |
| 34 | 34 | |
| 35 | −void hf_generation(sbr_info *sbr, const qmf_t *Xlow, | |
| 36 | − qmf_t *Xhigh | |
| 35 | +void hf_generation(sbr_info *sbr, const qmf_t Xlow[40][32], | |
| 36 | + qmf_t Xhigh[40][64] | |
| 37 | 37 | #ifdef SBR_LOW_POWER |
| 38 | 38 | ,real_t *deg |
| 39 | 39 | #endif |
| 40 | 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 | 43 | complex_t *alpha_0, complex_t *alpha_1 |
| 44 | 44 | #ifdef SBR_LOW_POWER |
| 45 | 45 | , real_t *rxx |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | #include "common.h" |
| @@ -60,7 +60,7 @@ void qmfa_end(qmfa_info *qmfa) · 31 unmodified lines | ||
| 60 | 60 | } |
| 61 | 61 | |
| 62 | 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 | 65 | uint8_t l; |
| 66 | 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 | 114 | if (n < kx) |
| 115 | 115 | { |
| 116 | 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 | 118 | #else |
| 119 | − QMF_RE(X[((l + offset)<<5) + n]) = 2. * u[n]; | |
| 119 | + QMF_RE(X[l + offset][n]) = 2. * u[n]; | |
| 120 | 120 | #endif |
| 121 | 121 | } else { |
| 122 | − QMF_RE(X[((l + offset)<<5) + n]) = 0; | |
| 122 | + QMF_RE(X[l + offset][n]) = 0; | |
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | 125 | #else |
| 126 | +#if 0 | |
| 126 | 127 | x[0] = u[0]; |
| 127 | 128 | x[63] = u[32]; |
| 128 | 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 | 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 | 148 | for (n = 0; n < 32; n++) |
| 137 | 149 | { |
| 138 | 150 | if (n < kx) |
| 139 | 151 | { |
| 140 | 152 | #ifdef FIXED_POINT |
| 141 | − QMF_RE(X[((l + offset)<<5) + n]) = y[n] << 1; | |
| 142 | − QMF_IM(X[((l + offset)<<5) + n]) = -y[63-n] << 1; | |
| 153 | + QMF_RE(X[l + offset][n]) = y[n] << 1; | |
| 154 | + QMF_IM(X[l + offset][n]) = -y[63-n] << 1; | |
| 143 | 155 | #else |
| 144 | − QMF_RE(X[((l + offset)<<5) + n]) = 2. * y[n]; | |
| 145 | − QMF_IM(X[((l + offset)<<5) + n]) = -2. * y[63-n]; | |
| 156 | + QMF_RE(X[l + offset][n]) = 2. * y[n]; | |
| 157 | + QMF_IM(X[l + offset][n]) = -2. * y[63-n]; | |
| 146 | 158 | #endif |
| 147 | 159 | } else { |
| 148 | − QMF_RE(X[((l + offset)<<5) + n]) = 0; | |
| 149 | − QMF_IM(X[((l + offset)<<5) + n]) = 0; | |
| 160 | + QMF_RE(X[l + offset][n]) = 0; | |
| 161 | + QMF_IM(X[l + offset][n]) = 0; | |
| 150 | 162 | } |
| 151 | 163 | } |
| 152 | 164 | #endif |
| @@ -181,7 +193,7 @@ void qmfs_end(qmfs_info *qmfs) · 28 unmodified lines | ||
| 181 | 193 | } |
| 182 | 194 | |
| 183 | 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 | 197 | real_t *output) |
| 186 | 198 | { |
| 187 | 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 | 219 | for (k = 0; k < 64; k++) |
| 208 | 220 | { |
| 209 | 221 | #ifdef FIXED_POINT |
| 210 | − x[k] = QMF_RE(X[(l<<6) + k]); | |
| 222 | + x[k] = QMF_RE(X[l][k]); | |
| 211 | 223 | #else |
| 212 | − x[k] = QMF_RE(X[(l<<6) + k]) / 32.; | |
| 224 | + x[k] = QMF_RE(X[l][k]) / 32.; | |
| 213 | 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 | 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 | 261 | real_t *output) |
| 250 | 262 | { |
| 251 | − uint8_t l; | |
| 252 | − int16_t n, k; | |
| 253 | 263 | real_t x1[64], x2[64]; |
| 254 | 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 | 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 | 281 | qmfs->v_index = (qmfs->v_index + 1) & 0x1; |
| 269 | 282 | |
| 270 | 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.; | |
| 274 | − x2[63 - k] = QMF_IM(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])); | |
| 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); | |
| 278 | − DCT4_64(x2, x2); | |
| 297 | + DCT4_64_kernel(x1, x1); | |
| 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]; | |
| 283 | − v0[n+1] = -x2[n+1] - x1[n+1]; | |
| 284 | − v1[63-n] = x2[n] + x1[n]; | |
| 285 | − v1[63-n-1] = -x2[n+1] + x1[n+1]; | |
| 302 | + v0[ 2*n] = x2[2*n] - x1[2*n]; | |
| 303 | + v1[63-2*n] = x2[2*n] + x1[2*n]; | |
| 304 | + v0[ 2*n+1] = -x2[2*n+1] - x1[2*n+1]; | |
| 305 | + v1[62-2*n] = -x2[2*n+1] + x1[2*n+1]; | |
| 286 | 306 | } |
| 287 | 307 | |
| 288 | 308 | /* calculate 64 output samples and window */ |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | #ifndef __SBR_QMF_H__ |
| @@ -38,12 +38,10 @@ qmfs_info *qmfs_init(uint8_t channels); · 9 unmodified lines | ||
| 38 | 38 | void qmfs_end(qmfs_info *qmfs); |
| 39 | 39 | |
| 40 | 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); | |
| 42 | −void sbr_qmf_analysis_64(qmfa_info *qmfa, const real_t *input, | |
| 43 | − qmf_t *X, uint8_t maxband, uint8_t offset); | |
| 41 | + qmf_t X[40][32], uint8_t offset, uint8_t kx); | |
| 44 | 42 | void sbr_qmf_synthesis_32(qmfs_info *qmfs, const qmf_t *X, |
| 45 | 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 | 45 | real_t *output); |
| 48 | 46 | |
| 49 | 47 | |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | #ifndef __SBR_QMF_C_H__ |
| @@ -1,19 +1,19 @@ | ||
| 1 | 1 | /* |
| 2 | 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
| 3 | 3 | ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com |
| 4 | −** | |
| 4 | +** | |
| 5 | 5 | ** This program is free software; you can redistribute it and/or modify |
| 6 | 6 | ** it under the terms of the GNU General Public License as published by |
| 7 | 7 | ** the Free Software Foundation; either version 2 of the License, or |
| 8 | 8 | ** (at your option) any later version. |
| 9 | −** | |
| 9 | +** | |
| 10 | 10 | ** This program is distributed in the hope that it will be useful, |
| 11 | 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | 13 | ** GNU General Public License for more details. |
| 14 | −** | |
| 14 | +** | |
| 15 | 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 | 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | 18 | ** |
| 19 | 19 | ** Any non-GPL usage of this software or parts of this software is strictly |
| @@ -22,7 +22,7 @@ · 2 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | #include "common.h" |
| @@ -78,7 +78,7 @@ static void sbr_reset(sbr_info *sbr) · 49 unmodified lines | ||
| 78 | 78 | } |
| 79 | 79 | |
| 80 | 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 | 83 | uint8_t result; |
| 84 | 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 | 106 | if (sbr->Is_DRM_SBR) |
| 107 | 107 | { |
| 108 | 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 | 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 | 138 | #endif |
| 139 | 139 | |
| 140 | 140 | if (sbr->bs_header_flag) |
| 141 | − sbr_header(ld, sbr, id_aac); | |
| 141 | + sbr_header(ld, sbr); | |
| 142 | 142 | |
| 143 | 143 | /* TODO: Reset? */ |
| 144 | 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 | 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 | 185 | return result; |
| 186 | 186 | |
| 187 | 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 | 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 | 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 | 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 | 295 | uint8_t result; |
| 296 | 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 | 305 | sbr->rate = 2; |
| 306 | 306 | #endif |
| 307 | 307 | |
| 308 | − switch (id_aac) | |
| 308 | + switch (sbr->id_aac) | |
| 309 | 309 | { |
| 310 | 310 | case ID_SCE: |
| 311 | − if ((result = sbr_single_channel_element(ld, sbr)) > 0) | |
| 312 | − return result; | |
| 311 | + if ((result = sbr_single_channel_element(ld, sbr)) > 0) | |
| 312 | + return result; | |
| 313 | 313 | break; |
| 314 | 314 | case ID_CPE: |
| 315 | − if ((result = sbr_channel_pair_element(ld, sbr)) > 0) | |
| 316 | − return result; | |
| 315 | + if ((result = sbr_channel_pair_element(ld, sbr)) > 0) | |
| 316 | + return result; | |
| 317 | 317 | break; |
| 318 | 318 | } |
| 319 | 319 | |
| 320 | − return 0; | |
| 320 | + return 0; | |
| 321 | 321 | } |
| 322 | 322 | |
| 323 | 323 | /* table 5 */ |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | #ifndef __SBR_SYNTAX_H__ |
| @@ -59,9 +59,9 @@ extern "C" { · 30 unmodified lines | ||
| 59 | 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); | |
| 63 | −static void sbr_header(bitfile *ld, sbr_info *sbr, uint8_t id_aac); | |
| 64 | −static uint8_t sbr_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); | |
| 64 | +static uint8_t sbr_data(bitfile *ld, sbr_info *sbr); | |
| 65 | 65 | static uint8_t sbr_single_channel_element(bitfile *ld, sbr_info *sbr); |
| 66 | 66 | static uint8_t sbr_channel_pair_element(bitfile *ld, sbr_info *sbr); |
| 67 | 67 | static uint8_t sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch); |
| @@ -1,19 +1,19 @@ | ||
| 1 | 1 | /* |
| 2 | 2 | ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding |
| 3 | 3 | ** Copyright (C) 2003 M. Bakker, Ahead Software AG, http://www.nero.com |
| 4 | −** | |
| 4 | +** | |
| 5 | 5 | ** This program is free software; you can redistribute it and/or modify |
| 6 | 6 | ** it under the terms of the GNU General Public License as published by |
| 7 | 7 | ** the Free Software Foundation; either version 2 of the License, or |
| 8 | 8 | ** (at your option) any later version. |
| 9 | −** | |
| 9 | +** | |
| 10 | 10 | ** This program is distributed in the hope that it will be useful, |
| 11 | 11 | ** but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 12 | 12 | ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 13 | 13 | ** GNU General Public License for more details. |
| 14 | −** | |
| 14 | +** | |
| 15 | 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 | 17 | ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. |
| 18 | 18 | ** |
| 19 | 19 | ** Any non-GPL usage of this software or parts of this software is strictly |
| @@ -22,7 +22,7 @@ · 2 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | /* Time/Frequency grid */ |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 39 | #include "specrec.h" |
| 40 | 40 | #include "syntax.h" |
| 41 | 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 | 53 | #ifdef LD_DEC |
| 44 | 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 | 420 | - Within a scalefactor window band, the coefficients are in ascending |
| 411 | 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 | 425 | uint8_t g, sfb, win; |
| 416 | 426 | uint16_t width, bin, k, gindex; |
| 417 | 427 | |
| 418 | − real_t tmp_spec[1024]; | |
| 419 | − | |
| 420 | − memset(tmp_spec, 0, frame_len*sizeof(real_t)); | |
| 428 | + real_t tmp_spec[1024] = {0}; | |
| 421 | 429 | |
| 422 | 430 | k = 0; |
| 423 | 431 | gindex = 0; |
| @@ -470,27 +478,23 @@ static INLINE real_t iquant(int16_t q, real_t *tab) · 46 unmodified lines | ||
| 470 | 478 | #ifdef FIXED_POINT |
| 471 | 479 | int16_t sgn = 1; |
| 472 | 480 | |
| 473 | − if (q == 0) return 0; | |
| 474 | − | |
| 475 | 481 | if (q < 0) |
| 476 | 482 | { |
| 477 | 483 | q = -q; |
| 478 | 484 | sgn = -1; |
| 479 | 485 | } |
| 480 | 486 | |
| 481 | − if (q >= IQ_TABLE_SIZE) | |
| 482 | − return 0; /* sgn * tab[q>>3] * 16; */ | |
| 483 | − | |
| 484 | − return sgn * tab[q]; | |
| 487 | + if (q < IQ_TABLE_SIZE) | |
| 488 | + return sgn * tab[q]; | |
| 489 | + | |
| 490 | + return 0; /* sgn * tab[q>>3] * 16; */ | |
| 485 | 491 | #else |
| 486 | − int16_t sgn = 1; | |
| 487 | − | |
| 488 | − if (q == 0) return 0; | |
| 492 | + real_t sgn = REAL_CONST(1.0); | |
| 489 | 493 | |
| 490 | 494 | if (q < 0) |
| 491 | 495 | { |
| 492 | 496 | q = -q; |
| 493 | − sgn = -1; | |
| 497 | + sgn = REAL_CONST(-1.0); | |
| 494 | 498 | } |
| 495 | 499 | |
| 496 | 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 | 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 | 509 | int16_t i; |
| 506 | 510 | real_t *tab = iq_table; |
| @@ -535,8 +539,8 @@ static real_t pow2_table[] = · 28 unmodified lines | ||
| 535 | 539 | }; |
| 536 | 540 | #endif |
| 537 | 541 | |
| 538 | −void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics, real_t *x_invquant, | |
| 539 | − uint16_t frame_len) | |
| 542 | +static void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics, | |
| 543 | + real_t *x_invquant, uint16_t frame_len) | |
| 540 | 544 | { |
| 541 | 545 | uint8_t g, sfb; |
| 542 | 546 | uint16_t top; |
| @@ -617,3 +621,333 @@ void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics, real_t *x_invqua · 74 unmodified lines | ||
| 617 | 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 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | #ifndef __SPECREC_H__ |
| @@ -35,14 +35,19 @@ extern "C" { · 6 unmodified lines | ||
| 35 | 35 | #include "syntax.h" |
| 36 | 36 | |
| 37 | 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); | |
| 39 | −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, | |
| 41 | − uint16_t frame_len); | |
| 38 | +static void quant_to_spec(ic_stream *ics, real_t *spec_data, uint16_t frame_len); | |
| 39 | +static void inverse_quantization(real_t *x_invquant, int16_t *x_quant, uint16_t frame_len); | |
| 40 | +static void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics, real_t *x_invquant, | |
| 41 | + uint16_t frame_len); | |
| 42 | 42 | #ifndef FIXED_POINT |
| 43 | 43 | void build_tables(real_t *pow2_table); |
| 44 | 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 | 51 | #ifdef __cplusplus |
| 47 | 52 | } |
| 48 | 53 | #endif |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 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 | 44 | uint8_t band; |
| 45 | 45 | uint16_t ssr_frame_len = frame_len/SSR_BANDS; |
| 46 | − real_t time_tmp[2048]; | |
| 47 | − real_t output[1024]; | |
| 48 | − | |
| 49 | − memset(output, 0, 1024*sizeof(real_t)); | |
| 50 | − memset(time_tmp, 0, 2048*sizeof(real_t)); | |
| 46 | + real_t time_tmp[2048] = {0}; | |
| 47 | + real_t output[1024] = {0}; | |
| 51 | 48 | |
| 52 | 49 | for (band = 0; band < SSR_BANDS; band++) |
| 53 | 50 | { |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | #ifndef __STRUCTS_H__ |
| @@ -32,6 +32,7 @@ · 3 unmodified lines | ||
| 32 | 32 | extern "C" { |
| 33 | 33 | #endif |
| 34 | 34 | |
| 35 | +#include "cfft.h" | |
| 35 | 36 | #ifdef SBR_DEC |
| 36 | 37 | #include "sbr_dec.h" |
| 37 | 38 | #endif |
| @@ -50,14 +51,6 @@ typedef struct { · 12 unmodified lines | ||
| 50 | 51 | real_t VAR[2]; |
| 51 | 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 | 54 | typedef struct { |
| 62 | 55 | uint16_t N; |
| 63 | 56 | cfft_info *cfft; |
| @@ -377,7 +370,6 @@ typedef struct · 313 unmodified lines | ||
| 377 | 370 | |
| 378 | 371 | uint8_t downMatrix; |
| 379 | 372 | uint8_t first_syn_ele; |
| 380 | − uint8_t last_syn_ele; | |
| 381 | 373 | uint8_t has_lfe; |
| 382 | 374 | uint8_t fr_channels; |
| 383 | 375 | uint8_t fr_ch_ele; |
| @@ -429,6 +421,7 @@ typedef struct · 45 unmodified lines | ||
| 429 | 421 | /* Program Config Element */ |
| 430 | 422 | uint8_t pce_set; |
| 431 | 423 | program_config pce; |
| 424 | + uint8_t element_id[MAX_CHANNELS]; | |
| 432 | 425 | uint8_t channel_element[MAX_CHANNELS]; |
| 433 | 426 | uint8_t internal_channel[MAX_CHANNELS]; |
| 434 | 427 | |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 260 | return 0; |
| 261 | 261 | } |
| 262 | 262 | |
| 263 | −element *decode_sce_lfe(faacDecHandle hDecoder, | |
| 264 | − faacDecFrameInfo *hInfo, bitfile *ld, | |
| 265 | − real_t **spec_coef, uint8_t id_syn_ele) | |
| 263 | +void decode_sce_lfe(faacDecHandle hDecoder, | |
| 264 | + faacDecFrameInfo *hInfo, bitfile *ld, | |
| 265 | + uint8_t id_syn_ele) | |
| 266 | 266 | { |
| 267 | − element *ele; | |
| 268 | 267 | uint8_t channels = hDecoder->fr_channels; |
| 268 | + uint8_t tag = 0; | |
| 269 | 269 | |
| 270 | 270 | if (channels+1 > MAX_CHANNELS) |
| 271 | 271 | { |
| 272 | 272 | hInfo->error = 12; |
| 273 | − return NULL; | |
| 273 | + return; | |
| 274 | 274 | } |
| 275 | 275 | if (hDecoder->fr_ch_ele+1 > MAX_SYNTAX_ELEMENTS) |
| 276 | 276 | { |
| 277 | 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)); | |
| 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]); | |
| 281 | + hInfo->error = single_lfe_channel_element(hDecoder, ld, channels, &tag); | |
| 291 | 282 | |
| 292 | 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 | 285 | else |
| 295 | 286 | hDecoder->internal_channel[channels] = channels; |
| 296 | 287 | |
| @@ -298,47 +289,35 @@ element *decode_sce_lfe(faacDecHandle hDecoder, · 1 unmodified line | ||
| 298 | 289 | hDecoder->channel_element[channels] = hDecoder->fr_ch_ele; |
| 299 | 290 | else /* LFE */ |
| 300 | 291 | hDecoder->channel_element[channels] = hDecoder->fr_ch_ele; |
| 292 | + hDecoder->element_id[hDecoder->fr_ch_ele] = id_syn_ele; | |
| 301 | 293 | |
| 302 | 294 | hDecoder->fr_channels++; |
| 303 | 295 | hDecoder->fr_ch_ele++; |
| 304 | − | |
| 305 | − return ele; | |
| 306 | 296 | } |
| 307 | 297 | |
| 308 | −element *decode_cpe(faacDecHandle hDecoder, | |
| 309 | − faacDecFrameInfo *hInfo, bitfile *ld, | |
| 310 | − real_t **spec_coef, uint8_t id_syn_ele) | |
| 298 | +void decode_cpe(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, bitfile *ld, | |
| 299 | + uint8_t id_syn_ele) | |
| 311 | 300 | { |
| 312 | − element *ele; | |
| 313 | 301 | uint8_t channels = hDecoder->fr_channels; |
| 302 | + uint8_t tag = 0; | |
| 314 | 303 | |
| 315 | 304 | if (channels+2 > MAX_CHANNELS) |
| 316 | 305 | { |
| 317 | 306 | hInfo->error = 12; |
| 318 | − return NULL; | |
| 307 | + return; | |
| 319 | 308 | } |
| 320 | 309 | if (hDecoder->fr_ch_ele+1 > MAX_SYNTAX_ELEMENTS) |
| 321 | 310 | { |
| 322 | 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)); | |
| 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]); | |
| 315 | + hInfo->error = channel_pair_element(hDecoder, ld, channels, &tag); | |
| 337 | 316 | |
| 338 | 317 | if (hDecoder->pce_set) |
| 339 | 318 | { |
| 340 | − hDecoder->internal_channel[hDecoder->pce.cpe_channel[ele->element_instance_tag]] = channels; | |
| 341 | − hDecoder->internal_channel[hDecoder->pce.cpe_channel[ele->element_instance_tag]+1] = channels+1; | |
| 319 | + hDecoder->internal_channel[hDecoder->pce.cpe_channel[tag]] = channels; | |
| 320 | + hDecoder->internal_channel[hDecoder->pce.cpe_channel[tag]+1] = channels+1; | |
| 342 | 321 | } else { |
| 343 | 322 | hDecoder->internal_channel[channels] = channels; |
| 344 | 323 | hDecoder->internal_channel[channels+1] = channels+1; |
| @@ -346,16 +325,14 @@ element *decode_cpe(faacDecHandle hDecoder, · 1 unmodified line | ||
| 346 | 325 | |
| 347 | 326 | hDecoder->channel_element[channels] = hDecoder->fr_ch_ele; |
| 348 | 327 | hDecoder->channel_element[channels+1] = hDecoder->fr_ch_ele; |
| 328 | + hDecoder->element_id[hDecoder->fr_ch_ele] = id_syn_ele; | |
| 349 | 329 | |
| 350 | 330 | hDecoder->fr_channels += 2; |
| 351 | 331 | hDecoder->fr_ch_ele++; |
| 352 | − | |
| 353 | − return ele; | |
| 354 | 332 | } |
| 355 | 333 | |
| 356 | −element **raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, | |
| 357 | − bitfile *ld, element **elements, | |
| 358 | − real_t **spec_coef, program_config *pce, drc_info *drc) | |
| 334 | +void raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, | |
| 335 | + bitfile *ld, program_config *pce, drc_info *drc) | |
| 359 | 336 | { |
| 360 | 337 | uint8_t id_syn_ele; |
| 361 | 338 | uint8_t ch_ele = 0; |
| @@ -376,38 +353,36 @@ element **raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, · 14 unmodified lines | ||
| 376 | 353 | switch (id_syn_ele) { |
| 377 | 354 | case ID_SCE: |
| 378 | 355 | if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = id_syn_ele; |
| 379 | − hDecoder->last_syn_ele = id_syn_ele; | |
| 380 | − elements[ch_ele++] = decode_sce_lfe(hDecoder, | |
| 381 | − hInfo, ld, spec_coef, id_syn_ele); | |
| 356 | + decode_sce_lfe(hDecoder, hInfo, ld, id_syn_ele); | |
| 357 | + ch_ele++; | |
| 382 | 358 | if (hInfo->error > 0) |
| 383 | − return elements; | |
| 359 | + return; | |
| 384 | 360 | break; |
| 385 | 361 | case ID_CPE: |
| 386 | 362 | if (hDecoder->first_syn_ele == 25) hDecoder->first_syn_ele = id_syn_ele; |
| 387 | − hDecoder->last_syn_ele = id_syn_ele; | |
| 388 | − elements[ch_ele++] = decode_cpe(hDecoder, | |
| 389 | − hInfo, ld, spec_coef, id_syn_ele); | |
| 363 | + decode_cpe(hDecoder, hInfo, ld, id_syn_ele); | |
| 364 | + ch_ele++; | |
| 390 | 365 | if (hInfo->error > 0) |
| 391 | − return elements; | |
| 366 | + return; | |
| 392 | 367 | break; |
| 393 | 368 | case ID_LFE: |
| 394 | 369 | hDecoder->has_lfe++; |
| 395 | − elements[ch_ele++] = decode_sce_lfe(hDecoder, | |
| 396 | − hInfo, ld, spec_coef, id_syn_ele); | |
| 370 | + decode_sce_lfe(hDecoder, hInfo, ld, id_syn_ele); | |
| 371 | + ch_ele++; | |
| 397 | 372 | if (hInfo->error > 0) |
| 398 | − return elements; | |
| 373 | + return; | |
| 399 | 374 | break; |
| 400 | 375 | case ID_CCE: /* not implemented yet, but skip the bits */ |
| 401 | 376 | hInfo->error = coupling_channel_element(hDecoder, ld); |
| 402 | 377 | if (hInfo->error > 0) |
| 403 | − return elements; | |
| 378 | + return; | |
| 404 | 379 | break; |
| 405 | 380 | case ID_DSE: |
| 406 | 381 | data_stream_element(hDecoder, ld); |
| 407 | 382 | break; |
| 408 | 383 | case ID_PCE: |
| 409 | 384 | if ((hInfo->error = program_config_element(pce, ld)) > 0) |
| 410 | − return elements; | |
| 385 | + return; | |
| 411 | 386 | hDecoder->pce_set = 1; |
| 412 | 387 | break; |
| 413 | 388 | case ID_FIL: |
| @@ -417,7 +392,7 @@ element **raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, · 3 unmodified lines | ||
| 417 | 392 | , (ch_ele-1) |
| 418 | 393 | #endif |
| 419 | 394 | )) > 0) |
| 420 | − return elements; | |
| 395 | + return; | |
| 421 | 396 | #ifdef SBR_DEC |
| 422 | 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 | 410 | switch (hDecoder->channelConfiguration) |
| 436 | 411 | { |
| 437 | 412 | case 1: |
| 438 | − elements[ch_ele++] = decode_sce_lfe(hDecoder, | |
| 439 | − hInfo, ld, spec_coef, ID_SCE); | |
| 413 | + decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); | |
| 414 | + ch_ele++; | |
| 440 | 415 | if (hInfo->error > 0) |
| 441 | − return elements; | |
| 416 | + return; | |
| 442 | 417 | break; |
| 443 | 418 | case 2: |
| 444 | − elements[ch_ele++] = decode_cpe(hDecoder, | |
| 445 | − hInfo, ld, spec_coef, ID_CPE); | |
| 419 | + decode_cpe(hDecoder, hInfo, ld, ID_CPE); | |
| 420 | + ch_ele++; | |
| 446 | 421 | if (hInfo->error > 0) |
| 447 | − return elements; | |
| 422 | + return; | |
| 448 | 423 | break; |
| 449 | 424 | case 3: |
| 450 | − elements[ch_ele++] = decode_sce_lfe(hDecoder, | |
| 451 | − hInfo, ld, spec_coef, ID_SCE); | |
| 452 | − elements[ch_ele++] = decode_cpe(hDecoder, | |
| 453 | − hInfo, ld, spec_coef, ID_CPE); | |
| 425 | + decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); | |
| 426 | + ch_ele++; | |
| 427 | + decode_cpe(hDecoder, hInfo, ld, ID_CPE); | |
| 428 | + ch_ele++; | |
| 454 | 429 | if (hInfo->error > 0) |
| 455 | − return elements; | |
| 430 | + return; | |
| 456 | 431 | break; |
| 457 | 432 | case 4: |
| 458 | − elements[ch_ele++] = decode_sce_lfe(hDecoder, | |
| 459 | − hInfo, ld, spec_coef, ID_SCE); | |
| 460 | − elements[ch_ele++] = decode_cpe(hDecoder, | |
| 461 | − hInfo, ld, spec_coef, ID_CPE); | |
| 462 | − elements[ch_ele++] = decode_sce_lfe(hDecoder, | |
| 463 | − hInfo, ld, spec_coef, ID_SCE); | |
| 433 | + decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); | |
| 434 | + ch_ele++; | |
| 435 | + decode_cpe(hDecoder, hInfo, ld, ID_CPE); | |
| 436 | + ch_ele++; | |
| 437 | + decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); | |
| 438 | + ch_ele++; | |
| 464 | 439 | if (hInfo->error > 0) |
| 465 | − return elements; | |
| 440 | + return; | |
| 466 | 441 | break; |
| 467 | 442 | case 5: |
| 468 | − elements[ch_ele++] = decode_sce_lfe(hDecoder, | |
| 469 | − hInfo, ld, spec_coef, ID_SCE); | |
| 470 | − elements[ch_ele++] = decode_cpe(hDecoder, | |
| 471 | − hInfo, ld, spec_coef, ID_CPE); | |
| 472 | − elements[ch_ele++] = decode_cpe(hDecoder, | |
| 473 | − hInfo, ld, spec_coef, ID_CPE); | |
| 443 | + decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); | |
| 444 | + ch_ele++; | |
| 445 | + decode_cpe(hDecoder, hInfo, ld, ID_CPE); | |
| 446 | + ch_ele++; | |
| 447 | + decode_cpe(hDecoder, hInfo, ld, ID_CPE); | |
| 448 | + ch_ele++; | |
| 474 | 449 | if (hInfo->error > 0) |
| 475 | − return elements; | |
| 450 | + return; | |
| 476 | 451 | break; |
| 477 | 452 | case 6: |
| 478 | − elements[ch_ele++] = decode_sce_lfe(hDecoder, | |
| 479 | − hInfo, ld, spec_coef, ID_SCE); | |
| 480 | − elements[ch_ele++] = decode_cpe(hDecoder, | |
| 481 | − hInfo, ld, spec_coef, ID_CPE); | |
| 482 | − elements[ch_ele++] = decode_cpe(hDecoder, | |
| 483 | − hInfo, ld, spec_coef, ID_CPE); | |
| 484 | − elements[ch_ele++] = decode_sce_lfe(hDecoder, | |
| 485 | − hInfo, ld, spec_coef, ID_LFE); | |
| 453 | + decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); | |
| 454 | + ch_ele++; | |
| 455 | + decode_cpe(hDecoder, hInfo, ld, ID_CPE); | |
| 456 | + ch_ele++; | |
| 457 | + decode_cpe(hDecoder, hInfo, ld, ID_CPE); | |
| 458 | + ch_ele++; | |
| 459 | + decode_sce_lfe(hDecoder, hInfo, ld, ID_LFE); | |
| 460 | + ch_ele++; | |
| 486 | 461 | if (hInfo->error > 0) |
| 487 | − return elements; | |
| 462 | + return; | |
| 488 | 463 | break; |
| 489 | 464 | case 7: |
| 490 | − elements[ch_ele++] = decode_sce_lfe(hDecoder, | |
| 491 | − hInfo, ld, spec_coef, ID_SCE); | |
| 492 | − elements[ch_ele++] = decode_cpe(hDecoder, | |
| 493 | − hInfo, ld, spec_coef, ID_CPE); | |
| 494 | − elements[ch_ele++] = decode_cpe(hDecoder, | |
| 495 | − hInfo, ld, spec_coef, ID_CPE); | |
| 496 | − elements[ch_ele++] = decode_cpe(hDecoder, | |
| 497 | − hInfo, ld, spec_coef, ID_CPE); | |
| 498 | − elements[ch_ele++] = decode_sce_lfe(hDecoder, | |
| 499 | − hInfo, ld, spec_coef, ID_LFE); | |
| 465 | + decode_sce_lfe(hDecoder, hInfo, ld, ID_SCE); | |
| 466 | + ch_ele++; | |
| 467 | + decode_cpe(hDecoder, hInfo, ld, ID_CPE); | |
| 468 | + ch_ele++; | |
| 469 | + decode_cpe(hDecoder, hInfo, ld, ID_CPE); | |
| 470 | + ch_ele++; | |
| 471 | + decode_cpe(hDecoder, hInfo, ld, ID_CPE); | |
| 472 | + ch_ele++; | |
| 473 | + decode_sce_lfe(hDecoder, hInfo, ld, ID_LFE); | |
| 474 | + ch_ele++; | |
| 500 | 475 | if (hInfo->error > 0) |
| 501 | − return elements; | |
| 476 | + return; | |
| 502 | 477 | break; |
| 503 | 478 | default: |
| 504 | 479 | hInfo->error = 7; |
| 505 | − return elements; | |
| 480 | + return; | |
| 506 | 481 | } |
| 507 | 482 | #if 0 |
| 508 | 483 | cnt = bits_to_decode() / 8; |
| @@ -522,30 +497,34 @@ element **raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, · 13 unmodified lines | ||
| 522 | 497 | faad_byte_align(ld); |
| 523 | 498 | } |
| 524 | 499 | |
| 525 | − return elements; | |
| 500 | + return; | |
| 526 | 501 | } |
| 527 | 502 | |
| 528 | 503 | /* Table 4.4.4 and */ |
| 529 | 504 | /* Table 4.4.9 */ |
| 530 | −static uint8_t single_lfe_channel_element(faacDecHandle hDecoder, | |
| 531 | − element *sce, bitfile *ld, | |
| 532 | − real_t *spec_coef) | |
| 505 | +static uint8_t single_lfe_channel_element(faacDecHandle hDecoder, bitfile *ld, | |
| 506 | + uint8_t channel, uint8_t *tag) | |
| 533 | 507 | { |
| 534 | 508 | uint8_t retval = 0; |
| 535 | − ic_stream *ics = &(sce->ics1); | |
| 536 | − int16_t spec_data[1024]; | |
| 509 | + element sce = {0}; | |
| 510 | + ic_stream *ics = &(sce.ics1); | |
| 511 | + int16_t spec_data[1024] = {0}; | |
| 537 | 512 | #ifdef DRM |
| 538 | 513 | uint8_t result; |
| 539 | 514 | |
| 540 | 515 | if (hDecoder->object_type != DRM_ER_LC) |
| 541 | 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 | 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 | 524 | #ifdef DRM |
| 546 | 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 | 529 | if (ics->tns_data_present) |
| 551 | 530 | tns_data(ics, &(ics->tns), ld); |
| @@ -571,49 +550,43 @@ static uint8_t single_lfe_channel_element(faacDecHandle hDecoder, · 19 unmodified lines | ||
| 571 | 550 | } else |
| 572 | 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 | 554 | if (retval > 0) |
| 576 | 555 | return retval; |
| 577 | 556 | } |
| 578 | 557 | |
| 579 | − | |
| 580 | 558 | /* noiseless coding is done, spectral reconstruction is done now */ |
| 581 | − | |
| 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); | |
| 559 | + reconstruct_single_channel(hDecoder, ics, &sce, spec_data); | |
| 591 | 560 | |
| 592 | 561 | return 0; |
| 593 | 562 | } |
| 594 | 563 | |
| 595 | 564 | /* Table 4.4.5 */ |
| 596 | −static uint8_t channel_pair_element(faacDecHandle hDecoder, element *cpe, | |
| 597 | − bitfile *ld, | |
| 598 | − real_t *spec_coef1, real_t *spec_coef2) | |
| 565 | +static uint8_t channel_pair_element(faacDecHandle hDecoder, bitfile *ld, | |
| 566 | + uint8_t channels, uint8_t *tag) | |
| 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 | 573 | uint8_t result; |
| 601 | − ic_stream *ics1 = &(cpe->ics1); | |
| 602 | − ic_stream *ics2 = &(cpe->ics2); | |
| 603 | − int16_t spec_data1[1024]; | |
| 604 | − int16_t spec_data2[1024]; | |
| 574 | + | |
| 575 | + cpe.channel = channels; | |
| 576 | + cpe.paired_channel = channels+1; | |
| 605 | 577 | |
| 606 | 578 | #ifdef DRM |
| 607 | 579 | if (hDecoder->object_type != DRM_ER_LC) |
| 608 | 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 | 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 | 586 | DEBUGVAR(1,40,"channel_pair_element(): common_window"))) & 1) |
| 614 | 587 | { |
| 615 | 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 | 590 | return result; |
| 618 | 591 | |
| 619 | 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 | 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 | 624 | 0, spec_data1)) > 0) |
| 652 | 625 | { |
| 653 | 626 | return result; |
| 654 | 627 | } |
| 655 | 628 | |
| 656 | 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 | 631 | (ics1->predictor_data_present)) |
| 659 | 632 | { |
| 660 | 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 | 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 | 642 | 0, spec_data2)) > 0) |
| 670 | 643 | { |
| 671 | 644 | return result; |
| @@ -713,20 +686,7 @@ static uint8_t channel_pair_element(faacDecHandle hDecoder, element *cpe, · 41 unmodified lines | ||
| 713 | 686 | #endif |
| 714 | 687 | |
| 715 | 688 | /* noiseless coding is done, spectral reconstruction is done now */ |
| 716 | − | |
| 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); | |
| 689 | + reconstruct_channel_pair(hDecoder, ics1, ics2, &cpe, spec_data1, spec_data2); | |
| 730 | 690 | |
| 731 | 691 | return 0; |
| 732 | 692 | } |
| @@ -873,13 +833,10 @@ static uint8_t coupling_channel_element(faacDecHandle hDecoder, bitfile *ld) · 140 unmodified lines | ||
| 873 | 833 | uint8_t num_gain_element_lists = 0; |
| 874 | 834 | uint8_t num_coupled_elements = 0; |
| 875 | 835 | |
| 876 | − element el_empty; | |
| 877 | − ic_stream ics_empty; | |
| 836 | + element el_empty = {0}; | |
| 837 | + ic_stream ics_empty = {0}; | |
| 878 | 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 | 840 | c = faad_getbits(ld, LEN_TAG |
| 884 | 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 | 985 | /* read in all the SBR data for processing later on */ |
| 1029 | 986 | hDecoder->sbr[sbr_ele]->data = (uint8_t*)faad_getbitbuffer(ld, count*8); |
| 1030 | 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 | 990 | } else { |
| 1032 | 991 | hDecoder->sbr_used[sbr_ele] = 0; |
| 1033 | 992 | #endif |
| @@ -1602,7 +1561,7 @@ static uint8_t spectral_data(faacDecHandle hDecoder, ic_stream *ics, bitfile *ld · 568 unmodified lines | ||
| 1602 | 1561 | uint16_t nshort = hDecoder->frameLength/8; |
| 1603 | 1562 | |
| 1604 | 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 | 1566 | for(g = 0; g < ics->num_window_groups; g++) |
| 1608 | 1567 | { |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | ||
| 22 | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | 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 | 28 | #ifndef __SYNTAX_H__ |
| @@ -109,15 +109,19 @@ int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC, · 80 unmodified lines | ||
| 109 | 109 | |
| 110 | 110 | uint8_t adts_frame(adts_header *adts, bitfile *ld); |
| 111 | 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 | 120 | /* static functions */ |
| 115 | −static uint8_t single_lfe_channel_element(faacDecHandle hDecoder, | |
| 116 | − element *sce, bitfile *ld, | |
| 117 | − real_t *spec_coef); | |
| 118 | −static uint8_t channel_pair_element(faacDecHandle hDecoder, element *cpe, | |
| 119 | − bitfile *ld, | |
| 120 | − real_t *spec_coef1, real_t *spec_coef2); | |
| 121 | +static uint8_t single_lfe_channel_element(faacDecHandle hDecoder, bitfile *ld, | |
| 122 | + uint8_t channel, uint8_t *tag); | |
| 123 | +static uint8_t channel_pair_element(faacDecHandle hDecoder, bitfile *ld, | |
| 124 | + uint8_t channel, uint8_t *tag); | |
| 121 | 125 | static uint8_t coupling_channel_element(faacDecHandle hDecoder, bitfile *ld); |
| 122 | 126 | static uint16_t data_stream_element(faacDecHandle hDecoder, bitfile *ld); |
| 123 | 127 | static uint8_t program_config_element(program_config *pce, bitfile *ld); |