Esempio n. 1
0
static void adaptThresholdsToPe(PSY_OUT_CHANNEL  psyOutChannel[MAX_CHANNELS],
                                PSY_OUT_ELEMENT* psyOutElement,
                                PE_DATA *peData,
                                const int nChannels,
                                const float desiredPe,
                                AH_PARAM *ahParam,
                                MINSNR_ADAPT_PARAM *msaParam)
{
   float noRedPe, redPe, redPeNoAH;
   float constPart, constPartNoAH;
   float nActiveLines, nActiveLinesNoAH;
   float desiredPeNoAH;
   float avgThrExp, redVal;
   int   ahFlag[MAX_CHANNELS][MAX_GROUPED_SFB];
   float thrExp[MAX_CHANNELS][MAX_GROUPED_SFB];
   int iter;

   COUNT_sub_start("adaptThresholdsToPe");

   FUNC(3);
   calcThreshExp(thrExp, psyOutChannel, nChannels);

   FUNC(3);
   adaptMinSnr(psyOutChannel, msaParam, nChannels);

   FUNC(5);
   initAvoidHoleFlag(ahFlag, psyOutChannel, psyOutElement, nChannels, ahParam);

   INDIRECT(3); MOVE(3);
   noRedPe = peData->pe;
   constPart = peData->constPart;
   nActiveLines = peData->nActiveLines;

   MULT(1); ADD(1); DIV(1); TRANS(1);
   avgThrExp = (float)pow(2.0f, (constPart - noRedPe)/(invRedExp*nActiveLines));

   /* MULT(1); calculated above */ ADD(2); DIV(1); TRANS(1);
   redVal = (float)pow(2.0f, (constPart - desiredPe)/(invRedExp*nActiveLines)) -
            avgThrExp;

   BRANCH(1); MOVE(1);
   redVal = max(0.0f, redVal);

   FUNC(5);
   reduceThresholds(psyOutChannel, ahFlag, thrExp, nChannels, redVal);

   FUNC(3);
   calcPe(peData, psyOutChannel, nChannels);

   INDIRECT(1); MOVE(1);
   redPe = peData->pe;

   MOVE(1);
   iter = 0;

   LOOP(1);
   do {

     PTR_INIT(3); FUNC(7);
     calcPeNoAH(&redPeNoAH, &constPartNoAH, &nActiveLinesNoAH,
                peData, ahFlag, psyOutChannel, nChannels);

     ADD(2); BRANCH(1); MOVE(1);
     desiredPeNoAH = max(desiredPe - (redPe - redPeNoAH), 0);

     BRANCH(1);
     if (nActiveLinesNoAH > 0) {

       MULT(1); ADD(1); DIV(1); TRANS(1);
       avgThrExp = (float)pow(2.0f, (constPartNoAH - redPeNoAH) / (invRedExp*nActiveLinesNoAH));

       /* MULT(1); calculated above */ ADD(3); DIV(1); TRANS(1);
       redVal   += (float)pow(2.0f, (constPartNoAH - desiredPeNoAH) / (invRedExp*nActiveLinesNoAH))
                   - avgThrExp;

       BRANCH(1); MOVE(1);
       redVal = max(0.0f, redVal);

       FUNC(5);
       reduceThresholds(psyOutChannel, ahFlag, thrExp, nChannels, redVal);
     }

     FUNC(3);
     calcPe(peData, psyOutChannel, nChannels);

     INDIRECT(1); MOVE(1);
     redPe = peData->pe;

     ADD(1);
     iter++;

     ADD(3); MISC(1); MULT(1); LOGIC(1); /* while() condition */
   } while ((fabs(redPe - desiredPe) > (0.05f)*desiredPe) && (iter < 2));


   MULT(1); ADD(1); BRANCH(1);
   if (redPe < 1.15f*desiredPe) {

     ADD(1); FUNC(7);
     correctThresh(psyOutChannel, ahFlag, peData, thrExp, redVal,
                   nChannels, desiredPe - redPe);
   }
   else {

     MULT(1); FUNC(5);
     reduceMinSnr(psyOutChannel, peData, ahFlag, nChannels, 1.05f*desiredPe);

     MULT(1); FUNC(7);
     allowMoreHoles(psyOutChannel, psyOutElement, peData, ahFlag,
                    ahParam, nChannels, 1.05f*desiredPe);
   }

   COUNT_sub_end();
}
Esempio n. 2
0
static void adaptThresholdsToPe(PSY_OUT_CHANNEL  psyOutChannel[MAX_CHANNELS],
                                PSY_OUT_ELEMENT* psyOutElement,
                                PE_DATA *peData,
                                const int nChannels,
                                const float desiredPe,
                                AH_PARAM *ahParam,
                                MINSNR_ADAPT_PARAM *msaParam)
{
   float noRedPe, redPe, redPeNoAH;
   float constPart, constPartNoAH;
   float nActiveLines, nActiveLinesNoAH;
   float desiredPeNoAH;
   float avgThrExp, redVal;
   int   ahFlag[MAX_CHANNELS][MAX_GROUPED_SFB];
   float thrExp[MAX_CHANNELS][MAX_GROUPED_SFB];
   int iter;

   

   
   calcThreshExp(thrExp, psyOutChannel, nChannels);

   
   adaptMinSnr(psyOutChannel, msaParam, nChannels);

   
   initAvoidHoleFlag(ahFlag, psyOutChannel, psyOutElement, nChannels, ahParam);

    
   noRedPe = peData->pe;
   constPart = peData->constPart;
   nActiveLines = peData->nActiveLines;

      
   avgThrExp = (float)pow(2.0f, (constPart - noRedPe)/(invRedExp*nActiveLines));

   /*  calculated above */   
   redVal = (float)pow(2.0f, (constPart - desiredPe)/(invRedExp*nActiveLines)) -
            avgThrExp;

    
   redVal = max(0.0f, redVal);

   
   reduceThresholds(psyOutChannel, ahFlag, thrExp, nChannels, redVal);

   
   calcPe(peData, psyOutChannel, nChannels);

    
   redPe = peData->pe;

   
   iter = 0;

   
   do {

      
     calcPeNoAH(&redPeNoAH, &constPartNoAH, &nActiveLinesNoAH,
                peData, ahFlag, psyOutChannel, nChannels);

       
     desiredPeNoAH = max(desiredPe - (redPe - redPeNoAH), 0);

     
     if (nActiveLinesNoAH > 0) {

          
       avgThrExp = (float)pow(2.0f, (constPartNoAH - redPeNoAH) / (invRedExp*nActiveLinesNoAH));

       /*  calculated above */   
       redVal   += (float)pow(2.0f, (constPartNoAH - desiredPeNoAH) / (invRedExp*nActiveLinesNoAH))
                   - avgThrExp;

        
       redVal = max(0.0f, redVal);

       
       reduceThresholds(psyOutChannel, ahFlag, thrExp, nChannels, redVal);
     }

     
     calcPe(peData, psyOutChannel, nChannels);

      
     redPe = peData->pe;

     
     iter++;

         /* while() condition */
   } while ((fabs(redPe - desiredPe) > (0.05f)*desiredPe) && (iter < 2));


     
   if (redPe < 1.15f*desiredPe) {

      
     correctThresh(psyOutChannel, ahFlag, peData, thrExp, redVal,
                   nChannels, desiredPe - redPe);
   }
   else {

      
     reduceMinSnr(psyOutChannel, peData, ahFlag, nChannels, 1.05f*desiredPe);

      
     allowMoreHoles(psyOutChannel, psyOutElement, peData, ahFlag,
                    ahParam, nChannels, 1.05f*desiredPe);
   }

   
}