📄 syntax.c
字号:
ics->sect_end[g][i] = k + sect_len;#if 0 printf("%d\n", ics->sect_start[g][i]);#endif#if 0 printf("%d\n", ics->sect_end[g][i]);#endif if (k + sect_len >= 8*15) return 15; if (i >= 8*15) return 15; for (sfb = k; sfb < k + sect_len; sfb++) { ics->sfb_cb[g][sfb] = ics->sect_cb[g][i];#if 0 printf("%d\n", ics->sfb_cb[g][sfb]);#endif }#if 0 printf(" %6d %6d %6d\n", i, ics->sect_end[g][i], ics->sect_cb[g][i]);#endif k += sect_len; i++; } ics->num_sec[g] = i;#if 0 printf("%d\n", ics->num_sec[g]);#endif }#if 0 printf("\n");#endif return 0;}/* * decode_scale_factors() * decodes the scalefactors from the bitstream *//* * All scalefactors (and also the stereo positions and pns energies) are * transmitted using Huffman coded DPCM relative to the previous active * scalefactor (respectively previous stereo position or previous pns energy, * see subclause 4.6.2 and 4.6.3). The first active scalefactor is * differentially coded relative to the global gain. */static uint8_t decode_scale_factors(ic_stream *ics, bitfile *ld){ uint8_t g, sfb; int16_t t; int8_t noise_pcm_flag = 1; int16_t scale_factor = ics->global_gain; int16_t is_position = 0; int16_t noise_energy = ics->global_gain - 90; for (g = 0; g < ics->num_window_groups; g++) { for (sfb = 0; sfb < ics->max_sfb; sfb++) { switch (ics->sfb_cb[g][sfb]) { case ZERO_HCB: /* zero book */ ics->scale_factors[g][sfb] = 0;//#define SF_PRINT#ifdef SF_PRINT printf("%d\n", ics->scale_factors[g][sfb]);#endif break; case INTENSITY_HCB: /* intensity books */ case INTENSITY_HCB2: /* decode intensity position */ t = huffman_scale_factor(ld); is_position += (t - 60); ics->scale_factors[g][sfb] = is_position;#ifdef SF_PRINT printf("%d\n", ics->scale_factors[g][sfb]);#endif break; case NOISE_HCB: /* noise books */ /* decode noise energy */ if (noise_pcm_flag) { noise_pcm_flag = 0; t = (int16_t)faad_getbits(ld, 9 DEBUGVAR(1,73,"scale_factor_data(): first noise")) - 256; } else { t = huffman_scale_factor(ld); t -= 60; } noise_energy += t; ics->scale_factors[g][sfb] = noise_energy;#ifdef SF_PRINT printf("%d\n", ics->scale_factors[g][sfb]);#endif break; default: /* spectral books */ /* ics->scale_factors[g][sfb] must be between 0 and 255 */ ics->scale_factors[g][sfb] = 0; /* decode scale factor */ t = huffman_scale_factor(ld); scale_factor += (t - 60); if (scale_factor < 0 || scale_factor > 255) return 4; ics->scale_factors[g][sfb] = scale_factor;#ifdef SF_PRINT printf("%d\n", ics->scale_factors[g][sfb]);#endif break; } } } return 0;}/* Table 4.4.26 */static uint8_t scale_factor_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld){ uint8_t ret = 0;#ifdef PROFILE int64_t count = faad_get_ts();#endif#ifdef ERROR_RESILIENCE if (!hDecoder->aacScalefactorDataResilienceFlag) {#endif ret = decode_scale_factors(ics, ld);#ifdef ERROR_RESILIENCE } else { /* In ER AAC the parameters for RVLC are seperated from the actual data that holds the scale_factors. Strangely enough, 2 parameters for HCR are put inbetween them. */ ret = rvlc_scale_factor_data(ics, ld); }#endif#ifdef PROFILE count = faad_get_ts() - count; hDecoder->scalefac_cycles += count;#endif return ret;}/* Table 4.4.27 */static void tns_data(ic_stream *ics, tns_info *tns, bitfile *ld){ uint8_t w, filt, i, start_coef_bits, coef_bits; uint8_t n_filt_bits = 2; uint8_t length_bits = 6; uint8_t order_bits = 5; if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) { n_filt_bits = 1; length_bits = 4; order_bits = 3; } for (w = 0; w < ics->num_windows; w++) { tns->n_filt[w] = (uint8_t)faad_getbits(ld, n_filt_bits DEBUGVAR(1,74,"tns_data(): n_filt"));#if 0 printf("%d\n", tns->n_filt[w]);#endif if (tns->n_filt[w]) { if ((tns->coef_res[w] = faad_get1bit(ld DEBUGVAR(1,75,"tns_data(): coef_res"))) & 1) { start_coef_bits = 4; } else { start_coef_bits = 3; }#if 0 printf("%d\n", tns->coef_res[w]);#endif } for (filt = 0; filt < tns->n_filt[w]; filt++) { tns->length[w][filt] = (uint8_t)faad_getbits(ld, length_bits DEBUGVAR(1,76,"tns_data(): length"));#if 0 printf("%d\n", tns->length[w][filt]);#endif tns->order[w][filt] = (uint8_t)faad_getbits(ld, order_bits DEBUGVAR(1,77,"tns_data(): order"));#if 0 printf("%d\n", tns->order[w][filt]);#endif if (tns->order[w][filt]) { tns->direction[w][filt] = faad_get1bit(ld DEBUGVAR(1,78,"tns_data(): direction"));#if 0 printf("%d\n", tns->direction[w][filt]);#endif tns->coef_compress[w][filt] = faad_get1bit(ld DEBUGVAR(1,79,"tns_data(): coef_compress"));#if 0 printf("%d\n", tns->coef_compress[w][filt]);#endif coef_bits = start_coef_bits - tns->coef_compress[w][filt]; for (i = 0; i < tns->order[w][filt]; i++) { tns->coef[w][filt][i] = (uint8_t)faad_getbits(ld, coef_bits DEBUGVAR(1,80,"tns_data(): coef"));#if 0 printf("%d\n", tns->coef[w][filt][i]);#endif } } } }}#ifdef LTP_DEC/* Table 4.4.28 */static uint8_t ltp_data(NeAACDecHandle hDecoder, ic_stream *ics, ltp_info *ltp, bitfile *ld){ uint8_t sfb, w; ltp->lag = 0;#ifdef LD_DEC if (hDecoder->object_type == LD) { ltp->lag_update = (uint8_t)faad_getbits(ld, 1 DEBUGVAR(1,142,"ltp_data(): lag_update")); if (ltp->lag_update) { ltp->lag = (uint16_t)faad_getbits(ld, 10 DEBUGVAR(1,81,"ltp_data(): lag")); } } else {#endif ltp->lag = (uint16_t)faad_getbits(ld, 11 DEBUGVAR(1,81,"ltp_data(): lag"));#ifdef LD_DEC }#endif /* Check length of lag */ if (ltp->lag > (hDecoder->frameLength << 1)) return 18; ltp->coef = (uint8_t)faad_getbits(ld, 3 DEBUGVAR(1,82,"ltp_data(): coef")); if (ics->window_sequence == EIGHT_SHORT_SEQUENCE) { for (w = 0; w < ics->num_windows; w++) { if ((ltp->short_used[w] = faad_get1bit(ld DEBUGVAR(1,83,"ltp_data(): short_used"))) & 1) { ltp->short_lag_present[w] = faad_get1bit(ld DEBUGVAR(1,84,"ltp_data(): short_lag_present")); if (ltp->short_lag_present[w]) { ltp->short_lag[w] = (uint8_t)faad_getbits(ld, 4 DEBUGVAR(1,85,"ltp_data(): short_lag")); } } } } else { ltp->last_band = (ics->max_sfb < MAX_LTP_SFB ? ics->max_sfb : MAX_LTP_SFB); for (sfb = 0; sfb < ltp->last_band; sfb++) { ltp->long_used[sfb] = faad_get1bit(ld DEBUGVAR(1,86,"ltp_data(): long_used")); } } return 0;}#endif/* Table 4.4.29 */static uint8_t spectral_data(NeAACDecHandle hDecoder, ic_stream *ics, bitfile *ld, int16_t *spectral_data){ int8_t i; uint8_t g; uint16_t inc, k, p = 0; uint8_t groups = 0; uint8_t sect_cb; uint8_t result; uint16_t nshort = hDecoder->frameLength/8;#ifdef PROFILE int64_t count = faad_get_ts();#endif for(g = 0; g < ics->num_window_groups; g++) { p = groups*nshort; for (i = 0; i < ics->num_sec[g]; i++) { sect_cb = ics->sect_cb[g][i]; inc = (sect_cb >= FIRST_PAIR_HCB) ? 2 : 4; switch (sect_cb) { case ZERO_HCB: case NOISE_HCB: case INTENSITY_HCB: case INTENSITY_HCB2://#define SD_PRINT#ifdef SD_PRINT { int j; for (j = ics->sect_sfb_offset[g][ics->sect_start[g][i]]; j < ics->sect_sfb_offset[g][ics->sect_end[g][i]]; j++) { printf("%d\n", 0); } }#endif//#define SFBO_PRINT#ifdef SFBO_PRINT printf("%d\n", ics->sect_sfb_offset[g][ics->sect_start[g][i]]);#endif p += (ics->sect_sfb_offset[g][ics->sect_end[g][i]] - ics->sect_sfb_offset[g][ics->sect_start[g][i]]); break; default:#ifdef SFBO_PRINT printf("%d\n", ics->sect_sfb_offset[g][ics->sect_start[g][i]]);#endif for (k = ics->sect_sfb_offset[g][ics->sect_start[g][i]]; k < ics->sect_sfb_offset[g][ics->sect_end[g][i]]; k += inc) { if ((result = huffman_spectral_data(sect_cb, ld, &spectral_data[p])) > 0) return result;#ifdef SD_PRINT { int j; for (j = p; j < p+inc; j++) { printf("%d\n", spectral_data[j]); } }#endif p += inc; } break; } } groups += ics->window_group_length[g]; }#ifdef PROFILE count = faad_get_ts() - count; hDecoder->spectral_cycles += count;#endif return 0;}/* Table 4.4.30 */static uint16_t extension_payload(bitfile *ld, drc_info *drc, uint16_t count){ uint16_t i, n, dataElementLength; uint8_t dataElementLengthPart; uint8_t align = 4, data_element_version, loopCounter; uint8_t extension_type = (uint8_t)faad_getbits(ld, 4 DEBUGVAR(1,87,"extension_payload(): extension_type")); switch (extension_type) { case EXT_DYNAMIC_RANGE: drc->present = 1; n = dynamic_range_info(ld, drc); return n; case EXT_FILL_DATA: /* fill_nibble = */ faad_getbits(ld, 4 DEBUGVAR(1,136,"extension_payload(): fill_nibble")); /* must be
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -