changeset 8123:cd756806be02 libavcodec

More OKed parts of the QCELP decoder patch by Kenan Gillet, kenan.gillet gmail com
author vitor
date Sun, 09 Nov 2008 12:00:47 +0000
parents aec296246352
children 4070139042c7
files qcelpdata.h qcelpdec.c
diffstat 2 files changed, 79 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/qcelpdata.h	Sat Nov 08 18:15:13 2008 +0000
+++ b/qcelpdata.h	Sun Nov 09 12:00:47 2008 +0000
@@ -378,4 +378,54 @@
     qcelp_lspvq5
 };
 
+/**
+ * circular codebook for rate 1 frames in x*100 form
+ *
+ * TIA/EIA/IS-733 2.4.6.1-2
+ */
+static const int16_t qcelp_rate_full_codebook[128] = {
+     10,  -65,  -59,   12,  110,   34, -134,  157,
+    104,  -84,  -34, -115,   23, -101,    3,   45,
+   -101,  -16,  -59,   28,  -45,  134,  -67,   22,
+     61,  -29,  226,  -26,  -55, -179,  157,  -51,
+   -220,  -93,  -37,   60,  118,   74,  -48,  -95,
+   -181,  111,   36,  -52, -215,   78, -112,   39,
+    -17,  -47, -223,   19,   12,  -98, -142,  130,
+     54, -127,   21,  -12,   39,  -48,   12,  128,
+      6, -167,   82, -102,  -79,   55,  -44,   48,
+    -20,  -53,    8,  -61,   11,  -70, -157, -168,
+     20,  -56,  -74,   78,   33,  -63, -173,   -2,
+    -75,  -53, -146,   77,   66,  -29,    9,  -75,
+     65,  119,  -43,   76,  233,   98,  125, -156,
+    -27,   78,   -9,  170,  176,  143, -148,   -7,
+     27, -136,    5,   27,   18,  139,  204,    7,
+   -184, -197,   52,   -3,   78, -189,    8,  -65
+};
+#define QCELP_RATE_FULL_CODEBOOK_RATIO .01
+
+/**
+ * circular codebook for rate 1/2 frames in x*2 form
+ *
+ * TIA/EIA/IS-733 2.4.6.1-1
+ */
+static const int8_t qcelp_rate_half_codebook[128] = {
+     0, -4,  0, -3,  0,  0,  0,  0,
+     0,  0,  0,  0,  0,  0,  0,  0,
+     0, -3, -2,  0,  0,  0,  0,  0,
+     0,  0,  0,  0,  0,  0,  0,  5,
+     0,  0,  0,  0,  0,  0,  4,  0,
+     0,  3,  2,  0,  3,  4,  0,  0,
+     0,  0,  0,  0,  0,  0,  0,  0,
+     0,  0,  0,  0,  0,  3,  0,  0,
+    -3,  3,  0,  0, -2,  0,  3,  0,
+     0,  0,  0,  0,  0,  0, -5,  0,
+     0,  0,  0,  3,  0,  0,  0,  3,
+     0,  0,  0,  0,  0,  0,  0,  4,
+     0,  0,  0,  0,  0,  0,  0,  0,
+     0,  3,  6, -3, -4,  0, -3, -3,
+     3, -3,  0,  0,  0,  0,  0,  0,
+     0,  0,  0,  0,  0,  0,  0,  0
+};
+#define QCELP_RATE_HALF_CODEBOOK_RATIO 0.5
+
 #endif /* AVCODEC_QCELPDATA_H */
--- a/qcelpdec.c	Sat Nov 08 18:15:13 2008 +0000
+++ b/qcelpdec.c	Sun Nov 09 12:00:47 2008 +0000
@@ -38,6 +38,19 @@
 #undef NDEBUG
 #include <assert.h>
 
+static void weighted_vector_sumf(float *out,
+                                 const float *in_a,
+                                 const float *in_b,
+                                 float weight_coeff_a,
+                                 float weight_coeff_b,
+                                 int length) {
+    int   i;
+
+    for (i = 0; i < length; i++)
+        out[i] = weight_coeff_a * in_a[i]
+               + weight_coeff_b * in_b[i];
+}
+
 /**
  * Apply filter in pitch-subframe steps.
  *
@@ -90,6 +103,22 @@
     return memory + 143;
 }
 
+static int buf_size2framerate(const int buf_size) {
+    switch (buf_size) {
+    case 35:
+        return RATE_FULL;
+    case 17:
+        return RATE_HALF;
+    case  8:
+        return RATE_QUARTER;
+    case  4:
+        return RATE_OCTAVE;
+    case  1:
+        return SILENCE;
+    }
+    return -1;
+}
+
 static void warn_insufficient_frame_quality(AVCodecContext *avctx,
                                             const char *message) {
     av_log(avctx, AV_LOG_WARNING, "Frame #%d, IFQ: %s\n", avctx->frame_number, message);