[FFmpeg-soc] [soc]: r5573 - in amr: amrnbdata.h amrnbdec.c

cmcq subversion at mplayerhq.hu
Tue Jan 12 01:20:16 CET 2010


Author: cmcq
Date: Tue Jan 12 01:20:15 2010
New Revision: 5573

Log:
Use offsetof in bit-order tables to ensure code portability
This replaces relative offsets with absolute offsets (0 to 58). These don't fit
in a byte alongside the field length, so take up an extra 217 bytes total.

Modified:
   amr/amrnbdata.h
   amr/amrnbdec.c

Modified: amr/amrnbdata.h
==============================================================================
--- amr/amrnbdata.h	Sun Jan 10 11:42:27 2010	(r5572)
+++ amr/amrnbdata.h	Tue Jan 12 01:20:15 2010	(r5573)
@@ -87,265 +87,281 @@ typedef struct {
     AMRNBSubframe subframe[4]; ///< unpacked data for each subframe
 } AMRNBFrame;
 
+/** The index of a frame parameter */
+#define AMR_BIT(field)                  (offsetof(AMRNBFrame, field) >> 1)
+/** The index of a subframe-specific parameter */
+#define AMR_OF(frame_num, variable)     AMR_BIT(subframe[frame_num].variable)
 
 // The following order* tables are used to convert AMR frame parameters to and
 // from a bitstream. See 3GPP TS 26.101 for more information.
 // Each field in AMRNBFrame is stored as:
-//   one byte of 16 * index in AMRNBFrame relative to previous field
-//               + number of bits in the field
-//   then, one byte for each bit of the field (from most-significant to least)
+// * one byte for the number of bits in the field
+// * one byte for the field index
+// * then, one byte for each bit of the field (from most-significant to least)
 //         of the position of that bit in the AMR frame.
 static const uint8_t order_MODE_4k75[] = {
-    0x28,   7,   6,   5,   4,   3,   2,   1,   0,
-    0x18,  15,  14,  13,  12,  11,  10,   9,   8,
-    0x17,  51,  35,  34,  50,  33,  49,  32,
-    0x38,  23,  22,  21,  20,  19,  18,  43,  42,
-    0x18,  54,  55,  40,  41,  24,  25,  26,  27,
-    0x27,  92,  68,  67,  84,  66,  65,  80,
-    0x12,  53,  52,
-    0x94,  17,  16,  48,  63,
-    0x37,  91,  64,  79,  83,  78,  77,  95,
-    0x12,  62,  61,
-    0x94,  31,  30,  60,  59,
-    0x18,  44,  45,  46,  47,  36,  37,  38,  39,
-    0x27,  90,  76,  75,  82,  74,  73,  94,
-    0x12,  58,  57,
-    0x94,  29,  28,  56,  71,
-    0x37,  89,  72,  87,  81,  86,  85,  93,
-    0x12,  70,  69,
-    0
+     8, AMR_BIT(lsf[0]),        7,   6,   5,   4,   3,   2,   1,   0,
+     8, AMR_BIT(lsf[1]),       15,  14,  13,  12,  11,  10,   9,   8,
+     7, AMR_BIT(lsf[2]),       51,  35,  34,  50,  33,  49,  32,
+     8, AMR_OF(0,p_lag),       23,  22,  21,  20,  19,  18,  43,  42,
+     8, AMR_OF(0,p_gain),      54,  55,  40,  41,  24,  25,  26,  27,
+     7, AMR_OF(0,pulses[0]),   92,  68,  67,  84,  66,  65,  80,
+     2, AMR_OF(0,pulses[1]),   53,  52,
+     4, AMR_OF(1,p_lag),       17,  16,  48,  63,
+     7, AMR_OF(1,pulses[0]),   91,  64,  79,  83,  78,  77,  95,
+     2, AMR_OF(1,pulses[1]),   62,  61,
+     4, AMR_OF(2,p_lag),       31,  30,  60,  59,
+     8, AMR_OF(2,p_gain),      44,  45,  46,  47,  36,  37,  38,  39,
+     7, AMR_OF(2,pulses[0]),   90,  76,  75,  82,  74,  73,  94,
+     2, AMR_OF(2,pulses[1]),   58,  57,
+     4, AMR_OF(3,p_lag),       29,  28,  56,  71,
+     7, AMR_OF(3,pulses[0]),   89,  72,  87,  81,  86,  85,  93,
+     2, AMR_OF(3,pulses[1]),   70,  69,
+     0
 };
 
 static const uint8_t order_MODE_5k15[] = {
-    0x28,   0,   1,   2,   3,   4,   5,   6,   7,
-    0x18,   8,   9,  10,  11,  12,  13,  14,  15,
-    0x17,  70,  51,  43,  71,  50,  60,  49,
-    0x38,  23,  22,  21,  20,  19,  47,  54,  59,
-    0x16,  48,  42,  35,  29,  30,  31,
-    0x27,  92,  84,  82, 100,  79,  72,  88,
-    0x12,  67,  68,
-    0x94,  18,  46,  53,  58,
-    0x16,  63,  41,  34,  26,  27,  28,
-    0x27,  91,  83,  81,  99,  78,  87, 103,
-    0x12,  65,  66,
-    0x94,  17,  45,  52,  57,
-    0x16,  62,  40,  33,  39,  24,  25,
-    0x27,  90,  80,  95,  98,  77,  86, 102,
-    0x12,  75,  64,
-    0x94,  16,  44,  56,  69,
-    0x16,  61,  55,  32,  36,  37,  38,
-    0x27,  89,  94,  93,  97,  76,  85, 101,
-    0x12,  73,  74,
-    0
+     8, AMR_BIT(lsf[0]),        0,   1,   2,   3,   4,   5,   6,   7,
+     8, AMR_BIT(lsf[1]),        8,   9,  10,  11,  12,  13,  14,  15,
+     7, AMR_BIT(lsf[2]),       70,  51,  43,  71,  50,  60,  49,
+     8, AMR_OF(0,p_lag),       23,  22,  21,  20,  19,  47,  54,  59,
+     6, AMR_OF(0,p_gain),      48,  42,  35,  29,  30,  31,
+     7, AMR_OF(0,pulses[0]),   92,  84,  82, 100,  79,  72,  88,
+     2, AMR_OF(0,pulses[1]),   67,  68,
+     4, AMR_OF(1,p_lag),       18,  46,  53,  58,
+     6, AMR_OF(1,p_gain),      63,  41,  34,  26,  27,  28,
+     7, AMR_OF(1,pulses[0]),   91,  83,  81,  99,  78,  87, 103,
+     2, AMR_OF(1,pulses[1]),   65,  66,
+     4, AMR_OF(2,p_lag),       17,  45,  52,  57,
+     6, AMR_OF(2,p_gain),      62,  40,  33,  39,  24,  25,
+     7, AMR_OF(2,pulses[0]),   90,  80,  95,  98,  77,  86, 102,
+     2, AMR_OF(2,pulses[1]),   75,  64,
+     4, AMR_OF(3,p_lag),       16,  44,  56,  69,
+     6, AMR_OF(3,p_gain),      61,  55,  32,  36,  37,  38,
+     7, AMR_OF(3,pulses[0]),   89,  94,  93,  97,  76,  85, 101,
+     2, AMR_OF(3,pulses[1]),   73,  74,
+     0
 };
 
 static const uint8_t order_MODE_5k9[] = {
-    0x28,   7,   6,   0,   3,   5,   4,   2,   1,
-    0x19,  13,  12,   8,  11,  10,  15,   9,  14,  23,
-    0x19,  71,  56,  60,  70,  59,  57,  58,  69,  76,
-    0x38,  16,  18,  22,  20,  30,  38,  44,  42,
-    0x16,  75,  48,  52,  40,  34,  26,
-    0x29, 101,  89,  93, 117, 105,  81,  85, 109,  97,
-    0x12,  67,  78,
-    0x94,  28,  36,  46,  87,
-    0x16,  74,  63,  51,  55,  33,  25,
-    0x29, 100,  88,  92, 116, 104,  80,  84, 108,  96,
-    0x12,  64,  79,
-    0x98,  31,  17,  21,  19,  29,  37,  43,  41,
-    0x16,  73,  62,  50,  54,  32,  24,
-    0x29,  99, 103,  91, 115, 119,  95,  83, 107, 111,
-    0x12,  66,  77,
-    0x94,  27,  35,  45,  86,
-    0x16,  72,  61,  49,  53,  47,  39,
-    0x29,  98, 102,  90, 114, 118,  94,  82, 106, 110,
-    0x12,  65,  68,
-    0
+     8, AMR_BIT(lsf[0]),        7,   6,   0,   3,   5,   4,   2,   1,
+     9, AMR_BIT(lsf[1]),       13,  12,   8,  11,  10,  15,   9,  14,  23,
+     9, AMR_BIT(lsf[2]),       71,  56,  60,  70,  59,  57,  58,  69,  76,
+     8, AMR_OF(0,p_lag),       16,  18,  22,  20,  30,  38,  44,  42,
+     6, AMR_OF(0,p_gain),      75,  48,  52,  40,  34,  26,
+     9, AMR_OF(0,pulses[0]),  101,  89,  93, 117, 105,  81,  85, 109,  97,
+     2, AMR_OF(0,pulses[1]),   67,  78,
+     4, AMR_OF(1,p_lag),       28,  36,  46,  87,
+     6, AMR_OF(1,p_gain),      74,  63,  51,  55,  33,  25,
+     9, AMR_OF(1,pulses[0]),  100,  88,  92, 116, 104,  80,  84, 108,  96,
+     2, AMR_OF(1,pulses[1]),   64,  79,
+     8, AMR_OF(2,p_lag),       31,  17,  21,  19,  29,  37,  43,  41,
+     6, AMR_OF(2,p_gain),      73,  62,  50,  54,  32,  24,
+     9, AMR_OF(2,pulses[0]),   99, 103,  91, 115, 119,  95,  83, 107, 111,
+     2, AMR_OF(2,pulses[1]),   66,  77,
+     4, AMR_OF(3,p_lag),       27,  35,  45,  86,
+     6, AMR_OF(3,p_gain),      72,  61,  49,  53,  47,  39,
+     9, AMR_OF(3,pulses[0]),   98, 102,  90, 114, 118,  94,  82, 106, 110,
+     2, AMR_OF(3,pulses[1]),   65,  68,
+     0
 };
 
 static const uint8_t order_MODE_6k7[] = {
-    0x28,   7,   6,  15,   4,   5,   3,   2,   0,
-    0x19,  14,  13,   8,  12,  10,   1,   9,  11,  29,
-    0x19,  57,  58,  50,  56,  60,  59,  49,  71,  70,
-    0x38,  17,  19,  23,  21,  31,  24,  32,  52,
-    0x17,  36,  82,  69,  46,  42,  48,  77,
-    0x2b, 109,  97, 133, 121, 101,  89, 125, 113,  93, 117, 105,
-    0x13,  81,  73,  65,
-    0x94,  28,  26,  38,  54,
-    0x17,  35,  83,  68,  45,  41,  63,  76,
-    0x2b, 108,  96, 132, 120, 100,  88, 124, 112,  92, 116, 104,
-    0x13,  80,  72,  64,
-    0x98,  16,  18,  22,  20,  30,  39,  47,  51,
-    0x17,  34,  84,  67,  44,  40,  62,  75,
-    0x2b, 107, 111, 131, 135,  99, 103, 123, 127,  91, 115, 119,
-    0x13,  95,  87,  79,
-    0x94,  27,  25,  37,  53,
-    0x17,  33,  85,  66,  43,  55,  61,  74,
-    0x2b, 106, 110, 130, 134,  98, 102, 122, 126,  90, 114, 118,
-    0x13,  94,  86,  78,
-    0
+     8, AMR_BIT(lsf[0]),        7,   6,  15,   4,   5,   3,   2,   0,
+     9, AMR_BIT(lsf[1]),       14,  13,   8,  12,  10,   1,   9,  11,  29,
+     9, AMR_BIT(lsf[2]),       57,  58,  50,  56,  60,  59,  49,  71,  70,
+     8, AMR_OF(0,p_lag),       17,  19,  23,  21,  31,  24,  32,  52,
+     7, AMR_OF(0,p_gain),      36,  82,  69,  46,  42,  48,  77,
+    11, AMR_OF(0,pulses[0]),  109,  97, 133, 121, 101,  89, 125, 113,  93, 117,
+                              105,
+     3, AMR_OF(0,pulses[1]),   81,  73,  65,
+     4, AMR_OF(1,p_lag),       28,  26,  38,  54,
+     7, AMR_OF(1,p_gain),      35,  83,  68,  45,  41,  63,  76,
+    11, AMR_OF(1,pulses[0]),  108,  96, 132, 120, 100,  88, 124, 112,  92, 116,
+                              104,
+     3, AMR_OF(1,pulses[1]),   80,  72,  64,
+     8, AMR_OF(2,p_lag),       16,  18,  22,  20,  30,  39,  47,  51,
+     7, AMR_OF(2,p_gain),      34,  84,  67,  44,  40,  62,  75,
+    11, AMR_OF(2,pulses[0]),  107, 111, 131, 135,  99, 103, 123, 127,  91, 115,
+                              119,
+     3, AMR_OF(2,pulses[1]),   95,  87,  79,
+     4, AMR_OF(3,p_lag),       27,  25,  37,  53,
+     7, AMR_OF(3,p_gain),      33,  85,  66,  43,  55,  61,  74,
+    11, AMR_OF(3,pulses[0]),  106, 110, 130, 134,  98, 102, 122, 126,  90, 114,
+                              118,
+     3, AMR_OF(3,pulses[1]),   94,  86,  78,
+     0
 };
 
 static const uint8_t order_MODE_7k4[] = {
-    0x28,   7,   6,   5,   4,   3,   2,   1,   0,
-    0x19,  15,  14,  13,  12,  11,  10,   9,   8,  23,
-    0x19,  53,  52,  51,  58,  40,  55,  54,  57,  56,
-    0x38,  22,  20,  18,  16,  30,  50,  95,  94,
-    0x17,  28,  24,  73,  36,  32,  62,  67,
-    0x2d, 127, 123, 135, 131, 143, 139, 151, 103, 102, 101, 100,  99,  98,
-    0x14,  83,  75,  79,  71,
-    0x95,  44,  42,  49,  93,  92,
-    0x17,  27,  39,  72,  35,  47,  61,  66,
-    0x2d, 126, 122, 134, 130, 142, 138, 150,  97,  96, 111, 110, 109, 108,
-    0x14,  82,  74,  78,  70,
-    0x98,  21,  19,  17,  31,  29,  48,  91,  90,
-    0x17,  26,  38,  87,  34,  46,  60,  65,
-    0x2d, 125, 121, 133, 129, 141, 137, 149, 107, 106, 105, 104, 119, 118,
-    0x14,  81,  85,  77,  69,
-    0x95,  43,  41,  63,  89,  88,
-    0x17,  25,  37,  86,  33,  45,  59,  64,
-    0x2d, 124, 120, 132, 128, 140, 136, 148, 117, 116, 115, 114, 113, 112,
-    0x14,  80,  84,  76,  68,
-    0
+     8, AMR_BIT(lsf[0]),        7,   6,   5,   4,   3,   2,   1,   0,
+     9, AMR_BIT(lsf[1]),       15,  14,  13,  12,  11,  10,   9,   8,  23,
+     9, AMR_BIT(lsf[2]),       53,  52,  51,  58,  40,  55,  54,  57,  56,
+     8, AMR_OF(0,p_lag),       22,  20,  18,  16,  30,  50,  95,  94,
+     7, AMR_OF(0,p_gain),      28,  24,  73,  36,  32,  62,  67,
+    13, AMR_OF(0,pulses[0]),  127, 123, 135, 131, 143, 139, 151, 103, 102, 101,
+                              100,  99,  98,
+     4, AMR_OF(0,pulses[1]),   83,  75,  79,  71,
+     5, AMR_OF(1,p_lag),       44,  42,  49,  93,  92,
+     7, AMR_OF(1,p_gain),      27,  39,  72,  35,  47,  61,  66,
+    13, AMR_OF(1,pulses[0]),  126, 122, 134, 130, 142, 138, 150,  97,  96, 111,
+                              110, 109, 108,
+     4, AMR_OF(1,pulses[1]),   82,  74,  78,  70,
+     8, AMR_OF(2,p_lag),       21,  19,  17,  31,  29,  48,  91,  90,
+     7, AMR_OF(2,p_gain),      26,  38,  87,  34,  46,  60,  65,
+    13, AMR_OF(2,pulses[0]),  125, 121, 133, 129, 141, 137, 149, 107, 106, 105,
+                              104, 119, 118,
+     4, AMR_OF(2,pulses[1]),   81,  85,  77,  69,
+     5, AMR_OF(3,p_lag),       43,  41,  63,  89,  88,
+     7, AMR_OF(3,p_gain),      25,  37,  86,  33,  45,  59,  64,
+    13, AMR_OF(3,pulses[0]),  124, 120, 132, 128, 140, 136, 148, 117, 116, 115,
+                              114, 113, 112,
+     4, AMR_OF(3,pulses[1]),   80,  84,  76,  68,
+     0
 };
 
 static const uint8_t order_MODE_7k95[] = {
-    0x29,  67,  68,   1,   2,   3,   4,   5,   6,   7,
-    0x19,  14,  13,   9,  12,  11,   0,  10,  15,   8,
-    0x19,  18,  19,  23,  17,  22,  20,  21,  66,  65,
-    0x38,  44,  42,  40,  54,  52,  56,  64,  78,
-    0x14,  36,  32,  72,  80,
-    0x15,  16,  28,  24,  60,  84,
-    0x1d, 135, 109, 144, 156, 120,  97, 148, 121, 101, 122, 123,  89, 124,
-    0x14, 125, 126, 127, 112,
-    0x96,  50,  48,  62,  70,  76,  74,
-    0x14,  35,  47,  87,  95,
-    0x15,  31,  27,  39,  59,  83,
-    0x1d, 129, 108, 159, 155, 130,  96, 147, 131, 100, 132, 133,  88, 134,
-    0x14, 113, 114, 115, 116,
-    0x98,  43,  41,  55,  53,  51,  71,  79,  77,
-    0x14,  34,  46,  86,  94,
-    0x15,  30,  26,  38,  58,  82,
-    0x1d, 139, 107, 158, 154, 140, 111, 146, 141,  99, 142, 143, 103, 128,
-    0x14, 105,  90,  91,  92,
-    0x96,  49,  63,  61,  69,  75,  73,
-    0x14,  33,  45,  85,  93,
-    0x15,  29,  25,  37,  57,  81,
-    0x1d, 149, 106, 157, 153, 150, 110, 145, 151,  98, 136, 137, 102, 138,
-    0x14, 117, 118, 119, 104,
-    0
+     9, AMR_BIT(lsf[0]),       67,  68,   1,   2,   3,   4,   5,   6,   7,
+     9, AMR_BIT(lsf[1]),       14,  13,   9,  12,  11,   0,  10,  15,   8,
+     9, AMR_BIT(lsf[2]),       18,  19,  23,  17,  22,  20,  21,  66,  65,
+     8, AMR_OF(0,p_lag),       44,  42,  40,  54,  52,  56,  64,  78,
+     4, AMR_OF(0,p_gain),      36,  32,  72,  80,
+     5, AMR_OF(0,fixed_gain),  16,  28,  24,  60,  84,
+    13, AMR_OF(0,pulses[0]),  135, 109, 144, 156, 120,  97, 148, 121, 101, 122,
+                              123,  89, 124,
+     4, AMR_OF(0,pulses[1]),  125, 126, 127, 112,
+     6, AMR_OF(1,p_lag),       50,  48,  62,  70,  76,  74,
+     4, AMR_OF(1,p_gain),      35,  47,  87,  95,
+     5, AMR_OF(1,fixed_gain),  31,  27,  39,  59,  83,
+    13, AMR_OF(1,pulses[0]),  129, 108, 159, 155, 130,  96, 147, 131, 100, 132,
+                              133,  88, 134,
+     4, AMR_OF(1,pulses[1]),  113, 114, 115, 116,
+     8, AMR_OF(2,p_lag),       43,  41,  55,  53,  51,  71,  79,  77,
+     4, AMR_OF(2,p_gain),      34,  46,  86,  94,
+     5, AMR_OF(2,fixed_gain),  30,  26,  38,  58,  82,
+    13, AMR_OF(2,pulses[0]),  139, 107, 158, 154, 140, 111, 146, 141,  99, 142,
+                              143, 103, 128,
+     4, AMR_OF(2,pulses[1]),  105,  90,  91,  92,
+     6, AMR_OF(3,p_lag),       49,  63,  61,  69,  75,  73,
+     4, AMR_OF(3,p_gain),      33,  45,  85,  93,
+     5, AMR_OF(3,fixed_gain),  29,  25,  37,  57,  81,
+    13, AMR_OF(3,pulses[0]),  149, 106, 157, 153, 150, 110, 145, 151,  98, 136,
+                              137, 102, 138,
+     4, AMR_OF(3,pulses[1]),  117, 118, 119, 104,
+     0
 };
 
 static const uint8_t order_MODE_10k2[] = {
-    0x28,   0,   1,   2,   3,   4,   5,   6,   7,
-    0x19,  23,   8,   9,  10,  11,  12,  13,  14,  15,
-    0x19,  57,  58,  62,  56,  60,  59,  61,  71,  70,
-    0x38,  22,  21,  20,  19,  18,  17,  42,  41,
-    0x17,  38,  50,  84,  37,  36,  85,  83,
-    0x21,  66,
-    0x11,  67,
-    0x11,  68,
-    0x11,  69,
-    0x1a, 145, 144, 156, 153, 154, 163, 161, 192, 206, 195,
-    0x1a, 158, 159, 157, 152, 155, 165, 160, 205, 204, 194,
-    0x17, 167, 166, 162, 164, 196, 207, 193,
-    0x45,  26,  25,  54,  53,  89,
-    0x17,  35,  49,  81,  34,  33,  82,  80,
-    0x21,  78,
-    0x11,  79,
-    0x11,  64,
-    0x11,  65,
-    0x1a, 103, 102,  98, 111,  96, 105, 119, 185, 199, 188,
-    0x1a, 100, 101,  99, 110,  97, 107, 118, 198, 197, 187,
-    0x17, 109, 108, 104, 106, 189, 184, 186,
-    0x48,  16,  31,  30,  29,  28,  27,  40,  55,
-    0x17,  32,  48,  94,  47,  46,  95,  93,
-    0x21,  74,
-    0x11,  75,
-    0x11,  76,
-    0x11,  77,
-    0x1a, 117, 116, 112, 125, 126, 135, 133, 178, 176, 181,
-    0x1a, 114, 115, 113, 124, 127, 121, 132, 191, 190, 180,
-    0x17, 123, 122, 134, 120, 182, 177, 179,
-    0x45,  24,  39,  52,  51,  88,
-    0x17,  45,  63,  91,  44,  43,  92,  90,
-    0x21,  86,
-    0x11,  87,
-    0x11,  72,
-    0x11,  73,
-    0x1a, 131, 130, 142, 139, 140, 149, 147, 171, 169, 174,
-    0x1a, 128, 129, 143, 138, 141, 151, 146, 168, 183, 173,
-    0x17, 137, 136, 148, 150, 175, 170, 172,
-    0
+     8, AMR_BIT(lsf[0]),        0,   1,   2,   3,   4,   5,   6,   7,
+     9, AMR_BIT(lsf[1]),       23,   8,   9,  10,  11,  12,  13,  14,  15,
+     9, AMR_BIT(lsf[2]),       57,  58,  62,  56,  60,  59,  61,  71,  70,
+     8, AMR_OF(0,p_lag),       22,  21,  20,  19,  18,  17,  42,  41,
+     7, AMR_OF(0,p_gain),      38,  50,  84,  37,  36,  85,  83,
+     1, AMR_OF(0,pulses[0]),   66,
+     1, AMR_OF(0,pulses[1]),   67,
+     1, AMR_OF(0,pulses[2]),   68,
+     1, AMR_OF(0,pulses[3]),   69,
+    10, AMR_OF(0,pulses[4]),  145, 144, 156, 153, 154, 163, 161, 192, 206, 195,
+    10, AMR_OF(0,pulses[5]),  158, 159, 157, 152, 155, 165, 160, 205, 204, 194,
+     7, AMR_OF(0,pulses[6]),  167, 166, 162, 164, 196, 207, 193,
+     5, AMR_OF(1,p_lag),       26,  25,  54,  53,  89,
+     7, AMR_OF(1,p_gain),      35,  49,  81,  34,  33,  82,  80,
+     1, AMR_OF(1,pulses[0]),   78,
+     1, AMR_OF(1,pulses[1]),   79,
+     1, AMR_OF(1,pulses[2]),   64,
+     1, AMR_OF(1,pulses[3]),   65,
+    10, AMR_OF(1,pulses[4]),  103, 102,  98, 111,  96, 105, 119, 185, 199, 188,
+    10, AMR_OF(1,pulses[5]),  100, 101,  99, 110,  97, 107, 118, 198, 197, 187,
+     7, AMR_OF(1,pulses[6]),  109, 108, 104, 106, 189, 184, 186,
+     8, AMR_OF(2,p_lag),       16,  31,  30,  29,  28,  27,  40,  55,
+     7, AMR_OF(2,p_gain),      32,  48,  94,  47,  46,  95,  93,
+     1, AMR_OF(2,pulses[0]),   74,
+     1, AMR_OF(2,pulses[1]),   75,
+     1, AMR_OF(2,pulses[2]),   76,
+     1, AMR_OF(2,pulses[3]),   77,
+    10, AMR_OF(2,pulses[4]),  117, 116, 112, 125, 126, 135, 133, 178, 176, 181,
+    10, AMR_OF(2,pulses[5]),  114, 115, 113, 124, 127, 121, 132, 191, 190, 180,
+     7, AMR_OF(2,pulses[6]),  123, 122, 134, 120, 182, 177, 179,
+     5, AMR_OF(3,p_lag),       24,  39,  52,  51,  88,
+     7, AMR_OF(3,p_gain),      45,  63,  91,  44,  43,  92,  90,
+     1, AMR_OF(3,pulses[0]),   86,
+     1, AMR_OF(3,pulses[1]),   87,
+     1, AMR_OF(3,pulses[2]),   72,
+     1, AMR_OF(3,pulses[3]),   73,
+    10, AMR_OF(3,pulses[4]),  131, 130, 142, 139, 140, 149, 147, 171, 169, 174,
+    10, AMR_OF(3,pulses[5]),  128, 129, 143, 138, 141, 151, 146, 168, 183, 173,
+     7, AMR_OF(3,pulses[6]),  137, 136, 148, 150, 175, 170, 172,
+     0
 };
 
 static const uint8_t order_MODE_12k2[] = {
-    0x27,   7,   6,   5,   4,   3,   2,   1,
-    0x18,   0,  15,  14,  13,  12,  11,  10,   9,
-    0x19,  23,  22,  21,  20,  19,  18,  17,  16,   8,
-    0x18,  31,  30,  29,  28,  27,  86,  85,  84,
-    0x16,  83,  82,  81,  80, 127, 126,
-    0x19,  26,  24,  38,  36,  34,  32,  46,  44,  42,
-    0x14,  40,  52,  48,  95,
-    0x15,  60,  56,  68,  91, 111,
-    0x13, 191, 176, 177,
-    0x14, 103, 123, 124, 125,
-    0x13, 188, 189, 190,
-    0x14,  99, 120, 121, 122,
-    0x13, 185, 186, 187,
-    0x14, 107, 133, 134, 135,
-    0x13, 198, 199, 184,
-    0x14, 119, 130, 131, 132,
-    0x13, 195, 196, 197,
-    0x14, 115, 143, 128, 129,
-    0x16,  64,  78,  76,  74,  72, 245,
-    0x14,  55,  51,  63,  94,
-    0x15,  59,  71,  67,  90, 110,
-    0x13, 192, 193, 194,
-    0x14, 102, 140, 141, 142,
-    0x13, 205, 206, 207,
-    0x14,  98, 137, 138, 139,
-    0x13, 202, 203, 204,
-    0x14, 106, 150, 151, 136,
-    0x13, 215, 200, 201,
-    0x14, 118, 147, 148, 149,
-    0x13, 212, 213, 214,
-    0x14, 114, 144, 145, 146,
-    0x19,  25,  39,  37,  35,  33,  47,  45,  43,  41,
-    0x14,  54,  50,  62,  93,
-    0x15,  58,  70,  66,  89, 109,
-    0x13, 209, 210, 211,
-    0x14, 101, 157, 158, 159,
-    0x13, 222, 223, 208,
-    0x14,  97, 154, 155, 156,
-    0x13, 219, 220, 221,
-    0x14, 105, 167, 152, 153,
-    0x13, 216, 217, 218,
-    0x14, 117, 164, 165, 166,
-    0x13, 229, 230, 231,
-    0x14, 113, 161, 162, 163,
-    0x16,  79,  77,  75,  73,  87, 244,
-    0x14,  53,  49,  61,  92,
-    0x15,  57,  69,  65,  88, 108,
-    0x13, 226, 227, 228,
-    0x14, 100, 174, 175, 160,
-    0x13, 239, 224, 225,
-    0x14,  96, 171, 172, 173,
-    0x13, 236, 237, 238,
-    0x14, 104, 168, 169, 170,
-    0x13, 233, 234, 235,
-    0x14, 116, 181, 182, 183,
-    0x13, 246, 247, 232,
-    0x14, 112, 178, 179, 180,
-    0
+     7, AMR_BIT(lsf[0]),        7,   6,   5,   4,   3,   2,   1,
+     8, AMR_BIT(lsf[1]),        0,  15,  14,  13,  12,  11,  10,   9,
+     9, AMR_BIT(lsf[2]),       23,  22,  21,  20,  19,  18,  17,  16,   8,
+     8, AMR_BIT(lsf[3]),       31,  30,  29,  28,  27,  86,  85,  84,
+     6, AMR_BIT(lsf[4]),       83,  82,  81,  80, 127, 126,
+     9, AMR_OF(0,p_lag),       26,  24,  38,  36,  34,  32,  46,  44,  42,
+     4, AMR_OF(0,p_gain),      40,  52,  48,  95,
+     5, AMR_OF(0,fixed_gain),  60,  56,  68,  91, 111,
+     3, AMR_OF(0,pulses[0]),  191, 176, 177,
+     4, AMR_OF(0,pulses[1]),  103, 123, 124, 125,
+     3, AMR_OF(0,pulses[2]),  188, 189, 190,
+     4, AMR_OF(0,pulses[3]),   99, 120, 121, 122,
+     3, AMR_OF(0,pulses[4]),  185, 186, 187,
+     4, AMR_OF(0,pulses[5]),  107, 133, 134, 135,
+     3, AMR_OF(0,pulses[6]),  198, 199, 184,
+     4, AMR_OF(0,pulses[7]),  119, 130, 131, 132,
+     3, AMR_OF(0,pulses[8]),  195, 196, 197,
+     4, AMR_OF(0,pulses[9]),  115, 143, 128, 129,
+     6, AMR_OF(1,p_lag),       64,  78,  76,  74,  72, 245,
+     4, AMR_OF(1,p_gain),      55,  51,  63,  94,
+     5, AMR_OF(1,fixed_gain),  59,  71,  67,  90, 110,
+     3, AMR_OF(1,pulses[0]),  192, 193, 194,
+     4, AMR_OF(1,pulses[1]),  102, 140, 141, 142,
+     3, AMR_OF(1,pulses[2]),  205, 206, 207,
+     4, AMR_OF(1,pulses[3]),   98, 137, 138, 139,
+     3, AMR_OF(1,pulses[4]),  202, 203, 204,
+     4, AMR_OF(1,pulses[5]),  106, 150, 151, 136,
+     3, AMR_OF(1,pulses[6]),  215, 200, 201,
+     4, AMR_OF(1,pulses[7]),  118, 147, 148, 149,
+     3, AMR_OF(1,pulses[8]),  212, 213, 214,
+     4, AMR_OF(1,pulses[9]),  114, 144, 145, 146,
+     9, AMR_OF(2,p_lag),       25,  39,  37,  35,  33,  47,  45,  43,  41,
+     4, AMR_OF(2,p_gain),      54,  50,  62,  93,
+     5, AMR_OF(2,fixed_gain),  58,  70,  66,  89, 109,
+     3, AMR_OF(2,pulses[0]),  209, 210, 211,
+     4, AMR_OF(2,pulses[1]),  101, 157, 158, 159,
+     3, AMR_OF(2,pulses[2]),  222, 223, 208,
+     4, AMR_OF(2,pulses[3]),   97, 154, 155, 156,
+     3, AMR_OF(2,pulses[4]),  219, 220, 221,
+     4, AMR_OF(2,pulses[5]),  105, 167, 152, 153,
+     3, AMR_OF(2,pulses[6]),  216, 217, 218,
+     4, AMR_OF(2,pulses[7]),  117, 164, 165, 166,
+     3, AMR_OF(2,pulses[8]),  229, 230, 231,
+     4, AMR_OF(2,pulses[9]),  113, 161, 162, 163,
+     6, AMR_OF(3,p_lag),       79,  77,  75,  73,  87, 244,
+     4, AMR_OF(3,p_gain),      53,  49,  61,  92,
+     5, AMR_OF(3,fixed_gain),  57,  69,  65,  88, 108,
+     3, AMR_OF(3,pulses[0]),  226, 227, 228,
+     4, AMR_OF(3,pulses[1]),  100, 174, 175, 160,
+     3, AMR_OF(3,pulses[2]),  239, 224, 225,
+     4, AMR_OF(3,pulses[3]),   96, 171, 172, 173,
+     3, AMR_OF(3,pulses[4]),  236, 237, 238,
+     4, AMR_OF(3,pulses[5]),  104, 168, 169, 170,
+     3, AMR_OF(3,pulses[6]),  233, 234, 235,
+     4, AMR_OF(3,pulses[7]),  116, 181, 182, 183,
+     3, AMR_OF(3,pulses[8]),  246, 247, 232,
+     4, AMR_OF(3,pulses[9]),  112, 178, 179, 180,
+     0
 };
 
 static const uint8_t order_MODE_DTX[] = {
-    0x03,   7,   6,   5,
-    0x16,  26,  25,  24,  39,  38,  37,
-    0x18,   4,   3,   2,   1,   0,  15,  14,  13,
-    0x19,  12,  11,  10,   9,   8,  23,  22,  21,  20,
-    0x19,  19,  18,  17,  16,  31,  30,  29,  28,  27,
-    0
+     3, AMR_BIT(sid_vector),    7,   6,   5,
+     6, AMR_BIT(sid_energy),   26,  25,  24,  39,  38,  37,
+     8, AMR_BIT(lsf[0]),        4,   3,   2,   1,   0,  15,  14,  13,
+     9, AMR_BIT(lsf[1]),       12,  11,  10,   9,   8,  23,  22,  21,  20,
+     9, AMR_BIT(lsf[2]),       19,  18,  17,  16,  31,  30,  29,  28,  27,
+     0
 };
 
 /**

Modified: amr/amrnbdec.c
==============================================================================
--- amr/amrnbdec.c	Sun Jan 10 11:42:27 2010	(r5572)
+++ amr/amrnbdec.c	Tue Jan 12 01:20:15 2010	(r5573)
@@ -161,20 +161,19 @@ static enum Mode unpack_bitstream(AMRCon
     if (mode <= MODE_DTX) {
         uint16_t *data = (uint16_t *)&p->frame;
         const uint8_t *order = amr_unpacking_bitmaps_per_mode[mode];
-        int field_header; // 16 * relative field index + number of field bits
+        int field_size;
 
         memset(&p->frame, 0, sizeof(AMRNBFrame));
         buf++;
-        while ((field_header = *order++)) {
+        while ((field_size = *order++)) {
             int field = 0;
-            data += field_header >> 4;
-            field_header &= 0xf;
-            while (field_header--) {
+            int field_offset = *order++;
+            while (field_size--) {
                int bit = *order++;
                field <<= 1;
                field |= buf[bit >> 3] >> (bit & 7) & 1;
             }
-            *data = field;
+            data[field_offset] = field;
         }
     }
 


More information about the FFmpeg-soc mailing list