comparison src/aac/libfaad2/hcr.c @ 691:e6c5fdae6e88 trunk

[svn] - oh yes, commit mplayer patches as well
author nenolod
date Tue, 20 Feb 2007 06:38:03 -0800
parents 1d8b08df98c3
children f1b6f1b2cdb3
comparison
equal deleted inserted replaced
690:0305b3165a01 691:e6c5fdae6e88
1 /* 1 /*
2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding 2 ** FAAD2 - Freeware Advanced Audio (AAC) Decoder including SBR decoding
3 ** Copyright (C) 2003-2005 M. Bakker, Nero AG, http://www.nero.com 3 ** Copyright (C) 2004 G.C. Pascutto, Ahead Software AG, http://www.nero.com
4 ** 4 **
5 ** This program is free software; you can redistribute it and/or modify 5 ** This program is free software; you can redistribute it and/or modify
6 ** it under the terms of the GNU General Public License as published by 6 ** it under the terms of the GNU General Public License as published by
7 ** the Free Software Foundation; either version 2 of the License, or 7 ** the Free Software Foundation; either version 2 of the License, or
8 ** (at your option) any later version. 8 ** (at your option) any later version.
17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. 17 ** Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18 ** 18 **
19 ** Any non-GPL usage of this software or parts of this software is strictly 19 ** Any non-GPL usage of this software or parts of this software is strictly
20 ** forbidden. 20 ** forbidden.
21 ** 21 **
22 ** Software using this code must display the following message visibly in or 22 ** Commercial non-GPL licensing of this software is possible.
23 ** on each copy of the software: 23 ** For more info contact Ahead Software through Mpeg4AAClicense@nero.com.
24 ** "FAAD2 AAC/HE-AAC/HE-AACv2/DRM decoder (c) Nero AG, www.nero.com"
25 ** in, for example, the about-box or help/startup screen.
26 ** 24 **
27 ** Commercial non-GPL licensing of this software is possible. 25 ** $Id: hcr.c,v 1.18 2004/09/04 14:56:28 menno Exp $
28 ** For more info contact Nero AG through Mpeg4AAClicense@nero.com.
29 **
30 ** $Id: hcr.c,v 1.21 2006/07/22 14:13:21 menno Exp $
31 **/ 26 **/
32 27
33 #include "common.h" 28 #include "common.h"
34 #include "structs.h" 29 #include "structs.h"
35 30
225 codeword_t codeword[512]; 220 codeword_t codeword[512];
226 bits_t segment[512]; 221 bits_t segment[512];
227 222
228 uint16_t sp_offset[8]; 223 uint16_t sp_offset[8];
229 uint16_t g, i, sortloop, set, bitsread; 224 uint16_t g, i, sortloop, set, bitsread;
230 uint16_t bitsleft, codewordsleft;
231 uint8_t w_idx, sfb, this_CB, last_CB, this_sec_CB; 225 uint8_t w_idx, sfb, this_CB, last_CB, this_sec_CB;
232 226
233 const uint16_t nshort = hDecoder->frameLength/8; 227 const uint16_t nshort = hDecoder->frameLength/8;
234 const uint16_t sp_data_len = ics->length_of_reordered_spectral_data; 228 const uint16_t sp_data_len = ics->length_of_reordered_spectral_data;
235 229
240 return 0; 234 return 0;
241 235
242 /* since there is spectral data, at least one codeword has nonzero length */ 236 /* since there is spectral data, at least one codeword has nonzero length */
243 if (ics->length_of_longest_codeword == 0) 237 if (ics->length_of_longest_codeword == 0)
244 return 10; 238 return 10;
245 239
246 if (sp_data_len < ics->length_of_longest_codeword) 240 if (sp_data_len < ics->length_of_longest_codeword)
247 return 10; 241 return 10;
248 242
249 sp_offset[0] = 0; 243 sp_offset[0] = 0;
250 for (g = 1; g < ics->num_window_groups; g++) 244 for (g = 1; g < ics->num_window_groups; g++)
276 270
277 /* loop over sfbs */ 271 /* loop over sfbs */
278 for (sfb = 0; sfb < ics->max_sfb; sfb++) 272 for (sfb = 0; sfb < ics->max_sfb; sfb++)
279 { 273 {
280 /* loop over all in this sfb, 4 lines per loop */ 274 /* loop over all in this sfb, 4 lines per loop */
281 for (w_idx = 0; 4*w_idx < (min(ics->swb_offset[sfb+1], ics->swb_offset_max) - ics->swb_offset[sfb]); w_idx++) 275 for (w_idx = 0; 4*w_idx < (ics->swb_offset[sfb+1] - ics->swb_offset[sfb]); w_idx++)
282 { 276 {
283 for(g = 0; g < ics->num_window_groups; g++) 277 for(g = 0; g < ics->num_window_groups; g++)
284 { 278 {
285 for (i = 0; i < ics->num_sec[g]; i++) 279 for (i = 0; i < ics->num_sec[g]; i++)
286 { 280 {
408 } 402 }
409 for (i = 0; i < numberOfSegments; i++) 403 for (i = 0; i < numberOfSegments; i++)
410 rewrev_bits(&segment[i]); 404 rewrev_bits(&segment[i]);
411 } 405 }
412 406
413 bitsleft = 0;
414
415 for (i = 0; i < numberOfSegments && !bitsleft; i++)
416 bitsleft += segment[i].len;
417
418 if (bitsleft) return 10;
419
420 codewordsleft = 0;
421
422 for (i = 0; (i < numberOfCodewords - numberOfSegments) && (!codewordsleft); i++)
423 if (!codeword[i].decoded)
424 codewordsleft++;
425
426 if (codewordsleft) return 10;
427
428 return 0; 407 return 0;
429
430 } 408 }
431 #endif 409 #endif