Commit fb807776 authored by Paul Wilkins's avatar Paul Wilkins

Further QIndex realted Fixes:

Added code to support 256 index steps instead of 128 but disabled for now.
Replace hard wired table vp8cx_base_skip_false_prob[128]
Observed Qindex problem with setting minimum loop filter value.
(Experiment code using real Q in place but for now just returning 0. This has a big
beneficial effect on some clips, particularly waterfall which shows 5% ssim gain)

Change-Id: I2f7117de8adc1797164c106aa13effc900a1467e
parent b3ade15a
......@@ -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
......
......@@ -84,6 +84,10 @@ static int ac_qlookup[QINDEX_RANGE] =
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 @@ void vp8_init_quant_tables()
{
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 @@ int vp8_dc_quant(int QIndex, int Delta)
QIndex = QIndex + Delta;
if (QIndex > 127)
QIndex = 127;
if (QIndex > MAXQ)
QIndex = MAXQ;
else if (QIndex < 0)
QIndex = 0;
......@@ -147,8 +152,8 @@ int vp8_dc2quant(int QIndex, int Delta)
QIndex = QIndex + Delta;
if (QIndex > 127)
QIndex = 127;
if (QIndex > MAXQ)
QIndex = MAXQ;
else if (QIndex < 0)
QIndex = 0;
......@@ -166,8 +171,8 @@ int vp8_dc_uv_quant(int QIndex, int Delta)
QIndex = QIndex + Delta;
if (QIndex > 127)
QIndex = 127;
if (QIndex > MAXQ)
QIndex = MAXQ;
else if (QIndex < 0)
QIndex = 0;
......@@ -180,8 +185,8 @@ int vp8_ac_yquant(int QIndex)
{
int retval;
if (QIndex > 127)
QIndex = 127;
if (QIndex > MAXQ)
QIndex = MAXQ;
else if (QIndex < 0)
QIndex = 0;
......@@ -195,8 +200,8 @@ int vp8_ac2quant(int QIndex, int Delta)
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 @@ int vp8_ac_uv_quant(int QIndex, int Delta)
QIndex = QIndex + Delta;
if (QIndex > 127)
QIndex = 127;
if (QIndex > MAXQ)
QIndex = MAXQ;
else if (QIndex < 0)
QIndex = 0;
......
......@@ -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,
......
......@@ -9,6 +9,7 @@
*/
#include "type_aliases.h"
#include "onyxc_int.h"
#include "vp8/common/blockd.h"
#ifndef __INC_SEG_COMMON_H__
......
......@@ -1204,7 +1204,7 @@ int vp8_decode_frame(VP8D_COMP *pbi)
{
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);
......
......@@ -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 @@ void vp8_pack_bitstream(VP8_COMP *cpi, unsigned char *dest, unsigned long *size)
//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);
......
......@@ -157,10 +157,33 @@ extern unsigned int inter_b_modes[B_MODE_COUNT];
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];
......@@ -243,6 +266,28 @@ void init_minq_luts()
}
}
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 @@ void vp8_initialize()
#endif
vp8_init_me_luts();
init_minq_luts();
init_base_skip_probs();
init_done = 1;
}
}
......@@ -1829,7 +1875,25 @@ void vp8_alloc_compressor_data(VP8_COMP *cpi)
}
// 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,
......@@ -1841,6 +1905,7 @@ static const int q_trans[] =
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 @@ static void encode_frame_to_data_rate
{
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 @@ static void encode_frame_to_data_rate
*/
}
//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;
......
......@@ -599,7 +599,7 @@ typedef struct VP8_COMP
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
{
......
......@@ -107,18 +107,21 @@ static int vp8_calc_partial_ssl_err(YV12_BUFFER_CONFIG *source, YV12_BUFFER_CONF
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;
}
......
......@@ -278,7 +278,7 @@ void vp8_initialize_rd_consts(VP8_COMP *cpi, int QIndex)
// 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);
......
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