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

cmcq subversion at mplayerhq.hu
Fri Jan 8 18:16:25 CET 2010


Author: cmcq
Date: Fri Jan  8 18:16:25 2010
New Revision: 5570

Log:
Save about 1KB of space using a field-to-bit lookup instead of bit-to-field.

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

Modified: amr/amrnbdata.h
==============================================================================
--- amr/amrnbdata.h	Fri Jan  8 18:13:05 2010	(r5569)
+++ amr/amrnbdata.h	Fri Jan  8 18:16:25 2010	(r5570)
@@ -68,15 +68,6 @@ enum Mode {
 #define LP_FILTER_ORDER 10        ///< linear predictive coding filter order
 
 /**
- * Bit-order table type
- */
-typedef struct AMROrder {
-    uint8_t index;                ///< index in (uint16_t *)AMRNBFrame
-    uint8_t bit;                  ///< bit index, LSB=0, MSB=15
-} AMROrder;
-
-
-/**
  * AMRNB unpacked data subframe
  */
 typedef struct {
@@ -99,370 +90,269 @@ typedef struct {
 
 // The following order* tables are used to convert AMR frame parameters to and
 // from a bitstream. See 3GPP TS 26.101 for more information.
-
-#define AMR_BIT(field, bit)                  {offsetof(AMRNBFrame, field) >> 1, bit}
-/** Specify an LSF parameter bit */
-#define AMR_LSF(variable, bit)               AMR_BIT(lsf[variable], bit)
-/** Specify a subframe-specific bit */
-#define AMR_OF(frame_num, variable, bit)     AMR_BIT(subframe[frame_num].variable, bit)
-/** Specify a pitch gain bit */
-#define AMR_PGAIN(frame_num, bit)            AMR_OF(frame_num, p_gain, bit)
-/** Specify a fixed gain bit */
-#define AMR_FGAIN(frame_num, bit)            AMR_OF(frame_num, fixed_gain, bit)
-/** Specify a pitch lag bit */
-#define AMR_PLAG(frame_num, bit)             AMR_OF(frame_num, p_lag, bit)
-/** Specify a pulse bit */
-#define AMR_PULSE(frame_num, pulse_id, bit)  AMR_OF(frame_num, pulses[pulse_id], bit)
-/** Specify an SID reference vector bit */
-#define AMR_SVECTOR(bit)                     AMR_BIT(sid_vector, bit)
-/** Specify an SID energy index bit */
-#define AMR_SENERGY(bit)                     AMR_BIT(sid_energy, bit)
-
-static const AMROrder order_MODE_4k75[95] = {
- AMR_LSF  (  0, 7), AMR_LSF  (  0, 6), AMR_LSF  (  0, 5), AMR_LSF  (  0, 4),
- AMR_LSF  (  0, 3), AMR_LSF  (  0, 2), AMR_LSF  (  0, 1), AMR_LSF  (  0, 0),
- AMR_LSF  (  1, 7), AMR_LSF  (  1, 6), AMR_LSF  (  1, 5), AMR_LSF  (  1, 4),
- AMR_LSF  (  1, 3), AMR_LSF  (  1, 2), AMR_LSF  (  1, 1), AMR_LSF  (  1, 0),
- AMR_PLAG (0,   7), AMR_PLAG (0,   6), AMR_PLAG (0,   5), AMR_PLAG (0,   4),
- AMR_PLAG (0,   3), AMR_PLAG (0,   2), AMR_PLAG (1,   3), AMR_PLAG (1,   2),
- AMR_PLAG (2,   3), AMR_PLAG (2,   2), AMR_PLAG (3,   3), AMR_PLAG (3,   2),
- AMR_PGAIN(0,   0), AMR_PGAIN(0,   1), AMR_PGAIN(0,   2), AMR_PGAIN(0,   3),
- AMR_PGAIN(2,   0), AMR_PGAIN(2,   1), AMR_PGAIN(2,   2), AMR_PGAIN(2,   3),
- AMR_LSF  (  2, 5), AMR_LSF  (  2, 4), AMR_LSF  (  2, 2), AMR_LSF  (  2, 0),
- AMR_PGAIN(2,   4), AMR_PGAIN(2,   5), AMR_PGAIN(2,   6), AMR_PGAIN(2,   7),
- AMR_PLAG (0,   1), AMR_PLAG (0,   0), AMR_PGAIN(0,   4), AMR_PGAIN(0,   5),
- AMR_PGAIN(0,   6), AMR_PGAIN(0,   7), AMR_PULSE(0,1, 1), AMR_PULSE(0,1, 0),
- AMR_LSF  (  2, 6), AMR_LSF  (  2, 3), AMR_LSF  (  2, 1), AMR_PLAG (1,   1),
- AMR_PLAG (1,   0), AMR_PULSE(1,1, 1), AMR_PULSE(1,1, 0), AMR_PLAG (2,   1),
- AMR_PLAG (2,   0), AMR_PULSE(2,1, 1), AMR_PULSE(2,1, 0), AMR_PLAG (3,   1),
- AMR_PLAG (3,   0), AMR_PULSE(3,1, 1), AMR_PULSE(3,1, 0), AMR_PULSE(0,0, 5),
- AMR_PULSE(0,0, 4), AMR_PULSE(0,0, 2), AMR_PULSE(0,0, 1), AMR_PULSE(1,0, 5),
- AMR_PULSE(1,0, 4), AMR_PULSE(1,0, 2), AMR_PULSE(1,0, 1), AMR_PULSE(2,0, 5),
- AMR_PULSE(2,0, 4), AMR_PULSE(2,0, 2), AMR_PULSE(2,0, 1), AMR_PULSE(3,0, 5),
- AMR_PULSE(3,0, 4), AMR_PULSE(3,0, 2), AMR_PULSE(3,0, 1), AMR_PULSE(0,0, 3),
- AMR_PULSE(1,0, 3), AMR_PULSE(2,0, 3), AMR_PULSE(3,0, 3), AMR_PULSE(0,0, 0),
- AMR_PULSE(1,0, 0), AMR_PULSE(2,0, 0), AMR_PULSE(3,0, 0), AMR_PULSE(0,0, 6),
- AMR_PULSE(1,0, 6), AMR_PULSE(2,0, 6), AMR_PULSE(3,0, 6)
+// 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)
+//         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
 };
 
-static const AMROrder order_MODE_5k15[103] = {
- AMR_LSF  (  0, 0), AMR_LSF  (  0, 1), AMR_LSF  (  0, 2), AMR_LSF  (  0, 3),
- AMR_LSF  (  0, 4), AMR_LSF  (  0, 5), AMR_LSF  (  0, 6), AMR_LSF  (  0, 7),
- AMR_LSF  (  1, 0), AMR_LSF  (  1, 1), AMR_LSF  (  1, 2), AMR_LSF  (  1, 3),
- AMR_LSF  (  1, 4), AMR_LSF  (  1, 5), AMR_LSF  (  1, 6), AMR_LSF  (  1, 7),
- AMR_PLAG (0,   7), AMR_PLAG (0,   6), AMR_PLAG (0,   5), AMR_PLAG (0,   4),
- AMR_PLAG (0,   3), AMR_PLAG (1,   3), AMR_PLAG (2,   3), AMR_PLAG (3,   3),
- AMR_PGAIN(0,   0), AMR_PGAIN(0,   1), AMR_PGAIN(0,   2), AMR_PGAIN(1,   0),
- AMR_PGAIN(1,   1), AMR_PGAIN(1,   2), AMR_PGAIN(2,   0), AMR_PGAIN(2,   1),
- AMR_PGAIN(2,   2), AMR_PGAIN(3,   0), AMR_PGAIN(3,   1), AMR_PGAIN(3,   2),
- AMR_PGAIN(0,   3), AMR_PGAIN(1,   3), AMR_PGAIN(2,   3), AMR_PGAIN(3,   3),
- AMR_PLAG (0,   2), AMR_PLAG (1,   2), AMR_PLAG (2,   2), AMR_PLAG (3,   2),
- AMR_LSF  (  2, 4), AMR_PGAIN(0,   4), AMR_PGAIN(1,   4), AMR_PGAIN(2,   4),
- AMR_PGAIN(3,   4), AMR_PLAG (0,   1), AMR_PLAG (1,   1), AMR_PLAG (2,   1),
- AMR_LSF  (  2, 5), AMR_LSF  (  2, 2), AMR_LSF  (  2, 0), AMR_PGAIN(0,   5),
- AMR_PGAIN(1,   5), AMR_PGAIN(2,   5), AMR_PGAIN(3,   5), AMR_LSF  (  2, 1),
- AMR_PLAG (0,   0), AMR_PLAG (1,   0), AMR_PLAG (2,   0), AMR_PLAG (3,   1),
- AMR_LSF  (  2, 3), AMR_LSF  (  2, 6), AMR_PLAG (3,   0), AMR_PULSE(0,1, 0),
- AMR_PULSE(0,1, 1), AMR_PULSE(1,1, 0), AMR_PULSE(1,1, 1), AMR_PULSE(2,1, 0),
- AMR_PULSE(0,0, 2), AMR_PULSE(1,0, 2), AMR_PULSE(2,0, 2), AMR_PULSE(3,0, 2),
- AMR_PULSE(2,1, 1), AMR_PULSE(3,1, 0), AMR_PULSE(3,1, 1), AMR_PULSE(0,0, 1),
- AMR_PULSE(1,0, 1), AMR_PULSE(2,0, 1), AMR_PULSE(3,0, 1), AMR_PULSE(0,0, 5),
- AMR_PULSE(1,0, 5), AMR_PULSE(0,0, 4), AMR_PULSE(1,0, 4), AMR_PULSE(2,0, 5),
- AMR_PULSE(2,0, 4), AMR_PULSE(3,0, 5), AMR_PULSE(3,0, 4), AMR_PULSE(0,0, 6),
- AMR_PULSE(1,0, 6), AMR_PULSE(2,0, 6), AMR_PULSE(3,0, 6), AMR_PULSE(0,0, 0),
- AMR_PULSE(1,0, 0), AMR_PULSE(2,0, 0), AMR_PULSE(3,0, 0), AMR_PULSE(0,0, 3),
- AMR_PULSE(1,0, 3), AMR_PULSE(2,0, 3), AMR_PULSE(3,0, 3)
+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
 };
 
-static const AMROrder order_MODE_5k9[118] = {
- AMR_LSF  (  0, 7), AMR_LSF  (  0, 6), AMR_LSF  (  0, 3), AMR_LSF  (  0, 2),
- AMR_LSF  (  0, 4), AMR_LSF  (  0, 1), AMR_LSF  (  0, 0), AMR_LSF  (  0, 5),
- AMR_LSF  (  1, 3), AMR_LSF  (  1, 1), AMR_LSF  (  1, 8), AMR_LSF  (  1, 7),
- AMR_LSF  (  1, 5), AMR_LSF  (  1, 4), AMR_LSF  (  1, 2), AMR_LSF  (  1, 6),
- AMR_LSF  (  1, 0), AMR_PLAG (0,   5), AMR_PLAG (2,   5), AMR_PLAG (0,   4),
- AMR_PLAG (2,   4), AMR_PLAG (0,   6), AMR_PLAG (2,   6), AMR_PLAG (0,   7),
- AMR_PLAG (2,   7), AMR_PLAG (0,   3), AMR_PLAG (2,   3), AMR_PLAG (1,   3),
- AMR_PLAG (3,   3), AMR_PGAIN(0,   0), AMR_PGAIN(1,   0), AMR_PGAIN(2,   0),
- AMR_PGAIN(3,   0), AMR_PLAG (0,   2), AMR_PLAG (2,   2), AMR_PLAG (1,   2),
- AMR_PLAG (3,   2), AMR_PGAIN(0,   1), AMR_PGAIN(1,   1), AMR_PGAIN(2,   1),
- AMR_PGAIN(3,   1), AMR_PLAG (1,   1), AMR_PLAG (3,   1), AMR_PLAG (0,   1),
- AMR_PLAG (2,   1), AMR_PLAG (0,   0), AMR_PLAG (2,   0), AMR_PGAIN(0,   2),
- AMR_PGAIN(1,   2), AMR_PGAIN(2,   2), AMR_PGAIN(3,   2), AMR_PGAIN(0,   3),
- AMR_PGAIN(1,   3), AMR_PGAIN(2,   3), AMR_PGAIN(3,   3), AMR_PGAIN(0,   4),
- AMR_PGAIN(1,   4), AMR_PGAIN(2,   4), AMR_PGAIN(3,   4), AMR_LSF  (  2, 6),
- AMR_LSF  (  2, 4), AMR_LSF  (  2, 2), AMR_LSF  (  2, 3), AMR_LSF  (  2, 7),
- AMR_LSF  (  2, 8), AMR_LSF  (  2, 5), AMR_LSF  (  2, 1), AMR_PULSE(3,1, 0),
- AMR_PULSE(0,1, 1), AMR_PULSE(2,1, 1), AMR_PULSE(3,1, 1), AMR_PULSE(1,1, 1),
- AMR_PULSE(1,1, 0), AMR_PULSE(0,1, 0), AMR_PULSE(2,1, 0), AMR_LSF  (  2, 0),
- AMR_PGAIN(0,   5), AMR_PGAIN(1,   5), AMR_PGAIN(2,   5), AMR_PGAIN(3,   5),
- AMR_PLAG (1,   0), AMR_PLAG (3,   0), AMR_PULSE(0,0, 2), AMR_PULSE(1,0, 2),
- AMR_PULSE(2,0, 2), AMR_PULSE(3,0, 2), AMR_PULSE(0,0, 3), AMR_PULSE(1,0, 3),
- AMR_PULSE(2,0, 3), AMR_PULSE(3,0, 3), AMR_PULSE(0,0, 6), AMR_PULSE(1,0, 6),
- AMR_PULSE(2,0, 6), AMR_PULSE(3,0, 6), AMR_PULSE(0,0, 7), AMR_PULSE(1,0, 7),
- AMR_PULSE(2,0, 7), AMR_PULSE(3,0, 7), AMR_PULSE(0,0, 8), AMR_PULSE(1,0, 8),
- AMR_PULSE(2,0, 8), AMR_PULSE(3,0, 8), AMR_PULSE(0,0, 0), AMR_PULSE(1,0, 0),
- AMR_PULSE(2,0, 0), AMR_PULSE(3,0, 0), AMR_PULSE(0,0, 1), AMR_PULSE(1,0, 1),
- AMR_PULSE(2,0, 1), AMR_PULSE(3,0, 1), AMR_PULSE(0,0, 4), AMR_PULSE(1,0, 4),
- AMR_PULSE(2,0, 4), AMR_PULSE(3,0, 4), AMR_PULSE(0,0, 5), AMR_PULSE(1,0, 5),
- AMR_PULSE(2,0, 5), AMR_PULSE(3,0, 5)
+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
 };
 
-static const AMROrder order_MODE_6k7[134] = {
- AMR_LSF  (  0, 7), AMR_LSF  (  0, 6), AMR_LSF  (  0, 3), AMR_LSF  (  0, 4),
- AMR_LSF  (  0, 2), AMR_LSF  (  0, 1), AMR_LSF  (  1, 3), AMR_LSF  (  0, 0),
- AMR_LSF  (  0, 5), AMR_LSF  (  1, 8), AMR_LSF  (  1, 7), AMR_LSF  (  1, 5),
- AMR_LSF  (  1, 1), AMR_LSF  (  1, 4), AMR_LSF  (  1, 2), AMR_LSF  (  1, 6),
- AMR_PLAG (0,   5), AMR_PLAG (2,   5), AMR_PLAG (0,   4), AMR_PLAG (2,   4),
- AMR_PLAG (0,   6), AMR_PLAG (2,   6), AMR_PLAG (0,   7), AMR_PLAG (2,   7),
- AMR_PLAG (0,   3), AMR_PLAG (2,   3), AMR_LSF  (  1, 0), AMR_PLAG (1,   3),
- AMR_PLAG (3,   3), AMR_PLAG (1,   2), AMR_PLAG (3,   2), AMR_PLAG (0,   2),
- AMR_PLAG (2,   2), AMR_PLAG (1,   1), AMR_PLAG (3,   1), AMR_PGAIN(0,   6),
- AMR_PGAIN(1,   6), AMR_PGAIN(2,   6), AMR_PGAIN(3,   6), AMR_PLAG (0,   1),
- AMR_PLAG (2,   1), AMR_PGAIN(0,   3), AMR_PGAIN(1,   3), AMR_PGAIN(2,   3),
- AMR_PGAIN(3,   3), AMR_PGAIN(0,   2), AMR_PGAIN(1,   2), AMR_PGAIN(2,   2),
- AMR_PGAIN(3,   2), AMR_PLAG (1,   0), AMR_PLAG (3,   0), AMR_PLAG (0,   0),
- AMR_PLAG (2,   0), AMR_LSF  (  2, 6), AMR_LSF  (  2, 2), AMR_PGAIN(0,   1),
- AMR_PGAIN(1,   1), AMR_PGAIN(2,   1), AMR_PGAIN(3,   1), AMR_LSF  (  2, 4),
- AMR_LSF  (  2, 3), AMR_LSF  (  2, 7), AMR_LSF  (  2, 8), AMR_LSF  (  2, 5),
- AMR_LSF  (  2, 1), AMR_LSF  (  2, 0), AMR_PGAIN(0,   4), AMR_PGAIN(1,   4),
- AMR_PGAIN(2,   4), AMR_PGAIN(3,   4), AMR_PULSE(0,1, 0), AMR_PULSE(1,1, 0),
- AMR_PULSE(2,1, 0), AMR_PULSE(3,1, 0), AMR_PGAIN(0,   0), AMR_PGAIN(1,   0),
- AMR_PGAIN(2,   0), AMR_PGAIN(3,   0), AMR_PULSE(0,1, 1), AMR_PULSE(1,1, 1),
- AMR_PULSE(2,1, 1), AMR_PULSE(3,1, 1), AMR_PGAIN(3,   5), AMR_PGAIN(2,   5),
- AMR_PGAIN(1,   5), AMR_PGAIN(0,   5), AMR_PULSE(0,1, 2), AMR_PULSE(1,1, 2),
- AMR_PULSE(2,1, 2), AMR_PULSE(3,1, 2), AMR_PULSE(0,0, 2), AMR_PULSE(1,0, 2),
- AMR_PULSE(2,0, 2), AMR_PULSE(3,0, 2), AMR_PULSE(0,0, 5), AMR_PULSE(1,0, 5),
- AMR_PULSE(2,0, 5), AMR_PULSE(3,0, 5), AMR_PULSE(0,0, 6), AMR_PULSE(1,0, 6),
- AMR_PULSE(2,0, 6), AMR_PULSE(3,0, 6), AMR_PULSE(0,0, 9), AMR_PULSE(1,0, 9),
- AMR_PULSE(2,0, 9), AMR_PULSE(3,0, 9), AMR_PULSE(0,0,10), AMR_PULSE(1,0,10),
- AMR_PULSE(2,0,10), AMR_PULSE(3,0,10), AMR_PULSE(0,0, 0), AMR_PULSE(1,0, 0),
- AMR_PULSE(2,0, 0), AMR_PULSE(3,0, 0), AMR_PULSE(0,0, 1), AMR_PULSE(1,0, 1),
- AMR_PULSE(2,0, 1), AMR_PULSE(3,0, 1), AMR_PULSE(0,0, 3), AMR_PULSE(1,0, 3),
- AMR_PULSE(2,0, 3), AMR_PULSE(3,0, 3), AMR_PULSE(0,0, 4), AMR_PULSE(1,0, 4),
- AMR_PULSE(2,0, 4), AMR_PULSE(3,0, 4), AMR_PULSE(0,0, 7), AMR_PULSE(1,0, 7),
- AMR_PULSE(2,0, 7), AMR_PULSE(3,0, 7), AMR_PULSE(0,0, 8), AMR_PULSE(1,0, 8),
- AMR_PULSE(2,0, 8), AMR_PULSE(3,0, 8)
+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
 };
 
-static const AMROrder order_MODE_7k4[148] = {
- AMR_LSF  (  0, 7), AMR_LSF  (  0, 6), AMR_LSF  (  0, 5), AMR_LSF  (  0, 4),
- AMR_LSF  (  0, 3), AMR_LSF  (  0, 2), AMR_LSF  (  0, 1), AMR_LSF  (  0, 0),
- AMR_LSF  (  1, 8), AMR_LSF  (  1, 7), AMR_LSF  (  1, 6), AMR_LSF  (  1, 5),
- AMR_LSF  (  1, 4), AMR_LSF  (  1, 3), AMR_LSF  (  1, 2), AMR_LSF  (  1, 1),
- AMR_LSF  (  1, 0), AMR_PLAG (0,   7), AMR_PLAG (2,   7), AMR_PLAG (0,   6),
- AMR_PLAG (2,   6), AMR_PLAG (0,   5), AMR_PLAG (2,   5), AMR_PLAG (0,   4),
- AMR_PLAG (2,   4), AMR_PLAG (0,   3), AMR_PLAG (2,   3), AMR_PGAIN(0,   6),
- AMR_PGAIN(1,   6), AMR_PGAIN(2,   6), AMR_PGAIN(3,   6), AMR_PGAIN(0,   5),
- AMR_PGAIN(1,   5), AMR_PGAIN(2,   5), AMR_PGAIN(3,   5), AMR_PGAIN(0,   3),
- AMR_PGAIN(1,   3), AMR_PGAIN(2,   3), AMR_PGAIN(3,   3), AMR_PGAIN(0,   2),
- AMR_PGAIN(1,   2), AMR_PGAIN(2,   2), AMR_PGAIN(3,   2), AMR_PLAG (1,   4),
- AMR_PLAG (3,   4), AMR_PLAG (1,   3), AMR_PLAG (3,   3), AMR_LSF  (  2, 4),
- AMR_LSF  (  2, 3), AMR_LSF  (  2, 2), AMR_LSF  (  2, 8), AMR_LSF  (  2, 7),
- AMR_LSF  (  2, 6), AMR_PLAG (0,   2), AMR_PLAG (1,   2), AMR_PLAG (2,   2),
- AMR_PLAG (3,   2), AMR_PGAIN(0,   1), AMR_PGAIN(1,   1), AMR_PGAIN(2,   1),
- AMR_PGAIN(3,   1), AMR_LSF  (  2, 5), AMR_LSF  (  2, 1), AMR_LSF  (  2, 0),
- AMR_PULSE(0,1, 0), AMR_PULSE(1,1, 0), AMR_PULSE(2,1, 0), AMR_PULSE(3,1, 0),
- AMR_PGAIN(0,   0), AMR_PGAIN(1,   0), AMR_PGAIN(2,   0), AMR_PGAIN(3,   0),
- AMR_PULSE(0,1, 1), AMR_PULSE(1,1, 1), AMR_PULSE(2,1, 1), AMR_PULSE(3,1, 1),
- AMR_PULSE(0,1, 2), AMR_PULSE(1,1, 2), AMR_PGAIN(0,   4), AMR_PGAIN(1,   4),
- AMR_PGAIN(2,   4), AMR_PGAIN(3,   4), AMR_PULSE(2,1, 2), AMR_PULSE(3,1, 2),
- AMR_PULSE(0,1, 3), AMR_PULSE(1,1, 3), AMR_PULSE(2,1, 3), AMR_PULSE(3,1, 3),
- AMR_PLAG (0,   1), AMR_PLAG (0,   0), AMR_PLAG (1,   1), AMR_PLAG (1,   0),
- AMR_PLAG (2,   1), AMR_PLAG (2,   0), AMR_PLAG (3,   1), AMR_PLAG (3,   0),
- AMR_PULSE(0,0, 5), AMR_PULSE(0,0, 4), AMR_PULSE(0,0, 3), AMR_PULSE(0,0, 2),
- AMR_PULSE(0,0, 1), AMR_PULSE(0,0, 0), AMR_PULSE(1,0, 5), AMR_PULSE(1,0, 4),
- AMR_PULSE(1,0, 3), AMR_PULSE(1,0, 2), AMR_PULSE(1,0, 1), AMR_PULSE(1,0, 0),
- AMR_PULSE(2,0, 5), AMR_PULSE(2,0, 4), AMR_PULSE(2,0, 3), AMR_PULSE(2,0, 2),
- AMR_PULSE(2,0, 1), AMR_PULSE(2,0, 0), AMR_PULSE(3,0, 5), AMR_PULSE(3,0, 4),
- AMR_PULSE(3,0, 3), AMR_PULSE(3,0, 2), AMR_PULSE(3,0, 1), AMR_PULSE(3,0, 0),
- AMR_PULSE(0,0,12), AMR_PULSE(1,0,12), AMR_PULSE(2,0,12), AMR_PULSE(3,0,12),
- AMR_PULSE(0,0,11), AMR_PULSE(1,0,11), AMR_PULSE(2,0,11), AMR_PULSE(3,0,11),
- AMR_PULSE(0,0,10), AMR_PULSE(1,0,10), AMR_PULSE(2,0,10), AMR_PULSE(3,0,10),
- AMR_PULSE(0,0, 9), AMR_PULSE(1,0, 9), AMR_PULSE(2,0, 9), AMR_PULSE(3,0, 9),
- AMR_PULSE(0,0, 8), AMR_PULSE(1,0, 8), AMR_PULSE(2,0, 8), AMR_PULSE(3,0, 8),
- AMR_PULSE(0,0, 7), AMR_PULSE(1,0, 7), AMR_PULSE(2,0, 7), AMR_PULSE(3,0, 7),
- AMR_PULSE(0,0, 6), AMR_PULSE(1,0, 6), AMR_PULSE(2,0, 6), AMR_PULSE(3,0, 6)
+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
 };
 
-static const AMROrder order_MODE_7k95[159] = {
- AMR_LSF  (  0, 0), AMR_LSF  (  0, 1), AMR_LSF  (  0, 2), AMR_LSF  (  0, 3),
- AMR_LSF  (  0, 4), AMR_LSF  (  0, 5), AMR_LSF  (  0, 6), AMR_LSF  (  1, 3),
- AMR_LSF  (  1, 1), AMR_LSF  (  1, 8), AMR_LSF  (  1, 7), AMR_LSF  (  1, 5),
- AMR_LSF  (  1, 4), AMR_LSF  (  1, 2), AMR_LSF  (  1, 6), AMR_LSF  (  1, 0),
- AMR_LSF  (  2, 6), AMR_LSF  (  2, 4), AMR_LSF  (  2, 2), AMR_LSF  (  2, 3),
- AMR_LSF  (  2, 7), AMR_LSF  (  2, 8), AMR_LSF  (  2, 5), AMR_FGAIN(0,   4),
- AMR_FGAIN(1,   4), AMR_FGAIN(2,   4), AMR_FGAIN(3,   4), AMR_FGAIN(0,   3),
- AMR_FGAIN(1,   3), AMR_FGAIN(2,   3), AMR_FGAIN(3,   3), AMR_FGAIN(0,   2),
- AMR_FGAIN(1,   2), AMR_FGAIN(2,   2), AMR_FGAIN(3,   2), AMR_PGAIN(0,   3),
- AMR_PGAIN(1,   3), AMR_PGAIN(2,   3), AMR_PGAIN(3,   3), AMR_PGAIN(0,   2),
- AMR_PGAIN(1,   2), AMR_PGAIN(2,   2), AMR_PGAIN(3,   2), AMR_PLAG (0,   7),
- AMR_PLAG (2,   7), AMR_PLAG (0,   6), AMR_PLAG (2,   6), AMR_PLAG (0,   5),
- AMR_PLAG (2,   5), AMR_PLAG (0,   4), AMR_PLAG (2,   4), AMR_PLAG (0,   3),
- AMR_PLAG (2,   3), AMR_PLAG (1,   5), AMR_PLAG (3,   5), AMR_PLAG (1,   4),
- AMR_PLAG (3,   4), AMR_PLAG (1,   3), AMR_PLAG (3,   3), AMR_FGAIN(0,   1),
- AMR_FGAIN(1,   1), AMR_FGAIN(2,   1), AMR_FGAIN(3,   1), AMR_PLAG (0,   2),
- AMR_PLAG (2,   2), AMR_PLAG (1,   2), AMR_PLAG (3,   2), AMR_LSF  (  0, 7),
- AMR_LSF  (  0, 8), AMR_LSF  (  2, 1), AMR_LSF  (  2, 0), AMR_PLAG (0,   1),
- AMR_PLAG (2,   1), AMR_PLAG (0,   0), AMR_PLAG (2,   0), AMR_PLAG (1,   1),
- AMR_PLAG (3,   1), AMR_PLAG (1,   0), AMR_PLAG (3,   0), AMR_PGAIN(0,   1),
- AMR_PGAIN(1,   1), AMR_PGAIN(2,   1), AMR_PGAIN(3,   1), AMR_FGAIN(0,   0),
- AMR_FGAIN(1,   0), AMR_FGAIN(2,   0), AMR_FGAIN(3,   0), AMR_PGAIN(0,   0),
- AMR_PGAIN(1,   0), AMR_PGAIN(2,   0), AMR_PGAIN(3,   0), AMR_PULSE(2,1, 0),
- AMR_PULSE(2,1, 1), AMR_PULSE(2,1, 2), AMR_PULSE(0,0, 1), AMR_PULSE(1,0, 1),
- AMR_PULSE(2,0, 1), AMR_PULSE(3,0, 1), AMR_PULSE(0,0, 4), AMR_PULSE(1,0, 4),
- AMR_PULSE(2,0, 4), AMR_PULSE(3,0, 4), AMR_PULSE(0,0, 7), AMR_PULSE(1,0, 7),
- AMR_PULSE(2,0, 7), AMR_PULSE(3,0, 7), AMR_PULSE(0,0,11), AMR_PULSE(1,0,11),
- AMR_PULSE(2,0,11), AMR_PULSE(3,0,11), AMR_PULSE(2,1, 3), AMR_PULSE(3,1, 0),
- AMR_PULSE(3,1, 1), AMR_PULSE(3,1, 2), AMR_PULSE(3,1, 3), AMR_PULSE(1,1, 0),
- AMR_PULSE(1,1, 1), AMR_PULSE(1,1, 2), AMR_PULSE(1,1, 3), AMR_PULSE(0,1, 0),
- AMR_PULSE(0,1, 1), AMR_PULSE(0,1, 2), AMR_PULSE(0,1, 3), AMR_PULSE(0,0, 0),
- AMR_PULSE(0,0, 2), AMR_PULSE(0,0, 3), AMR_PULSE(0,0, 5), AMR_PULSE(0,0, 8),
- AMR_PULSE(0,0,12), AMR_PULSE(1,0, 0), AMR_PULSE(1,0, 2), AMR_PULSE(1,0, 3),
- AMR_PULSE(1,0, 5), AMR_PULSE(1,0, 8), AMR_PULSE(1,0,12), AMR_PULSE(2,0, 0),
- AMR_PULSE(2,0, 2), AMR_PULSE(2,0, 3), AMR_PULSE(2,0, 5), AMR_PULSE(2,0, 8),
- AMR_PULSE(2,0,12), AMR_PULSE(3,0, 0), AMR_PULSE(3,0, 2), AMR_PULSE(3,0, 3),
- AMR_PULSE(3,0, 5), AMR_PULSE(3,0, 8), AMR_PULSE(3,0,12), AMR_PULSE(0,0, 6),
- AMR_PULSE(1,0, 6), AMR_PULSE(2,0, 6), AMR_PULSE(3,0, 6), AMR_PULSE(0,0,10),
- AMR_PULSE(1,0,10), AMR_PULSE(2,0,10), AMR_PULSE(3,0,10), AMR_PULSE(0,0, 9),
- AMR_PULSE(1,0, 9), AMR_PULSE(2,0, 9), AMR_PULSE(3,0, 9)
+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
 };
 
-static const AMROrder order_MODE_10k2[204] = {
- AMR_LSF  (  0, 0), AMR_LSF  (  0, 1), AMR_LSF  (  0, 2), AMR_LSF  (  0, 3),
- AMR_LSF  (  0, 4), AMR_LSF  (  0, 5), AMR_LSF  (  0, 6), AMR_LSF  (  0, 7),
- AMR_LSF  (  1, 0), AMR_LSF  (  1, 1), AMR_LSF  (  1, 2), AMR_LSF  (  1, 3),
- AMR_LSF  (  1, 4), AMR_LSF  (  1, 5), AMR_LSF  (  1, 6), AMR_LSF  (  1, 7),
- AMR_LSF  (  1, 8), AMR_PLAG (0,   7), AMR_PLAG (0,   6), AMR_PLAG (0,   5),
- AMR_PLAG (0,   4), AMR_PLAG (0,   3), AMR_PLAG (0,   2), AMR_PLAG (2,   7),
- AMR_PLAG (2,   6), AMR_PLAG (2,   5), AMR_PLAG (2,   4), AMR_PLAG (2,   3),
- AMR_PLAG (2,   2), AMR_PLAG (1,   4), AMR_PLAG (1,   3), AMR_PLAG (3,   4),
- AMR_PLAG (3,   3), AMR_PGAIN(0,   6), AMR_PGAIN(0,   3), AMR_PGAIN(0,   2),
- AMR_PGAIN(1,   6), AMR_PGAIN(1,   3), AMR_PGAIN(1,   2), AMR_PGAIN(2,   6),
- AMR_PGAIN(2,   3), AMR_PGAIN(2,   2), AMR_PGAIN(3,   6), AMR_PGAIN(3,   3),
- AMR_PGAIN(3,   2), AMR_PLAG (0,   1), AMR_PLAG (0,   0), AMR_PLAG (2,   1),
- AMR_PLAG (2,   0), AMR_PLAG (1,   2), AMR_PLAG (1,   1), AMR_PLAG (3,   2),
- AMR_PLAG (3,   1), AMR_PGAIN(0,   5), AMR_PGAIN(1,   5), AMR_PGAIN(2,   5),
- AMR_PGAIN(3,   5), AMR_LSF  (  2, 6), AMR_LSF  (  2, 2), AMR_LSF  (  2, 4),
- AMR_LSF  (  2, 3), AMR_LSF  (  2, 7), AMR_LSF  (  2, 8), AMR_LSF  (  2, 5),
- AMR_LSF  (  2, 1), AMR_LSF  (  2, 0), AMR_PULSE(0,3, 0), AMR_PULSE(0,2, 0),
- AMR_PULSE(0,1, 0), AMR_PULSE(0,0, 0), AMR_PULSE(1,3, 0), AMR_PULSE(1,2, 0),
- AMR_PULSE(1,1, 0), AMR_PULSE(1,0, 0), AMR_PULSE(2,3, 0), AMR_PULSE(2,2, 0),
- AMR_PULSE(2,1, 0), AMR_PULSE(2,0, 0), AMR_PULSE(3,3, 0), AMR_PULSE(3,2, 0),
- AMR_PULSE(3,1, 0), AMR_PULSE(3,0, 0), AMR_PGAIN(0,   1), AMR_PGAIN(0,   4),
- AMR_PGAIN(0,   0), AMR_PGAIN(1,   1), AMR_PGAIN(1,   4), AMR_PGAIN(1,   0),
- AMR_PGAIN(2,   1), AMR_PGAIN(2,   4), AMR_PGAIN(2,   0), AMR_PGAIN(3,   1),
- AMR_PGAIN(3,   4), AMR_PGAIN(3,   0), AMR_PLAG (1,   0), AMR_PLAG (3,   0),
- AMR_PULSE(1,4, 9), AMR_PULSE(1,4, 8), AMR_PULSE(1,5, 8), AMR_PULSE(1,5, 9),
- AMR_PULSE(1,5, 7), AMR_PULSE(1,4, 7), AMR_PULSE(1,5, 5), AMR_PULSE(1,4, 5),
- AMR_PULSE(1,4, 6), AMR_PULSE(1,5, 6), AMR_PULSE(1,6, 6), AMR_PULSE(1,6, 5),
- AMR_PULSE(1,5, 4), AMR_PULSE(1,6, 3), AMR_PULSE(1,4, 4), AMR_PULSE(1,6, 4),
- AMR_PULSE(1,4, 3), AMR_PULSE(1,5, 3), AMR_PULSE(2,4, 9), AMR_PULSE(2,4, 8),
- AMR_PULSE(2,5, 8), AMR_PULSE(2,5, 9), AMR_PULSE(2,5, 7), AMR_PULSE(2,4, 7),
- AMR_PULSE(2,5, 5), AMR_PULSE(2,4, 5), AMR_PULSE(2,4, 6), AMR_PULSE(2,5, 6),
- AMR_PULSE(2,6, 6), AMR_PULSE(2,6, 5), AMR_PULSE(2,5, 4), AMR_PULSE(2,6, 3),
- AMR_PULSE(2,4, 4), AMR_PULSE(2,6, 4), AMR_PULSE(2,4, 3), AMR_PULSE(2,5, 3),
- AMR_PULSE(3,4, 9), AMR_PULSE(3,4, 8), AMR_PULSE(3,5, 8), AMR_PULSE(3,5, 9),
- AMR_PULSE(3,5, 7), AMR_PULSE(3,4, 7), AMR_PULSE(3,5, 5), AMR_PULSE(3,4, 5),
- AMR_PULSE(3,4, 6), AMR_PULSE(3,5, 6), AMR_PULSE(3,6, 6), AMR_PULSE(3,6, 5),
- AMR_PULSE(3,5, 4), AMR_PULSE(3,6, 3), AMR_PULSE(3,4, 4), AMR_PULSE(3,6, 4),
- AMR_PULSE(3,4, 3), AMR_PULSE(3,5, 3), AMR_PULSE(0,4, 9), AMR_PULSE(0,4, 8),
- AMR_PULSE(0,5, 8), AMR_PULSE(0,5, 9), AMR_PULSE(0,5, 7), AMR_PULSE(0,4, 7),
- AMR_PULSE(0,5, 5), AMR_PULSE(0,4, 5), AMR_PULSE(0,4, 6), AMR_PULSE(0,5, 6),
- AMR_PULSE(0,6, 6), AMR_PULSE(0,6, 5), AMR_PULSE(0,5, 4), AMR_PULSE(0,6, 3),
- AMR_PULSE(0,4, 4), AMR_PULSE(0,6, 4), AMR_PULSE(0,4, 3), AMR_PULSE(0,5, 3),
- AMR_PULSE(3,6, 2), AMR_PULSE(3,4, 0), AMR_PULSE(3,5, 0), AMR_PULSE(3,6, 0),
- AMR_PULSE(3,4, 2), AMR_PULSE(3,6, 1), AMR_PULSE(3,4, 1), AMR_PULSE(3,5, 2),
- AMR_PULSE(3,5, 1), AMR_PULSE(2,6, 2), AMR_PULSE(2,4, 0), AMR_PULSE(2,5, 0),
- AMR_PULSE(2,6, 0), AMR_PULSE(2,4, 2), AMR_PULSE(2,6, 1), AMR_PULSE(2,4, 1),
- AMR_PULSE(2,5, 2), AMR_PULSE(2,5, 1), AMR_PULSE(1,6, 2), AMR_PULSE(1,4, 0),
- AMR_PULSE(1,5, 0), AMR_PULSE(1,6, 0), AMR_PULSE(1,4, 2), AMR_PULSE(1,6, 1),
- AMR_PULSE(1,4, 1), AMR_PULSE(1,5, 2), AMR_PULSE(1,5, 1), AMR_PULSE(0,6, 2),
- AMR_PULSE(0,4, 0), AMR_PULSE(0,5, 0), AMR_PULSE(0,6, 0), AMR_PULSE(0,4, 2),
- AMR_PULSE(0,6, 1), AMR_PULSE(0,4, 1), AMR_PULSE(0,5, 2), AMR_PULSE(0,5, 1)
+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
 };
 
-static const AMROrder order_MODE_12k2[244] = {
- AMR_LSF  (  0, 6), AMR_LSF  (  0, 5), AMR_LSF  (  0, 4), AMR_LSF  (  0, 3),
- AMR_LSF  (  0, 2), AMR_LSF  (  0, 1), AMR_LSF  (  0, 0), AMR_LSF  (  1, 7),
- AMR_LSF  (  1, 6), AMR_LSF  (  1, 5), AMR_LSF  (  1, 4), AMR_LSF  (  1, 3),
- AMR_LSF  (  1, 2), AMR_LSF  (  1, 1), AMR_LSF  (  1, 0), AMR_LSF  (  2, 0),
- AMR_LSF  (  2, 8), AMR_LSF  (  2, 7), AMR_LSF  (  2, 6), AMR_LSF  (  2, 5),
- AMR_LSF  (  2, 4), AMR_LSF  (  2, 3), AMR_LSF  (  2, 2), AMR_LSF  (  2, 1),
- AMR_LSF  (  3, 7), AMR_LSF  (  3, 6), AMR_LSF  (  3, 5), AMR_LSF  (  3, 4),
- AMR_LSF  (  3, 3), AMR_PLAG (0,   8), AMR_PLAG (2,   8), AMR_PLAG (0,   7),
- AMR_PLAG (2,   7), AMR_PLAG (0,   6), AMR_PLAG (2,   6), AMR_PLAG (0,   5),
- AMR_PLAG (2,   5), AMR_PLAG (0,   4), AMR_PLAG (2,   4), AMR_PLAG (0,   3),
- AMR_PLAG (2,   3), AMR_PLAG (0,   2), AMR_PLAG (2,   2), AMR_PLAG (0,   1),
- AMR_PLAG (2,   1), AMR_PLAG (0,   0), AMR_PLAG (2,   0), AMR_PGAIN(0,   3),
- AMR_PGAIN(1,   3), AMR_PGAIN(2,   3), AMR_PGAIN(3,   3), AMR_PGAIN(0,   2),
- AMR_PGAIN(1,   2), AMR_PGAIN(2,   2), AMR_PGAIN(3,   2), AMR_PGAIN(0,   1),
- AMR_PGAIN(1,   1), AMR_PGAIN(2,   1), AMR_PGAIN(3,   1), AMR_FGAIN(0,   4),
- AMR_FGAIN(1,   4), AMR_FGAIN(2,   4), AMR_FGAIN(3,   4), AMR_FGAIN(0,   3),
- AMR_FGAIN(1,   3), AMR_FGAIN(2,   3), AMR_FGAIN(3,   3), AMR_FGAIN(0,   2),
- AMR_FGAIN(1,   2), AMR_FGAIN(2,   2), AMR_FGAIN(3,   2), AMR_PLAG (1,   5),
- AMR_PLAG (3,   5), AMR_PLAG (1,   4), AMR_PLAG (3,   4), AMR_PLAG (1,   3),
- AMR_PLAG (3,   3), AMR_PLAG (1,   2), AMR_PLAG (3,   2), AMR_PLAG (1,   1),
- AMR_PLAG (3,   1), AMR_LSF  (  3, 2), AMR_LSF  (  3, 1), AMR_LSF  (  3, 0),
- AMR_LSF  (  4, 5), AMR_LSF  (  4, 4), AMR_LSF  (  4, 3), AMR_LSF  (  4, 2),
- AMR_PGAIN(0,   0), AMR_PGAIN(1,   0), AMR_PGAIN(2,   0), AMR_PGAIN(3,   0),
- AMR_FGAIN(0,   1), AMR_FGAIN(1,   1), AMR_FGAIN(2,   1), AMR_FGAIN(3,   1),
- AMR_PULSE(0,1, 3), AMR_PULSE(1,1, 3), AMR_PULSE(2,1, 3), AMR_PULSE(3,1, 3),
- AMR_PULSE(0,3, 3), AMR_PULSE(1,3, 3), AMR_PULSE(2,3, 3), AMR_PULSE(3,3, 3),
- AMR_FGAIN(0,   0), AMR_FGAIN(1,   0), AMR_FGAIN(2,   0), AMR_FGAIN(3,   0),
- AMR_PULSE(0,5, 3), AMR_PULSE(1,5, 3), AMR_PULSE(2,5, 3), AMR_PULSE(3,5, 3),
- AMR_PULSE(0,7, 3), AMR_PULSE(1,7, 3), AMR_PULSE(2,7, 3), AMR_PULSE(3,7, 3),
- AMR_PULSE(0,9, 3), AMR_PULSE(1,9, 3), AMR_PULSE(2,9, 3), AMR_PULSE(3,9, 3),
- AMR_LSF  (  4, 1), AMR_LSF  (  4, 0), AMR_PULSE(0,1, 0), AMR_PULSE(0,1, 1),
- AMR_PULSE(0,1, 2), AMR_PULSE(0,3, 0), AMR_PULSE(0,3, 1), AMR_PULSE(0,3, 2),
- AMR_PULSE(0,5, 0), AMR_PULSE(0,5, 1), AMR_PULSE(0,5, 2), AMR_PULSE(0,7, 0),
- AMR_PULSE(0,7, 1), AMR_PULSE(0,7, 2), AMR_PULSE(0,9, 0), AMR_PULSE(0,9, 1),
- AMR_PULSE(0,9, 2), AMR_PULSE(1,1, 0), AMR_PULSE(1,1, 1), AMR_PULSE(1,1, 2),
- AMR_PULSE(1,3, 0), AMR_PULSE(1,3, 1), AMR_PULSE(1,3, 2), AMR_PULSE(1,5, 0),
- AMR_PULSE(1,5, 1), AMR_PULSE(1,5, 2), AMR_PULSE(1,7, 0), AMR_PULSE(1,7, 1),
- AMR_PULSE(1,7, 2), AMR_PULSE(1,9, 0), AMR_PULSE(1,9, 1), AMR_PULSE(1,9, 2),
- AMR_PULSE(2,1, 0), AMR_PULSE(2,1, 1), AMR_PULSE(2,1, 2), AMR_PULSE(2,3, 0),
- AMR_PULSE(2,3, 1), AMR_PULSE(2,3, 2), AMR_PULSE(2,5, 0), AMR_PULSE(2,5, 1),
- AMR_PULSE(2,5, 2), AMR_PULSE(2,7, 0), AMR_PULSE(2,7, 1), AMR_PULSE(2,7, 2),
- AMR_PULSE(2,9, 0), AMR_PULSE(2,9, 1), AMR_PULSE(2,9, 2), AMR_PULSE(3,1, 0),
- AMR_PULSE(3,1, 1), AMR_PULSE(3,1, 2), AMR_PULSE(3,3, 0), AMR_PULSE(3,3, 1),
- AMR_PULSE(3,3, 2), AMR_PULSE(3,5, 0), AMR_PULSE(3,5, 1), AMR_PULSE(3,5, 2),
- AMR_PULSE(3,7, 0), AMR_PULSE(3,7, 1), AMR_PULSE(3,7, 2), AMR_PULSE(3,9, 0),
- AMR_PULSE(3,9, 1), AMR_PULSE(3,9, 2), AMR_PULSE(0,0, 0), AMR_PULSE(0,0, 1),
- AMR_PULSE(0,0, 2), AMR_PULSE(0,2, 0), AMR_PULSE(0,2, 1), AMR_PULSE(0,2, 2),
- AMR_PULSE(0,4, 0), AMR_PULSE(0,4, 1), AMR_PULSE(0,4, 2), AMR_PULSE(0,6, 0),
- AMR_PULSE(0,6, 1), AMR_PULSE(0,6, 2), AMR_PULSE(0,8, 0), AMR_PULSE(0,8, 1),
- AMR_PULSE(0,8, 2), AMR_PULSE(1,0, 0), AMR_PULSE(1,0, 1), AMR_PULSE(1,0, 2),
- AMR_PULSE(1,2, 0), AMR_PULSE(1,2, 1), AMR_PULSE(1,2, 2), AMR_PULSE(1,4, 0),
- AMR_PULSE(1,4, 1), AMR_PULSE(1,4, 2), AMR_PULSE(1,6, 0), AMR_PULSE(1,6, 1),
- AMR_PULSE(1,6, 2), AMR_PULSE(1,8, 0), AMR_PULSE(1,8, 1), AMR_PULSE(1,8, 2),
- AMR_PULSE(2,0, 0), AMR_PULSE(2,0, 1), AMR_PULSE(2,0, 2), AMR_PULSE(2,2, 0),
- AMR_PULSE(2,2, 1), AMR_PULSE(2,2, 2), AMR_PULSE(2,4, 0), AMR_PULSE(2,4, 1),
- AMR_PULSE(2,4, 2), AMR_PULSE(2,6, 0), AMR_PULSE(2,6, 1), AMR_PULSE(2,6, 2),
- AMR_PULSE(2,8, 0), AMR_PULSE(2,8, 1), AMR_PULSE(2,8, 2), AMR_PULSE(3,0, 0),
- AMR_PULSE(3,0, 1), AMR_PULSE(3,0, 2), AMR_PULSE(3,2, 0), AMR_PULSE(3,2, 1),
- AMR_PULSE(3,2, 2), AMR_PULSE(3,4, 0), AMR_PULSE(3,4, 1), AMR_PULSE(3,4, 2),
- AMR_PULSE(3,6, 0), AMR_PULSE(3,6, 1), AMR_PULSE(3,6, 2), AMR_PULSE(3,8, 0),
- AMR_PULSE(3,8, 1), AMR_PULSE(3,8, 2), AMR_PLAG (1,   0), AMR_PLAG (3,   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
 };
 
-static const AMROrder order_MODE_DTX[35] = {
- AMR_SVECTOR(   2), AMR_SVECTOR(   1), AMR_SVECTOR(   0),
- AMR_LSF  (  0, 7), AMR_LSF  (  0, 6), AMR_LSF  (  0, 5), AMR_LSF  (  0, 4),
- AMR_LSF  (  0, 3), AMR_LSF  (  0, 2), AMR_LSF  (  0, 1), AMR_LSF  (  0, 0),
- AMR_LSF  (  1, 8), AMR_LSF  (  1, 7), AMR_LSF  (  1, 6), AMR_LSF  (  1, 5),
- AMR_LSF  (  1, 4), AMR_LSF  (  1, 3), AMR_LSF  (  1, 2), AMR_LSF  (  1, 1),
- AMR_LSF  (  1, 0), AMR_LSF  (  2, 8), AMR_LSF  (  2, 7), AMR_LSF  (  2, 6),
- AMR_LSF  (  2, 5), AMR_LSF  (  2, 4), AMR_LSF  (  2, 3), AMR_LSF  (  2, 2),
- AMR_LSF  (  2, 1), AMR_LSF  (  2, 0),
- AMR_SENERGY(   5), AMR_SENERGY(   4), AMR_SENERGY(   3),
- AMR_SENERGY(   2), AMR_SENERGY(   1), AMR_SENERGY(   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
 };
 
 /**
  * position of the bitmapping data for each packet type in
  * the AMRNBFrame
  */
-static const AMROrder * const amr_unpacking_bitmaps_per_mode[9] = {
+static const uint8_t * const amr_unpacking_bitmaps_per_mode[9] = {
     order_MODE_4k75,
     order_MODE_5k15,
     order_MODE_5k9,
@@ -476,15 +366,7 @@ static const AMROrder * const amr_unpack
 
 /** number of bits for each mode */
 static const uint8_t mode_bits[N_MODES] = {
-    FF_ARRAY_ELEMS(order_MODE_4k75),
-    FF_ARRAY_ELEMS(order_MODE_5k15),
-    FF_ARRAY_ELEMS(order_MODE_5k9),
-    FF_ARRAY_ELEMS(order_MODE_6k7),
-    FF_ARRAY_ELEMS(order_MODE_7k4),
-    FF_ARRAY_ELEMS(order_MODE_7k95),
-    FF_ARRAY_ELEMS(order_MODE_10k2),
-    FF_ARRAY_ELEMS(order_MODE_12k2),
-    FF_ARRAY_ELEMS(order_MODE_DTX)
+    95, 103, 118, 134, 148, 159, 204, 244, 35
 };
 
 

Modified: amr/amrnbdec.c
==============================================================================
--- amr/amrnbdec.c	Fri Jan  8 18:13:05 2010	(r5569)
+++ amr/amrnbdec.c	Fri Jan  8 18:16:25 2010	(r5570)
@@ -160,12 +160,22 @@ static enum Mode unpack_bitstream(AMRCon
 
     if (mode <= MODE_DTX) {
         uint16_t *data = (uint16_t *)&p->frame;
-        const AMROrder *order = amr_unpacking_bitmaps_per_mode[mode];
-        int i;
+        const uint8_t *order = amr_unpacking_bitmaps_per_mode[mode];
+        int field_header; // 16 * relative field index + number of field bits
 
         memset(&p->frame, 0, sizeof(AMRNBFrame));
-        for (i = 0; i < mode_bits[mode]; i++)
-            data[order[i].index] += get_bits1(&gb) << order[i].bit;
+        buf++;
+        while ((field_header = *order++)) {
+            int field = 0;
+            data += field_header >> 4;
+            field_header &= 0xf;
+            while (field_header--) {
+               int bit = *order++;
+               field <<= 1;
+               field |= buf[bit >> 3] >> (bit & 7) & 1;
+            }
+            *data = field;
+        }
     }
 
     return mode;


More information about the FFmpeg-soc mailing list