[FFmpeg-soc] [soc]AMR-WB decoder branch, master, updated.

Marcelo Póvoa marspeoplester at gmail.com
Sat Jul 10 22:11:05 CEST 2010


This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "AMR-WB decoder".

The branch, master has been updated
       via  90058508bef6d5043f0d039c1d9d6e8188079df5 (commit)
      from  9c54ab79501afa169d9ef4fb056ce6297ce29c0c (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
commit 90058508bef6d5043f0d039c1d9d6e8188079df5
Author: Marcelo Povoa <marspeoplester at gmail.com>
Date:   Sat Jul 10 17:07:03 2010 -0300

    Decode vector quantized gains, rename vq to vq_gain

diff --git a/libavcodec/amrwbdata.h b/libavcodec/amrwbdata.h
index ecb748a..92eed65 100644
--- a/libavcodec/amrwbdata.h
+++ b/libavcodec/amrwbdata.h
@@ -51,15 +51,14 @@ enum Mode {
 typedef struct {
     uint16_t adap;                         ///< adaptive codebook index
     uint8_t ltp;                           ///< ltp-filtering flag
-    uint8_t vq;                            ///< VQ gain
-    uint8_t gain;                          ///< codebooks gain
+    uint8_t vq_gain;                       ///< VQ adaptive and innovative gains
     uint8_t energy;                        ///< high-band energy
     uint16_t pul_ih[4];                    ///< MSBs part of codebook index (high modes only)
     uint16_t pul_il[4];                    ///< LSBs part of codebook index
 } AMRWBSubFrame;
 
 typedef struct {
-    uint8_t vad;                           ///< vad-flag
+    uint8_t vad;                           ///< voice activity detection flag
     uint16_t isp_id[7];                    ///< index of ISP subvectors
     AMRWBSubFrame subframe[4];             ///< data for subframes
 } AMRWBFrame;
@@ -89,19 +88,19 @@ static const uint16_t order_MODE_6k60[] = {
      8,      AMR_OF(0, adap),  12,  13,  14,  15,  27,  28,  54,  66,
     12, AMR_OF(0, pul_il[0]),  84,  92, 100, 108, 116, 124,  85,  96,
                               104, 112, 120, 128,
-     6,        AMR_OF(0, vq),  33,  16,  37,  20,   4,   8,
+     6,   AMR_OF(0, vq_gain),  33,  16,  37,  20,   4,   8,
      5,      AMR_OF(1, adap),  39,  46,  56,  68,  74,
     12, AMR_OF(1, pul_il[0]),  86,  93, 101, 109, 117, 125,  87,  97,
                               105, 113, 121, 129,
-     6,        AMR_OF(1, vq),  29,  17,  35,  21,   5,   9,
+     6,   AMR_OF(1, vq_gain),  29,  17,  35,  21,   5,   9,
      5,      AMR_OF(2, adap),  42,  47,  53,  55,  67,
     12, AMR_OF(2, pul_il[0]),  88,  94, 102, 110, 118, 126,  89,  98,
                               106, 114, 122, 130,
-     6,        AMR_OF(2, vq),  34,  18,  36,  22,   6,  24,
+     6,   AMR_OF(2, vq_gain),  34,  18,  36,  22,   6,  24,
      5,      AMR_OF(3, adap),  40,  41,  57,  69,  75,
     12, AMR_OF(3, pul_il[0]),  90,  95, 103, 111, 119, 127,  91,  99,
                               107, 115, 123, 131,
-     6,        AMR_OF(3, vq),  30,  19,  26,  23,   7,  25,
+     6,   AMR_OF(3, vq_gain),  30,  19,  26,  23,   7,  25,
      0
 };
 
@@ -119,25 +118,25 @@ static const uint16_t order_MODE_8k85[] = {
      5, AMR_OF(0, pul_il[1]),  98, 117, 133, 149, 165,
      5, AMR_OF(0, pul_il[2]),  99, 121, 137, 153, 169,
      5, AMR_OF(0, pul_il[3]), 100, 125, 141, 157, 173,
-     6,        AMR_OF(0, vq),  12,  32,  20,  24,  28,  16,
+     6,   AMR_OF(0, vq_gain),  12,  32,  20,  24,  28,  16,
      5,      AMR_OF(1, adap),  41,  64,  69,  75,  90,
      5, AMR_OF(1, pul_il[0]), 101, 114, 130, 146, 162,
      5, AMR_OF(1, pul_il[1]), 102, 118, 134, 150, 166,
      5, AMR_OF(1, pul_il[2]), 103, 122, 138, 154, 170,
      5, AMR_OF(1, pul_il[3]), 104, 126, 142, 158, 174,
-     6,        AMR_OF(1, vq),  13,  33,  21,  25,  29,  17,
+     6,   AMR_OF(1, vq_gain),  13,  33,  21,  25,  29,  17,
      8,      AMR_OF(2, adap),   9,  10,  11,  37,  42,  62,  72,  84,
      5, AMR_OF(2, pul_il[0]), 105, 115, 131, 147, 163,
      5, AMR_OF(2, pul_il[1]), 106, 119, 135, 151, 167,
      5, AMR_OF(2, pul_il[2]), 107, 123, 139, 155, 171,
      5, AMR_OF(2, pul_il[3]), 108, 127, 143, 159, 175,
-     6,        AMR_OF(2, vq),  14,  34,  22,  26,  30,  18,
+     6,   AMR_OF(2, vq_gain),  14,  34,  22,  26,  30,  18,
      5,      AMR_OF(3, adap),  43,  65,  70,  76,  91,
      5, AMR_OF(3, pul_il[0]), 109, 116, 132, 148, 164,
      5, AMR_OF(3, pul_il[1]), 110, 120, 136, 152, 168,
      5, AMR_OF(3, pul_il[2]), 111, 124, 140, 156, 172,
      5, AMR_OF(3, pul_il[3]), 112, 128, 144, 160, 176,
-     6,        AMR_OF(3, vq),  15,  35,  23,  27,  31,  19,
+     6,   AMR_OF(3, vq_gain),  15,  35,  23,  27,  31,  19,
      0
 };
 
@@ -161,7 +160,7 @@ static const uint16_t order_MODE_12k65[] = {
                               241,
      9, AMR_OF(0, pul_il[3]), 112, 149, 181, 213, 245, 153, 185, 217,
                               249,
-     7,        AMR_OF(0, vq),   3,  20,  42,  28,  32,  38,  24,
+     7,   AMR_OF(0, vq_gain),   3,  20,  42,  28,  32,  38,  24,
      6,      AMR_OF(2, adap),  36,  49,  72,  77,  83,  98,
      1,       AMR_OF(2, ltp), 106,
      9, AMR_OF(2, pul_il[0]), 113, 126, 158, 190, 222, 130, 162, 194,
@@ -172,7 +171,7 @@ static const uint16_t order_MODE_12k65[] = {
                               242,
      9, AMR_OF(2, pul_il[3]), 116, 150, 182, 214, 246, 154, 186, 218,
                               250,
-     7,        AMR_OF(2, vq),   4,  21,  43,  29,  33,  39,  25,
+     7,   AMR_OF(2, vq_gain),   4,  21,  43,  29,  33,  39,  25,
      9,      AMR_OF(3, adap),  15,  16,  17,  18,  19,  51,  70,  80,
                                92,
      1,       AMR_OF(3, ltp), 107,
@@ -184,7 +183,7 @@ static const uint16_t order_MODE_12k65[] = {
                               243,
      9, AMR_OF(3, pul_il[3]), 120, 151, 183, 215, 247, 155, 187, 219,
                               251,
-     7,        AMR_OF(3, vq),   5,  22,  44,  30,  34,  40,  26,
+     7,   AMR_OF(3, vq_gain),   5,  22,  44,  30,  34,  40,  26,
      6,      AMR_OF(4, adap),  37,  50,  73,  78,  84,  99,
      1,       AMR_OF(4, ltp), 108,
      9, AMR_OF(4, pul_il[0]), 121, 128, 160, 192, 224, 132, 164, 196,
@@ -195,7 +194,7 @@ static const uint16_t order_MODE_12k65[] = {
                               244,
      9, AMR_OF(4, pul_il[3]), 124, 152, 184, 216, 248, 156, 188, 220,
                               252,
-     7,        AMR_OF(4, vq),   6,  23,  45,  31,  35,  41,  27,
+     7,   AMR_OF(4, vq_gain),   6,  23,  45,  31,  35,  41,  27,
      0
 };
 
@@ -219,7 +218,7 @@ static const uint16_t order_MODE_14k25[] = {
                               277,
      9, AMR_OF(0, pul_il[3]), 137, 145, 153, 161, 185, 209, 233, 257,
                               281,
-     7,        AMR_OF(0, vq),   3,  20,  42,  28,  32,  38,  24,
+     7,   AMR_OF(0, vq_gain),   3,  20,  42,  28,  32,  38,  24,
      6,      AMR_OF(1, adap),  36,  49,  72,  77,  83,  98,
      1,       AMR_OF(1, ltp), 106,
     13, AMR_OF(1, pul_il[0]), 118, 190, 214, 238, 262, 110, 122, 166,
@@ -230,7 +229,7 @@ static const uint16_t order_MODE_14k25[] = {
                               278,
      9, AMR_OF(1, pul_il[3]), 138, 146, 154, 162, 186, 210, 234, 258,
                               282,
-     7,        AMR_OF(1, vq),   4,  21,  43,  29,  33,  39,  25,
+     7,   AMR_OF(1, vq_gain),   4,  21,  43,  29,  33,  39,  25,
      9,      AMR_OF(2, adap),  15,  16,  17,  18,  19,  51,  70,  80,
                                92,
      1,       AMR_OF(2, ltp), 107,
@@ -242,7 +241,7 @@ static const uint16_t order_MODE_14k25[] = {
                               279,
      9, AMR_OF(2, pul_il[3]), 139, 147, 155, 163, 187, 211, 235, 259,
                               283,
-     7,        AMR_OF(2, vq),   5,  22,  44,  30,  34,  40,  26,
+     7,   AMR_OF(2, vq_gain),   5,  22,  44,  30,  34,  40,  26,
      6,      AMR_OF(3, adap),  37,  50,  73,  78,  84,  99,
      1,       AMR_OF(3, ltp), 108,
     13, AMR_OF(3, pul_il[0]), 120, 192, 216, 240, 264, 112, 124, 168,
@@ -253,7 +252,7 @@ static const uint16_t order_MODE_14k25[] = {
                               280,
      9, AMR_OF(3, pul_il[3]), 140, 148, 156, 164, 188, 212, 236, 260,
                               284,
-     7,        AMR_OF(3, vq),   6,  23,  45,  31,  35,  41,  27,
+     7,   AMR_OF(3, vq_gain),   6,  23,  45,  31,  35,  41,  27,
      0
 };
 
@@ -277,7 +276,7 @@ static const uint16_t order_MODE_15k85[] = {
                               249, 297, 205, 253, 301,
     13, AMR_OF(0, pul_il[3]), 137, 169, 209, 257, 305, 153, 121, 213,
                               261, 309, 217, 265, 313,
-     7,        AMR_OF(0, vq),   3,  20,  42,  28,  32,  38,  24,
+     7,   AMR_OF(0, vq_gain),   3,  20,  42,  28,  32,  38,  24,
      6,      AMR_OF(1, adap),  36,  49,  72,  77,  83,  98,
      1,       AMR_OF(1, ltp), 106,
     13, AMR_OF(1, pul_il[0]), 126, 158, 174, 222, 270, 142, 110, 178,
@@ -288,7 +287,7 @@ static const uint16_t order_MODE_15k85[] = {
                               250, 298, 206, 254, 302,
     13, AMR_OF(1, pul_il[3]), 138, 170, 210, 258, 306, 154, 122, 214,
                               262, 310, 218, 266, 314,
-     7,        AMR_OF(1, vq),   4,  21,  43,  29,  33,  39,  25,
+     7,   AMR_OF(1, vq_gain),   4,  21,  43,  29,  33,  39,  25,
      9,      AMR_OF(2, adap),  15,  16,  17,  18,  19,  51,  70,  80,
                                92,
      1,       AMR_OF(2, ltp), 107,
@@ -300,7 +299,7 @@ static const uint16_t order_MODE_15k85[] = {
                               251, 299, 207, 255, 303,
     13, AMR_OF(2, pul_il[3]), 139, 171, 211, 259, 307, 155, 123, 215,
                               263, 311, 219, 267, 315,
-     7,        AMR_OF(2, vq),   5,  22,  44,  30,  34,  40,  26,
+     7,   AMR_OF(2, vq_gain),   5,  22,  44,  30,  34,  40,  26,
      6,      AMR_OF(3, adap),  37,  50,  73,  78,  84,  99,
      1,       AMR_OF(3, ltp), 108,
     13, AMR_OF(3, pul_il[0]), 128, 160, 176, 224, 272, 144, 112, 180,
@@ -311,7 +310,7 @@ static const uint16_t order_MODE_15k85[] = {
                               252, 300, 208, 256, 304,
     13, AMR_OF(3, pul_il[3]), 140, 172, 212, 260, 308, 156, 124, 216,
                               264, 312, 220, 268, 316,
-     7,        AMR_OF(3, vq),   6,  23,  45,  31,  35,  41,  27,
+     7,   AMR_OF(3, vq_gain),   6,  23,  45,  31,  35,  41,  27,
      0
 };
 
@@ -339,7 +338,7 @@ static const uint16_t order_MODE_18k25[] = {
                               172, 258, 306, 303, 350, 133,
     14, AMR_OF(0, pul_il[3]), 193, 276, 346, 188, 164, 285, 198, 196,
                               168, 237, 270, 294, 335, 112,
-     7,        AMR_OF(0, vq),   3,  20,  42,  28,  32,  38,  24,
+     7,   AMR_OF(0, vq_gain),   3,  20,  42,  28,  32,  38,  24,
      6,      AMR_OF(1, adap),  36,  49,  72,  77,  83,  98,
      1,       AMR_OF(1, ltp), 106,
      2, AMR_OF(1, pul_ih[0]), 140, 111,
@@ -354,7 +353,7 @@ static const uint16_t order_MODE_18k25[] = {
                               173, 260, 287, 314, 354, 147,
     14, AMR_OF(1, pul_il[3]), 204, 279, 337, 228, 199, 300, 238, 171,
                               176, 263, 284, 321, 356, 109,
-     7,        AMR_OF(1, vq),   4,  21,  43,  29,  33,  39,  25,
+     7,   AMR_OF(1, vq_gain),   4,  21,  43,  29,  33,  39,  25,
      9,      AMR_OF(2, adap),  15,  16,  17,  18,  19,  51,  70,  80,
                                92,
      1,       AMR_OF(2, ltp), 107,
@@ -370,7 +369,7 @@ static const uint16_t order_MODE_18k25[] = {
                               220, 269, 313, 328, 364, 152,
     14, AMR_OF(2, pul_il[3]), 232, 309, 361, 218, 229, 302, 252, 191,
                               181, 261, 291, 310, 349, 115,
-     7,        AMR_OF(2, vq),   5,  22,  44,  30,  34,  40,  26,
+     7,   AMR_OF(2, vq_gain),   5,  22,  44,  30,  34,  40,  26,
      6,      AMR_OF(3, adap),  37,  50,  73,  78,  84,  99,
      1,       AMR_OF(3, ltp), 108,
      2, AMR_OF(3, pul_ih[0]), 136, 121,
@@ -385,7 +384,7 @@ static const uint16_t order_MODE_18k25[] = {
                               187, 248, 286, 322, 345, 144,
     14, AMR_OF(3, pul_il[3]), 206, 288, 352, 223, 215, 327, 233, 163,
                               156, 222, 273, 297, 333, 118,
-     7,        AMR_OF(3, vq),   6,  23,  45,  31,  35,  41,  27,
+     7,   AMR_OF(3, vq_gain),   6,  23,  45,  31,  35,  41,  27,
      0
 };
 
@@ -415,7 +414,7 @@ static const uint16_t order_MODE_19k85[] = {
                               201, 207, 261, 288, 318, 366,
     14, AMR_OF(0, pul_il[3]), 151, 187, 285, 361, 222, 223, 306, 221,
                               198, 177, 242, 280, 299, 360,
-     7,        AMR_OF(0, vq),   3,  20,  42,  28,  32,  38,  24,
+     7,   AMR_OF(0, vq_gain),   3,  20,  42,  28,  32,  38,  24,
      6,      AMR_OF(1, adap),  36,  49,  72,  77,  83,  98,
      1,       AMR_OF(1, ltp), 106,
     10, AMR_OF(1, pul_ih[0]), 140, 174, 268, 347, 386, 164, 115, 186,
@@ -432,7 +431,7 @@ static const uint16_t order_MODE_19k85[] = {
                               196, 193, 244, 276, 324, 368,
     14, AMR_OF(1, pul_il[3]), 137, 184, 263, 358, 215, 219, 317, 234,
                               185, 211, 248, 311, 313, 372,
-     7,        AMR_OF(1, vq),   4,  21,  43,  29,  33,  39,  25,
+     7,   AMR_OF(1, vq_gain),   4,  21,  43,  29,  33,  39,  25,
      9,      AMR_OF(2, adap),  15,  16,  17,  18,  19,  51,  70,  80,
                                92,
      1,       AMR_OF(2, ltp), 107,
@@ -450,7 +449,7 @@ static const uint16_t order_MODE_19k85[] = {
                               231, 232, 247, 290, 316, 376,
     14, AMR_OF(2, pul_il[3]), 155, 214, 302, 370, 230, 208, 321, 240,
                               194, 191, 239, 294, 305, 362,
-     7,        AMR_OF(2, vq),   5,  22,  44,  30,  34,  40,  26,
+     7,   AMR_OF(2, vq_gain),   5,  22,  44,  30,  34,  40,  26,
      6,      AMR_OF(3, adap),  37,  50,  73,  78,  84,  99,
      1,       AMR_OF(3, ltp), 108,
     10, AMR_OF(3, pul_ih[0]), 147, 163, 271, 339, 387, 176, 114, 202,
@@ -467,7 +466,7 @@ static const uint16_t order_MODE_19k85[] = {
                               205, 203, 252, 300, 322, 367,
     14, AMR_OF(3, pul_il[3]), 146, 218, 304, 364, 229, 217, 315, 224,
                               200, 168, 238, 287, 284, 351,
-     7,        AMR_OF(3, vq),   6,  23,  45,  31,  35,  41,  27,
+     7,   AMR_OF(3, vq_gain),   6,  23,  45,  31,  35,  41,  27,
      0
 };
 
@@ -499,7 +498,7 @@ static const uint16_t order_MODE_23k05[] = {
                               405, 424, 456,
     11, AMR_OF(0, pul_il[3]), 218, 176, 342, 432, 244, 223, 252, 357,
                               385, 412, 457,
-     7,      AMR_OF(0, gain),   3,  20,  42,  28,  32,  38,  24,
+     7,   AMR_OF(0, vq_gain),   3,  20,  42,  28,  32,  38,  24,
      6,      AMR_OF(1, adap),  36,  49,  72,  77,  83,  98,
      1,       AMR_OF(1, ltp), 106,
     11, AMR_OF(1, pul_ih[0]), 116, 139, 137, 166, 225, 292, 344, 236,
@@ -518,7 +517,7 @@ static const uint16_t order_MODE_23k05[] = {
                               368, 415, 454,
     11, AMR_OF(1, pul_il[3]), 230, 199, 352, 435, 253, 261, 293, 386,
                               407, 419, 455,
-     7,      AMR_OF(1, gain),   4,  21,  43,  29,  33,  39,  25,
+     7,   AMR_OF(1, vq_gain),   4,  21,  43,  29,  33,  39,  25,
      9,      AMR_OF(2, adap),  15,  16,  17,  18,  19,  51,  70,  80,
                                92,
      1,       AMR_OF(2, ltp), 107,
@@ -538,7 +537,7 @@ static const uint16_t order_MODE_23k05[] = {
                               413, 429, 453,
     11, AMR_OF(2, pul_il[3]), 287, 189, 383, 434, 267, 259, 248, 363,
                               409, 422, 446,
-     7,      AMR_OF(2, gain),   5,  22,  44,  30,  34,  40,  26,
+     7,   AMR_OF(2, vq_gain),   5,  22,  44,  30,  34,  40,  26,
      6,      AMR_OF(3, adap),  37,  50,  73,  78,  84,  99,
      1,       AMR_OF(3, ltp), 108,
     11, AMR_OF(3, pul_ih[0]), 119, 152, 136, 163, 210, 286, 331, 283,
@@ -557,7 +556,7 @@ static const uint16_t order_MODE_23k05[] = {
                               414, 425, 448,
     11, AMR_OF(3, pul_il[3]), 239, 167, 373, 433, 228, 265, 289, 378,
                               389, 418, 444,
-     7,      AMR_OF(3, gain),   6,  23,  45,  31,  35,  41,  27,
+     7,   AMR_OF(3, vq_gain),   6,  23,  45,  31,  35,  41,  27,
      0
 };
     
@@ -589,7 +588,7 @@ static const uint16_t order_MODE_23k85[] = {
                               421, 440, 472,
     11, AMR_OF(0, pul_il[3]), 234, 192, 358, 448, 260, 239, 268, 373,
                               401, 428, 473,
-     7,      AMR_OF(0, gain),   3,  20,  42,  28,  32,  38,  24,
+     7,   AMR_OF(0, vq_gain),   3,  20,  42,  28,  32,  38,  24,
      4,    AMR_OF(0, energy),  72,  73,  74,  75,
      6,      AMR_OF(1, adap),  36,  49,  88,  93,  99, 114,
      1,       AMR_OF(1, ltp), 122,
@@ -609,7 +608,7 @@ static const uint16_t order_MODE_23k85[] = {
                               384, 431, 470,
     11, AMR_OF(1, pul_il[3]), 246, 215, 368, 451, 269, 277, 309, 402,
                               423, 435, 471,
-     7,      AMR_OF(1, gain),   4,  21,  43,  29,  33,  39,  25,
+     7,   AMR_OF(1, vq_gain),   4,  21,  43,  29,  33,  39,  25,
      4,    AMR_OF(1, energy),  76,  77,  78,  79,
      9,      AMR_OF(2, adap),  15,  16,  17,  18,  19,  51,  70,  96,
                               108,
@@ -630,7 +629,7 @@ static const uint16_t order_MODE_23k85[] = {
                               429, 445, 469,
     11, AMR_OF(2, pul_il[3]), 303, 205, 399, 450, 283, 275, 264, 379,
                               425, 438, 462,
-     7,      AMR_OF(2, gain),   5,  22,  44,  30,  34,  40,  26,
+     7,   AMR_OF(2, vq_gain),   5,  22,  44,  30,  34,  40,  26,
      4,    AMR_OF(2, energy),  80,  81,  82,  83,
      6,      AMR_OF(3, adap),  37,  50,  89,  94, 100, 115,
      1,       AMR_OF(3, ltp), 124,
@@ -650,7 +649,7 @@ static const uint16_t order_MODE_23k85[] = {
                               430, 441, 464,
     11, AMR_OF(3, pul_il[3]), 255, 183, 389, 449, 244, 281, 305, 394,
                               405, 434, 460,
-     7,      AMR_OF(3, gain),   6,  23,  45,  31,  35,  41,  27,
+     7,   AMR_OF(3, vq_gain),   6,  23,  45,  31,  35,  41,  27,
      4,    AMR_OF(3, energy),  84,  85,  86,  87,
      0
 };
@@ -1637,13 +1636,116 @@ static const float ac_inter[65] = {
    0.000098,   0.000048,   0.000007,   0.000000
 };
 
-/* [i][j] is the number of pulses in track j at mode i */
+/* [i][j] is the number of pulses present in track j at mode i */
 static const int pulses_nb_per_mode_tr[][4] = {
     {1, 1, 0, 0}, {1, 1, 1, 1}, {2, 2, 2, 2},
     {3, 3, 2, 2}, {3, 3, 3, 3}, {4, 4, 4, 4},
     {5, 5, 4, 4}, {6, 6, 6, 6}, {6, 6, 6, 6}
 };
 
+/* Tables for decoding quantized gains {pitch, fixed factor} */
+static const int16_t qua_gain_6b[64][2] = {
+    {  1566,  1332},    {  1577,  3557},
+    {  3071,  6490},    {  4193, 10163},
+    {  4496,  2534},    {  5019,  4488},
+    {  5586, 15614},    {  5725,  1422},
+    {  6453,   580},    {  6724,  6831},
+    {  7657,  3527},    {  8072,  2099},
+    {  8232,  5319},    {  8827,  8775},
+    {  9740,  2868},    {  9856,  1465},
+    { 10087, 12488},    { 10241,  4453},
+    { 10859,  6618},    { 11321,  3587},
+    { 11417,  1800},    { 11643,  2428},
+    { 11718,   988},    { 12312,  5093},
+    { 12523,  8413},    { 12574, 26214},
+    { 12601,  3396},    { 13172,  1623},
+    { 13285,  2423},    { 13418,  6087},
+    { 13459, 12810},    { 13656,  3607},
+    { 14111,  4521},    { 14144,  1229},
+    { 14425,  1871},    { 14431,  7234},
+    { 14445,  2834},    { 14628, 10036},
+    { 14860, 17496},    { 15161,  3629},
+    { 15209,  5819},    { 15299,  2256},
+    { 15518,  4722},    { 15663,  1060},
+    { 15759,  7972},    { 15939, 11964},
+    { 16020,  2996},    { 16086,  1707},
+    { 16521,  4254},    { 16576,  6224},
+    { 16894,  2380},    { 16906,   681},
+    { 17213,  8406},    { 17610,  3418},
+    { 17895,  5269},    { 18168, 11748},
+    { 18230,  1575},    { 18607, 32767},
+    { 18728, 21684},    { 19137,  2543},
+    { 19422,  6577},    { 19446,  4097},
+    { 19450,  9056},    { 20371, 14885}
+};
+
+static const int16_t qua_gain_7b[128][2] = {
+    {   204,   441},    {   464,  1977},
+    {   869,  1077},    {  1072,  3062},
+    {  1281,  4759},    {  1647,  1539},
+    {  1845,  7020},    {  1853,   634},
+    {  1995,  2336},    {  2351, 15400},
+    {  2661,  1165},    {  2702,  3900},
+    {  2710, 10133},    {  3195,  1752},
+    {  3498,  2624},    {  3663,   849},
+    {  3984,  5697},    {  4214,  3399},
+    {  4415,  1304},    {  4695,  2056},
+    {  5376,  4558},    {  5386,   676},
+    {  5518, 23554},    {  5567,  7794},
+    {  5644,  3061},    {  5672,  1513},
+    {  5957,  2338},    {  6533,  1060},
+    {  6804,  5998},    {  6820,  1767},
+    {  6937,  3837},    {  7277,   414},
+    {  7305,  2665},    {  7466, 11304},
+    {  7942,   794},    {  8007,  1982},
+    {  8007,  1366},    {  8326,  3105},
+    {  8336,  4810},    {  8708,  7954},
+    {  8989,  2279},    {  9031,  1055},
+    {  9247,  3568},    {  9283,  1631},
+    {  9654,  6311},    {  9811,  2605},
+    { 10120,   683},    { 10143,  4179},
+    { 10245,  1946},    { 10335,  1218},
+    { 10468,  9960},    { 10651,  3000},
+    { 10951,  1530},    { 10969,  5290},
+    { 11203,  2305},    { 11325,  3562},
+    { 11771,  6754},    { 11839,  1849},
+    { 11941,  4495},    { 11954,  1298},
+    { 11975, 15223},    { 11977,   883},
+    { 11986,  2842},    { 12438,  2141},
+    { 12593,  3665},    { 12636,  8367},
+    { 12658,  1594},    { 12886,  2628},
+    { 12984,  4942},    { 13146,  1115},
+    { 13224,   524},    { 13341,  3163},
+    { 13399,  1923},    { 13549,  5961},
+    { 13606,  1401},    { 13655,  2399},
+    { 13782,  3909},    { 13868, 10923},
+    { 14226,  1723},    { 14232,  2939},
+    { 14278,  7528},    { 14439,  4598},
+    { 14451,   984},    { 14458,  2265},
+    { 14792,  1403},    { 14818,  3445},
+    { 14899,  5709},    { 15017, 15362},
+    { 15048,  1946},    { 15069,  2655},
+    { 15405,  9591},    { 15405,  4079},
+    { 15570,  7183},    { 15687,  2286},
+    { 15691,  1624},    { 15699,  3068},
+    { 15772,  5149},    { 15868,  1205},
+    { 15970,   696},    { 16249,  3584},
+    { 16338,  1917},    { 16424,  2560},
+    { 16483,  4438},    { 16529,  6410},
+    { 16620, 11966},    { 16839,  8780},
+    { 17030,  3050},    { 17033, 18325},
+    { 17092,  1568},    { 17123,  5197},
+    { 17351,  2113},    { 17374,   980},
+    { 17566, 26214},    { 17609,  3912},
+    { 17639, 32767},    { 18151,  7871},
+    { 18197,  2516},    { 18202,  5649},
+    { 18679,  3283},    { 18930,  1370},
+    { 19271, 13757},    { 19317,  4120},
+    { 19460,  1973},    { 19654, 10018},
+    { 19764,  6792},    { 19912,  5135},
+    { 20040,  2841},    { 21234, 19833}
+};
+
 /* Core frame sizes in each mode */
 static const uint16_t cf_sizes_wb[] = {
     132, 177, 253, 285, 317, 365, 397, 461, 477,
diff --git a/libavcodec/amrwbdec.c b/libavcodec/amrwbdec.c
index 7b069ce..4def620 100644
--- a/libavcodec/amrwbdec.c
+++ b/libavcodec/amrwbdec.c
@@ -53,6 +53,8 @@ typedef struct {
     float                            *excitation; ///< points to current excitation in excitation_buf[]
     
     float      pitch_vector[AMRWB_SUBFRAME_SIZE]; ///< adaptive codebook (pitch) vector for current subframe
+    
+    float                          pitch_gain[5]; ///< quantified pitch gains for the current and previous four subframes 
 } AMRWBContext;
 
 static int amrwb_decode_init(AVCodecContext *avctx) 
@@ -548,10 +550,10 @@ static void decode_6p_track(int *out, int code, int m, int off)
  * Decode the algebraic codebook index to pulse positions and signs,
  * then construct the algebraic codebook vector.
  *
- * @param fixed_sparse        pointer to the algebraic (innovative) codebook
- * @param pulse_hi            MSBs part of the pulse index array (used in higher modes)
- * @param pulse_lo            LSBs part of the pulse index array
- * @param mode                mode of the current frame
+ * @param fixed_sparse        [out] pointer to the algebraic (innovative) codebook
+ * @param pulse_hi            [in] MSBs part of the pulse index array (higher modes only)
+ * @param pulse_lo            [in] LSBs part of the pulse index array
+ * @param mode                [in] mode of the current frame
  */
 // XXX: For now, uses the same AMRFixed struct from AMR-NB but
 // the maximum number of pulses in it was increased to 24
@@ -620,6 +622,28 @@ static void decode_fixed_sparse(AMRFixed *fixed_sparse, const uint16_t *pulse_hi
     fixed_sparse->n = pulses_nb;
 }
 
+/**
+ * Decode pitch gain and fixed gain correction factor
+ *
+ * @param vq_gain             [in] vector-quantized index for gains
+ * @param mode                [in] mode of the current frame
+ * @param fixed_gain_factor   [out] decoded fixed gain correction factor
+ * @param pitch_gain          [out] decoded pitch gain
+ */
+static void decode_gains(const uint8_t vq_gain, const enum Mode mode,
+                         float *fixed_gain_factor, float *pitch_gain)
+{
+    const int16_t *gains;
+    
+    if (mode == MODE_6k60 || mode == MODE_8k85)
+        gains = qua_gain_6b[vq_gain];
+    else
+        gains = qua_gain_7b[vq_gain];
+    
+    *pitch_gain        = gains[0] * (1.0 / 16384.0);
+    *fixed_gain_factor = gains[1] * (1.0 / 2048.0);
+}
+
 static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
                               AVPacket *avpkt)
 {
@@ -628,6 +652,7 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
     const uint8_t *buf = avpkt->data;
     int buf_size       = avpkt->size;
     AMRFixed fixed_sparse = {0};             // fixed vector up to anti-sparseness processing
+    float fixed_gain_factor;                 // fixed gain correction factor (gamma)
     int sub;
     
     ctx->fr_cur_mode = unpack_bitstream(ctx, buf, buf_size);
@@ -663,9 +688,12 @@ static int amrwb_decode_frame(AVCodecContext *avctx, void *data, int *data_size,
 
         /* Decode adaptive codebook */
         decode_pitch_vector(ctx, cur_subframe, sub);
-        /* Decode innovative codebook */
+        /* Decode innovative codebook (sparse representation) */
         decode_fixed_sparse(&fixed_sparse, cur_subframe->pul_ih,
                             cur_subframe->pul_il, ctx->fr_cur_mode);
+
+        decode_gains(cur_subframe->vq_gain, ctx->fr_cur_mode,
+                     &fixed_gain_factor, &ctx->pitch_gain[4]);
     }
     
     //update state for next frame

-----------------------------------------------------------------------

Summary of changes:
 libavcodec/amrwbdata.h |  182 +++++++++++++++++++++++++++++++++++++-----------
 libavcodec/amrwbdec.c  |   38 +++++++++--
 2 files changed, 175 insertions(+), 45 deletions(-)


hooks/post-receive
-- 
AMR-WB decoder


More information about the FFmpeg-soc mailing list