Lines Matching refs:sfb
122 INT j, sfb, sfbGrp;
129 for (sfb = 0; sfb < tmp1; sfb++) {
132 for(j=psyOutChan->sfbOffsets[sfbGrp+sfb]; j<psyOutChan->sfbOffsets[sfbGrp+sfb+1]; j++ ) {
135 sfbFormFactorLdData[sfbGrp+sfb] = CalcLdData(formFactor);
138 for ( ; sfb < psyOutChan->sfbPerGroup; sfb++) {
139 sfbFormFactorLdData[sfbGrp+sfb] = FL2FXCONST_DBL(-1.0f);
178 INT sfbOffs, sfb;
188 for(sfb=0; sfb<maxSfbPerGroup; sfb++) {
190 if((FIXP_DBL)sfbEnergyLdData[sfbOffs+sfb] > (FIXP_DBL)sfbThresholdLdData[sfbOffs+sfb]) {
191 INT sfbWidth = sfbOffsets[sfbOffs+sfb+1] - sfbOffsets[sfbOffs+sfb];
193 /* avgFormFactorLdData = sqrtFixp(sqrtFixp(sfbEnergyLdData[sfbOffs+sfb]/sfbWidth)); */
194 /* sfbNRelevantLines[sfbOffs+sfb] = sfbFormFactor[sfbOffs+sfb] / avgFormFactorLdData; */
198 accu = sfbEnergyLdData[sfbOffs+sfb] - sfbWidthLdData - asPeFacLdData;
199 accu = sfbFormFactorLdData[sfbOffs+sfb] - (accu >> 2);
201 sfbNRelevantLines[sfbOffs+sfb] = CalcInvLdData(accu) >> 1;
264 INT sfb = 0, sfbLast;
267 /* search for first relevant sfb */
271 /* search for previous relevant sfb and count diff */
279 for (sfb=sfbLast+1; sfb<stopSfb; sfb++) {
280 if (scfOld[sfb]!=FDK_INT_MIN) {
281 scfBitsDiff += FDKaacEnc_bitCountScalefactorDelta(scfNew[sfbLast]-scfNew[sfb]) -
282 FDKaacEnc_bitCountScalefactorDelta(scfOld[sfbLast]-scfOld[sfb]);
283 sfbLast = sfb;
286 /* search for next relevant sfb and count diff */
316 INT sfb;
319 for (sfb=startSfb; sfb<stopSfb; sfb++) {
320 if (scfOld[sfb]!=FDK_INT_MIN) {
323 /* sfbConstPePart[sfb] = (float)log(psyOutChan->sfbEnergy[sfb] * 6.75f / sfbFormFactor[sfb]) * LOG2_1; */
326 if (sfbConstPePart[sfb] == (FIXP_DBL)FDK_INT_MIN)
327 sfbConstPePart[sfb] = ((psyOutChan->sfbEnergyLdData[sfb] - sfbFormFactorLdData[sfb] - FL2FXCONST_DBL(0.09375f)) >> 1) + FL2FXCONST_DBL(0.02152255861f);
329 scfFract = (FIXP_DBL) (scfOld[sfb] << (DFRACT_BITS-1-AS_PE_FAC_SHIFT));
330 ldRatioOld = sfbConstPePart[sfb] - fMult(FL2FXCONST_DBL(0.375f),scfFract);
332 scfFract = (FIXP_DBL) (scfNew[sfb] << (DFRACT_BITS-1-AS_PE_FAC_SHIFT));
333 ldRatioNew = sfbConstPePart[sfb] - fMult(FL2FXCONST_DBL(0.375f),scfFract);
345 specPeDiff += fMult(FL2FXCONST_DBL(0.7f),fMult(sfbNRelevantLines[sfb],(pNew - pOld)));
500 /* search for new relevant sfb */
606 /* save parameters to avoid multiple computations of the same sfb */
613 /* start again at first sfb */
647 INT sfb, startSfb, stopSfb;
661 for (sfb=0; sfb<sfbCnt; sfb++) {
662 if (scf[sfb]!=FDK_INT_MIN) {
663 scfMin = fixMin(scfMin, scf[sfb]);
664 scfMax = fixMax(scfMax, scf[sfb]);
680 sfb = stopSfb;
681 while (sfb<sfbCnt && (scf[sfb]==FDK_INT_MIN || scf[sfb] <= scfAct))
682 sfb++;
683 startSfb = sfb;
684 sfb++;
685 while (sfb<sfbCnt && (scf[sfb]==FDK_INT_MIN || scf[sfb] > scfAct))
686 sfb++;
687 stopSfb = sfb;
689 /* check if in all sfb of a valid region scfAct >= minScf[sfb] */
693 for (sfb=startSfb; sfb<stopSfb; sfb++) {
694 if (scf[sfb] != FDK_INT_MIN)
695 if (scfAct < minScf[sfb]) {
705 for (sfb=startSfb; sfb<stopSfb; sfb++) {
706 if (scfTmp[sfb] != FDK_INT_MIN)
707 scfTmp[sfb] = scfAct;
725 for (sfb=startSfb; sfb<stopSfb; sfb++) {
726 if (scfTmp[sfb] != FDK_INT_MIN) {
727 distOldSum += CalcInvLdData(sfbDist[sfb]) >> DIST_FAC_SHIFT;
729 sfbWidth = psyOutChan->sfbOffsets[sfb+1] - psyOutChan->sfbOffsets[sfb];
730 sfbOffs = psyOutChan->sfbOffsets[sfb];
732 sfbDistNew[sfb] = FDKaacEnc_calcSfbDist(qcOutChannel->mdctSpectrum+sfbOffs,
738 if (sfbDistNew[sfb] >qcOutChannel->sfbThresholdLdData[sfb]) {
743 distNewSum += CalcInvLdData(sfbDistNew[sfb]) >> DIST_FAC_SHIFT;
749 for (sfb=startSfb; sfb<stopSfb; sfb++) {
750 if (scf[sfb] != FDK_INT_MIN) {
751 sfbWidth = psyOutChan->sfbOffsets[sfb+1] -
752 psyOutChan->sfbOffsets[sfb];
753 sfbOffs = psyOutChan->sfbOffsets[sfb];
754 scf[sfb] = scfAct;
755 sfbDist[sfb] = sfbDistNew[sfb];
788 INT sfb, startSfb, stopSfb;
806 for (sfb=0; sfb<sfbCnt; sfb++) {
807 if (scf[sfb]!=FDK_INT_MIN) {
808 scfMin = fixMin(scfMin, scf[sfb]);
809 scfMax = fixMax(scfMax, scf[sfb]);
819 sfb = stopSfb;
820 while (sfb<sfbCnt && (scf[sfb]==FDK_INT_MIN))
821 sfb++;
822 startSfb = sfb;
824 sfb++;
825 while (sfb<sfbCnt && ((scf[sfb]==FDK_INT_MIN) || (scf[sfb]==scf[startSfb])))
826 sfb++;
827 stopSfb = sfb;
854 for (sfb=startSfb; sfb<stopSfb; sfb++) {
855 if (scf[sfb] != FDK_INT_MIN) {
856 /* sfbDistMax[sfb] = (float)pow(qcOutChannel->sfbThreshold[sfb]*sfbDist[sfb]*sfbDist[sfb],1.0f/3.0f); */
857 /* sfbDistMax[sfb] = fixMax(sfbDistMax[sfb],qcOutChannel->sfbEnergy[sfb]*FL2FXCONST_DBL(1.e-3f)); */
859 sfbDistMax[sfb] = fMult(FL2FXCONST_DBL(1.0f/3.0f),qcOutChannel->sfbThresholdLdData[sfb])+fMult(FL2FXCONST_DBL(1.0f/3.0f),sfbDist[sfb])+fMult(FL2FXCONST_DBL(1.0f/3.0f),sfbDist[sfb]);
860 sfbDistMax[sfb] = fixMax(sfbDistMax[sfb],qcOutChannel->sfbEnergyLdData[sfb]-FL2FXCONST_DBL(0.15571537944));
861 sfbDistMax[sfb] = fixMin(sfbDistMax[sfb],qcOutChannel->sfbThresholdLdData[sfb]);
872 for (sfb=startSfb; sfb<stopSfb; sfb++) {
873 if (scfTmp[sfb] != FDK_INT_MIN)
874 scfTmp[sfb] = scfNew;
891 for (sfb=startSfb; sfb<stopSfb; sfb++) {
892 if (scfTmp[sfb] != FDK_INT_MIN) {
893 sfbDistNew[sfb] = FDKaacEnc_calcSfbDist(qcOutChannel->mdctSpectrum+sfbOffs[sfb],
894 quantSpecTmp+sfbOffs[sfb],
895 sfbOffs[sfb+1]-sfbOffs[sfb],
899 if (sfbDistNew[sfb] > sfbDistMax[sfb]) {
902 if (sfbDistNew[sfb] == qcOutChannel->sfbEnergyLdData[sfb]) {
903 /* if whole sfb is already quantized to 0, further
916 for (sfb=startSfb; sfb<stopSfb; sfb++) {
917 if (scf[sfb] != FDK_INT_MIN) {
918 scf[sfb] = scfNew;
919 sfbDist[sfb] = sfbDistNew[sfb];
921 for (k=0; k<sfbOffs[sfb+1]-sfbOffs[sfb]; k++)
922 quantSpec[sfbOffs[sfb]+k] = quantSpecTmp[sfbOffs[sfb]+k];
945 check if in all sfb scfNew >= minScf[sfb] */
946 for (sfb=startSfb; sfb<stopSfb; sfb++) {
947 if (scfTmp[sfb] != FDK_INT_MIN) {
948 scfTmp[sfb] = scfNew;
949 if (scfNew < minScf[sfb])
970 for (sfb=startSfb; sfb<stopSfb; sfb++) {
971 if (scfTmp[sfb] != FDK_INT_MIN) {
972 distOldSum += CalcInvLdData(sfbDist[sfb]) >> DIST_FAC_SHIFT;
974 sfbDistNew[sfb] = FDKaacEnc_calcSfbDist(qcOutChannel->mdctSpectrum+sfbOffs[sfb],
975 quantSpecTmp+sfbOffs[sfb],
976 sfbOffs[sfb+1]-sfbOffs[sfb],
980 if (sfbDistNew[sfb] > qcOutChannel->sfbThresholdLdData[sfb]) {
985 distNewSum += CalcInvLdData(sfbDistNew[sfb]) >> DIST_FAC_SHIFT;
991 for (sfb=startSfb; sfb<stopSfb; sfb++) {
992 if (scf[sfb] != FDK_INT_MIN) {
993 scf[sfb] = scfNew;
994 sfbDist[sfb] = sfbDistNew[sfb];
996 for (k=0; k<sfbOffs[sfb+1]-sfbOffs[sfb]; k++)
997 quantSpec[sfbOffs[sfb]+k] = quantSpecTmp[sfbOffs[sfb]+k];
1015 for (sfb=startSfb; sfb<stopSfb; sfb++) {
1016 if (scfTmp[sfb] != FDK_INT_MIN)
1017 scfTmp[sfb] = scfNew;
1027 for (sfb=startSfb; sfb<stopSfb; sfb++) {
1028 if (scfTmp[sfb] != FDK_INT_MIN) {
1032 FDKaacEnc_calcSfbQuantEnergyAndDist(qcOutChannel->mdctSpectrum+sfbOffs[sfb],
1033 quantSpec+sfbOffs[sfb],
1034 sfbOffs[sfb+1]-sfbOffs[sfb], scfNew,
1035 &sfbEnQ, &sfbDistNew[sfb]);
1037 distOldSum += CalcInvLdData(sfbDist[sfb]) >> DIST_FAC_SHIFT;
1038 distNewSum += CalcInvLdData(sfbDistNew[sfb]) >> DIST_FAC_SHIFT;
1042 if ((sfbDistNew[sfb] > (sfbDist[sfb]+FL2FXCONST_DBL(0.00259488556167f))) || (sfbEnQ < (qcOutChannel->sfbEnergyLdData[sfb] - FL2FXCONST_DBL(0.00778722686652f)))){
1051 for (sfb=startSfb; sfb<stopSfb; sfb++) {
1052 if (scf[sfb] != FDK_INT_MIN) {
1053 scf[sfb] = scfNew;
1054 sfbDist[sfb] = sfbDistNew[sfb];
1077 INT i, j, sfb, sfbOffs;
1113 for(sfb=0; sfb<psyOutChannel->maxSfbPerGroup; sfb++) {
1115 threshLdData = qcOutChannel->sfbThresholdLdData[sfbOffs+sfb];
1116 energyLdData = qcOutChannel->sfbEnergyLdData[sfbOffs+sfb];
1118 sfbDistLdData[sfbOffs+sfb] = energyLdData;
1124 /* energyPart = (float)log10(sfbFormFactor[sfbOffs+sfb]); */
1126 energyPartLdData = sfbFormFactorLdData[sfbOffs+sfb] + FL2FXCONST_DBL(0.09375f);
1147 for(j=psyOutChannel->sfbOffsets[sfbOffs+sfb]; j<psyOutChannel->sfbOffsets[sfbOffs+sfb+1]; j++ ){
1154 /* minSfMaxQuant[sfbOffs+sfb] = (int)ceil(C1 + C2*log(maxSpec)); */
1157 //minSfMaxQuant[sfbOffs+sfb] = ((INT) ((c1Const + CalcLdData(maxSpec)) >> ((DFRACT_BITS-1)-8))) + 1;
1160 minSfMaxQuant[sfbOffs+sfb] = ((INT) ((c1Const + tmp) >> ((DFRACT_BITS-1)-8))) + 1;
1163 minSfMaxQuant[sfbOffs+sfb] = ((INT) (FL2FXCONST_DBL(-1.f) >> ((DFRACT_BITS-1)-8))) + 1;
1166 scfInt = fixMax(scfInt, minSfMaxQuant[sfbOffs+sfb]);
1171 scfInt = FDKaacEnc_improveScf(qcOutChannel->mdctSpectrum+psyOutChannel->sfbOffsets[sfbOffs+sfb],
1172 quantSpec+psyOutChannel->sfbOffsets[sfbOffs+sfb],
1173 quantSpecTmp+psyOutChannel->sfbOffsets[sfbOffs+sfb],
1174 psyOutChannel->sfbOffsets[sfbOffs+sfb+1]-psyOutChannel->sfbOffsets[sfbOffs+sfb],
1175 threshLdData, scfInt, minSfMaxQuant[sfbOffs+sfb],
1176 &sfbDistLdData[sfbOffs+sfb], &minScfCalculated[sfbOffs+sfb],
1180 scf[sfbOffs+sfb] = scfInt;
1236 for (sfb = 0; sfb < psyOutChannel->maxSfbPerGroup; sfb++) {
1237 if (scf[sfbOffs+sfb]!=FDK_INT_MIN)
1238 minSf = fixMin(minSf,scf[sfbOffs+sfb]);
1244 for (sfb = 0; sfb < psyOutChannel->maxSfbPerGroup; sfb++) {
1245 if ((scf[sfbOffs+sfb] != FDK_INT_MIN) && (minSf+MAX_SCF_DELTA) < scf[sfbOffs+sfb]) {
1246 scf[sfbOffs+sfb] = minSf + MAX_SCF_DELTA;
1248 sfbDistLdData[sfbOffs+sfb] =
1249 FDKaacEnc_calcSfbDist(qcOutChannel->mdctSpectrum+psyOutChannel->sfbOffsets[sfbOffs+sfb],
1250 quantSpec+psyOutChannel->sfbOffsets[sfbOffs+sfb],
1251 psyOutChannel->sfbOffsets[sfbOffs+sfb+1]-psyOutChannel->sfbOffsets[sfbOffs+sfb],
1252 scf[sfbOffs+sfb],
1264 for (sfb = 0; sfb < psyOutChannel->maxSfbPerGroup; sfb++) {
1265 maxSf = fixMax(maxSf,scf[sfbOffs+sfb]);
1273 for (sfb = 0; sfb < psyOutChannel->maxSfbPerGroup; sfb++) {
1274 if( scf[sfbOffs+sfb] == FDK_INT_MIN ) {
1275 scf[sfbOffs+sfb] = 0;
1277 for(j=psyOutChannel->sfbOffsets[sfbOffs+sfb]; j<psyOutChannel->sfbOffsets[sfbOffs+sfb+1]; j++ ) {
1282 scf[sfbOffs+sfb] = maxSf - scf[sfbOffs+sfb];
1291 for (sfb = 0; sfb < psyOutChannel->maxSfbPerGroup; sfb++) {
1292 scf[sfbOffs+sfb] = 0;
1294 for(j=psyOutChannel->sfbOffsets[sfbOffs+sfb]; j<psyOutChannel->sfbOffsets[sfbOffs+sfb+1]; j++ ) {