static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t X[MAX_NTSR][64], uint8_t ch, uint8_t dont_process, const uint8_t downSampledSBR) { int16_t k, l; (void)downSampledSBR; #ifdef DRM if (sbr->Is_DRM_SBR) { sbr->bsco = max((int32_t)sbr->maxAACLine*32/(int32_t)sbr->frame_len - (int32_t)sbr->kx, 0); } else { #endif sbr->bsco = 0; #ifdef DRM } #endif //#define PRE_QMF_PRINT #ifdef PRE_QMF_PRINT { int i; for (i = 0; i < 1024; i++) { printf("%d\n", channel_buf[i]); } } #endif /* subband analysis */ if (dont_process) sbr_qmf_analysis_32(sbr, &sbr->qmfa[ch], channel_buf, sbr->Xsbr[ch], sbr->tHFGen, 32); else sbr_qmf_analysis_32(sbr, &sbr->qmfa[ch], channel_buf, sbr->Xsbr[ch], sbr->tHFGen, sbr->kx); if (!dont_process) { #if 1 /* insert high frequencies here */ /* hf generation using patching */ hf_generation(sbr, sbr->Xsbr[ch], sbr->Xsbr[ch] #ifdef SBR_LOW_POWER ,deg #endif ,ch); #endif #ifdef SBR_LOW_POWER for (l = sbr->t_E[ch][0]; l < sbr->t_E[ch][sbr->L_E[ch]]; l++) { for (k = 0; k < sbr->kx; k++) { QMF_RE(sbr->Xsbr[ch][sbr->tHFAdj + l][k]) = 0; } } #endif #if 1 /* hf adjustment */ hf_adjustment(sbr, sbr->Xsbr[ch] #ifdef SBR_LOW_POWER ,deg #endif ,ch); #endif } if ((sbr->just_seeked != 0) || dont_process) { for (l = 0; l < sbr->numTimeSlotsRate; l++) { for (k = 0; k < 32; k++) { QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); #ifndef SBR_LOW_POWER QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); #endif } for (k = 32; k < 64; k++) { QMF_RE(X[l][k]) = 0; #ifndef SBR_LOW_POWER QMF_IM(X[l][k]) = 0; #endif } } } else { for (l = 0; l < sbr->numTimeSlotsRate; l++) { uint8_t kx_band, M_band, bsco_band; if (l < sbr->t_E[ch][0]) { kx_band = sbr->kx_prev; M_band = sbr->M_prev; bsco_band = sbr->bsco_prev; } else { kx_band = sbr->kx; M_band = sbr->M; bsco_band = sbr->bsco; } #ifndef SBR_LOW_POWER for (k = 0; k < kx_band + bsco_band; k++) { QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); } for (k = kx_band + bsco_band; k < kx_band + M_band; k++) { QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); } for (k = max(kx_band + bsco_band, kx_band + M_band); k < 64; k++) { QMF_RE(X[l][k]) = 0; QMF_IM(X[l][k]) = 0; } #else for (k = 0; k < kx_band + bsco_band; k++) { QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); } for (k = kx_band + bsco_band; k < min(kx_band + M_band, 63); k++) { QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); } for (k = max(kx_band + bsco_band, kx_band + M_band); k < 64; k++) { QMF_RE(X[l][k]) = 0; } QMF_RE(X[l][kx_band - 1 + bsco_band]) += QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][kx_band - 1 + bsco_band]); #endif } } }
static void sbr_process_channel(sbr_info *sbr, real_t *channel_buf, qmf_t X[MAX_NTSR][64], uint8_t ch, uint8_t dont_process) { int16_t i, k, l; #ifdef SBR_LOW_POWER ALIGN real_t deg[64]; #endif if (sbr->frame == 0) { uint8_t j; sbr->qmfa[ch] = qmfa_init(32); sbr->qmfs[ch] = qmfs_init(64); for (j = 0; j < 5; j++) { sbr->G_temp_prev[ch][j] = faad_malloc(64*sizeof(real_t)); sbr->Q_temp_prev[ch][j] = faad_malloc(64*sizeof(real_t)); } memset(sbr->Xsbr[ch], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*64 * sizeof(qmf_t)); memset(sbr->Xcodec[ch], 0, (sbr->numTimeSlotsRate+sbr->tHFGen)*32 * sizeof(qmf_t)); } /* subband analysis */ if (dont_process) sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], channel_buf, sbr->Xcodec[ch], sbr->tHFGen, 32); else sbr_qmf_analysis_32(sbr, sbr->qmfa[ch], channel_buf, sbr->Xcodec[ch], sbr->tHFGen, sbr->kx); if (!dont_process) { #if 1 /* insert high frequencies here */ /* hf generation using patching */ hf_generation(sbr, sbr->Xcodec[ch], sbr->Xsbr[ch] #ifdef SBR_LOW_POWER ,deg #endif ,ch); #endif #ifdef SBR_LOW_POWER for (l = sbr->t_E[ch][0]; l < sbr->t_E[ch][sbr->L_E[ch]]; l++) { for (k = 0; k < sbr->kx; k++) { QMF_RE(sbr->Xsbr[ch][sbr->tHFAdj + l][k]) = 0; } } #endif #if 1 /* hf adjustment */ hf_adjustment(sbr, sbr->Xsbr[ch] #ifdef SBR_LOW_POWER ,deg #endif ,ch); #endif } if ((sbr->just_seeked != 0) || dont_process) { for (l = 0; l < sbr->numTimeSlotsRate; l++) { for (k = 0; k < 32; k++) { QMF_RE(X[l][k]) = QMF_RE(sbr->Xcodec[ch][l + sbr->tHFAdj][k]); #ifndef SBR_LOW_POWER QMF_IM(X[l][k]) = QMF_IM(sbr->Xcodec[ch][l + sbr->tHFAdj][k]); #endif } for (k = 32; k < 64; k++) { QMF_RE(X[l][k]) = 0; #ifndef SBR_LOW_POWER QMF_IM(X[l][k]) = 0; #endif } } } else { for (l = 0; l < sbr->numTimeSlotsRate; l++) { uint8_t xover_band; if (l < sbr->t_E[ch][0]) xover_band = sbr->kx_prev; else xover_band = sbr->kx; for (k = 0; k < xover_band; k++) { QMF_RE(X[l][k]) = QMF_RE(sbr->Xcodec[ch][l + sbr->tHFAdj][k]); #ifndef SBR_LOW_POWER QMF_IM(X[l][k]) = QMF_IM(sbr->Xcodec[ch][l + sbr->tHFAdj][k]); #endif } for (k = xover_band; k < 64; k++) { QMF_RE(X[l][k]) = QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); #ifndef SBR_LOW_POWER QMF_IM(X[l][k]) = QMF_IM(sbr->Xsbr[ch][l + sbr->tHFAdj][k]); #endif } #ifdef SBR_LOW_POWER QMF_RE(X[l][xover_band - 1]) += QMF_RE(sbr->Xsbr[ch][l + sbr->tHFAdj][xover_band - 1]); #endif } } for (i = 0; i < sbr->tHFGen; i++) { memmove(sbr->Xcodec[ch][i], sbr->Xcodec[ch][i+sbr->numTimeSlotsRate], 32 * sizeof(qmf_t)); memmove(sbr->Xsbr[ch][i], sbr->Xsbr[ch][i+sbr->numTimeSlotsRate], 64 * sizeof(qmf_t)); } }
void sbrDecodeFrame(sbr_info *sbr, real_t *left_channel, real_t *right_channel, uint8_t id_aac, uint8_t just_seeked) { int16_t i, k, l; uint8_t dont_process = 0; uint8_t ch, channels, ret; real_t *ch_buf; sbr->id_aac = id_aac; channels = (id_aac == ID_SCE) ? 1 : 2; ret = sbr_extension_data(&sbr->ld, sbr, id_aac); ret = (sbr->ld.error)? sbr->ld.error : ret; if(ret || (sbr->header_count == 0)) dont_process = 1; if(just_seeked) sbr->just_seeked = 1; else sbr->just_seeked = 0; for (ch = 0; ch < channels; ch++){ if (ch == 0) ch_buf = left_channel; else ch_buf = right_channel; for (i = 0; i < tHFAdj; i++){ int8_t j; for (j = sbr->kx_prev; j < sbr->kx; j++){ QMF_RE(sbr->Xcodec[ch][i*32 + j]) = 0; QMF_IM(sbr->Xcodec[ch][i*32 + j]) = 0; } } sbr_qmf_analysis_32(sbr->qmfa[ch], ch_buf, sbr->Xcodec[ch], tHFGen); if(!dont_process){ hf_generation(sbr, sbr->Xcodec[ch], sbr->Xsbr[ch],ch); hf_adjustment(sbr, sbr->Xsbr[ch],ch); } if((sbr->just_seeked != 0) || dont_process){ for (l = 0; l < 32; l++){ for (k = 0; k < 32; k++){ QMF_RE(sbr->temp_X[l * 64 + k]) = QMF_RE(sbr->Xcodec[ch][(l + tHFAdj)*32 + k]); QMF_IM(sbr->temp_X[l * 64 + k]) = QMF_IM(sbr->Xcodec[ch][(l + tHFAdj)*32 + k]); } for (k = 32; k < 64; k++){ QMF_RE(sbr->temp_X[l * 64 + k]) = 0; QMF_IM(sbr->temp_X[l * 64 + k]) = 0; } } }else{ for (l = 0; l < 32; l++){ uint8_t xover_band; if (l < sbr->t_E[ch][0]) xover_band = sbr->kx_prev; else xover_band = sbr->kx; for (k = 0; k < xover_band; k++){ QMF_RE(sbr->temp_X[l * 64 + k]) = QMF_RE(sbr->Xcodec[ch][(l + tHFAdj)*32 + k]); QMF_IM(sbr->temp_X[l * 64 + k]) = QMF_IM(sbr->Xcodec[ch][(l + tHFAdj)*32 + k]); } for (k = xover_band; k < 64; k++){ QMF_RE(sbr->temp_X[l * 64 + k]) = QMF_RE(sbr->Xsbr[ch][(l + tHFAdj)*64 + k]); QMF_IM(sbr->temp_X[l * 64 + k]) = QMF_IM(sbr->Xsbr[ch][(l + tHFAdj)*64 + k]); } } } sbr_qmf_synthesis_64(sbr->qmfs[ch], (const complex_t*)sbr->temp_X, ch_buf); for (i = 0; i < 32; i++){ int8_t j; for (j = 0; j < tHFGen; j++){ QMF_RE(sbr->Xcodec[ch][j*32 + i]) = QMF_RE(sbr->Xcodec[ch][(j+32)*32 + i]); QMF_IM(sbr->Xcodec[ch][j*32 + i]) = QMF_IM(sbr->Xcodec[ch][(j+32)*32 + i]); } } for (i = 0; i < 64; i++){ int8_t j; for (j = 0; j < tHFGen; j++){ QMF_RE(sbr->Xsbr[ch][j*64 + i]) = QMF_RE(sbr->Xsbr[ch][(j+32)*64 + i]); QMF_IM(sbr->Xsbr[ch][j*64 + i]) = QMF_IM(sbr->Xsbr[ch][(j+32)*64 + i]); } } } if (sbr->bs_header_flag) sbr->just_seeked = 0; if (sbr->header_count != 0){ for (ch = 0; ch < channels; ch++) sbr_save_prev_data(sbr, ch); } sbr->frame++; }