Unified · Split
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: bits.c,v 1.34 2004/01/14 20:32:30 menno Exp $ | 25 | ** $Id: bits.c,v 1.35 2004/01/16 20:20:32 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #include "common.h" | 28 | #include "common.h" |
| @@ -74,7 +74,13 @@ void faad_initbits(bitfile *ld, const void *_buffer, const uint32_t buffer_size) · 45 unmodified lines | |||
| 74 | void faad_endbits(bitfile *ld) | 74 | void faad_endbits(bitfile *ld) |
| 75 | { | 75 | { |
| 76 | if (ld) | 76 | if (ld) |
| 77 | if (ld->buffer) faad_free(ld->buffer); | 77 | { |
| 78 | if (ld->buffer) | ||
| 79 | { | ||
| 80 | faad_free(ld->buffer); | ||
| 81 | ld->buffer = NULL; | ||
| 82 | } | ||
| 83 | } | ||
| 78 | } | 84 | } |
| 79 | 85 | ||
| 80 | uint32_t faad_get_processed_bits(bitfile *ld) | 86 | uint32_t faad_get_processed_bits(bitfile *ld) |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: bits.h,v 1.33 2004/01/14 20:36:22 menno Exp $ | 25 | ** $Id: bits.h,v 1.34 2004/01/16 20:20:32 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #ifndef __BITS_H__ | 28 | #ifndef __BITS_H__ |
| @@ -178,7 +178,7 @@ static INLINE uint8_t faad_get1bit(bitfile *ld DEBUGDEC) · 149 unmodified lines | |||
| 178 | r = (uint8_t)(ld->bufb >> 31); | 178 | r = (uint8_t)(ld->bufb >> 31); |
| 179 | faad_flushbits_ex(ld, 1); | 179 | faad_flushbits_ex(ld, 1); |
| 180 | #else | 180 | #else |
| 181 | r = faad_getbits(ld, 1); | 181 | r = (uint8_t)faad_getbits(ld, 1); |
| 182 | #endif | 182 | #endif |
| 183 | return r; | 183 | return r; |
| 184 | } | 184 | } |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: decoder.c,v 1.91 2004/01/14 20:32:30 menno Exp $ | 25 | ** $Id: decoder.c,v 1.92 2004/01/16 20:20:32 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #include "common.h" | 28 | #include "common.h" |
| @@ -128,7 +128,7 @@ faacDecHandle FAADAPI faacDecOpen(void) · 99 unmodified lines | |||
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | #ifdef SBR_DEC | 130 | #ifdef SBR_DEC |
| 131 | for (i = 0; i < 32; i++) | 131 | for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++) |
| 132 | { | 132 | { |
| 133 | hDecoder->sbr[i] = NULL; | 133 | hDecoder->sbr[i] = NULL; |
| 134 | } | 134 | } |
| @@ -441,7 +441,7 @@ int8_t FAADAPI faacDecInitDRM(faacDecHandle hDecoder, uint32_t samplerate, · 306 unmodified lines | |||
| 441 | } | 441 | } |
| 442 | 442 | ||
| 443 | #ifdef SBR_DEC | 443 | #ifdef SBR_DEC |
| 444 | for (i = 0; i < 32; i++) | 444 | for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++) |
| 445 | { | 445 | { |
| 446 | if (hDecoder->sbr[i]) | 446 | if (hDecoder->sbr[i]) |
| 447 | sbrDecodeEnd(hDecoder->sbr[i]); | 447 | sbrDecodeEnd(hDecoder->sbr[i]); |
| @@ -497,7 +497,7 @@ void FAADAPI faacDecClose(faacDecHandle hDecoder) · 49 unmodified lines | |||
| 497 | if (hDecoder->sample_buffer) faad_free(hDecoder->sample_buffer); | 497 | if (hDecoder->sample_buffer) faad_free(hDecoder->sample_buffer); |
| 498 | 498 | ||
| 499 | #ifdef SBR_DEC | 499 | #ifdef SBR_DEC |
| 500 | for (i = 0; i < 32; i++) | 500 | for (i = 0; i < MAX_SYNTAX_ELEMENTS; i++) |
| 501 | { | 501 | { |
| 502 | if (hDecoder->sbr[i]) | 502 | if (hDecoder->sbr[i]) |
| 503 | sbrDecodeEnd(hDecoder->sbr[i]); | 503 | sbrDecodeEnd(hDecoder->sbr[i]); |
| @@ -803,6 +803,13 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 299 unmodified lines | |||
| 803 | if (hInfo->error > 0) | 803 | if (hInfo->error > 0) |
| 804 | goto error; | 804 | goto error; |
| 805 | 805 | ||
| 806 | /* safety check */ | ||
| 807 | if (channels == 0 || channels > MAX_CHANNELS) | ||
| 808 | { | ||
| 809 | /* invalid number of channels */ | ||
| 810 | hInfo->error = 12; | ||
| 811 | goto error; | ||
| 812 | } | ||
| 806 | 813 | ||
| 807 | /* no more bit reading after this */ | 814 | /* no more bit reading after this */ |
| 808 | bitsconsumed = faad_get_processed_bits(&ld); | 815 | bitsconsumed = faad_get_processed_bits(&ld); |
| @@ -862,7 +869,8 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 53 unmodified lines | |||
| 862 | } | 869 | } |
| 863 | 870 | ||
| 864 | /* allocate the buffer for the final samples */ | 871 | /* allocate the buffer for the final samples */ |
| 865 | if (hDecoder->sample_buffer == NULL) | 872 | if ((hDecoder->sample_buffer == NULL) || |
| 873 | (hDecoder->alloced_channels != output_channels)) | ||
| 866 | { | 874 | { |
| 867 | static const uint8_t str[] = { sizeof(int16_t), sizeof(int32_t), sizeof(int32_t), | 875 | static const uint8_t str[] = { sizeof(int16_t), sizeof(int32_t), sizeof(int32_t), |
| 868 | sizeof(float32_t), sizeof(double), sizeof(int16_t), sizeof(int16_t), | 876 | sizeof(float32_t), sizeof(double), sizeof(int16_t), sizeof(int16_t), |
| @@ -873,7 +881,11 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 4 unmodified lines | |||
| 873 | if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) | 881 | if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) |
| 874 | stride = 2 * stride; | 882 | stride = 2 * stride; |
| 875 | #endif | 883 | #endif |
| 876 | hDecoder->sample_buffer = faad_malloc(frame_len*channels*stride); | 884 | if (hDecoder->sample_buffer) |
| 885 | faad_free(hDecoder->sample_buffer); | ||
| 886 | hDecoder->sample_buffer = NULL; | ||
| 887 | hDecoder->sample_buffer = faad_malloc(frame_len*output_channels*stride); | ||
| 888 | hDecoder->alloced_channels = output_channels; | ||
| 877 | } | 889 | } |
| 878 | 890 | ||
| 879 | sample_buffer = hDecoder->sample_buffer; | 891 | sample_buffer = hDecoder->sample_buffer; |
| @@ -881,11 +893,23 @@ void* FAADAPI faacDecDecode(faacDecHandle hDecoder, · 1 unmodified line | |||
| 881 | #ifdef SBR_DEC | 893 | #ifdef SBR_DEC |
| 882 | if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) | 894 | if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) |
| 883 | { | 895 | { |
| 896 | uint8_t ele; | ||
| 897 | |||
| 884 | /* this data is different when SBR is used or when the data is upsampled */ | 898 | /* this data is different when SBR is used or when the data is upsampled */ |
| 885 | frame_len *= 2; | 899 | frame_len *= 2; |
| 886 | hInfo->samples *= 2; | 900 | hInfo->samples *= 2; |
| 887 | hInfo->samplerate *= 2; | 901 | hInfo->samplerate *= 2; |
| 888 | 902 | ||
| 903 | /* check if every element was provided with SBR data */ | ||
| 904 | for (ele = 0; ele < hDecoder->fr_ch_ele; ele++) | ||
| 905 | { | ||
| 906 | if (hDecoder->sbr[ele] == NULL) | ||
| 907 | { | ||
| 908 | hInfo->error = 25; | ||
| 909 | goto error; | ||
| 910 | } | ||
| 911 | } | ||
| 912 | |||
| 889 | /* sbr */ | 913 | /* sbr */ |
| 890 | if (hDecoder->sbr_present_flag == 1) | 914 | if (hDecoder->sbr_present_flag == 1) |
| 891 | { | 915 | { |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: error.c,v 1.19 2004/01/05 14:05:11 menno Exp $ | 25 | ** $Id: error.c,v 1.20 2004/01/16 20:20:32 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #include "common.h" | 28 | #include "common.h" |
| @@ -41,12 +41,19 @@ int8_t *err_msg[] = { · 12 unmodified lines | |||
| 41 | "Error decoding huffman scalefactor (bitstream error)", | 41 | "Error decoding huffman scalefactor (bitstream error)", |
| 42 | "Error decoding huffman codeword (bitstream error)", | 42 | "Error decoding huffman codeword (bitstream error)", |
| 43 | "Non existent huffman codebook number found", | 43 | "Non existent huffman codebook number found", |
| 44 | "Maximum number of channels exceeded", | 44 | "Invalid number of channels", |
| 45 | "Maximum number of bitstream elements exceeded", | 45 | "Maximum number of bitstream elements exceeded", |
| 46 | "Input data buffer too small", | 46 | "Input data buffer too small", |
| 47 | "Array index out of range", | 47 | "Array index out of range", |
| 48 | "Maximum number of scalefactor bands exceeded", | 48 | "Maximum number of scalefactor bands exceeded", |
| 49 | "Quantised value out of range", | 49 | "Quantised value out of range", |
| 50 | "LTP lag out of range" | 50 | "LTP lag out of range", |
| 51 | "Invalid SBR parameter decoded", | ||
| 52 | "SBR called without being initialised", | ||
| 53 | "Unexpected channel configuration change", | ||
| 54 | "Error in program_config_element", | ||
| 55 | "First SBR frame is not the same as first AAC frame", | ||
| 56 | "Unexpected fill element with SBR data", | ||
| 57 | "Not all elements were provided with SBR data" | ||
| 51 | }; | 58 | }; |
| 52 | 59 | ||
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: error.h,v 1.14 2004/01/05 14:05:11 menno Exp $ | 25 | ** $Id: error.h,v 1.15 2004/01/16 20:20:32 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #ifndef __ERROR_H__ | 28 | #ifndef __ERROR_H__ |
| @@ -32,7 +32,7 @@ · 3 unmodified lines | |||
| 32 | extern "C" { | 32 | extern "C" { |
| 33 | #endif | 33 | #endif |
| 34 | 34 | ||
| 35 | #define NUM_ERROR_MESSAGES 19 | 35 | #define NUM_ERROR_MESSAGES 26 |
| 36 | extern int8_t *err_msg[]; | 36 | extern int8_t *err_msg[]; |
| 37 | 37 | ||
| 38 | #ifdef __cplusplus | 38 | #ifdef __cplusplus |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: huffman.c,v 1.14 2004/01/14 20:39:59 menno Exp $ | 25 | ** $Id: huffman.c,v 1.15 2004/01/16 20:20:32 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #include "common.h" | 28 | #include "common.h" |
| @@ -168,12 +168,8 @@ static uint8_t huffman_2step_quad(uint8_t cb, bitfile *ld, int16_t *sp) · 139 unmodified lines | |||
| 168 | { | 168 | { |
| 169 | /* we know for sure it's more than hcbN[cb] bits long */ | 169 | /* we know for sure it's more than hcbN[cb] bits long */ |
| 170 | faad_flushbits(ld, hcbN[cb]); | 170 | faad_flushbits(ld, hcbN[cb]); |
| 171 | #if 1 | ||
| 172 | offset += (uint16_t)faad_showbits(ld, extra_bits); | 171 | offset += (uint16_t)faad_showbits(ld, extra_bits); |
| 173 | faad_flushbits(ld, hcb_2_quad_table[cb][offset].bits - hcbN[cb]); | 172 | faad_flushbits(ld, hcb_2_quad_table[cb][offset].bits - hcbN[cb]); |
| 174 | #else | ||
| 175 | offset += (uint16_t)faad_getbits(ld, extra_bits); | ||
| 176 | #endif | ||
| 177 | } else { | 173 | } else { |
| 178 | faad_flushbits(ld, hcb_2_quad_table[cb][offset].bits); | 174 | faad_flushbits(ld, hcb_2_quad_table[cb][offset].bits); |
| 179 | } | 175 | } |
| @@ -215,12 +211,8 @@ static uint8_t huffman_2step_pair(uint8_t cb, bitfile *ld, int16_t *sp) · 35 unmodified lines | |||
| 215 | { | 211 | { |
| 216 | /* we know for sure it's more than hcbN[cb] bits long */ | 212 | /* we know for sure it's more than hcbN[cb] bits long */ |
| 217 | faad_flushbits(ld, hcbN[cb]); | 213 | faad_flushbits(ld, hcbN[cb]); |
| 218 | #if 1 | ||
| 219 | offset += (uint16_t)faad_showbits(ld, extra_bits); | 214 | offset += (uint16_t)faad_showbits(ld, extra_bits); |
| 220 | faad_flushbits(ld, hcb_2_pair_table[cb][offset].bits - hcbN[cb]); | 215 | faad_flushbits(ld, hcb_2_pair_table[cb][offset].bits - hcbN[cb]); |
| 221 | #else | ||
| 222 | offset += (uint16_t)faad_getbits(ld, extra_bits); | ||
| 223 | #endif | ||
| 224 | } else { | 216 | } else { |
| 225 | faad_flushbits(ld, hcb_2_pair_table[cb][offset].bits); | 217 | faad_flushbits(ld, hcb_2_pair_table[cb][offset].bits); |
| 226 | } | 218 | } |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: is.c,v 1.19 2004/01/05 14:05:12 menno Exp $ | 25 | ** $Id: is.c,v 1.21 2004/02/26 09:29:27 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #include "common.h" | 28 | #include "common.h" |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: rvlc.c,v 1.13 2004/01/05 14:05:12 menno Exp $ | 25 | ** $Id: rvlc.c,v 1.17 2004/09/04 14:56:28 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | /* RVLC scalefactor decoding | 28 | /* RVLC scalefactor decoding |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: sbr_dec.c,v 1.24 2004/01/14 20:32:30 menno Exp $ | 25 | ** $Id: sbr_dec.c,v 1.25 2004/01/16 20:20:32 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | 28 | ||
| @@ -42,7 +42,7 @@ · 13 unmodified lines | |||
| 42 | #include "sbr_hfadj.h" | 42 | #include "sbr_hfadj.h" |
| 43 | 43 | ||
| 44 | /* static function declarations */ | 44 | /* static function declarations */ |
| 45 | static void sbr_save_prev_data(sbr_info *sbr, uint8_t ch); | 45 | static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch); |
| 46 | 46 | ||
| 47 | sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, | 47 | sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, |
| 48 | uint32_t sample_rate | 48 | uint32_t sample_rate |
| @@ -120,7 +120,7 @@ void sbrDecodeEnd(sbr_info *sbr) · 71 unmodified lines | |||
| 120 | } | 120 | } |
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | static void sbr_save_prev_data(sbr_info *sbr, uint8_t ch) | 123 | static uint8_t sbr_save_prev_data(sbr_info *sbr, uint8_t ch) |
| 124 | { | 124 | { |
| 125 | uint8_t i; | 125 | uint8_t i; |
| 126 | 126 | ||
| @@ -130,21 +130,14 @@ static void sbr_save_prev_data(sbr_info *sbr, uint8_t ch) · 3 unmodified lines | |||
| 130 | sbr->L_E_prev[ch] = sbr->L_E[ch]; | 130 | sbr->L_E_prev[ch] = sbr->L_E[ch]; |
| 131 | 131 | ||
| 132 | /* sbr->L_E[ch] can become 0 on files with bit errors */ | 132 | /* sbr->L_E[ch] can become 0 on files with bit errors */ |
| 133 | if (sbr->L_E[ch] > 0) | 133 | if (sbr->L_E[ch] <= 0) |
| 134 | return 19; | ||
| 135 | |||
| 136 | sbr->f_prev[ch] = sbr->f[ch][sbr->L_E[ch] - 1]; | ||
| 137 | for (i = 0; i < 64; i++) | ||
| 134 | { | 138 | { |
| 135 | sbr->f_prev[ch] = sbr->f[ch][sbr->L_E[ch] - 1]; | 139 | sbr->E_prev[ch][i] = sbr->E[ch][i][sbr->L_E[ch] - 1]; |
| 136 | for (i = 0; i < 64; i++) | 140 | sbr->Q_prev[ch][i] = sbr->Q[ch][i][sbr->L_Q[ch] - 1]; |
| 137 | { | ||
| 138 | sbr->E_prev[ch][i] = sbr->E[ch][i][sbr->L_E[ch] - 1]; | ||
| 139 | sbr->Q_prev[ch][i] = sbr->Q[ch][i][sbr->L_Q[ch] - 1]; | ||
| 140 | } | ||
| 141 | } else { | ||
| 142 | sbr->f_prev[ch] = 0; | ||
| 143 | for (i = 0; i < 64; i++) | ||
| 144 | { | ||
| 145 | sbr->E_prev[ch][i] = 0; | ||
| 146 | sbr->Q_prev[ch][i] = 0; | ||
| 147 | } | ||
| 148 | } | 141 | } |
| 149 | 142 | ||
| 150 | for (i = 0; i < 64; i++) | 143 | for (i = 0; i < 64; i++) |
| @@ -157,6 +150,8 @@ static void sbr_save_prev_data(sbr_info *sbr, uint8_t ch) · 6 unmodified lines | |||
| 157 | sbr->prevEnvIsShort[ch] = 0; | 150 | sbr->prevEnvIsShort[ch] = 0; |
| 158 | else | 151 | else |
| 159 | sbr->prevEnvIsShort[ch] = -1; | 152 | sbr->prevEnvIsShort[ch] = -1; |
| 153 | |||
| 154 | return 0; | ||
| 160 | } | 155 | } |
| 161 | 156 | ||
| 162 | static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, | 157 | static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, |
| @@ -252,10 +247,6 @@ static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, · 89 unmodified lines | |||
| 252 | else | 247 | else |
| 253 | xover_band = sbr->kx; | 248 | xover_band = sbr->kx; |
| 254 | 249 | ||
| 255 | /* kx can be > 32 in cases of bit errors */ | ||
| 256 | /* TODO: should be checked somewhere else */ | ||
| 257 | xover_band = min(xover_band, 32); | ||
| 258 | |||
| 259 | for (k = 0; k < xover_band; k++) | 250 | for (k = 0; k < xover_band; k++) |
| 260 | { | 251 | { |
| 261 | QMF_RE(X[l][k]) = QMF_RE(sbr->Xcodec[ch][l + sbr->tHFAdj][k]); | 252 | QMF_RE(X[l][k]) = QMF_RE(sbr->Xcodec[ch][l + sbr->tHFAdj][k]); |
| @@ -290,17 +281,18 @@ static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, · 28 unmodified lines | |||
| 290 | } | 281 | } |
| 291 | } | 282 | } |
| 292 | 283 | ||
| 293 | void sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan, | 284 | uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan, |
| 294 | const uint8_t just_seeked, const uint8_t upsample_only) | 285 | const uint8_t just_seeked, const uint8_t upsample_only) |
| 295 | { | 286 | { |
| 296 | uint8_t dont_process = 0; | 287 | uint8_t dont_process = 0; |
| 288 | uint8_t ret = 0; | ||
| 297 | 289 | ||
| 298 | if (sbr == NULL) | 290 | if (sbr == NULL) |
| 299 | return; | 291 | return 20; |
| 300 | 292 | ||
| 301 | /* case can occur due to bit errors */ | 293 | /* case can occur due to bit errors */ |
| 302 | if (sbr->id_aac != ID_CPE) | 294 | if (sbr->id_aac != ID_CPE) |
| 303 | return; | 295 | return 21; |
| 304 | 296 | ||
| 305 | if (sbr->ret || (sbr->header_count == 0)) | 297 | if (sbr->ret || (sbr->header_count == 0)) |
| 306 | { | 298 | { |
| @@ -325,26 +317,31 @@ void sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan, · 18 unmodified lines | |||
| 325 | if (sbr->bs_header_flag) | 317 | if (sbr->bs_header_flag) |
| 326 | sbr->just_seeked = 0; | 318 | sbr->just_seeked = 0; |
| 327 | 319 | ||
| 328 | if (sbr->header_count != 0) | 320 | if (sbr->header_count != 0 && sbr->ret == 0) |
| 329 | { | 321 | { |
| 330 | sbr_save_prev_data(sbr, 0); | 322 | ret = sbr_save_prev_data(sbr, 0); |
| 331 | sbr_save_prev_data(sbr, 1); | 323 | if (ret) return ret; |
| 324 | ret = sbr_save_prev_data(sbr, 1); | ||
| 325 | if (ret) return ret; | ||
| 332 | } | 326 | } |
| 333 | 327 | ||
| 334 | sbr->frame++; | 328 | sbr->frame++; |
| 329 | |||
| 330 | return 0; | ||
| 335 | } | 331 | } |
| 336 | 332 | ||
| 337 | void sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel, | 333 | uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel, |
| 338 | const uint8_t just_seeked, const uint8_t upsample_only) | 334 | const uint8_t just_seeked, const uint8_t upsample_only) |
| 339 | { | 335 | { |
| 340 | uint8_t dont_process = 0; | 336 | uint8_t dont_process = 0; |
| 337 | uint8_t ret = 0; | ||
| 341 | 338 | ||
| 342 | if (sbr == NULL) | 339 | if (sbr == NULL) |
| 343 | return; | 340 | return 20; |
| 344 | 341 | ||
| 345 | /* case can occur due to bit errors */ | 342 | /* case can occur due to bit errors */ |
| 346 | if (sbr->id_aac != ID_SCE && sbr->id_aac != ID_LFE) | 343 | if (sbr->id_aac != ID_SCE && sbr->id_aac != ID_LFE) |
| 347 | return; | 344 | return 21; |
| 348 | 345 | ||
| 349 | if (sbr->ret || (sbr->header_count == 0)) | 346 | if (sbr->ret || (sbr->header_count == 0)) |
| 350 | { | 347 | { |
| @@ -368,12 +365,15 @@ void sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel, · 17 unmodified lines | |||
| 368 | if (sbr->bs_header_flag) | 365 | if (sbr->bs_header_flag) |
| 369 | sbr->just_seeked = 0; | 366 | sbr->just_seeked = 0; |
| 370 | 367 | ||
| 371 | if (sbr->header_count != 0) | 368 | if (sbr->header_count != 0 && sbr->ret == 0) |
| 372 | { | 369 | { |
| 373 | sbr_save_prev_data(sbr, 0); | 370 | ret = sbr_save_prev_data(sbr, 0); |
| 371 | if (ret) return ret; | ||
| 374 | } | 372 | } |
| 375 | 373 | ||
| 376 | sbr->frame++; | 374 | sbr->frame++; |
| 375 | |||
| 376 | return 0; | ||
| 377 | } | 377 | } |
| 378 | 378 | ||
| 379 | #endif | 379 | #endif |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: sbr_dec.h,v 1.18 2004/01/14 20:32:30 menno Exp $ | 25 | ** $Id: sbr_dec.h,v 1.19 2004/01/16 20:20:32 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #ifndef __SBR_DEC_H__ | 28 | #ifndef __SBR_DEC_H__ |
| @@ -213,10 +213,10 @@ sbr_info *sbrDecodeInit(uint16_t framelength, uint8_t id_aac, · 184 unmodified lines | |||
| 213 | ); | 213 | ); |
| 214 | void sbrDecodeEnd(sbr_info *sbr); | 214 | void sbrDecodeEnd(sbr_info *sbr); |
| 215 | 215 | ||
| 216 | void sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan, | 216 | uint8_t sbrDecodeCoupleFrame(sbr_info *sbr, real_t *left_chan, real_t *right_chan, |
| 217 | const uint8_t just_seeked, const uint8_t upsample_only); | 217 | const uint8_t just_seeked, const uint8_t upsample_only); |
| 218 | void sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel, | 218 | uint8_t sbrDecodeSingleFrame(sbr_info *sbr, real_t *channel, |
| 219 | const uint8_t just_seeked, const uint8_t upsample_only); | 219 | const uint8_t just_seeked, const uint8_t upsample_only); |
| 220 | 220 | ||
| 221 | 221 | ||
| 222 | #ifdef __cplusplus | 222 | #ifdef __cplusplus |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: sbr_fbt.c,v 1.9 2004/01/05 14:05:12 menno Exp $ | 25 | ** $Id: sbr_fbt.c,v 1.10 2004/01/16 20:20:32 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | /* Calculate frequency band tables */ | 28 | /* Calculate frequency band tables */ |
| @@ -184,8 +184,8 @@ uint8_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate, · 155 unmodified lines | |||
| 184 | 184 | ||
| 185 | version for bs_freq_scale = 0 | 185 | version for bs_freq_scale = 0 |
| 186 | */ | 186 | */ |
| 187 | void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, | 187 | uint8_t master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, |
| 188 | uint8_t bs_alter_scale) | 188 | uint8_t bs_alter_scale) |
| 189 | { | 189 | { |
| 190 | int8_t incr; | 190 | int8_t incr; |
| 191 | uint8_t k; | 191 | uint8_t k; |
| @@ -197,7 +197,7 @@ void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, · 5 unmodified lines | |||
| 197 | if (k2 <= k0) | 197 | if (k2 <= k0) |
| 198 | { | 198 | { |
| 199 | sbr->N_master = 0; | 199 | sbr->N_master = 0; |
| 200 | return; | 200 | return 0; |
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | dk = bs_alter_scale ? 2 : 1; | 203 | dk = bs_alter_scale ? 2 : 1; |
| @@ -213,6 +213,8 @@ void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, · 9 unmodified lines | |||
| 213 | } | 213 | } |
| 214 | #endif | 214 | #endif |
| 215 | nrBands = min(nrBands, 63); | 215 | nrBands = min(nrBands, 63); |
| 216 | if (nrBands <= 0) | ||
| 217 | return 1; | ||
| 216 | 218 | ||
| 217 | k2Achieved = k0 + nrBands * dk; | 219 | k2Achieved = k0 + nrBands * dk; |
| 218 | k2Diff = k2 - k2Achieved; | 220 | k2Diff = k2 - k2Achieved; |
| @@ -247,6 +249,8 @@ void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, · 28 unmodified lines | |||
| 247 | } | 249 | } |
| 248 | printf("\n"); | 250 | printf("\n"); |
| 249 | #endif | 251 | #endif |
| 252 | |||
| 253 | return 0; | ||
| 250 | } | 254 | } |
| 251 | 255 | ||
| 252 | /* | 256 | /* |
| @@ -255,22 +259,93 @@ void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, · 2 unmodified lines | |||
| 255 | */ | 259 | */ |
| 256 | static int32_t find_bands(uint8_t warp, uint8_t bands, uint8_t a0, uint8_t a1) | 260 | static int32_t find_bands(uint8_t warp, uint8_t bands, uint8_t a0, uint8_t a1) |
| 257 | { | 261 | { |
| 262 | #ifdef FIXED_POINT | ||
| 263 | /* table with log2() values */ | ||
| 264 | static const real_t log2Table[65] = { | ||
| 265 | COEF_CONST(0.0), COEF_CONST(0.0), COEF_CONST(1.0000000000), COEF_CONST(1.5849625007), | ||
| 266 | COEF_CONST(2.0000000000), COEF_CONST(2.3219280949), COEF_CONST(2.5849625007), COEF_CONST(2.8073549221), | ||
| 267 | COEF_CONST(3.0000000000), COEF_CONST(3.1699250014), COEF_CONST(3.3219280949), COEF_CONST(3.4594316186), | ||
| 268 | COEF_CONST(3.5849625007), COEF_CONST(3.7004397181), COEF_CONST(3.8073549221), COEF_CONST(3.9068905956), | ||
| 269 | COEF_CONST(4.0000000000), COEF_CONST(4.0874628413), COEF_CONST(4.1699250014), COEF_CONST(4.2479275134), | ||
| 270 | COEF_CONST(4.3219280949), COEF_CONST(4.3923174228), COEF_CONST(4.4594316186), COEF_CONST(4.5235619561), | ||
| 271 | COEF_CONST(4.5849625007), COEF_CONST(4.6438561898), COEF_CONST(4.7004397181), COEF_CONST(4.7548875022), | ||
| 272 | COEF_CONST(4.8073549221), COEF_CONST(4.8579809951), COEF_CONST(4.9068905956), COEF_CONST(4.9541963104), | ||
| 273 | COEF_CONST(5.0000000000), COEF_CONST(5.0443941194), COEF_CONST(5.0874628413), COEF_CONST(5.1292830169), | ||
| 274 | COEF_CONST(5.1699250014), COEF_CONST(5.2094533656), COEF_CONST(5.2479275134), COEF_CONST(5.2854022189), | ||
| 275 | COEF_CONST(5.3219280949), COEF_CONST(5.3575520046), COEF_CONST(5.3923174228), COEF_CONST(5.4262647547), | ||
| 276 | COEF_CONST(5.4594316186), COEF_CONST(5.4918530963), COEF_CONST(5.5235619561), COEF_CONST(5.5545888517), | ||
| 277 | COEF_CONST(5.5849625007), COEF_CONST(5.6147098441), COEF_CONST(5.6438561898), COEF_CONST(5.6724253420), | ||
| 278 | COEF_CONST(5.7004397181), COEF_CONST(5.7279204546), COEF_CONST(5.7548875022), COEF_CONST(5.7813597135), | ||
| 279 | COEF_CONST(5.8073549221), COEF_CONST(5.8328900142), COEF_CONST(5.8579809951), COEF_CONST(5.8826430494), | ||
| 280 | COEF_CONST(5.9068905956), COEF_CONST(5.9307373376), COEF_CONST(5.9541963104), COEF_CONST(5.9772799235), | ||
| 281 | COEF_CONST(6.0) | ||
| 282 | }; | ||
| 283 | real_t r0 = log2Table[a0]; /* coef */ | ||
| 284 | real_t r1 = log2Table[a1]; /* coef */ | ||
| 285 | real_t r2 = (r1 - r0); /* coef */ | ||
| 286 | |||
| 287 | if (warp) | ||
| 288 | r2 = MUL_C(r2, COEF_CONST(1.0/1.3)); | ||
| 289 | |||
| 290 | /* convert r2 to real and then multiply and round */ | ||
| 291 | r2 = (r2 >> (COEF_BITS-REAL_BITS)) * bands + (1<<(REAL_BITS-1)); | ||
| 292 | |||
| 293 | return (r2 >> REAL_BITS); | ||
| 294 | #else | ||
| 258 | real_t div = (real_t)log(2.0); | 295 | real_t div = (real_t)log(2.0); |
| 259 | if (warp) div *= (real_t)1.3; | 296 | if (warp) div *= (real_t)1.3; |
| 260 | 297 | ||
| 261 | return (int32_t)(bands * log((float)a1/(float)a0)/div + 0.5); | 298 | return (int32_t)(bands * log((float)a1/(float)a0)/div + 0.5); |
| 299 | #endif | ||
| 262 | } | 300 | } |
| 263 | 301 | ||
| 264 | static real_t find_initial_power(uint8_t bands, uint8_t a0, uint8_t a1) | 302 | static real_t find_initial_power(uint8_t bands, uint8_t a0, uint8_t a1) |
| 265 | { | 303 | { |
| 304 | #ifdef FIXED_POINT | ||
| 305 | /* table with log() values */ | ||
| 306 | static const real_t logTable[65] = { | ||
| 307 | COEF_CONST(0.0), COEF_CONST(0.0), COEF_CONST(0.6931471806), COEF_CONST(1.0986122887), | ||
| 308 | COEF_CONST(1.3862943611), COEF_CONST(1.6094379124), COEF_CONST(1.7917594692), COEF_CONST(1.9459101491), | ||
| 309 | COEF_CONST(2.0794415417), COEF_CONST(2.1972245773), COEF_CONST(2.3025850930), COEF_CONST(2.3978952728), | ||
| 310 | COEF_CONST(2.4849066498), COEF_CONST(2.5649493575), COEF_CONST(2.6390573296), COEF_CONST(2.7080502011), | ||
| 311 | COEF_CONST(2.7725887222), COEF_CONST(2.8332133441), COEF_CONST(2.8903717579), COEF_CONST(2.9444389792), | ||
| 312 | COEF_CONST(2.9957322736), COEF_CONST(3.0445224377), COEF_CONST(3.0910424534), COEF_CONST(3.1354942159), | ||
| 313 | COEF_CONST(3.1780538303), COEF_CONST(3.2188758249), COEF_CONST(3.2580965380), COEF_CONST(3.2958368660), | ||
| 314 | COEF_CONST(3.3322045102), COEF_CONST(3.3672958300), COEF_CONST(3.4011973817), COEF_CONST(3.4339872045), | ||
| 315 | COEF_CONST(3.4657359028), COEF_CONST(3.4965075615), COEF_CONST(3.5263605246), COEF_CONST(3.5553480615), | ||
| 316 | COEF_CONST(3.5835189385), COEF_CONST(3.6109179126), COEF_CONST(3.6375861597), COEF_CONST(3.6635616461), | ||
| 317 | COEF_CONST(3.6888794541), COEF_CONST(3.7135720667), COEF_CONST(3.7376696183), COEF_CONST(3.7612001157), | ||
| 318 | COEF_CONST(3.7841896339), COEF_CONST(3.8066624898), COEF_CONST(3.8286413965), COEF_CONST(3.8501476017), | ||
| 319 | COEF_CONST(3.8712010109), COEF_CONST(3.8918202981), COEF_CONST(3.9120230054), COEF_CONST(3.9318256327), | ||
| 320 | COEF_CONST(3.9512437186), COEF_CONST(3.9702919136), COEF_CONST(3.9889840466), COEF_CONST(4.0073331852), | ||
| 321 | COEF_CONST(4.0253516907), COEF_CONST(4.0430512678), COEF_CONST(4.0604430105), COEF_CONST(4.0775374439), | ||
| 322 | COEF_CONST(4.0943445622), COEF_CONST(4.1108738642), COEF_CONST(4.1271343850), COEF_CONST(4.1431347264), | ||
| 323 | COEF_CONST(4.158883083) | ||
| 324 | }; | ||
| 325 | /* standard Taylor polynomial coefficients for exp(x) around 0 */ | ||
| 326 | /* a polynomial around x=1 is more precise, as most values are around 1.07, | ||
| 327 | but this is just fine already */ | ||
| 328 | static const real_t c1 = COEF_CONST(1.0); | ||
| 329 | static const real_t c2 = COEF_CONST(1.0/2.0); | ||
| 330 | static const real_t c3 = COEF_CONST(1.0/6.0); | ||
| 331 | static const real_t c4 = COEF_CONST(1.0/24.0); | ||
| 332 | |||
| 333 | real_t r0 = logTable[a0]; /* coef */ | ||
| 334 | real_t r1 = logTable[a1]; /* coef */ | ||
| 335 | real_t r2 = (r1 - r0) / bands; /* coef */ | ||
| 336 | real_t rexp = c1 + MUL_C((c1 + MUL_C((c2 + MUL_C((c3 + MUL_C(c4,r2)), r2)), r2)), r2); | ||
| 337 | |||
| 338 | return (rexp >> (COEF_BITS-REAL_BITS)); /* real */ | ||
| 339 | #else | ||
| 266 | return (real_t)pow((real_t)a1/(real_t)a0, 1.0/(real_t)bands); | 340 | return (real_t)pow((real_t)a1/(real_t)a0, 1.0/(real_t)bands); |
| 341 | #endif | ||
| 267 | } | 342 | } |
| 268 | 343 | ||
| 269 | /* | 344 | /* |
| 270 | version for bs_freq_scale > 0 | 345 | version for bs_freq_scale > 0 |
| 271 | */ | 346 | */ |
| 272 | void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, | 347 | uint8_t master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, |
| 273 | uint8_t bs_freq_scale, uint8_t bs_alter_scale) | 348 | uint8_t bs_freq_scale, uint8_t bs_alter_scale) |
| 274 | { | 349 | { |
| 275 | uint8_t k, bands, twoRegions; | 350 | uint8_t k, bands, twoRegions; |
| 276 | uint8_t k1; | 351 | uint8_t k1; |
| @@ -285,12 +360,16 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, · 8 unmodified lines | |||
| 285 | if (k2 <= k0) | 360 | if (k2 <= k0) |
| 286 | { | 361 | { |
| 287 | sbr->N_master = 0; | 362 | sbr->N_master = 0; |
| 288 | return; | 363 | return 0; |
| 289 | } | 364 | } |
| 290 | 365 | ||
| 291 | bands = temp1[bs_freq_scale-1]; | 366 | bands = temp1[bs_freq_scale-1]; |
| 292 | 367 | ||
| 368 | #ifdef FIXED_POINT | ||
| 369 | if (REAL_CONST(k2) > MUL_R(REAL_CONST(k0),REAL_CONST(2.2449))) | ||
| 370 | #else | ||
| 293 | if ((float)k2/(float)k0 > 2.2449) | 371 | if ((float)k2/(float)k0 > 2.2449) |
| 372 | #endif | ||
| 294 | { | 373 | { |
| 295 | twoRegions = 1; | 374 | twoRegions = 1; |
| 296 | k1 = k0 << 1; | 375 | k1 = k0 << 1; |
| @@ -301,15 +380,26 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, · 4 unmodified lines | |||
| 301 | 380 | ||
| 302 | nrBand0 = 2 * find_bands(0, bands, k0, k1); | 381 | nrBand0 = 2 * find_bands(0, bands, k0, k1); |
| 303 | nrBand0 = min(nrBand0, 63); | 382 | nrBand0 = min(nrBand0, 63); |
| 383 | if (nrBand0 <= 0) | ||
| 384 | return 1; | ||
| 304 | 385 | ||
| 305 | q = find_initial_power(nrBand0, k0, k1); | 386 | q = find_initial_power(nrBand0, k0, k1); |
| 306 | qk = REAL_CONST(k0); | 387 | qk = REAL_CONST(k0); |
| 388 | #ifdef FIXED_POINT | ||
| 389 | A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS); | ||
| 390 | #else | ||
| 307 | A_1 = (int32_t)(qk + .5); | 391 | A_1 = (int32_t)(qk + .5); |
| 392 | #endif | ||
| 308 | for (k = 0; k <= nrBand0; k++) | 393 | for (k = 0; k <= nrBand0; k++) |
| 309 | { | 394 | { |
| 310 | int32_t A_0 = A_1; | 395 | int32_t A_0 = A_1; |
| 396 | #ifdef FIXED_POINT | ||
| 397 | qk = MUL_R(qk,q); | ||
| 398 | A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS); | ||
| 399 | #else | ||
| 311 | qk *= q; | 400 | qk *= q; |
| 312 | A_1 = (int32_t)(qk + 0.5); | 401 | A_1 = (int32_t)(qk + 0.5); |
| 402 | #endif | ||
| 313 | vDk0[k] = A_1 - A_0; | 403 | vDk0[k] = A_1 - A_0; |
| 314 | } | 404 | } |
| 315 | 405 | ||
| @@ -320,6 +410,8 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, · 4 unmodified lines | |||
| 320 | for (k = 1; k <= nrBand0; k++) | 410 | for (k = 1; k <= nrBand0; k++) |
| 321 | { | 411 | { |
| 322 | vk0[k] = vk0[k-1] + vDk0[k-1]; | 412 | vk0[k] = vk0[k-1] + vDk0[k-1]; |
| 413 | if (vDk0[k-1] == 0) | ||
| 414 | return 1; | ||
| 323 | } | 415 | } |
| 324 | 416 | ||
| 325 | if (!twoRegions) | 417 | if (!twoRegions) |
| @@ -329,7 +421,7 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, · 3 unmodified lines | |||
| 329 | 421 | ||
| 330 | sbr->N_master = nrBand0; | 422 | sbr->N_master = nrBand0; |
| 331 | sbr->N_master = min(sbr->N_master, 64); | 423 | sbr->N_master = min(sbr->N_master, 64); |
| 332 | return; | 424 | return 0; |
| 333 | } | 425 | } |
| 334 | 426 | ||
| 335 | nrBand1 = 2 * find_bands(1 /* warped */, bands, k1, k2); | 427 | nrBand1 = 2 * find_bands(1 /* warped */, bands, k1, k2); |
| @@ -337,12 +429,21 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, · 1 unmodified line | |||
| 337 | 429 | ||
| 338 | q = find_initial_power(nrBand1, k1, k2); | 430 | q = find_initial_power(nrBand1, k1, k2); |
| 339 | qk = REAL_CONST(k1); | 431 | qk = REAL_CONST(k1); |
| 432 | #ifdef FIXED_POINT | ||
| 433 | A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS); | ||
| 434 | #else | ||
| 340 | A_1 = (int32_t)(qk + .5); | 435 | A_1 = (int32_t)(qk + .5); |
| 436 | #endif | ||
| 341 | for (k = 0; k <= nrBand1 - 1; k++) | 437 | for (k = 0; k <= nrBand1 - 1; k++) |
| 342 | { | 438 | { |
| 343 | int32_t A_0 = A_1; | 439 | int32_t A_0 = A_1; |
| 440 | #ifdef FIXED_POINT | ||
| 441 | qk = MUL_R(qk,q); | ||
| 442 | A_1 = (int32_t)((qk + REAL_CONST(0.5)) >> REAL_BITS); | ||
| 443 | #else | ||
| 344 | qk *= q; | 444 | qk *= q; |
| 345 | A_1 = (int32_t)(qk + 0.5); | 445 | A_1 = (int32_t)(qk + 0.5); |
| 446 | #endif | ||
| 346 | vDk1[k] = A_1 - A_0; | 447 | vDk1[k] = A_1 - A_0; |
| 347 | } | 448 | } |
| 348 | 449 | ||
| @@ -363,6 +464,8 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, · 14 unmodified lines | |||
| 363 | for (k = 1; k <= nrBand1; k++) | 464 | for (k = 1; k <= nrBand1; k++) |
| 364 | { | 465 | { |
| 365 | vk1[k] = vk1[k-1] + vDk1[k-1]; | 466 | vk1[k] = vk1[k-1] + vDk1[k-1]; |
| 467 | if (vDk1[k-1] == 0) | ||
| 468 | return 1; | ||
| 366 | } | 469 | } |
| 367 | 470 | ||
| 368 | sbr->N_master = nrBand0 + nrBand1; | 471 | sbr->N_master = nrBand0 + nrBand1; |
| @@ -384,6 +487,8 @@ void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, · 15 unmodified lines | |||
| 384 | } | 487 | } |
| 385 | printf("\n"); | 488 | printf("\n"); |
| 386 | #endif | 489 | #endif |
| 490 | |||
| 491 | return 0; | ||
| 387 | } | 492 | } |
| 388 | 493 | ||
| 389 | /* calculate the derived frequency border tables from f_master */ | 494 | /* calculate the derived frequency border tables from f_master */ |
| @@ -410,6 +515,10 @@ uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band, · 20 unmodified lines | |||
| 410 | 515 | ||
| 411 | sbr->M = sbr->f_table_res[HI_RES][sbr->N_high] - sbr->f_table_res[HI_RES][0]; | 516 | sbr->M = sbr->f_table_res[HI_RES][sbr->N_high] - sbr->f_table_res[HI_RES][0]; |
| 412 | sbr->kx = sbr->f_table_res[HI_RES][0]; | 517 | sbr->kx = sbr->f_table_res[HI_RES][0]; |
| 518 | if (sbr->kx > 32) | ||
| 519 | return 1; | ||
| 520 | if (sbr->kx + sbr->M > 64) | ||
| 521 | return 1; | ||
| 413 | 522 | ||
| 414 | minus = (sbr->N_high & 1) ? 1 : 0; | 523 | minus = (sbr->N_high & 1) ? 1 : 0; |
| 415 | 524 | ||
| @@ -556,7 +665,11 @@ restart: · 140 unmodified lines | |||
| 556 | #if 0 | 665 | #if 0 |
| 557 | nOctaves = REAL_CONST(log((float)limTable[k]/(float)limTable[k-1])/log(2.0)); | 666 | nOctaves = REAL_CONST(log((float)limTable[k]/(float)limTable[k-1])/log(2.0)); |
| 558 | #endif | 667 | #endif |
| 668 | #ifdef FIXED_POINT | ||
| 669 | nOctaves = SBR_DIV(REAL_CONST(limTable[k]),REAL_CONST(limTable[k-1])); | ||
| 670 | #else | ||
| 559 | nOctaves = (real_t)limTable[k]/(real_t)limTable[k-1]; | 671 | nOctaves = (real_t)limTable[k]/(real_t)limTable[k-1]; |
| 672 | #endif | ||
| 560 | else | 673 | else |
| 561 | nOctaves = 0; | 674 | nOctaves = 0; |
| 562 | 675 | ||
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: sbr_fbt.h,v 1.9 2004/01/05 14:05:12 menno Exp $ | 25 | ** $Id: sbr_fbt.h,v 1.10 2004/01/16 20:20:32 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #ifndef __SBR_FBT_H__ | 28 | #ifndef __SBR_FBT_H__ |
| @@ -36,10 +36,10 @@ uint8_t qmf_start_channel(uint8_t bs_start_freq, uint8_t bs_samplerate_mode, · 7 unmodified lines | |||
| 36 | uint32_t sample_rate); | 36 | uint32_t sample_rate); |
| 37 | uint8_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate, | 37 | uint8_t qmf_stop_channel(uint8_t bs_stop_freq, uint32_t sample_rate, |
| 38 | uint8_t k0); | 38 | uint8_t k0); |
| 39 | void master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, | 39 | uint8_t master_frequency_table_fs0(sbr_info *sbr, uint8_t k0, uint8_t k2, |
| 40 | uint8_t bs_alter_scale); | 40 | uint8_t bs_alter_scale); |
| 41 | void master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, | 41 | uint8_t master_frequency_table(sbr_info *sbr, uint8_t k0, uint8_t k2, |
| 42 | uint8_t bs_freq_scale, uint8_t bs_alter_scale); | 42 | uint8_t bs_freq_scale, uint8_t bs_alter_scale); |
| 43 | uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band, | 43 | uint8_t derived_frequency_table(sbr_info *sbr, uint8_t bs_xover_band, |
| 44 | uint8_t k2); | 44 | uint8_t k2); |
| 45 | void limiter_frequency_table(sbr_info *sbr); | 45 | void limiter_frequency_table(sbr_info *sbr); |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: sbr_syntax.c,v 1.21 2004/01/13 14:24:10 menno Exp $ | 25 | ** $Id: sbr_syntax.c,v 1.22 2004/01/16 20:20:32 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #include "common.h" | 28 | #include "common.h" |
| @@ -105,7 +105,7 @@ static void sbr_reset(sbr_info *sbr) · 76 unmodified lines | |||
| 105 | /* table 2 */ | 105 | /* table 2 */ |
| 106 | uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt) | 106 | uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt) |
| 107 | { | 107 | { |
| 108 | uint8_t result; | 108 | uint8_t result = 0; |
| 109 | uint16_t num_align_bits = 0; | 109 | uint16_t num_align_bits = 0; |
| 110 | uint16_t num_sbr_bits = (uint16_t)faad_get_processed_bits(ld); | 110 | uint16_t num_sbr_bits = (uint16_t)faad_get_processed_bits(ld); |
| 111 | 111 | ||
| @@ -149,27 +149,30 @@ uint8_t sbr_extension_data(bitfile *ld, sbr_info *sbr, uint16_t cnt) · 37 unmodified lines | |||
| 149 | if (sbr->sample_rate >= 48000) | 149 | if (sbr->sample_rate >= 48000) |
| 150 | { | 150 | { |
| 151 | if ((k2 - sbr->k0) > 32) | 151 | if ((k2 - sbr->k0) > 32) |
| 152 | return 1; | 152 | result += 1; |
| 153 | } else if (sbr->sample_rate <= 32000) { | 153 | } else if (sbr->sample_rate <= 32000) { |
| 154 | if ((k2 - sbr->k0) > 48) | 154 | if ((k2 - sbr->k0) > 48) |
| 155 | return 1; | 155 | result += 1; |
| 156 | } else { /* (sbr->sample_rate == 44100) */ | 156 | } else { /* (sbr->sample_rate == 44100) */ |
| 157 | if ((k2 - sbr->k0) > 45) | 157 | if ((k2 - sbr->k0) > 45) |
| 158 | return 1; | 158 | result += 1; |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | if (sbr->bs_freq_scale == 0) | 161 | if (sbr->bs_freq_scale == 0) |
| 162 | { | 162 | { |
| 163 | master_frequency_table_fs0(sbr, sbr->k0, k2, sbr->bs_alter_scale); | 163 | result += master_frequency_table_fs0(sbr, sbr->k0, k2, |
| 164 | sbr->bs_alter_scale); | ||
| 164 | } else { | 165 | } else { |
| 165 | master_frequency_table(sbr, sbr->k0, k2, sbr->bs_freq_scale, | 166 | result += master_frequency_table(sbr, sbr->k0, k2, sbr->bs_freq_scale, |
| 166 | sbr->bs_alter_scale); | 167 | sbr->bs_alter_scale); |
| 167 | } | 168 | } |
| 168 | if ((result = derived_frequency_table(sbr, sbr->bs_xover_band, k2)) > 0) | 169 | result += derived_frequency_table(sbr, sbr->bs_xover_band, k2); |
| 169 | return result; | 170 | |
| 171 | result = (result > 0) ? 1 : 0; | ||
| 170 | } | 172 | } |
| 171 | 173 | ||
| 172 | result = sbr_data(ld, sbr); | 174 | if (result == 0) |
| 175 | result = sbr_data(ld, sbr); | ||
| 173 | } else { | 176 | } else { |
| 174 | result = 1; | 177 | result = 1; |
| 175 | } | 178 | } |
| @@ -634,6 +637,9 @@ static uint8_t sbr_grid(bitfile *ld, sbr_info *sbr, uint8_t ch) · 458 unmodified lines | |||
| 634 | else | 637 | else |
| 635 | sbr->L_E[ch] = min(bs_num_env, 4); | 638 | sbr->L_E[ch] = min(bs_num_env, 4); |
| 636 | 639 | ||
| 640 | if (sbr->L_E[ch] <= 0) | ||
| 641 | return 1; | ||
| 642 | |||
| 637 | if (sbr->L_E[ch] > 1) | 643 | if (sbr->L_E[ch] > 1) |
| 638 | sbr->L_Q[ch] = 2; | 644 | sbr->L_Q[ch] = 2; |
| 639 | else | 645 | else |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: specrec.c,v 1.40 2004/01/14 20:32:30 menno Exp $ | 25 | ** $Id: specrec.c,v 1.41 2004/01/16 20:20:32 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | /* | 28 | /* |
| @@ -588,7 +588,8 @@ void apply_scalefactors(faacDecHandle hDecoder, ic_stream *ics, · 559 unmodified lines | |||
| 588 | { | 588 | { |
| 589 | top = ics->sect_sfb_offset[g][sfb+1]; | 589 | top = ics->sect_sfb_offset[g][sfb+1]; |
| 590 | 590 | ||
| 591 | /* this could be scalefactor for IS or PNS, those could be negative or bigger then 255??? */ | 591 | /* this could be scalefactor for IS or PNS, those can be negative or bigger then 255 */ |
| 592 | /* just ignore them */ | ||
| 592 | if (ics->scale_factors[g][sfb] < 0 || ics->scale_factors[g][sfb] > 255) | 593 | if (ics->scale_factors[g][sfb] < 0 || ics->scale_factors[g][sfb] > 255) |
| 593 | { | 594 | { |
| 594 | exp = 0; | 595 | exp = 0; |
| @@ -790,12 +791,12 @@ uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics, · 195 unmodified lines | |||
| 790 | { | 791 | { |
| 791 | mul = 1; | 792 | mul = 1; |
| 792 | #ifdef SBR_DEC | 793 | #ifdef SBR_DEC |
| 793 | hDecoder->sbr_alloced = 0; | 794 | hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0; |
| 794 | if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) | 795 | if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) |
| 795 | { | 796 | { |
| 796 | /* SBR requires 2 times as much output data */ | 797 | /* SBR requires 2 times as much output data */ |
| 797 | mul = 2; | 798 | mul = 2; |
| 798 | hDecoder->sbr_alloced = 1; | 799 | hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1; |
| 799 | } | 800 | } |
| 800 | #endif | 801 | #endif |
| 801 | hDecoder->time_out[sce->channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t)); | 802 | hDecoder->time_out[sce->channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t)); |
| @@ -858,7 +859,7 @@ uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics, · 56 unmodified lines | |||
| 858 | 859 | ||
| 859 | #ifdef SBR_DEC | 860 | #ifdef SBR_DEC |
| 860 | if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) | 861 | if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) |
| 861 | && hDecoder->sbr_alloced) | 862 | && hDecoder->sbr_alloced[hDecoder->fr_ch_ele]) |
| 862 | { | 863 | { |
| 863 | uint8_t ele = hDecoder->fr_ch_ele; | 864 | uint8_t ele = hDecoder->fr_ch_ele; |
| 864 | uint8_t ch = sce->channel; | 865 | uint8_t ch = sce->channel; |
| @@ -874,11 +875,14 @@ uint8_t reconstruct_single_channel(faacDecHandle hDecoder, ic_stream *ics, · 9 unmodified lines | |||
| 874 | ); | 875 | ); |
| 875 | } | 876 | } |
| 876 | 877 | ||
| 877 | sbrDecodeSingleFrame(hDecoder->sbr[ele], hDecoder->time_out[ch], | 878 | retval = sbrDecodeSingleFrame(hDecoder->sbr[ele], hDecoder->time_out[ch], |
| 878 | hDecoder->postSeekResetFlag, hDecoder->forceUpSampling); | 879 | hDecoder->postSeekResetFlag, hDecoder->forceUpSampling); |
| 879 | } else { | 880 | if (retval > 0) |
| 880 | hDecoder->sbr_present_flag = 0; | 881 | return retval; |
| 881 | hDecoder->forceUpSampling = 0; | 882 | } else if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) |
| 883 | && !hDecoder->sbr_alloced[hDecoder->fr_ch_ele]) | ||
| 884 | { | ||
| 885 | return 23; | ||
| 882 | } | 886 | } |
| 883 | #endif | 887 | #endif |
| 884 | 888 | ||
| @@ -976,7 +980,7 @@ uint8_t reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_str · 91 unmodified lines | |||
| 976 | if (is_ltp_ot(hDecoder->object_type)) | 980 | if (is_ltp_ot(hDecoder->object_type)) |
| 977 | { | 981 | { |
| 978 | ltp_info *ltp1 = &(ics1->ltp); | 982 | ltp_info *ltp1 = &(ics1->ltp); |
| 979 | ltp_info *ltp2 = (cpe->common_window) ? &(ics2->ltp2) : &(ics2->ltp) ; | 983 | ltp_info *ltp2 = (cpe->common_window) ? &(ics2->ltp2) : &(ics2->ltp); |
| 980 | #ifdef LD_DEC | 984 | #ifdef LD_DEC |
| 981 | if (hDecoder->object_type == LD) | 985 | if (hDecoder->object_type == LD) |
| 982 | { | 986 | { |
| @@ -1036,12 +1040,12 @@ uint8_t reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_str · 53 unmodified lines | |||
| 1036 | { | 1040 | { |
| 1037 | mul = 1; | 1041 | mul = 1; |
| 1038 | #ifdef SBR_DEC | 1042 | #ifdef SBR_DEC |
| 1039 | hDecoder->sbr_alloced = 0; | 1043 | hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 0; |
| 1040 | if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) | 1044 | if ((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) |
| 1041 | { | 1045 | { |
| 1042 | /* SBR requires 2 times as much output data */ | 1046 | /* SBR requires 2 times as much output data */ |
| 1043 | mul = 2; | 1047 | mul = 2; |
| 1044 | hDecoder->sbr_alloced = 1; | 1048 | hDecoder->sbr_alloced[hDecoder->fr_ch_ele] = 1; |
| 1045 | } | 1049 | } |
| 1046 | #endif | 1050 | #endif |
| 1047 | hDecoder->time_out[cpe->channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t)); | 1051 | hDecoder->time_out[cpe->channel] = (real_t*)faad_malloc(mul*hDecoder->frameLength*sizeof(real_t)); |
| @@ -1140,7 +1144,7 @@ uint8_t reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_str · 92 unmodified lines | |||
| 1140 | 1144 | ||
| 1141 | #ifdef SBR_DEC | 1145 | #ifdef SBR_DEC |
| 1142 | if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) | 1146 | if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) |
| 1143 | && hDecoder->sbr_alloced) | 1147 | && hDecoder->sbr_alloced[hDecoder->fr_ch_ele]) |
| 1144 | { | 1148 | { |
| 1145 | uint8_t ele = hDecoder->fr_ch_ele; | 1149 | uint8_t ele = hDecoder->fr_ch_ele; |
| 1146 | uint8_t ch0 = cpe->channel; | 1150 | uint8_t ch0 = cpe->channel; |
| @@ -1157,12 +1161,15 @@ uint8_t reconstruct_channel_pair(faacDecHandle hDecoder, ic_stream *ics1, ic_str · 10 unmodified lines | |||
| 1157 | ); | 1161 | ); |
| 1158 | } | 1162 | } |
| 1159 | 1163 | ||
| 1160 | sbrDecodeCoupleFrame(hDecoder->sbr[ele], | 1164 | retval = sbrDecodeCoupleFrame(hDecoder->sbr[ele], |
| 1161 | hDecoder->time_out[ch0], hDecoder->time_out[ch1], | 1165 | hDecoder->time_out[ch0], hDecoder->time_out[ch1], |
| 1162 | hDecoder->postSeekResetFlag, hDecoder->forceUpSampling); | 1166 | hDecoder->postSeekResetFlag, hDecoder->forceUpSampling); |
| 1163 | } else { | 1167 | if (retval > 0) |
| 1164 | hDecoder->sbr_present_flag = 0; | 1168 | return retval; |
| 1165 | hDecoder->forceUpSampling = 0; | 1169 | } else if (((hDecoder->sbr_present_flag == 1) || (hDecoder->forceUpSampling == 1)) |
| 1170 | && !hDecoder->sbr_alloced[hDecoder->fr_ch_ele]) | ||
| 1171 | { | ||
| 1172 | return 23; | ||
| 1166 | } | 1173 | } |
| 1167 | #endif | 1174 | #endif |
| 1168 | 1175 | ||
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: structs.h,v 1.28 2004/01/14 20:32:30 menno Exp $ | 25 | ** $Id: structs.h,v 1.29 2004/01/16 20:20:32 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #ifndef __STRUCTS_H__ | 28 | #ifndef __STRUCTS_H__ |
| @@ -385,6 +385,7 @@ typedef struct · 356 unmodified lines | |||
| 385 | uint8_t fr_ch_ele; | 385 | uint8_t fr_ch_ele; |
| 386 | 386 | ||
| 387 | void *sample_buffer; | 387 | void *sample_buffer; |
| 388 | uint8_t alloced_channels; | ||
| 388 | 389 | ||
| 389 | uint8_t window_shape_prev[MAX_CHANNELS]; | 390 | uint8_t window_shape_prev[MAX_CHANNELS]; |
| 390 | #ifdef LTP_DEC | 391 | #ifdef LTP_DEC |
| @@ -399,9 +400,9 @@ typedef struct · 8 unmodified lines | |||
| 399 | #ifdef SBR_DEC | 400 | #ifdef SBR_DEC |
| 400 | int8_t sbr_present_flag; | 401 | int8_t sbr_present_flag; |
| 401 | int8_t forceUpSampling; | 402 | int8_t forceUpSampling; |
| 402 | uint8_t sbr_alloced; | 403 | uint8_t sbr_alloced[MAX_SYNTAX_ELEMENTS]; |
| 403 | 404 | ||
| 404 | sbr_info *sbr[32]; | 405 | sbr_info *sbr[MAX_SYNTAX_ELEMENTS]; |
| 405 | #ifdef DRM | 406 | #ifdef DRM |
| 406 | int8_t lcstereo_flag; | 407 | int8_t lcstereo_flag; |
| 407 | #endif | 408 | #endif |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: syntax.c,v 1.67 2004/01/14 20:32:30 menno Exp $ | 25 | ** $Id: syntax.c,v 1.68 2004/01/16 20:20:32 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | /* | 28 | /* |
| @@ -118,7 +118,8 @@ int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC, · 89 unmodified lines | |||
| 118 | mp4ASC->extensionFlag = faad_get1bit(ld DEBUGVAR(1,141,"GASpecificConfig(): ExtensionFlag")); | 118 | mp4ASC->extensionFlag = faad_get1bit(ld DEBUGVAR(1,141,"GASpecificConfig(): ExtensionFlag")); |
| 119 | if (mp4ASC->channelsConfiguration == 0) | 119 | if (mp4ASC->channelsConfiguration == 0) |
| 120 | { | 120 | { |
| 121 | program_config_element(&pce, ld); | 121 | if (program_config_element(&pce, ld)) |
| 122 | return -3; | ||
| 122 | //mp4ASC->channelsConfiguration = pce.channels; | 123 | //mp4ASC->channelsConfiguration = pce.channels; |
| 123 | 124 | ||
| 124 | if (pce_out != NULL) | 125 | if (pce_out != NULL) |
| @@ -158,7 +159,7 @@ int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC, · 33 unmodified lines | |||
| 158 | PCEs transmitted in raw data blocks cannot be used to convey decoder | 159 | PCEs transmitted in raw data blocks cannot be used to convey decoder |
| 159 | configuration information. | 160 | configuration information. |
| 160 | */ | 161 | */ |
| 161 | uint8_t program_config_element(program_config *pce, bitfile *ld) | 162 | static uint8_t program_config_element(program_config *pce, bitfile *ld) |
| 162 | { | 163 | { |
| 163 | uint8_t i; | 164 | uint8_t i; |
| 164 | 165 | ||
| @@ -303,6 +304,9 @@ uint8_t program_config_element(program_config *pce, bitfile *ld) · 138 unmodified lines | |||
| 303 | } | 304 | } |
| 304 | pce->comment_field_data[i] = 0; | 305 | pce->comment_field_data[i] = 0; |
| 305 | 306 | ||
| 307 | if (pce->channels > MAX_CHANNELS) | ||
| 308 | return 22; | ||
| 309 | |||
| 306 | return 0; | 310 | return 0; |
| 307 | } | 311 | } |
| 308 | 312 | ||
| @@ -431,15 +435,21 @@ void raw_data_block(faacDecHandle hDecoder, faacDecFrameInfo *hInfo, · 122 unmodified lines | |||
| 431 | data_stream_element(hDecoder, ld); | 435 | data_stream_element(hDecoder, ld); |
| 432 | break; | 436 | break; |
| 433 | case ID_PCE: | 437 | case ID_PCE: |
| 434 | if ((hInfo->error = program_config_element(pce, ld)) > 0) | 438 | /* 14496-4: 5.6.4.1.2.1.3: */ |
| 435 | return; | 439 | /* program_configuration_element()'s in access units shall be ignored */ |
| 436 | hDecoder->pce_set = 1; | 440 | program_config_element(pce, ld); |
| 441 | //if ((hInfo->error = program_config_element(pce, ld)) > 0) | ||
| 442 | // return; | ||
| 443 | //hDecoder->pce_set = 1; | ||
| 437 | break; | 444 | break; |
| 438 | case ID_FIL: | 445 | case ID_FIL: |
| 439 | /* one sbr_info describes a channel_element not a channel! */ | 446 | /* one sbr_info describes a channel_element not a channel! */ |
| 447 | /* if we encounter SBR data here: error */ | ||
| 448 | /* SBR data will be read directly in the SCE/LFE/CPE element */ | ||
| 440 | if ((hInfo->error = fill_element(hDecoder, ld, drc | 449 | if ((hInfo->error = fill_element(hDecoder, ld, drc |
| 441 | #ifdef SBR_DEC | 450 | #ifdef SBR_DEC |
| 442 | , (ch_ele == 0) ? 0 : (ch_ele-1) | 451 | //, (ch_ele == 0) ? INVALID_SBR_ELEMENT : (ch_ele-1) |
| 452 | , INVALID_SBR_ELEMENT | ||
| 443 | #endif | 453 | #endif |
| 444 | )) > 0) | 454 | )) > 0) |
| 445 | return; | 455 | return; |
| @@ -968,6 +978,9 @@ static uint8_t fill_element(faacDecHandle hDecoder, bitfile *ld, drc_info *drc · 522 unmodified lines | |||
| 968 | if ((bs_extension_type == EXT_SBR_DATA) || | 978 | if ((bs_extension_type == EXT_SBR_DATA) || |
| 969 | (bs_extension_type == EXT_SBR_DATA_CRC)) | 979 | (bs_extension_type == EXT_SBR_DATA_CRC)) |
| 970 | { | 980 | { |
| 981 | if (sbr_ele == INVALID_SBR_ELEMENT) | ||
| 982 | return 24; | ||
| 983 | |||
| 971 | if (!hDecoder->sbr[sbr_ele]) | 984 | if (!hDecoder->sbr[sbr_ele]) |
| 972 | { | 985 | { |
| 973 | hDecoder->sbr[sbr_ele] = sbrDecodeInit(hDecoder->frameLength, | 986 | hDecoder->sbr[sbr_ele] = sbrDecodeInit(hDecoder->frameLength, |
| @@ -22,7 +22,7 @@ · 21 unmodified lines | |||
| 22 | ** Commercial non-GPL licensing of this software is possible. | 22 | ** Commercial non-GPL licensing of this software is possible. |
| 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. | 23 | ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com. |
| 24 | ** | 24 | ** |
| 25 | ** $Id: syntax.h,v 1.45 2004/01/05 14:05:12 menno Exp $ | 25 | ** $Id: syntax.h,v 1.46 2004/01/16 20:20:32 menno Exp $ |
| 26 | **/ | 26 | **/ |
| 27 | 27 | ||
| 28 | #ifndef __SYNTAX_H__ | 28 | #ifndef __SYNTAX_H__ |
| @@ -33,7 +33,6 @@ extern "C" { · 4 unmodified lines | |||
| 33 | #endif | 33 | #endif |
| 34 | 34 | ||
| 35 | #include "decoder.h" | 35 | #include "decoder.h" |
| 36 | #include "drc.h" | ||
| 37 | #include "bits.h" | 36 | #include "bits.h" |
| 38 | 37 | ||
| 39 | #define MAIN 1 | 38 | #define MAIN 1 |
| @@ -104,6 +103,8 @@ extern "C" { · 64 unmodified lines | |||
| 104 | #define INTENSITY_HCB2 14 | 103 | #define INTENSITY_HCB2 14 |
| 105 | #define INTENSITY_HCB 15 | 104 | #define INTENSITY_HCB 15 |
| 106 | 105 | ||
| 106 | #define INVALID_SBR_ELEMENT 255 | ||
| 107 | |||
| 107 | int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC, | 108 | int8_t GASpecificConfig(bitfile *ld, mp4AudioSpecificConfig *mp4ASC, |
| 108 | program_config *pce); | 109 | program_config *pce); |
| 109 | 110 | ||