📄 decoder_tf.c
字号:
Info sfbInfoNScale; unsigned char nrOfSignificantElements = 0; /* SCE (mono) and CPE (stereo) only */ if(debug['n']) { /* fprintf(stderr, "\rblock %ld", bno); */ printf("\n-------\nBlock: %ld\n", bno); } /* Set the current bitStream for aac-decoder */ setHuffdec2BitBuffer(fixed_stream); reset_mc_info(mip); if ( bitStreamType != SCALABLE ) { { ele_id = GetBits ( ID_SYN_ELE, LEN_SE_ID, hResilience, hVm, hEpInfo ); } if ( ele_id == ID_SCE || ele_id == ID_CPE ) { nrOfSignificantElements++; } sfbInfoP = &sfbInfoNScale; } else { sfbInfoP = sfbInfo[windowSequence[MONO_CHAN]]; if (numChannels == 2) { ele_id = ID_CPE; if ( commonWindow ) { wnd[mip->ch_info[0].widx] = windowSequence[MONO_CHAN] ; } else { CommonExit(-1,"\n 2 channels but no common window: not supported"); } } else { ele_id=ID_SCE; wnd[mip->ch_info[0].widx]=windowSequence[MONO_CHAN]; } } if(debug['v']) fprintf(stderr, "\nele_id %d\n", ele_id); while ( ele_id != ID_END ) { /* get audio syntactic element */ switch (ele_id) { case ID_SCE: /* single channel */ case ID_CPE: /* channel pair */ case ID_LFE: /* low freq effects channel */ if ( huffdecode ( ele_id, mip, wnd, wnd_shape, cb_map, factors, group, hasmask, mask, max_sfb, pred_type, lpflag, prstflag, nok_lt_status, tns, gc_stream, coef, bitStreamType, commonWindow, sfbInfoP, hResilience, hVm, hHcrSpecData, hHcrInfo, hEpInfo, hConcealment, qc_select) < 0 ) CommonExit(1,"huffdecode (decoder.c)"); if ((bitStreamType == SCALABLE)){ for (ch=0; ch<Chans; ch++ ) { if (!(mip->ch_info[ch].present)) continue; for (sfb=0; sfb<*max_sfb; sfb++) { sfbCbMap[ch][sfb] = cb_map[ch][sfb]; } } } break;#if (CChans > 0) case ID_CCE: /* coupling channel */ if ( getcc ( mip, cc_wnd, cc_wnd_shape, cc_coef, cc_gain, hVm, hHcrSpecData, hHcrInfo, hEpInfo ) < 0) CommonExit(1,"getcc"); break;#endif case ID_DSE: /* data element */ if ( getdata ( &d_tag, &d_cnt, d_bytes, hResilience, hVm, hEpInfo ) < 0) CommonExit(1,"data channel"); break; case ID_PCE: /* program config element */ get_prog_config ( &prog_config, blockSize, hResilience, hVm, hEpInfo ); break; case ID_FIL: /* fill element */ getfill ( hResilience, hVm, hEpInfo ); break; default: fprintf(stderr, "Element not supported: %d\n", ele_id); break; } if (bitStreamType != SCALABLE) { { ele_id = GetBits ( ID_SYN_ELE, LEN_SE_ID, hResilience, hVm, hEpInfo ); } if ( ele_id == ID_SCE || ele_id == ID_CPE ) { nrOfSignificantElements++; } } else { ele_id=ID_END; } if(debug['v']) { fprintf(stderr, "\nele_id %d\n", ele_id); } } check_mc_info ( mip, ( ! mc_info.mcInfoCorrectFlag && default_config ) || ( bitStreamType == SCALABLE ), hEpInfo, hResilience ); #if (ICChans > 0) /* transform independently switched coupling channels */ ind_coupling(mip, wnd, wnd_shape, cc_wnd, cc_wnd_shape, cc_coef ,cc_state);#endif if ((bitStreamType != SCALABLE)) { /* * set window sequence and shape * parameters of the framework variables */ int chanCnt = 0; for (ch=0; ch<Chans; ch++) { cip = &mip->ch_info[ch]; if (cip->present) { windowSequence[chanCnt] = wnd[cip->widx]; window_shape[chanCnt] = wnd_shape[cip->widx].this_bk; chanCnt++; } if (chanCnt >= MAX_TIME_CHANNELS) { break; } } /* m/s stereo */ for (ch=0; ch<Chans; ch++) { cip = &mip->ch_info[ch]; if ((cip->present) && (cip->cpe) && (cip->ch_is_left)) { wn = cip->widx; if(hasmask[wn]) { left = ch; right = cip->paired_ch; info = winmap[wnd[wn]]; if (hasmask[wn] == 1) { map_mask(info, group[wn], mask[wn], cb_map[ch]); } synt(info, group[wn], mask[wn], coef[right], coef[left]); } } } } /* Common part for aac_raw and aac_scaleable */ chCnt = 0; for (ch=0; ch<Chans; ch++) { if (!(mip->ch_info[ch].present)) continue; if (bitStreamType != SCALABLE) wn = mip->ch_info[ch].widx; else wn = 0; info = winmap[wnd[wn]]; /* calc PNS spectrum */ pns( mip, info, ch, group[wn], cb_map[ch], factors[ch], lpflag[wn], coef ); chCnt++; } if ((bitStreamType != SCALABLE)){ /* intensity stereo and prediction */ chCnt = 0; for (ch=0; ch<Chans; ch++) { if (!(mip->ch_info[ch].present)) continue; wn = mip->ch_info[ch].widx; info = winmap[wnd[wn]]; intensity(mip, info, ch, group[wn], cb_map[ch], factors[ch], lpflag[wn], coef); if (pred_type == MONOPRED) { if (mip->profile == Main_Profile) { predict(info, lpflag[wn], sp_status[ch], coef[ch], hConcealment); } else { if (*lpflag[wn] != 0) { CommonExit(1,"AacDecodeFrame: prediction not allowed in this profile!"); } } } else if (pred_type == NOK_BWP) nok_predict(info, mip->profile, lpflag[wn], nok_sp_status[ch], nok_sp_status[ch]->prev_quant, coef[ch]); else if (pred_type == NOK_LTP) /* Long term prediction. */ nok_lt_predict(info, wnd[ch], wnd_shape[ch].this_bk, wnd_shape[ch].prev_bk, nok_lt_status[chCnt]->sbk_prediction_used, nok_lt_status[chCnt]->sfb_prediction_used, nok_lt_status[chCnt], nok_lt_status[chCnt]->weight, nok_lt_status[chCnt]->delay, coef[ch], BLOCK_LEN_LONG, BLOCK_LEN_MEDIUM, BLOCK_LEN_SHORT, tns[ch], qc_select); chCnt++; } chCnt = 0; for (ch=0; ch<Chans; ch++) { if (!(mip->ch_info[ch].present)) continue; /* Save window shape for next frame (used by LTP tool)*/ wnd_shape[ch].prev_bk = wnd_shape[ch].this_bk; wn = mip->ch_info[ch].widx; info = winmap[wnd[wn]]; /* predictor reset */ left = ch; right = left; if ( (mip->ch_info[ch].cpe) && (mip->ch_info[ch].common_window) ) /* prstflag's shared by channel pair */ right = mip->ch_info[ch].paired_ch; if (pred_type == MONOPRED) predict_reset(info, prstflag[wn], sp_status, left, right); else if (pred_type == NOK_BWP) nok_predict_reset(info, prstflag[wn], nok_sp_status, left, right); /* PNS predictor reset, works only for MONOPRED ! */ if(pred_type==MONOPRED) predict_pns_reset(info, sp_status[ch], cb_map[ch]); #if (CChans > 0) /* if cc_domain indicates before TNS */ void coupling(Info *info, MC_Info *mip, Float **coef, Float **cc_coef, Float **cc_gain, int ch, int cc_dom, int cc_dep); coupling(mip, coef, cc_coef, cc_gain, ch, CC_DOM, !CC_IND);#endif /* tns */ if (bitStreamType != SCALABLE) { for (i=j=0; i<tns[ch]->n_subblocks; i++) { if (debug['T']) { fprintf(stderr, "%ld %d %d\n", bno, ch, i); print_tns( &(tns[ch]->info[i])); } tns_decode_subblock(&coef[ch][j], max_sfb[wn], info->sbk_sfb_top[i], info->islong, &(tns[ch]->info[i]), qc_select); j += info->bins_per_sbk[i]; } } #if (CChans > 0) /* if cc_domain indicated after TNS */ coupling(mip, coef, cc_coef, cc_gain, ch, CC_DOM, !CC_IND);#endif#if (CChans > 0) /* independently switched coupling */# /* coupling(info, mip, coef, cc_coef, cc_gain, ch, CC_DOM, CC_IND); */#pragma warning " coupling is currently not supported in VM "#endif } } /* Copy the coeff and pass them back to VM */ outCh=0; for (ch=0; ch<Chans; ch++) { if ((mip->ch_info[ch].present)){ if ((outCh+1)> numChannels){ CommonExit(-1,"wrong number of channels in command line"); } for (i=0;i<blockSize;i++){ spectral_line_vector[outCh][i] = (double)coef[ch][i]; } outCh++; } } bno++; return GetReadBitCnt ( hVm );}void decodeBlockType ( int coded_types, int granules, int gran_block_type[], int act_gran ){ static int ty_seq[4][2]={{0,1},{2,3},{2,3},{0,1}}; register int tmp; register int i; if( act_gran < 0 ) { gran_block_type[0] = (coded_types >> (granules - 1)) & 0x03; } else if( act_gran == 0 ) { gran_block_type[0] = coded_types & 0x03; } for( i=1; i<granules; i++ ) { if( act_gran < 0 ) { tmp = ((coded_types >> (granules - 1 - i)) & 0x01); gran_block_type[i] = ty_seq[gran_block_type[i-1]][tmp]; } else if( act_gran == i ) { tmp = coded_types & 0x01; gran_block_type[i] = ty_seq[gran_block_type[i-1]][tmp]; } }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -