ref: e92c8ccd925717cc2fc0a2cb3d6334f559ad536b
parent: 0fafd0543f45321356fd4a0a2467b8e40bbffdd1
parent: fb807776a2bb56630311d72affb9fcb34c42dad0
author: Paul Wilkins <paulwilkins@google.com>
date: Tue Dec 20 06:11:09 EST 2011
Merge "Further QIndex realted Fixes:" into experimental
--- a/vp8/common/onyxc_int.h
+++ b/vp8/common/onyxc_int.h
@@ -32,7 +32,16 @@
void vp8_initialize_common(void);
#define MINQ 0
+
+/*#if CONFIG_EXTEND_QRANGE
+#define MAXQ 255
+#define QINDEX_BITS 8
+#else*/
#define MAXQ 127
+#define QINDEX_BITS 7
+//#endif
+
+
#define QINDEX_RANGE (MAXQ + 1)
#define NUM_YV12_BUFFERS 4
--- a/vp8/common/quant_common.c
+++ b/vp8/common/quant_common.c
@@ -84,6 +84,10 @@
155, 158, 161, 164, 167, 170, 173, 177, 181, 185, 189, 193, 197, 201, 205, 209,
213, 217, 221, 225, 229, 234, 239, 245, 249, 254, 259, 264, 269, 274, 279, 284,
};
+
+//static int dc_qlookup[QINDEX_RANGE];
+//static int ac_qlookup[QINDEX_RANGE];
+
#endif
#if CONFIG_EXTEND_QRANGE
@@ -109,6 +113,7 @@
{
ac_qlookup[i] = current_val;
current_val = (int)((double)current_val * 1.042);
+ //current_val = (int)((double)current_val * 1.01765);
if ( current_val == last_val )
current_val++;
last_val = current_val;
@@ -132,8 +137,8 @@
QIndex = QIndex + Delta;
- if (QIndex > 127)
- QIndex = 127;
+ if (QIndex > MAXQ)
+ QIndex = MAXQ;
else if (QIndex < 0)
QIndex = 0;
@@ -147,8 +152,8 @@
QIndex = QIndex + Delta;
- if (QIndex > 127)
- QIndex = 127;
+ if (QIndex > MAXQ)
+ QIndex = MAXQ;
else if (QIndex < 0)
QIndex = 0;
@@ -166,8 +171,8 @@
QIndex = QIndex + Delta;
- if (QIndex > 127)
- QIndex = 127;
+ if (QIndex > MAXQ)
+ QIndex = MAXQ;
else if (QIndex < 0)
QIndex = 0;
@@ -180,8 +185,8 @@
{
int retval;
- if (QIndex > 127)
- QIndex = 127;
+ if (QIndex > MAXQ)
+ QIndex = MAXQ;
else if (QIndex < 0)
QIndex = 0;
@@ -195,8 +200,8 @@
QIndex = QIndex + Delta;
- if (QIndex > 127)
- QIndex = 127;
+ if (QIndex > MAXQ)
+ QIndex = MAXQ;
else if (QIndex < 0)
QIndex = 0;
#if !CONFIG_EXTEND_QRANGE
@@ -216,8 +221,8 @@
QIndex = QIndex + Delta;
- if (QIndex > 127)
- QIndex = 127;
+ if (QIndex > MAXQ)
+ QIndex = MAXQ;
else if (QIndex < 0)
QIndex = 0;
--- a/vp8/common/seg_common.c
+++ b/vp8/common/seg_common.c
@@ -12,7 +12,8 @@
//#if CONFIG_SEGFEATURES
const int segfeaturedata_signed[SEG_LVL_MAX] = {1, 1, 0, 0, 0, 0};
-const int vp8_seg_feature_data_bits[SEG_LVL_MAX] = {7, 6, 4, 4, 6, 2};
+const int vp8_seg_feature_data_bits[SEG_LVL_MAX] =
+ {QINDEX_BITS, 6, 4, 4, 6, 2};
// These functions provide access to new segment level features.
// Eventually these function may be "optimized out" but for the moment,
--- a/vp8/common/seg_common.h
+++ b/vp8/common/seg_common.h
@@ -9,6 +9,7 @@
*/
#include "type_aliases.h"
+#include "onyxc_int.h"
#include "vp8/common/blockd.h"
#ifndef __INC_SEG_COMMON_H__
--- a/vp8/decoder/decodframe.c
+++ b/vp8/decoder/decodframe.c
@@ -1204,7 +1204,7 @@
{
int Q, q_update;
- Q = vp8_read_literal(bc, 7); /* AC 1st order Q = default */
+ Q = vp8_read_literal(bc, QINDEX_BITS); /* AC 1st order Q = default */
pc->base_qindex = Q;
q_update = 0;
pc->y1dc_delta_q = get_delta_q(bc, pc->y1dc_delta_q, &q_update);
--- a/vp8/encoder/bitstream.c
+++ b/vp8/encoder/bitstream.c
@@ -28,26 +28,6 @@
//#if CONFIG_SEGFEATURES
#include "vp8/common/seg_common.h"
-const int vp8cx_base_skip_false_prob[128] =
-{
- 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255,
- 255, 255, 255, 255, 255, 255, 255, 255,
- 251, 248, 244, 240, 236, 232, 229, 225,
- 221, 217, 213, 208, 204, 199, 194, 190,
- 187, 183, 179, 175, 172, 168, 164, 160,
- 157, 153, 149, 145, 142, 138, 134, 130,
- 127, 124, 120, 117, 114, 110, 107, 104,
- 101, 98, 95, 92, 89, 86, 83, 80,
- 77, 74, 71, 68, 65, 62, 59, 56,
- 53, 50, 47, 44, 41, 38, 35, 32,
- 30, 28, 26, 24, 22, 20, 18, 16,
-};
-
#if defined(SECTIONBITS_OUTPUT)
unsigned __int64 Sectionbits[500];
#endif
@@ -2252,8 +2232,8 @@
//signal here is multi token partition is enabled
vp8_write_literal(bc, pc->multi_token_partition, 2);
- // Frame Qbaseline quantizer index
- vp8_write_literal(bc, pc->base_qindex, 7);
+ // Frame Q baseline quantizer index
+ vp8_write_literal(bc, pc->base_qindex, QINDEX_BITS);
// Transmit Dc, Second order and Uv quantizer delta information
put_delta_q(bc, pc->y1dc_delta_q);
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -157,11 +157,34 @@
extern void (*vp8_short_fdct4x4)(short *input, short *output, int pitch);
extern void (*vp8_short_fdct8x4)(short *input, short *output, int pitch);
-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
+int vp8cx_base_skip_false_prob[QINDEX_RANGE];
+#else
+int vp8cx_base_skip_false_prob[QINDEX_RANGE] =
+{
+ 255, 255, 255, 255, 255, 255, 255, 255,
+ 255, 255, 255, 255, 255, 255, 255, 255,
+ 255, 255, 255, 255, 255, 255, 255, 255,
+ 255, 255, 255, 255, 255, 255, 255, 255,
+ 255, 255, 255, 255, 255, 255, 255, 255,
+ 255, 255, 255, 255, 255, 255, 255, 255,
+ 255, 255, 255, 255, 255, 255, 255, 255,
+ 251, 248, 244, 240, 236, 232, 229, 225,
+ 221, 217, 213, 208, 204, 199, 194, 190,
+ 187, 183, 179, 175, 172, 168, 164, 160,
+ 157, 153, 149, 145, 142, 138, 134, 130,
+ 127, 124, 120, 117, 114, 110, 107, 104,
+ 101, 98, 95, 92, 89, 86, 83, 80,
+ 77, 74, 71, 68, 65, 62, 59, 56,
+ 53, 50, 47, 44, 41, 38, 35, 32,
+ 30, 28, 26, 24, 22, 20, 18, 16,
+
+};
+#endif*/
+int vp8cx_base_skip_false_prob[QINDEX_RANGE];
+
// Tables relating active max Q to active min Q
static int kf_low_motion_minq[QINDEX_RANGE];
static int kf_high_motion_minq[QINDEX_RANGE];
@@ -243,6 +266,28 @@
}
}
+void init_base_skip_probs()
+{
+ int i;
+ double q;
+ int skip_prob;
+
+ for ( i = 0; i < QINDEX_RANGE; i++ )
+ {
+ q = vp8_convert_qindex_to_q(i);
+
+ // Exponential decay caluclation of baseline skip prob with clamping
+ // Based on crude best fit of old table.
+ skip_prob = (int)( 564.25 * pow( 2.71828, (-0.012*q) ) );
+ if ( skip_prob < 1 )
+ skip_prob = 1;
+ else if ( skip_prob > 255 )
+ skip_prob = 255;
+
+ vp8cx_base_skip_false_prob[i] = skip_prob;
+ }
+}
+
void vp8_initialize()
{
static int init_done = 0;
@@ -258,6 +303,7 @@
#endif
vp8_init_me_luts();
init_minq_luts();
+ init_base_skip_probs();
init_done = 1;
}
}
@@ -1829,9 +1875,27 @@
}
-// Quant MOD
+// TODO perhaps change number of steps expose to outside world when setting
+// max and min limits. Also this will likely want refining for the extended Q
+// range.
+//
+// Table that converts 0-63 Q range values passed in outside to the Qindex
+// range used internally.
+/*#if CONFIG_EXTEND_QRANGE
static const int q_trans[] =
{
+ 0, 4, 8, 12, 16, 20, 24, 28,
+ 32, 36, 40, 44, 48, 52, 56, 60,
+ 64, 68, 72, 76, 80, 84, 88, 92,
+ 96, 100, 104, 108, 112, 116, 120, 124,
+ 128, 132, 136, 140, 144, 148, 152, 156,
+ 160, 164, 168, 172, 176, 180, 184, 188,
+ 192, 196, 200, 204, 208, 212, 216, 220,
+ 224, 228, 232, 236, 240, 244, 249, 255,
+};
+#else*/
+static const int q_trans[] =
+{
0, 1, 2, 3, 4, 5, 7, 8,
9, 10, 12, 13, 15, 17, 18, 19,
20, 21, 23, 24, 25, 26, 27, 28,
@@ -1841,6 +1905,7 @@
82, 85, 88, 91, 94, 97, 100, 103,
106, 109, 112, 115, 118, 121, 124, 127,
};
+//#endif
int vp8_reverse_trans(int x)
{
@@ -4292,11 +4357,6 @@
{
vp8_clear_system_state(); //__asm emms;
- /*
- if(cpi->is_src_frame_alt_ref)
- Q = 127;
- */
-
vp8_set_quantizer(cpi, Q);
this_q = Q;
@@ -4344,7 +4404,8 @@
*/
}
- //as this is for cost estimate, let's make sure it does not go extreme eitehr way
+ // as this is for cost estimate, let's make sure it does not
+ // get extreme either way
if (cpi->prob_skip_false < 5)
cpi->prob_skip_false = 5;
--- a/vp8/encoder/onyx_int.h
+++ b/vp8/encoder/onyx_int.h
@@ -599,7 +599,7 @@
unsigned int time_pick_lpf;
unsigned int time_encode_mb_row;
- int base_skip_false_prob[128];
+ int base_skip_false_prob[QINDEX_RANGE];
struct twopass_rc
{
--- a/vp8/encoder/picklpf.c
+++ b/vp8/encoder/picklpf.c
@@ -107,18 +107,21 @@
static int get_min_filter_level(VP8_COMP *cpi, int base_qindex)
{
int min_filter_level;
+ /*int q = (int) vp8_convert_qindex_to_q(base_qindex);
if (cpi->source_alt_ref_active && cpi->common.refresh_golden_frame && !cpi->common.refresh_alt_ref_frame)
min_filter_level = 0;
else
{
- if (base_qindex <= 6)
+ if (q <= 10)
min_filter_level = 0;
- else if (base_qindex <= 16)
+ else if (q <= 64)
min_filter_level = 1;
else
- min_filter_level = (base_qindex / 8);
+ min_filter_level = (q >> 6);
}
+ */
+ min_filter_level = 0;
return min_filter_level;
}
--- a/vp8/encoder/rdopt.c
+++ b/vp8/encoder/rdopt.c
@@ -278,7 +278,7 @@
// for key frames, golden frames and arf frames.
// if (cpi->common.refresh_golden_frame ||
// cpi->common.refresh_alt_ref_frame)
- QIndex=(QIndex<0)? 0 : ((QIndex>127)?127 : QIndex);
+ QIndex=(QIndex<0)? 0 : ((QIndex>MAXQ)?MAXQ : QIndex);
cpi->RDMULT = compute_rd_mult(QIndex);
--
⑨