Commit a0b7db22 authored by Paul Wilkins's avatar Paul Wilkins
Browse files

Further resolution of QIndex LUTS;

This commit resolves further QIndex look up tables to facilitate
experimentation with the quantizer range.

In some cases  rather than remove the look up tables completely
I have created functions that are called once  to populate them
using a formulaic approach base on the actual quantizer.

The use of these functions based on best fit of data from the original
tables does affect the results on some clips but across the derf test
set the effect was broadly neutral.

Change-Id: I8baa61c97ce87dc09a6340d56fdeb681b9345793
parent 08491b86
......@@ -63,7 +63,7 @@ extern void vp8_alloc_compressor_data(VP8_COMP *cpi);
static int vscale_lookup[7] = {0, 1, 1, 2, 2, 3, 3};
static int hscale_lookup[7] = {0, 0, 1, 1, 2, 2, 3};
// TODO #if CONFIG_EXTEND_QRANGE
static const int cq_level[QINDEX_RANGE] =
{
0,0,1,1,2,3,3,4,4,5,6,6,7,8,8,9,
......
......@@ -161,144 +161,84 @@ extern const int qrounding_factors[129];
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;
......@@ -310,6 +250,7 @@ void vp8_initialize()
//vp8_dmachine_specific_config();
vp8_tokenize_initialize();
vp8_init_me_luts();
init_minq_luts();
init_done = 1;
}
......
......@@ -160,47 +160,8 @@ static int rd_iifactor [ 32 ] = { 4, 4, 3, 2, 1, 0, 0, 0,
};
// 3* dc_qlookup[Q]*dc_qlookup[Q];
#if !CONFIG_EXTEND_QRANGE
static int rdmult_lut[QINDEX_RANGE]=
{
48,75,108,147,192,243,300,300,
363,432,507,588,675,768,867,867,
972,1083,1200,1200,1323,1323,1452,1452,
1587,1587,1728,1875,1875,2028,2187,2352,
2523,2700,2883,3072,3267,3468,3675,3888,
4107,4107,4332,4563,4800,5043,5292,5547,
5808,6075,6348,6348,6627,6912,7203,7500,
7803,8112,8427,8748,9075,9408,9747,10092,
10443,10800,11163,11532,11907,12288,12675,13068,
13467,13872,14283,14700,15123,15552,15987,16428,
16875,17328,17328,17787,18252,18723,19200,19683,
20172,20667,21168,21675,22188,22707,23232,23763,
24843,25947,27075,27648,28812,30000,30603,31212,
32448,33708,34992,36300,37632,38988,40368,41772,
44652,46128,47628,49152,50700,52272,53868,55488,
57132,58800,61347,63075,65712,68403,71148,73947,
};
#else
static int rdmult_lut[QINDEX_RANGE]=
{
3,5,7,9,12,15,19,23,
27,32,37,42,48,54,61,68,
75,83,91,99,108,117,127,137,
147,169,192,217,243,271,300,331,
363,397,450,507,567,631,698,768,
842,919,999,1083,1170,1261,1355,1452,
1587,1728,1875,2028,2187,2352,2523,2700,
2883,3072,3267,3468,3675,3888,4107,4332,
4563,4800,5043,5292,5547,5808,6075,6348,
6627,6912,7203,7500,7880,8269,8667,9075,
9492,9919,10355,10800,11255,11719,12192,12675,
13167,13669,14180,14700,15230,15769,16317,16875,
18019,19200,20419,21675,22969,24300,25669,27075,
28519,30000,31519,33075,34669,36300,37969,39675,
41772,43923,46128,48387,50700,53067,55488,57963,
61347,64827,69312,73947,78732,83667,89787,97200,
};
#endif
static int rdmult_lut[QINDEX_RANGE];
/* values are now correlated to quantizer */
static int sad_per_bit16lut[QINDEX_RANGE];
static int sad_per_bit4lut[QINDEX_RANGE];
......@@ -220,6 +181,19 @@ void vp8_init_me_luts()
}
}
int compute_rd_mult( int qindex )
{
int q;
q = vp8_dc_quant(qindex,0);
#if CONFIG_EXTEND_QRANGE
return (3 * q * q) >> 4;
#else
return (3 * q * q);
#endif
}
void vp8cx_initialize_me_consts(VP8_COMP *cpi, int QIndex)
{
cpi->mb.sadperbit16 = sad_per_bit16lut[QIndex];
......@@ -239,7 +213,8 @@ void vp8_initialize_rd_consts(VP8_COMP *cpi, int QIndex)
// if (cpi->common.refresh_golden_frame ||
// cpi->common.refresh_alt_ref_frame)
QIndex=(QIndex<0)? 0 : ((QIndex>127)?127 : QIndex);
cpi->RDMULT = rdmult_lut[QIndex];
cpi->RDMULT = compute_rd_mult(QIndex);
// Extend rate multiplier along side quantizer zbin increases
if (cpi->zbin_over_quant > 0)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment