⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 vad1.c

📁 arm音频编解码库
💻 C
📖 第 1 页 / 共 3 页
字号:
           if ((st->vadreg & 0x4000) != 0)           {              test ();              if (st->stat_count != 0)              {                 st->stat_count = sub(st->stat_count, 1);  move16 ();              }           }        }     }  }    /* Update average amplitude estimate for stationarity estimation */  alpha = ALPHA4;                                          move16 ();  test ();  if (sub(st->stat_count, STAT_COUNT) == 0)   {     alpha = 32767;                                        move16 ();  }  else if ((st->vadreg & 0x4000) == 0)   {     logic16 (); test ();     alpha = ALPHA5;                                       move16 ();  }    for (i = 0; i < COMPLEN; i++)  {     st->ave_level[i] = add(st->ave_level[i],                            mult_r(alpha, sub(level[i], st->ave_level[i])));     move16 ();  }  }/**************************************************************************** * *     Function     : hangover_addition *     Purpose      : Add hangover for complex signal or after speech bursts *     Inputs       : burst_count:  counter for the length of speech bursts *                    hang_count:   hangover counter *                    vadreg:       intermediate VAD decision *     Outputs      : burst_count:  counter for the length of speech bursts *                    hang_count:   hangover counter *     Return value : VAD_flag indicating final VAD decision * ***************************************************************************/static Word16 hangover_addition(              vadState1 *st,       /* i/o : State struct                     */              Word16 noise_level, /* i   : average level of the noise       */                                  /*       estimates                        */              Word16 low_power    /* i   : flag power of the input frame    */              ){   Word16 hang_len, burst_len;      /*       Calculate burst_len and hang_len      burst_len: number of consecutive intermediate vad flags with "1"-decision                 required for hangover addition      hang_len:  length of the hangover      */   test ();   if (sub(noise_level, HANG_NOISE_THR) > 0)   {      burst_len = BURST_LEN_HIGH_NOISE;                           move16 ();      hang_len = HANG_LEN_HIGH_NOISE;                             move16 ();   }   else   {      burst_len = BURST_LEN_LOW_NOISE;                            move16 ();      hang_len = HANG_LEN_LOW_NOISE;                              move16 ();   }      /* if the input power (pow_sum) is lower than a threshold, clear      counters and set VAD_flag to "0"  "fast exit"                 */   test ();   if (low_power != 0)   {      st->burst_count = 0;                                        move16 ();      st->hang_count = 0;                                         move16 ();      st->complex_hang_count = 0;                                 move16 ();      st->complex_hang_timer = 0;                                 move16 ();      return 0;   }      test ();   if (sub(st->complex_hang_timer, CVAD_HANG_LIMIT) > 0)   {      test ();      if (sub(st->complex_hang_count, CVAD_HANG_LENGTH) < 0)      {         st->complex_hang_count = CVAD_HANG_LENGTH;               move16 ();      }         }      /* long time very complex signal override VAD output function */   test ();   if (st->complex_hang_count != 0)   {      st->burst_count = BURST_LEN_HIGH_NOISE;                     move16 ();      st->complex_hang_count = sub(st->complex_hang_count, 1);    move16 ();      return 1;    }   else   {      /* let hp_corr work in from a noise_period indicated by the VAD */      test (); test (); logic16 ();      if (((st->vadreg & 0x3ff0) == 0) &&          (sub(st->corr_hp_fast, CVAD_THRESH_IN_NOISE) > 0))      {         return 1;      }     }   /* update the counters (hang_count, burst_count) */   logic16 (); test ();   if ((st->vadreg & 0x4000) != 0)   {      st->burst_count = add(st->burst_count, 1);                  move16 ();      test ();      if (sub(st->burst_count, burst_len) >= 0)      {         st->hang_count = hang_len;                               move16 ();      }      return 1;   }   else   {      st->burst_count = 0;                                        move16 ();      test ();      if (st->hang_count > 0)      {         st->hang_count = sub(st->hang_count, 1);                 move16 ();         return 1;      }   }   return 0;}/**************************************************************************** * *     Function   : noise_estimate_update *     Purpose    : Update of background noise estimate *     Inputs     : bckr_est:   background noise estimate *                  pitch:      flags for pitch detection *                  stat_count: stationary counter *     Outputs    : bckr_est:   background noise estimate * ***************************************************************************/static void noise_estimate_update(                  vadState1 *st,    /* i/o : State struct                       */                  Word16 level[]   /* i   : sub-band levels of the input frame */                  ){   Word16 i, alpha_up, alpha_down, bckr_add;      /* Control update of bckr_est[] */   update_cntrl(st, level);      /* Choose update speed */   bckr_add = 2;                                           move16 ();      logic16 (); test (); logic16 (); test (); test ();   if (((0x7800 & st->vadreg) == 0) &&        ((st->pitch & 0x7800) == 0)        &&  (st->complex_hang_count == 0))   {      alpha_up = ALPHA_UP1;                                move16 ();      alpha_down = ALPHA_DOWN1;                            move16 ();   }   else    {      test (); test ();      if ((st->stat_count == 0)           && (st->complex_hang_count == 0))      {         alpha_up = ALPHA_UP2;                             move16 ();         alpha_down = ALPHA_DOWN2;                         move16 ();      }      else      {         alpha_up = 0;                                     move16 ();         alpha_down = ALPHA3;                              move16 ();         bckr_add = 0;                                     move16 ();      }   }      /* Update noise estimate (bckr_est) */   for (i = 0; i < COMPLEN; i++)   {      Word16 temp;      temp = sub(st->old_level[i], st->bckr_est[i]);            test ();      if (temp < 0)      { /* update downwards*/         st->bckr_est[i] = add(-2, add(st->bckr_est[i], mult_r(alpha_down, temp)));         move16 ();                  /* limit minimum value of the noise estimate to NOISE_MIN */         test ();         if (sub(st->bckr_est[i], NOISE_MIN) < 0)         {            st->bckr_est[i] = NOISE_MIN;                  move16 ();         }      }      else      { /* update upwards */         st->bckr_est[i] = add(bckr_add, add(st->bckr_est[i], mult_r(alpha_up, temp)));         move16 ();                  /* limit maximum value of the noise estimate to NOISE_MAX */         test ();         if (sub(st->bckr_est[i], NOISE_MAX) > 0)         {            st->bckr_est[i] = NOISE_MAX;                  move16 ();         }      }   }      /* Update signal levels of the previous frame (old_level) */   for(i = 0; i < COMPLEN; i++)   {      st->old_level[i] = level[i];                        move16 ();   }}/**************************************************************************** * *     Function   : complex_estimate_adapt *     Purpose    : Update/adapt of complex signal estimate *     Inputs     : low_power:   low signal power flag  *     Outputs    : st->corr_hp_fast:   long term complex signal estimate * ***************************************************************************/static void complex_estimate_adapt(         vadState1 *st,       /* i/o : VAD state struct                       */         Word16 low_power    /* i   : very low level flag of the input frame */         ){   Word16 alpha;            /* Q15 */   Word32 L_tmp;            /* Q31 */   /* adapt speed on own state */   test ();   if (sub(st->best_corr_hp, st->corr_hp_fast) < 0) /* decrease */   {      test ();      if (sub(st->corr_hp_fast, CVAD_THRESH_ADAPT_HIGH) < 0)      {  /* low state  */         alpha = CVAD_ADAPT_FAST;                          move16();       }        else       {  /* high state */         alpha = CVAD_ADAPT_REALLY_FAST;                   move16();         }         }   else  /* increase */    {      test ();      if (sub(st->corr_hp_fast, CVAD_THRESH_ADAPT_HIGH) < 0)      {           alpha = CVAD_ADAPT_FAST;                          move16();       }        else       {           alpha = CVAD_ADAPT_SLOW;                          move16();      }         }   L_tmp = L_deposit_h(st->corr_hp_fast);   L_tmp = L_msu(L_tmp, alpha, st->corr_hp_fast);   L_tmp = L_mac(L_tmp, alpha, st->best_corr_hp);   st->corr_hp_fast = round(L_tmp);           /* Q15 */    move16();      test ();   if (sub(st->corr_hp_fast, CVAD_MIN_CORR) <  0)   {      st->corr_hp_fast = CVAD_MIN_CORR;                    move16();   }   test ();   if (low_power != 0)   {      st->corr_hp_fast = CVAD_MIN_CORR;                    move16();   }   }/**************************************************************************** * *     Function     : complex_vad *     Purpose      : complex background decision *     Return value : the complex background decision * ***************************************************************************/static Word16 complex_vad(vadState1 *st,    /* i/o : VAD state struct              */                          Word16 low_power /* i   : flag power of the input frame */                          ){   st->complex_high = shr(st->complex_high, 1);                      move16 ();   st->complex_low = shr(st->complex_low, 1);                        move16 ();   test ();   if (low_power == 0)   {      test ();      if (sub(st->corr_hp_fast, CVAD_THRESH_ADAPT_HIGH) > 0)      {         st->complex_high = st->complex_high | 0x4000;   logic16 (); move16 ();      }            test ();      if (sub(st->corr_hp_fast, CVAD_THRESH_ADAPT_LOW) > 0 )      {         st->complex_low = st->complex_low | 0x4000;     logic16 (); move16 ();      }   }   test ();   if (sub(st->corr_hp_fast, CVAD_THRESH_HANG) > 0)   {      st->complex_hang_timer = add(st->complex_hang_timer, 1);       move16 ();   }   else   {      st->complex_hang_timer =  0;                                   move16 ();   }                     test (); logic16 (); test (); logic16 ();   return ((sub((st->complex_high & 0x7f80), 0x7f80) == 0) ||           (sub((st->complex_low & 0x7fff), 0x7fff) == 0));}/**************************************************************************** * *     Function     : vad_decision *     Purpose      : Calculates VAD_flag *     Inputs       : bckr_est:    background noise estimate *                    vadreg:      intermediate VAD flags *     Outputs      : noise_level: average level of the noise estimates *                    vadreg:      intermediate VAD flags *     Return value : VAD_flag * ***************************************************************************/static Word16 vad_decision(             vadState1 *st,          /* i/o : State struct                       */             Word16 level[COMPLEN], /* i   : sub-band levels of the input frame */             Word32 pow_sum         /* i   : power of the input frame           */             ){   Word16 i;   Word16 snr_sum;   Word32 L_temp;   Word16 vad_thr, temp, noise_level;   Word16 low_power_flag;      /* 

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -