[FFmpegsoc] [soc]: r226  amr/ffamr_nb.c
superdump
subversion at mplayerhq.hu
Tue Jun 5 01:45:20 CEST 2007
Author: superdump
Date: Tue Jun 5 01:45:20 2007
New Revision: 226
Log:
Remove trailing whitespace and naughty DOS line breaks
Modified:
amr/ffamr_nb.c
Modified: amr/ffamr_nb.c
==============================================================================
 amr/ffamr_nb.c (original)
+++ amr/ffamr_nb.c Tue Jun 5 01:45:20 2007
@@ 984,7 +984,7 @@ static void fixed2position(int16_t *fixe
/**
 * Decode the algebraic codebook index to pulse positions and signs and construct
+ * Decode the algebraic codebook index to pulse positions and signs and construct
* the algebraic codebook vector for MODE_475 and MODE_515
*
* @param avctx pointer to AVCodecContext
@@ 1013,7 +1013,7 @@ static void decode_2_pulses_9bits(AVCode
/**
 * Decode the algebraic codebook index to pulse positions and signs and construct
+ * Decode the algebraic codebook index to pulse positions and signs and construct
* the algebraic codebook vector for MODE_59
*
* @param sign signs of the two pulses
@@ 1026,7 +1026,7 @@ static void decode_2_pulses_9bits(AVCode
static void decode_2_pulses_11bits(int sign, int fixed_index, int *fixed_code) {
int pulse_position[2];
int pulse_subset;

+
// find the subset of pulses used for the first pulse
pulse_subset = fixed_index & 1;
// find the position of the first pulse
@@ 1046,7 +1046,7 @@ static void decode_2_pulses_11bits(int s
/**
 * Decode the algebraic codebook index to pulse positions and signs and construct
+ * Decode the algebraic codebook index to pulse positions and signs and construct
* the algebraic codebook vector for MODE_67
*
* @param sign signs of the three pulses
@@ 1077,7 +1077,7 @@ static void decode_3_pulses_14bits(int s
/**
 * Decode the algebraic codebook index to pulse positions and signs and construct
+ * Decode the algebraic codebook index to pulse positions and signs and construct
* the algebraic codebook vector for MODE_74 and MODE_795
*
* @param sign signs of the four pulses
@@ 1108,7 +1108,7 @@ static void decode_4_pulses_17bits(int s
/**
 * Decode the algebraic codebook index to pulse positions and signs and construct
+ * Decode the algebraic codebook index to pulse positions and signs and construct
* the algebraic codebook vector for MODE_102
*
* @param fixed_index positions of the eight pulses
@@ 1143,7 +1143,7 @@ static void decode_8_pulses_31bits(int16
/**
 * Decode the algebraic codebook index to pulse positions and signs and construct
+ * Decode the algebraic codebook index to pulse positions and signs and construct
* the algebraic codebook vector for MODE_122
*
* @param fixed_index positions of the ten pulses
@@ 1177,123 +1177,123 @@ static void decode_10_pulses_35bits(int1
// general functions FIXME  useful enough to put into libavutil?
/**
 * Comparison function for use with qsort
 *
 * @param a First value for comparison
 * @param b Second value for comparison
 * @return ab : the result of the comparison
+/**
+ * Comparison function for use with qsort
+ *
+ * @param a First value for comparison
+ * @param b Second value for comparison
+ * @return ab : the result of the comparison
*/
int qsort_compare(const int *a, const int *b) {
return (int)(*a  *b);
}

/**
 * Find the median of some values
 *
 * @param values pointer to the values of which to find the median
 * @param n number of values
 * @return Returns the median value
+
+/**
+ * Find the median of some values
+ *
+ * @param values pointer to the values of which to find the median
+ * @param n number of values
+ * @return Returns the median value
*/
static int median(int *values, int n) {
 int temp[9]; // largest n used for median calculation is 9
 int i;

 for(i=0; i<n; i++) {
 temp[i] = values[i];
 }
+static int median(int *values, int n) {
+ int temp[9]; // largest n used for median calculation is 9
+ int i;
+
+ for(i=0; i<n; i++) {
+ temp[i] = values[i];
+ }
// is memcpy better here instead of the above loop?
// memcpy(values, temp, n*sizeof(int));
qsort(temp, n, sizeof(int), qsort_compare);
 return(temp[ n>>1 ]);
+ return(temp[ n>>1 ]);
}
// gain functions

+
/**
 * Calculate the pitch gain from previous values
 *
+ * Calculate the pitch gain from previous values
+ *
* @param state_ptr pointer to the current state
 * @return Returns the pitch gain
+ * @return Returns the pitch gain
*/

static int find_pitch_gain(AMRDecoderState *state_ptr) {
 int temp_median;

 // find the median of the previous five pitch gains
 temp_median = median(state_ptr>prev_pitch_gains, 5);
 // clip the median pitch gain to the previous pitch gain
 if(temp_median > state_ptr>prev_pitch_gain) {
 temp_median = state_ptr>prev_pitch_gain;
 }
 return ( (temp_median*pitch_gain_attenuation[ state_ptr>state ])>>15 );
}


/**
 * Decode the pitch gain using the received index
 *
 * @param mode current mode
 * @param index quantisation index
 * @return Returns the pitch gain
+static int find_pitch_gain(AMRDecoderState *state_ptr) {
+ int temp_median;
+
+ // find the median of the previous five pitch gains
+ temp_median = median(state_ptr>prev_pitch_gains, 5);
+
+ // clip the median pitch gain to the previous pitch gain
+ if(temp_median > state_ptr>prev_pitch_gain) {
+ temp_median = state_ptr>prev_pitch_gain;
+ }
+ return ( (temp_median*pitch_gain_attenuation[ state_ptr>state ])>>15 );
+}
+
+
+/**
+ * Decode the pitch gain using the received index
+ *
+ * @param mode current mode
+ * @param index quantisation index
+ * @return Returns the pitch gain
*/

static int decode_pitch_gain(enum Mode mode, int index) {
 int gain;

 if(mode == MODE_122) {
 // zero the two least significant bits
+
+static int decode_pitch_gain(enum Mode mode, int index) {
+ int gain;
+
+ if(mode == MODE_122) {
+ // zero the two least significant bits
// gain = ( pitch_gain_quant[index]>>2 )<<2;
 gain = pitch_gain_quant[index] & 0xFFFC;
 }else {
 gain = pitch_gain_quant[index];
 }
 return gain;
}


/**
 * Update the pitch gain and limit pitch_gain if the previous frame was bad
+ gain = pitch_gain_quant[index] & 0xFFFC;
+ }else {
+ gain = pitch_gain_quant[index];
+ }
+ return gain;
+}
+
+
+/**
+ * Update the pitch gain and limit pitch_gain if the previous frame was bad
*
 * @param state_ptr pointer to the current state
+ * @param state_ptr pointer to the current state
* @param bad_frame_indicator bad frame indicator
 * @param pitch_gain pointer to the pitch gain
+ * @param pitch_gain pointer to the pitch gain
*/

+
static void pitch_gain_update(AMRDecoderState *state_ptr, int bad_frame_indicator,
int *pitch_gain) {
if(bad_frame_indicator == 0) {
if(state_ptr>prev_frame_bad != 0) {
// if the previous frame was bad, limit the current pitch gain to
 // the previous good pitch gain
 if(*pitch_gain > state_ptr>prev_good_pitch_gain) {
 *pitch_gain = state_ptr>prev_good_pitch_gain;
 }
+ // the previous good pitch gain
+ if(*pitch_gain > state_ptr>prev_good_pitch_gain) {
+ *pitch_gain = state_ptr>prev_good_pitch_gain;
+ }
}
 // if the current frame is good, update the previous good pitch gain
 state_ptr>prev_good_pitch_gain = *pitch_gain;
 }
 state_ptr>prev_pitch_gain = *pitch_gain;

 // clip the previous pitch gain to 1.0
 if(state_ptr>prev_pitch_gain > 16384) {
 state_ptr>prev_pitch_gain = 16384;
+ // if the current frame is good, update the previous good pitch gain
+ state_ptr>prev_good_pitch_gain = *pitch_gain;
}
+ state_ptr>prev_pitch_gain = *pitch_gain;
 // update the array of the previous five pitch gains
 state_ptr>prev_pitch_gains[0] = state_ptr>prev_pitch_gains[1];
 state_ptr>prev_pitch_gains[1] = state_ptr>prev_pitch_gains[2];
 state_ptr>prev_pitch_gains[2] = state_ptr>prev_pitch_gains[3];
 state_ptr>prev_pitch_gains[3] = state_ptr>prev_pitch_gains[4];
 state_ptr>prev_pitch_gains[4] = state_ptr>prev_pitch_gain;
}
+ // clip the previous pitch gain to 1.0
+ if(state_ptr>prev_pitch_gain > 16384) {
+ state_ptr>prev_pitch_gain = 16384;
+ }
+
+ // update the array of the previous five pitch gains
+ state_ptr>prev_pitch_gains[0] = state_ptr>prev_pitch_gains[1];
+ state_ptr>prev_pitch_gains[1] = state_ptr>prev_pitch_gains[2];
+ state_ptr>prev_pitch_gains[2] = state_ptr>prev_pitch_gains[3];
+ state_ptr>prev_pitch_gains[3] = state_ptr>prev_pitch_gains[4];
+ state_ptr>prev_pitch_gains[4] = state_ptr>prev_pitch_gain;
+}
/**
More information about the FFmpegsoc
mailing list