extern const int qzbin_factors[129];
extern void vp8cx_init_quantizer(VP8_COMP *cpi);
extern const int vp8cx_base_skip_false_prob[128];
-#if !CONFIG_EXTEND_QRANGE
+
// Tables relating active max Q to active min Q
-static const int kf_low_motion_minq[QINDEX_RANGE] =
-{
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,
- 3,3,3,3,3,3,4,4,4,5,5,5,5,5,6,6,
- 6,6,7,7,8,8,8,8,9,9,10,10,10,10,11,11,
- 11,11,12,12,13,13,13,13,14,14,15,15,15,15,16,16,
- 16,16,17,17,18,18,18,18,19,20,20,21,21,22,23,23
-};
-static const int kf_high_motion_minq[QINDEX_RANGE] =
-{
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
- 1,1,1,1,1,1,1,1,2,2,2,2,3,3,3,3,
- 3,3,3,3,4,4,4,4,5,5,5,5,5,5,6,6,
- 6,6,7,7,8,8,8,8,9,9,10,10,10,10,11,11,
- 11,11,12,12,13,13,13,13,14,14,15,15,15,15,16,16,
- 16,16,17,17,18,18,18,18,19,19,20,20,20,20,21,21,
- 21,21,22,22,23,23,24,25,25,26,26,27,28,28,29,30
-};
-static const int gf_low_motion_minq[QINDEX_RANGE] =
-{
- 0,0,0,0,1,1,1,1,1,1,1,1,2,2,2,2,
- 3,3,3,3,4,4,4,4,5,5,5,5,6,6,6,6,
- 7,7,7,7,8,8,8,8,9,9,9,9,10,10,10,10,
- 11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,18,
- 19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,
- 27,27,28,28,29,29,30,30,31,31,32,32,33,33,34,34,
- 35,35,36,36,37,37,38,38,39,39,40,40,41,41,42,42,
- 43,44,45,46,47,48,49,50,51,52,53,54,55,56,57,58
-};
-static const int gf_mid_motion_minq[QINDEX_RANGE] =
-{
- 0,0,0,0,1,1,1,1,1,1,2,2,3,3,3,4,
- 4,4,5,5,5,6,6,6,7,7,7,8,8,8,9,9,
- 9,10,10,10,10,11,11,11,12,12,12,12,13,13,13,14,
- 14,14,15,15,16,16,17,17,18,18,19,19,20,20,21,21,
- 22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,
- 30,30,31,31,32,32,33,33,34,34,35,35,36,36,37,37,
- 38,39,39,40,40,41,41,42,42,43,43,44,45,46,47,48,
- 49,50,51,52,53,54,55,56,57,58,59,60,61,62,63,64
-};
-static const int gf_high_motion_minq[QINDEX_RANGE] =
+static int kf_low_motion_minq[QINDEX_RANGE];
+static int kf_high_motion_minq[QINDEX_RANGE];
+static int gf_low_motion_minq[QINDEX_RANGE];
+static int gf_mid_motion_minq[QINDEX_RANGE];
+static int gf_high_motion_minq[QINDEX_RANGE];
+static int inter_minq[QINDEX_RANGE];
+
+// Functions to compute the active minq lookup table entries based on a
+// formulaic approach to facilitate easier adjustment of the Q tables.
+// The formulae were derived from computing a 3rd order polynomial best
+// fit to the original data (after plotting real maxq vs minq (not q index))
+int calculate_minq_index( double maxq,
+ double x3, double x2, double x, double c )
{
- 0,0,0,0,1,1,1,1,1,2,2,2,3,3,3,4,
- 4,4,5,5,5,6,6,6,7,7,7,8,8,8,9,9,
- 9,10,10,10,11,11,12,12,13,13,14,14,15,15,16,16,
- 17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,
- 25,25,26,26,27,27,28,28,29,29,30,30,31,31,32,32,
- 33,33,34,34,35,35,36,36,37,37,38,38,39,39,40,40,
- 41,41,42,42,43,44,45,46,47,48,49,50,51,52,53,54,
- 55,56,57,58,59,60,62,64,66,68,70,72,74,76,78,80
-};
-static const int inter_minq[QINDEX_RANGE] =
-{
- 0,0,1,1,2,3,3,4,4,5,6,6,7,8,8,9,
- 9,10,11,11,12,13,13,14,15,15,16,17,17,18,19,20,
- 20,21,22,22,23,24,24,25,26,27,27,28,29,30,30,31,
- 32,33,33,34,35,36,36,37,38,39,39,40,41,42,42,43,
- 44,45,46,46,47,48,49,50,50,51,52,53,54,55,55,56,
- 57,58,59,60,60,61,62,63,64,65,66,67,67,68,69,70,
- 71,72,73,74,75,75,76,77,78,79,80,81,82,83,84,85,
- 86,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100
-};
-#else
-static const int kf_low_motion_minq[QINDEX_RANGE] =
-{
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 3,
- 4, 4, 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8,
- 9, 9, 9, 10,10,11,11,12,12,13,13,14,14,15,15,16,
- 16,17,17,18,18,19,19,20,20,21,21,22,23,23,24,24,
- 25,25,26,27,28,29,30,30,31,32,33,34,35,35,36,36,
- 38,38,39,40,40,41,42,42,43,44,44,45,46,46,47,48,
- 49,49,50,50,51,52,52,53,54,55,56,57,58,59,60,61,
-};
-static const int kf_high_motion_minq[QINDEX_RANGE] =
-{
- 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 2,
- 2, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 5, 5, 5, 5, 6,
- 6, 6, 6, 7, 7, 7, 7, 8, 8, 8, 8, 9, 9, 9,10,10,
- 11,11,12,13,14,15,16,17,18,19,20,21,22,23,24,24,
- 25,26,27,28,28,29,29,30,30,31,31,32,33,33,34,34,
- 35,36,37,38,39,39,40,41,41,42,43,44,45,45,46,46,
- 47,47,48,48,49,49,50,50,51,51,52,52,53,53,54,54,
- 55,55,56,56,57,58,59,60,61,62,63,64,65,67,69,70,
-};
+ int i;
+ double minqtarget;
+ double thisq;
-static const int gf_low_motion_minq[QINDEX_RANGE] =
-{
- 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4,
- 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9, 9,
- 10,10,10,11,11,12,12,13,13,14,14,15,15,16,16,17,
- 17,18,18,19,19,20,21,22,23,24,25,26,27,29,29,30,
- 31,32,33,34,35,36,37,38,39,40,41,41,42,42,43,43,
- 44,44,45,45,46,46,47,47,48,48,49,49,50,50,51,51,
- 52,52,53,53,54,54,55,55,56,56,57,57,58,59,60,61,
- 62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,
-};
-static const int gf_mid_motion_minq[QINDEX_RANGE] =
-{
- 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4,
- 4, 5, 5, 5, 6, 6, 6, 7, 7, 7, 8, 8, 8, 9, 9,10,
- 10,11,11,12,12,13,13,14,14,15,15,16,16,17,17,18,
- 18,19,19,20,20,21,22,23,24,25,26,27,28,29,30,31,
- 32,33,34,35,35,36,36,37,37,38,38,39,39,40,40,41,
- 41,42,42,43,43,44,44,45,45,46,46,47,48,49,50,51,
- 52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,
- 68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,
-};
-static const int gf_high_motion_minq[QINDEX_RANGE] =
-{
- 0, 0, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 3, 3, 3, 4,
- 4, 4, 5, 5, 5, 6, 6, 6, 7, 7, 8, 8, 9, 9,10,10,
- 11,11,12,12,13,14,15,16,17,18,18,19,19,20,20,21,
- 22,23,24,25,26,26,27,28,29,30,31,32,33,34,35,36,
- 37,38,39,39,40,40,40,41,41,41,42,42,43,43,44,44,
- 44,45,45,45,46,46,47,47,47,48,48,48,49,49,49,50,
- 50,50,51,51,52,53,54,54,55,56,57,57,58,59,60,61,
- 62,63,64,66,68,69,72,74,77,80,82,85,87,89,91,93,
-};
+ minqtarget = ( (x3 * maxq * maxq * maxq) +
+ (x2 * maxq * maxq) +
+ (x * maxq) +
+ c );
+
+ if ( minqtarget > maxq )
+ maxq = maxq;
-static const int inter_minq[QINDEX_RANGE] =
+ for ( i = 0; i < QINDEX_RANGE; i++ )
+ {
+ thisq = vp8_convert_qindex_to_q(i);
+ if ( minqtarget <= vp8_convert_qindex_to_q(i) )
+ return i;
+ }
+}
+void init_minq_luts()
{
- 0, 0, 0, 1, 1, 2, 2, 3, 3, 4, 4, 5, 5, 6, 6, 7,
- 8, 9,10,11,12,13,14,15,16,17,18,18,19,19,20,21,
- 21,22,23,23,24,25,26,26,27,28,29,30,31,32,32,33,
- 34,35,36,36,37,38,39,40,40,41,41,42,43,44,44,45,
- 46,46,47,47,48,49,49,50,50,51,52,52,53,54,54,55,
- 55,56,57,57,58,59,60,60,61,62,63,63,64,65,66,67,
- 68,68,69,70,71,72,72,73,74,75,76,77,78,79,80,81,
- 81,82,83,84,85,86,87,88,89,90,90,91,92,93,94,95,
-};
-#endif
+ int i;
+ double maxq;
+
+ for ( i = 0; i < QINDEX_RANGE; i++ )
+ {
+ maxq = vp8_convert_qindex_to_q(i);
+
+ kf_low_motion_minq[i] = calculate_minq_index( maxq,
+ 0.00000006,
+ -0.0000276,
+ 0.098,
+ 0.0 );
+ kf_high_motion_minq[i] = calculate_minq_index( maxq,
+ 0.00000024,
+ -0.000201,
+ 0.154,
+ 0.0 );
+ gf_low_motion_minq[i] = calculate_minq_index( maxq,
+ 0.00000179,
+ -0.000975,
+ 0.355,
+ 0.0 );
+ gf_mid_motion_minq[i] = calculate_minq_index( maxq,
+ 0.00000409,
+ -0.00176,
+ 0.443,
+ 0.0 );
+ gf_high_motion_minq[i] = calculate_minq_index( maxq,
+ 0.00000819,
+ -0.00286,
+ 0.532,
+ 0.0 );
+ inter_minq[i] = calculate_minq_index( maxq,
+ 0.00000271,
+ -0.00113,
+ 0.697,
+ 0.0 );
+
+ }
+}
+
void vp8_initialize()
{
static int init_done = 0;
//vp8_dmachine_specific_config();
vp8_tokenize_initialize();
vp8_init_me_luts();
+ init_minq_luts();
init_done = 1;
}