Пример #1
0
void WebRtcIlbcfix_NearestNeighbor(
    int16_t *index, /* (o) index of array element closest to value */
    int16_t *array, /* (i) data array (Q2) */
    int16_t value, /* (i) value (Q2) */
    int16_t arlength /* (i) dimension of data array (==8) */
                                   ){
  int i;
  int16_t diff;
  /* Stack based */
  int32_t crit[8];

  /* Calculate square distance */
  for(i=0;i<arlength;i++){
    diff=array[i]-value;
    crit[i]=WEBRTC_SPL_MUL_16_16(diff, diff);
  }

  /* Find the minimum square distance */
  *index=WebRtcSpl_MinIndexW32(crit, (int16_t)arlength);
}
Пример #2
0
void WebRtcIlbcfix_NearestNeighbor(
    iLBC_Dec_Inst_t *iLBCdec_inst,
    /* (i) Decoder state */
    WebRtc_Word16 *index, /* (o) index of array element closest to value */
    WebRtc_Word16 *array, /* (i) data array (Q2) */
    WebRtc_Word16 value, /* (i) value (Q2) */
    WebRtc_Word16 arlength /* (i) dimension of data array (==8) */
                                   ){
  int i;
  WebRtc_Word16 diff;
  /* Stack based */
  WebRtc_Word32 crit[8];
  /* The input variable iLBCdec_inst is unused if not using scratch memory */
  iLBCdec_inst = iLBCdec_inst;

  /* Calculate square distance */
  for(i=0;i<arlength;i++){
    diff=array[i]-value;
    crit[i]=WEBRTC_SPL_MUL_16_16(diff, diff);
  }

  /* Find the minimum square distance */
  *index=WebRtcSpl_MinIndexW32(crit, (WebRtc_Word16)arlength);
}