[FFmpeg-cvslog] r20540 - in trunk/libavcodec: acelp_pitch_delay.c acelp_pitch_delay.h
vitor
subversion
Sun Nov 15 11:41:46 CET 2009
Author: vitor
Date: Sun Nov 15 11:41:46 2009
New Revision: 20540
Log:
Implement ff_decode_pitch_lag() that is used by both AMR and SIPR.
Based on code written by Colin McQuillan during his SoC project.
Modified:
trunk/libavcodec/acelp_pitch_delay.c
trunk/libavcodec/acelp_pitch_delay.h
Modified: trunk/libavcodec/acelp_pitch_delay.c
==============================================================================
--- trunk/libavcodec/acelp_pitch_delay.c Sun Nov 15 04:26:47 2009 (r20539)
+++ trunk/libavcodec/acelp_pitch_delay.c Sun Nov 15 11:41:46 2009 (r20540)
@@ -140,3 +140,47 @@ float ff_amr_set_fixed_gain(float fixed_
return val;
}
+
+void ff_decode_pitch_lag(int *lag_int, int *lag_frac, int pitch_index,
+ const int prev_lag_int, const int subframe,
+ int third_as_first, int resolution)
+{
+ /* Note n * 10923 >> 15 is floor(x/3) for 0 <= n <= 32767 */
+ if (subframe == 0 || (subframe == 2 && third_as_first)) {
+
+ if (pitch_index < 197)
+ pitch_index += 59;
+ else
+ pitch_index = 3 * pitch_index - 335;
+
+ } else {
+ if (resolution == 4) {
+ int search_range_min = av_clip(prev_lag_int - 5, PITCH_DELAY_MIN,
+ PITCH_DELAY_MAX - 9);
+
+ // decoding with 4-bit resolution
+ if (pitch_index < 4) {
+ // integer only precision for [search_range_min, search_range_min+3]
+ pitch_index = 3 * (pitch_index + search_range_min) + 1;
+ } else if (pitch_index < 12) {
+ // 1/3 fractional precision for [search_range_min+3 1/3, search_range_min+5 2/3]
+ pitch_index += 3 * search_range_min + 7;
+ } else {
+ // integer only precision for [search_range_min+6, search_range_min+9]
+ pitch_index = 3 * (pitch_index + search_range_min - 6) + 1;
+ }
+ } else {
+ // decoding with 5 or 6 bit resolution, 1/3 fractional precision
+ pitch_index--;
+
+ if (resolution == 5) {
+ pitch_index += 3 * av_clip(prev_lag_int - 10, PITCH_DELAY_MIN,
+ PITCH_DELAY_MAX - 19);
+ } else
+ pitch_index += 3 * av_clip(prev_lag_int - 5, PITCH_DELAY_MIN,
+ PITCH_DELAY_MAX - 9);
+ }
+ }
+ *lag_int = pitch_index * 10923 >> 15;
+ *lag_frac = pitch_index - 3 * *lag_int - 1;
+}
Modified: trunk/libavcodec/acelp_pitch_delay.h
==============================================================================
--- trunk/libavcodec/acelp_pitch_delay.h Sun Nov 15 04:26:47 2009 (r20539)
+++ trunk/libavcodec/acelp_pitch_delay.h Sun Nov 15 11:41:46 2009 (r20540)
@@ -234,4 +234,22 @@ float ff_amr_set_fixed_gain(float fixed_
float *prediction_error, float energy_mean,
const float *pred_table);
+
+/**
+ * Decode the adaptive codebook index to the integer and fractional parts
+ * of the pitch lag for one subframe at 1/3 fractional precision.
+ *
+ * The choice of pitch lag is described in 3GPP TS 26.090 section 5.6.1.
+ *
+ * @param lag_int integer part of pitch lag of the current subframe
+ * @param lag_frac fractional part of pitch lag of the current subframe
+ * @param pitch_index parsed adaptive codebook (pitch) index
+ * @param prev_lag_int integer part of pitch lag for the previous subframe
+ * @param subframe current subframe number
+ * @param third_as_first treat the third frame the same way as the first
+ */
+void ff_decode_pitch_lag(int *lag_int, int *lag_frac, int pitch_index,
+ const int prev_lag_int, const int subframe,
+ int third_as_first, int resolution);
+
#endif /* AVCODEC_ACELP_PITCH_DELAY_H */
More information about the ffmpeg-cvslog
mailing list