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

cmcq subversion at mplayerhq.hu
Thu Jan 14 19:30:52 CET 2010


Author: cmcq
Date: Thu Jan 14 19:30:52 2010
New Revision: 5576

Log:
Use a lookup table to avoid (x%5) and (x/5) in pulse decoding

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

Modified: amr/amrnbdata.h
==============================================================================
--- amr/amrnbdata.h	Thu Jan 14 19:28:40 2010	(r5575)
+++ amr/amrnbdata.h	Thu Jan 14 19:30:52 2010	(r5576)
@@ -385,6 +385,33 @@ static const uint8_t mode_bits[N_MODES] 
     95, 103, 118, 134, 148, 159, 204, 244, 35
 };
 
+/**
+ * Base-5 representation for values 0-124
+ *
+ * This is useful for decoding pulse positions in 10.2 kbit/s frames.
+ * Safe values are provided for out of range positions 125-127.
+ */
+static const uint8_t base_five_table[128][3] = {
+ {0, 0, 0}, {0, 0, 1}, {0, 0, 2}, {0, 0, 3}, {0, 0, 4}, {0, 1, 0}, {0, 1, 1},
+ {0, 1, 2}, {0, 1, 3}, {0, 1, 4}, {0, 2, 0}, {0, 2, 1}, {0, 2, 2}, {0, 2, 3},
+ {0, 2, 4}, {0, 3, 0}, {0, 3, 1}, {0, 3, 2}, {0, 3, 3}, {0, 3, 4}, {0, 4, 0},
+ {0, 4, 1}, {0, 4, 2}, {0, 4, 3}, {0, 4, 4}, {1, 0, 0}, {1, 0, 1}, {1, 0, 2},
+ {1, 0, 3}, {1, 0, 4}, {1, 1, 0}, {1, 1, 1}, {1, 1, 2}, {1, 1, 3}, {1, 1, 4},
+ {1, 2, 0}, {1, 2, 1}, {1, 2, 2}, {1, 2, 3}, {1, 2, 4}, {1, 3, 0}, {1, 3, 1},
+ {1, 3, 2}, {1, 3, 3}, {1, 3, 4}, {1, 4, 0}, {1, 4, 1}, {1, 4, 2}, {1, 4, 3},
+ {1, 4, 4}, {2, 0, 0}, {2, 0, 1}, {2, 0, 2}, {2, 0, 3}, {2, 0, 4}, {2, 1, 0},
+ {2, 1, 1}, {2, 1, 2}, {2, 1, 3}, {2, 1, 4}, {2, 2, 0}, {2, 2, 1}, {2, 2, 2},
+ {2, 2, 3}, {2, 2, 4}, {2, 3, 0}, {2, 3, 1}, {2, 3, 2}, {2, 3, 3}, {2, 3, 4},
+ {2, 4, 0}, {2, 4, 1}, {2, 4, 2}, {2, 4, 3}, {2, 4, 4}, {3, 0, 0}, {3, 0, 1},
+ {3, 0, 2}, {3, 0, 3}, {3, 0, 4}, {3, 1, 0}, {3, 1, 1}, {3, 1, 2}, {3, 1, 3},
+ {3, 1, 4}, {3, 2, 0}, {3, 2, 1}, {3, 2, 2}, {3, 2, 3}, {3, 2, 4}, {3, 3, 0},
+ {3, 3, 1}, {3, 3, 2}, {3, 3, 3}, {3, 3, 4}, {3, 4, 0}, {3, 4, 1}, {3, 4, 2},
+ {3, 4, 3}, {3, 4, 4}, {4, 0, 0}, {4, 0, 1}, {4, 0, 2}, {4, 0, 3}, {4, 0, 4},
+ {4, 1, 0}, {4, 1, 1}, {4, 1, 2}, {4, 1, 3}, {4, 1, 4}, {4, 2, 0}, {4, 2, 1},
+ {4, 2, 2}, {4, 2, 3}, {4, 2, 4}, {4, 3, 0}, {4, 3, 1}, {4, 3, 2}, {4, 3, 3},
+ {4, 3, 4}, {4, 4, 0}, {4, 4, 1}, {4, 4, 2}, {4, 4, 3}, {4, 4, 4}, {0, 0, 0},
+ {0, 0, 0}, {0, 0, 0}
+};
 
 /**
  * Values for the lsp vector from the 4th subframe of the

Modified: amr/amrnbdec.c
==============================================================================
--- amr/amrnbdec.c	Thu Jan 14 19:28:40 2010	(r5575)
+++ amr/amrnbdec.c	Thu Jan 14 19:30:52 2010	(r5576)
@@ -405,10 +405,10 @@ static void decode_10bit_pulse(int code,
 {
     // coded using 7+3 bits with the 3 LSBs being, individually, the LSB of 1 of
     // the 3 pulses and the upper 7 bits being coded in base 5
-    int temp = code >> 3;
-    pulse_position[i1] = (( temp       % 5) << 1) + ( code       & 1);
-    pulse_position[i2] = (((temp /  5) % 5) << 1) + ((code >> 1) & 1);
-    pulse_position[i3] = (((temp / 25) % 5) << 1) + ((code >> 2) & 1);
+    const uint8_t *positions = base_five_table[code >> 3];
+    pulse_position[i1] = (positions[2] << 1) + ( code       & 1);
+    pulse_position[i2] = (positions[1] << 1) + ((code >> 1) & 1);
+    pulse_position[i3] = (positions[0] << 1) + ((code >> 2) & 1);
 }
 
 /**


More information about the FFmpeg-soc mailing list