2010-05-18 17:58:33 +02:00
|
|
|
/*
|
2010-09-09 14:16:39 +02:00
|
|
|
* Copyright (c) 2010 The WebM project authors. All Rights Reserved.
|
2010-05-18 17:58:33 +02:00
|
|
|
*
|
2010-06-18 18:39:21 +02:00
|
|
|
* Use of this source code is governed by a BSD-style license
|
2010-06-04 22:19:40 +02:00
|
|
|
* that can be found in the LICENSE file in the root of the source
|
|
|
|
* tree. An additional intellectual property rights grant can be found
|
2010-06-18 18:39:21 +02:00
|
|
|
* in the file PATENTS. All contributing project authors may
|
2010-06-04 22:19:40 +02:00
|
|
|
* be found in the AUTHORS file in the root of the source tree.
|
2010-05-18 17:58:33 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
#include <math.h>
|
|
|
|
#include "vpx_mem/vpx_mem.h"
|
|
|
|
|
2011-05-19 17:04:03 +02:00
|
|
|
#include "onyx_int.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
#include "quantize.h"
|
2011-05-19 17:04:03 +02:00
|
|
|
#include "vp8/common/quant_common.h"
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2011-10-05 12:26:00 +02:00
|
|
|
#include "vp8/common/seg_common.h"
|
|
|
|
|
2011-02-14 23:18:18 +01:00
|
|
|
#ifdef ENC_DEBUG
|
|
|
|
extern int enc_debug;
|
|
|
|
#endif
|
|
|
|
|
2010-11-08 16:28:54 +01:00
|
|
|
#define EXACT_QUANT
|
2010-11-11 18:41:07 +01:00
|
|
|
|
|
|
|
#ifdef EXACT_FASTQUANT
|
2010-05-18 17:58:33 +02:00
|
|
|
void vp8_fast_quantize_b_c(BLOCK *b, BLOCKD *d)
|
|
|
|
{
|
|
|
|
int i, rc, eob;
|
|
|
|
int zbin;
|
|
|
|
int x, y, z, sz;
|
2010-10-22 02:04:30 +02:00
|
|
|
short *coeff_ptr = b->coeff;
|
|
|
|
short *zbin_ptr = b->zbin;
|
|
|
|
short *round_ptr = b->round;
|
2010-12-28 20:51:46 +01:00
|
|
|
short *quant_ptr = b->quant_fast;
|
2011-04-13 19:45:58 +02:00
|
|
|
unsigned char *quant_shift_ptr = b->quant_shift;
|
2010-10-22 02:04:30 +02:00
|
|
|
short *qcoeff_ptr = d->qcoeff;
|
|
|
|
short *dqcoeff_ptr = d->dqcoeff;
|
|
|
|
short *dequant_ptr = d->dequant;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
vpx_memset(qcoeff_ptr, 0, 32);
|
|
|
|
vpx_memset(dqcoeff_ptr, 0, 32);
|
|
|
|
|
|
|
|
eob = -1;
|
|
|
|
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
{
|
|
|
|
rc = vp8_default_zig_zag1d[i];
|
|
|
|
z = coeff_ptr[rc];
|
|
|
|
zbin = zbin_ptr[rc] ;
|
|
|
|
|
|
|
|
sz = (z >> 31); // sign of z
|
|
|
|
x = (z ^ sz) - sz; // x = abs(z)
|
|
|
|
|
|
|
|
if (x >= zbin)
|
|
|
|
{
|
2010-06-29 02:15:09 +02:00
|
|
|
x += round_ptr[rc];
|
|
|
|
y = (((x * quant_ptr[rc]) >> 16) + x)
|
|
|
|
>> quant_shift_ptr[rc]; // quantize (x)
|
2010-05-18 17:58:33 +02:00
|
|
|
x = (y ^ sz) - sz; // get the sign back
|
|
|
|
qcoeff_ptr[rc] = x; // write to destination
|
|
|
|
dqcoeff_ptr[rc] = x * dequant_ptr[rc]; // dequantized value
|
|
|
|
|
|
|
|
if (y)
|
|
|
|
{
|
|
|
|
eob = i; // last nonzero coeffs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
d->eob = eob + 1;
|
|
|
|
}
|
|
|
|
|
2010-11-11 18:41:07 +01:00
|
|
|
#else
|
|
|
|
|
|
|
|
void vp8_fast_quantize_b_c(BLOCK *b, BLOCKD *d)
|
|
|
|
{
|
|
|
|
int i, rc, eob;
|
|
|
|
int x, y, z, sz;
|
|
|
|
short *coeff_ptr = b->coeff;
|
|
|
|
short *round_ptr = b->round;
|
2010-12-28 20:51:46 +01:00
|
|
|
short *quant_ptr = b->quant_fast;
|
2010-11-11 18:41:07 +01:00
|
|
|
short *qcoeff_ptr = d->qcoeff;
|
|
|
|
short *dqcoeff_ptr = d->dqcoeff;
|
|
|
|
short *dequant_ptr = d->dequant;
|
2011-07-20 23:21:24 +02:00
|
|
|
#if CONFIG_T8X8
|
2010-11-11 18:41:07 +01:00
|
|
|
|
2011-02-14 23:18:18 +01:00
|
|
|
vpx_memset(qcoeff_ptr, 0, 32);
|
|
|
|
vpx_memset(dqcoeff_ptr, 0, 32);
|
2011-07-20 23:21:24 +02:00
|
|
|
#endif
|
2010-11-11 18:41:07 +01:00
|
|
|
eob = -1;
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
{
|
|
|
|
rc = vp8_default_zig_zag1d[i];
|
|
|
|
z = coeff_ptr[rc];
|
|
|
|
|
|
|
|
sz = (z >> 31); // sign of z
|
|
|
|
x = (z ^ sz) - sz; // x = abs(z)
|
|
|
|
|
|
|
|
y = ((x + round_ptr[rc]) * quant_ptr[rc]) >> 16; // quantize (x)
|
|
|
|
x = (y ^ sz) - sz; // get the sign back
|
|
|
|
qcoeff_ptr[rc] = x; // write to destination
|
|
|
|
dqcoeff_ptr[rc] = x * dequant_ptr[rc]; // dequantized value
|
|
|
|
|
|
|
|
if (y)
|
|
|
|
{
|
|
|
|
eob = i; // last nonzero coeffs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
d->eob = eob + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef EXACT_QUANT
|
2010-05-18 17:58:33 +02:00
|
|
|
void vp8_regular_quantize_b(BLOCK *b, BLOCKD *d)
|
|
|
|
{
|
|
|
|
int i, rc, eob;
|
|
|
|
int zbin;
|
|
|
|
int x, y, z, sz;
|
2010-10-22 02:04:30 +02:00
|
|
|
short *zbin_boost_ptr = b->zrun_zbin_boost;
|
|
|
|
short *coeff_ptr = b->coeff;
|
|
|
|
short *zbin_ptr = b->zbin;
|
|
|
|
short *round_ptr = b->round;
|
|
|
|
short *quant_ptr = b->quant;
|
2011-04-13 19:45:58 +02:00
|
|
|
unsigned char *quant_shift_ptr = b->quant_shift;
|
2010-10-22 02:04:30 +02:00
|
|
|
short *qcoeff_ptr = d->qcoeff;
|
|
|
|
short *dqcoeff_ptr = d->dqcoeff;
|
|
|
|
short *dequant_ptr = d->dequant;
|
|
|
|
short zbin_oq_value = b->zbin_extra;
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
vpx_memset(qcoeff_ptr, 0, 32);
|
|
|
|
vpx_memset(dqcoeff_ptr, 0, 32);
|
|
|
|
|
|
|
|
eob = -1;
|
|
|
|
|
2011-10-05 12:26:00 +02:00
|
|
|
for (i = 0; i < b->eob_max_offset; i++)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
|
|
|
rc = vp8_default_zig_zag1d[i];
|
|
|
|
z = coeff_ptr[rc];
|
|
|
|
|
|
|
|
zbin = zbin_ptr[rc] + *zbin_boost_ptr + zbin_oq_value;
|
|
|
|
|
|
|
|
zbin_boost_ptr ++;
|
|
|
|
sz = (z >> 31); // sign of z
|
|
|
|
x = (z ^ sz) - sz; // x = abs(z)
|
|
|
|
|
|
|
|
if (x >= zbin)
|
|
|
|
{
|
2010-06-29 02:15:09 +02:00
|
|
|
x += round_ptr[rc];
|
|
|
|
y = (((x * quant_ptr[rc]) >> 16) + x)
|
|
|
|
>> quant_shift_ptr[rc]; // quantize (x)
|
2010-05-18 17:58:33 +02:00
|
|
|
x = (y ^ sz) - sz; // get the sign back
|
2011-01-11 15:41:57 +01:00
|
|
|
qcoeff_ptr[rc] = x; // write to destination
|
|
|
|
dqcoeff_ptr[rc] = x * dequant_ptr[rc]; // dequantized value
|
2010-05-18 17:58:33 +02:00
|
|
|
|
|
|
|
if (y)
|
|
|
|
{
|
|
|
|
eob = i; // last nonzero coeffs
|
2011-01-11 15:41:57 +01:00
|
|
|
zbin_boost_ptr = b->zrun_zbin_boost; // reset zero runlength
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
d->eob = eob + 1;
|
|
|
|
}
|
2010-10-11 22:49:52 +02:00
|
|
|
|
|
|
|
/* Perform regular quantization, with unbiased rounding and no zero bin. */
|
|
|
|
void vp8_strict_quantize_b(BLOCK *b, BLOCKD *d)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int rc;
|
|
|
|
int eob;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int z;
|
|
|
|
int sz;
|
|
|
|
short *coeff_ptr;
|
|
|
|
short *quant_ptr;
|
2011-04-13 19:45:58 +02:00
|
|
|
unsigned char *quant_shift_ptr;
|
2010-10-11 22:49:52 +02:00
|
|
|
short *qcoeff_ptr;
|
|
|
|
short *dqcoeff_ptr;
|
|
|
|
short *dequant_ptr;
|
|
|
|
|
2010-10-22 02:04:30 +02:00
|
|
|
coeff_ptr = b->coeff;
|
|
|
|
quant_ptr = b->quant;
|
|
|
|
quant_shift_ptr = b->quant_shift;
|
|
|
|
qcoeff_ptr = d->qcoeff;
|
|
|
|
dqcoeff_ptr = d->dqcoeff;
|
|
|
|
dequant_ptr = d->dequant;
|
2010-10-11 22:49:52 +02:00
|
|
|
eob = - 1;
|
|
|
|
vpx_memset(qcoeff_ptr, 0, 32);
|
|
|
|
vpx_memset(dqcoeff_ptr, 0, 32);
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
{
|
|
|
|
int dq;
|
|
|
|
int round;
|
|
|
|
|
|
|
|
/*TODO: These arrays should be stored in zig-zag order.*/
|
|
|
|
rc = vp8_default_zig_zag1d[i];
|
|
|
|
z = coeff_ptr[rc];
|
|
|
|
dq = dequant_ptr[rc];
|
|
|
|
round = dq >> 1;
|
|
|
|
/* Sign of z. */
|
|
|
|
sz = -(z < 0);
|
|
|
|
x = (z + sz) ^ sz;
|
|
|
|
x += round;
|
|
|
|
if (x >= dq)
|
|
|
|
{
|
|
|
|
/* Quantize x. */
|
|
|
|
y = (((x * quant_ptr[rc]) >> 16) + x) >> quant_shift_ptr[rc];
|
|
|
|
/* Put the sign back. */
|
|
|
|
x = (y + sz) ^ sz;
|
|
|
|
/* Save the coefficient and its dequantized value. */
|
|
|
|
qcoeff_ptr[rc] = x;
|
|
|
|
dqcoeff_ptr[rc] = x * dq;
|
|
|
|
/* Remember the last non-zero coefficient. */
|
|
|
|
if (y)
|
|
|
|
eob = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
d->eob = eob + 1;
|
|
|
|
}
|
|
|
|
|
2010-07-28 19:44:17 +02:00
|
|
|
#else
|
2010-09-02 19:33:01 +02:00
|
|
|
|
|
|
|
void vp8_regular_quantize_b(BLOCK *b, BLOCKD *d)
|
|
|
|
{
|
|
|
|
int i, rc, eob;
|
|
|
|
int zbin;
|
|
|
|
int x, y, z, sz;
|
2010-10-22 02:04:30 +02:00
|
|
|
short *zbin_boost_ptr = b->zrun_zbin_boost;
|
|
|
|
short *coeff_ptr = b->coeff;
|
|
|
|
short *zbin_ptr = b->zbin;
|
|
|
|
short *round_ptr = b->round;
|
|
|
|
short *quant_ptr = b->quant;
|
|
|
|
short *qcoeff_ptr = d->qcoeff;
|
|
|
|
short *dqcoeff_ptr = d->dqcoeff;
|
|
|
|
short *dequant_ptr = d->dequant;
|
|
|
|
short zbin_oq_value = b->zbin_extra;
|
2010-09-02 19:33:01 +02:00
|
|
|
|
|
|
|
vpx_memset(qcoeff_ptr, 0, 32);
|
|
|
|
vpx_memset(dqcoeff_ptr, 0, 32);
|
|
|
|
|
|
|
|
eob = -1;
|
|
|
|
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
{
|
|
|
|
rc = vp8_default_zig_zag1d[i];
|
|
|
|
z = coeff_ptr[rc];
|
|
|
|
|
|
|
|
//if ( i == 0 )
|
|
|
|
// zbin = zbin_ptr[rc] + *zbin_boost_ptr + zbin_oq_value/2;
|
|
|
|
//else
|
|
|
|
zbin = zbin_ptr[rc] + *zbin_boost_ptr + zbin_oq_value;
|
|
|
|
|
|
|
|
zbin_boost_ptr ++;
|
|
|
|
sz = (z >> 31); // sign of z
|
|
|
|
x = (z ^ sz) - sz; // x = abs(z)
|
|
|
|
|
|
|
|
if (x >= zbin)
|
|
|
|
{
|
|
|
|
y = ((x + round_ptr[rc]) * quant_ptr[rc]) >> 16; // quantize (x)
|
|
|
|
x = (y ^ sz) - sz; // get the sign back
|
|
|
|
qcoeff_ptr[rc] = x; // write to destination
|
|
|
|
dqcoeff_ptr[rc] = x * dequant_ptr[rc]; // dequantized value
|
|
|
|
|
|
|
|
if (y)
|
|
|
|
{
|
|
|
|
eob = i; // last nonzero coeffs
|
|
|
|
zbin_boost_ptr = &b->zrun_zbin_boost[0]; // reset zero runlength
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
d->eob = eob + 1;
|
|
|
|
}
|
|
|
|
|
2011-02-14 23:18:18 +01:00
|
|
|
#endif //EXACT_QUANT
|
|
|
|
|
Add trellis quantization.
Replace the exponential search for optimal rounding during
quantization with a linear Viterbi trellis and enable it
by default when using --best.
Right now this operates on top of the output of the adaptive
zero-bin quantizer in vp8_regular_quantize_b() and gives a small
gain.
It can be tested as a replacement for that quantizer by
enabling the call to vp8_strict_quantize_b(), which uses
normal rounding and no zero bin offset.
Ultimately, the quantizer will have to become a function of lambda
in order to take advantage of activity masking, since there is
limited ability to change the quantization factor itself.
However, currently vp8_strict_quantize_b() plus the trellis
quantizer (which is lambda-dependent) loses to
vp8_regular_quantize_b() alone (which is not) on my test clip.
Patch Set 3:
Fix an issue related to the cost evaluation of successor
states when a coefficient is reduced to zero. With this
issue fixed, now the trellis search almost exactly matches
the exponential search.
Patch Set 2:
Overall, the goal of this patch set is to make "trellis"
search to produce encodings that match the exponential
search version. There are three main differences between
Patch Set 2 and 1:
a. Patch set 1 did not properly account for the scale of
2nd order error, so patch set 2 disable it all together
for 2nd blocks.
b. Patch set 1 was not consistent on when to enable the
the quantization optimization. Patch set 2 restore the
condition to be consistent.
c. Patch set 1 checks quantized level L-1, and L for any
input coefficient was quantized to L. Patch set 2 limits
the candidate coefficient to those that were rounded up
to L. It is worth noting here that a strategy to check
L and L+1 for coefficients that were truncated down to L
might work.
(a and b get trellis quant to basically match the exponential
search on all mid/low rate encodings on cif set, without
a, b, trellis quant can hurt the psnr by 0.2 to .3db at
200kbps for some cif clips)
(c gets trellis quant to match the exponential search
to match at Q0 encoding, without c, trellis quant can be
1.5 to 2db lower for encodings with fixed Q at 0 on most
derf cif clips)
Change-Id: Ib1a043b665d75fbf00cb0257b7c18e90eebab95e
2010-07-02 23:35:53 +02:00
|
|
|
|
2011-05-09 09:09:41 +02:00
|
|
|
void vp8_quantize_mby_c(MACROBLOCK *x)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
|
|
|
int i;
|
2010-08-12 22:25:43 +02:00
|
|
|
int has_2nd_order = (x->e_mbd.mode_info_context->mbmi.mode != B_PRED
|
2011-12-01 01:25:00 +01:00
|
|
|
&& x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED
|
2010-08-12 22:25:43 +02:00
|
|
|
&& x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-06-08 22:32:15 +02:00
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
x->quantize_b(&x->block[i], &x->e_mbd.block[i]);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-06-08 22:32:15 +02:00
|
|
|
if(has_2nd_order)
|
2010-05-18 17:58:33 +02:00
|
|
|
x->quantize_b(&x->block[24], &x->e_mbd.block[24]);
|
|
|
|
}
|
|
|
|
|
2011-05-09 09:09:41 +02:00
|
|
|
void vp8_quantize_mb_c(MACROBLOCK *x)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
|
|
|
int i;
|
2010-08-12 22:25:43 +02:00
|
|
|
int has_2nd_order=(x->e_mbd.mode_info_context->mbmi.mode != B_PRED
|
2011-12-01 01:25:00 +01:00
|
|
|
&& x->e_mbd.mode_info_context->mbmi.mode != I8X8_PRED
|
2010-08-12 22:25:43 +02:00
|
|
|
&& x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
|
2010-05-18 17:58:33 +02:00
|
|
|
|
2010-06-08 22:32:15 +02:00
|
|
|
for (i = 0; i < 24+has_2nd_order; i++)
|
|
|
|
x->quantize_b(&x->block[i], &x->e_mbd.block[i]);
|
2010-05-18 17:58:33 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2011-05-09 09:09:41 +02:00
|
|
|
void vp8_quantize_mbuv_c(MACROBLOCK *x)
|
2010-05-18 17:58:33 +02:00
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 16; i < 24; i++)
|
|
|
|
x->quantize_b(&x->block[i], &x->e_mbd.block[i]);
|
|
|
|
}
|
2011-05-19 17:04:03 +02:00
|
|
|
|
2011-02-14 23:18:18 +01:00
|
|
|
#if CONFIG_T8X8
|
|
|
|
|
|
|
|
#ifdef EXACT_FASTQUANT
|
|
|
|
void vp8_fast_quantize_b_2x2_c(BLOCK *b, BLOCKD *d)
|
|
|
|
{
|
|
|
|
int i, rc, eob;
|
|
|
|
int zbin;
|
|
|
|
int x, y, z, sz;
|
|
|
|
short *coeff_ptr = b->coeff;
|
|
|
|
short *zbin_ptr = b->zbin;
|
|
|
|
short *round_ptr = b->round;
|
|
|
|
short *quant_ptr = b->quant;
|
|
|
|
short *quant_shift_ptr = b->quant_shift;
|
|
|
|
short *qcoeff_ptr = d->qcoeff;
|
|
|
|
short *dqcoeff_ptr = d->dqcoeff;
|
|
|
|
short *dequant_ptr = d->dequant;
|
|
|
|
//double q2nd = 4;
|
|
|
|
|
|
|
|
|
|
|
|
vpx_memset(qcoeff_ptr, 0, 32);
|
|
|
|
vpx_memset(dqcoeff_ptr, 0, 32);
|
|
|
|
|
|
|
|
eob = -1;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
rc = vp8_default_zig_zag1d[i];
|
|
|
|
z = coeff_ptr[rc];
|
|
|
|
//zbin = zbin_ptr[rc]/q2nd ;
|
|
|
|
zbin = zbin_ptr[rc] ;
|
|
|
|
|
|
|
|
sz = (z >> 31); // sign of z
|
|
|
|
x = (z ^ sz) - sz; // x = abs(z)
|
|
|
|
|
|
|
|
if (x >= zbin)
|
|
|
|
{
|
|
|
|
//x += (round_ptr[rc]/q2nd);
|
|
|
|
x += (round_ptr[rc]);
|
|
|
|
//y = ((int)((int)(x * quant_ptr[rc] * q2nd) >> 16) + x)
|
|
|
|
// >> quant_shift_ptr[rc]; // quantize (x)
|
|
|
|
y = ((int)((int)(x * quant_ptr[rc]) >> 16) + x)
|
|
|
|
>> quant_shift_ptr[rc]; // quantize (x)
|
|
|
|
x = (y ^ sz) - sz; // get the sign back
|
|
|
|
qcoeff_ptr[rc] = x; // write to destination
|
|
|
|
dqcoeff_ptr[rc] = x * dequant_ptr[rc]; // dequantized value
|
|
|
|
|
|
|
|
if (y)
|
|
|
|
{
|
|
|
|
eob = i; // last nonzero coeffs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
d->eob = eob + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void vp8_fast_quantize_b_8x8_c(BLOCK *b, BLOCKD *d)// only ac and dc difference, no difference among ac
|
|
|
|
{
|
|
|
|
int i, rc, eob;
|
|
|
|
int zbin;
|
|
|
|
int x, y, z, sz;
|
|
|
|
short *coeff_ptr = b->coeff;
|
|
|
|
short *zbin_ptr = b->zbin;
|
|
|
|
short *round_ptr = b->round;
|
|
|
|
short *quant_ptr = b->quant;
|
|
|
|
short *quant_shift_ptr = b->quant_shift;
|
|
|
|
short *qcoeff_ptr = d->qcoeff;
|
|
|
|
short *dqcoeff_ptr = d->dqcoeff;
|
|
|
|
short *dequant_ptr = d->dequant;
|
|
|
|
//double q1st = 2;
|
|
|
|
vpx_memset(qcoeff_ptr, 0, 64*sizeof(short));
|
|
|
|
vpx_memset(dqcoeff_ptr, 0, 64*sizeof(short));
|
|
|
|
|
|
|
|
eob = -1;
|
|
|
|
|
|
|
|
for (i = 0; i < 64; i++)
|
|
|
|
{
|
|
|
|
rc = vp8_default_zig_zag1d_8x8[i];
|
|
|
|
z = coeff_ptr[rc];
|
|
|
|
//zbin = zbin_ptr[rc!=0]/q1st ;
|
|
|
|
zbin = zbin_ptr[rc!=0] ;
|
|
|
|
|
|
|
|
sz = (z >> 31); // sign of z
|
|
|
|
x = (z ^ sz) - sz; // x = abs(z)
|
|
|
|
|
|
|
|
if (x >= zbin)
|
|
|
|
{
|
|
|
|
//x += round_ptr[rc]/q1st;
|
|
|
|
//y = ((int)(((int)((x * quant_ptr[rc!=0] * q1st)) >> 16) + x))
|
|
|
|
// >> quant_shift_ptr[rc!=0]; // quantize (x)
|
|
|
|
x += round_ptr[rc];
|
|
|
|
y = ((int)(((int)((x * quant_ptr[rc!=0])) >> 16) + x))
|
|
|
|
>> quant_shift_ptr[rc!=0]; // quantize (x)
|
|
|
|
x = (y ^ sz) - sz; // get the sign back
|
|
|
|
qcoeff_ptr[rc] = x; // write to destination
|
|
|
|
//dqcoeff_ptr[rc] = x * dequant_ptr[rc!=0] / q1st; // dequantized value
|
|
|
|
dqcoeff_ptr[rc] = x * dequant_ptr[rc!=0]; // dequantized value
|
|
|
|
|
|
|
|
if (y)
|
|
|
|
{
|
|
|
|
eob = i; // last nonzero coeffs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
d->eob = eob + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
void vp8_fast_quantize_b_2x2_c(BLOCK *b, BLOCKD *d)
|
|
|
|
{
|
|
|
|
int i, rc, eob;
|
|
|
|
int zbin;
|
|
|
|
int x, y, z, sz;
|
|
|
|
short *coeff_ptr = b->coeff;
|
|
|
|
short *zbin_ptr = b->zbin;
|
|
|
|
short *round_ptr = b->round;
|
|
|
|
short *quant_ptr = b->quant;
|
|
|
|
short *qcoeff_ptr = d->qcoeff;
|
|
|
|
short *dqcoeff_ptr = d->dqcoeff;
|
|
|
|
short *dequant_ptr = d->dequant;
|
|
|
|
//double q2nd = 4;
|
|
|
|
vpx_memset(qcoeff_ptr, 0, 32);
|
|
|
|
vpx_memset(dqcoeff_ptr, 0, 32);
|
|
|
|
|
|
|
|
eob = -1;
|
|
|
|
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
rc = vp8_default_zig_zag1d[i];
|
|
|
|
z = coeff_ptr[rc];
|
|
|
|
//zbin = zbin_ptr[rc]/q2nd;
|
|
|
|
zbin = zbin_ptr[rc];
|
|
|
|
|
|
|
|
sz = (z >> 31); // sign of z
|
|
|
|
x = (z ^ sz) - sz; // x = abs(z)
|
|
|
|
|
|
|
|
if (x >= zbin)
|
|
|
|
{
|
|
|
|
//y = ((int)((x + round_ptr[rc]/q2nd) * quant_ptr[rc] * q2nd)) >> 16; // quantize (x)
|
|
|
|
y = ((int)((x + round_ptr[rc]) * quant_ptr[rc])) >> 16; // quantize (x)
|
|
|
|
x = (y ^ sz) - sz; // get the sign back
|
|
|
|
qcoeff_ptr[rc] = x; // write to destination
|
|
|
|
//dqcoeff_ptr[rc] = x * dequant_ptr[rc] / q2nd; // dequantized value
|
|
|
|
dqcoeff_ptr[rc] = x * dequant_ptr[rc]; // dequantized value
|
2011-11-10 21:54:22 +01:00
|
|
|
dqcoeff_ptr[rc] = (dqcoeff_ptr[rc]+2)>>2;
|
2011-02-14 23:18:18 +01:00
|
|
|
|
|
|
|
if (y)
|
|
|
|
{
|
|
|
|
eob = i; // last nonzero coeffs
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
d->eob = eob + 1;
|
|
|
|
//if (d->eob > 4) printf("Flag Fast 2 (%d)\n", d->eob);
|
|
|
|
}
|
|
|
|
|
|
|
|
void vp8_fast_quantize_b_8x8_c(BLOCK *b, BLOCKD *d)
|
|
|
|
{
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
int i, rc, eob;
|
|
|
|
int zbin;
|
|
|
|
int x, y, z, sz;
|
|
|
|
short *coeff_ptr = b->coeff;
|
|
|
|
short *zbin_ptr = b->zbin;
|
|
|
|
short *round_ptr = b->round;
|
|
|
|
short *quant_ptr = b->quant;
|
|
|
|
short *qcoeff_ptr = d->qcoeff;
|
|
|
|
short *dqcoeff_ptr = d->dqcoeff;
|
|
|
|
short *dequant_ptr = d->dequant;
|
|
|
|
//double q1st = 2;
|
|
|
|
vpx_memset(qcoeff_ptr, 0, 64*sizeof(short));
|
|
|
|
vpx_memset(dqcoeff_ptr, 0, 64*sizeof(short));
|
2011-02-14 23:18:18 +01:00
|
|
|
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
eob = -1;
|
2011-02-14 23:18:18 +01:00
|
|
|
|
|
|
|
|
|
|
|
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
for (i = 0; i < 64; i++)
|
2011-02-14 23:18:18 +01:00
|
|
|
{
|
2011-11-10 21:54:22 +01:00
|
|
|
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
rc = vp8_default_zig_zag1d_8x8[i];
|
|
|
|
z = coeff_ptr[rc];
|
|
|
|
//zbin = zbin_ptr[rc!=0]/q1st ;
|
|
|
|
zbin = zbin_ptr[rc!=0] ;
|
|
|
|
|
|
|
|
sz = (z >> 31); // sign of z
|
|
|
|
x = (z ^ sz) - sz; // x = abs(z)
|
|
|
|
|
|
|
|
if (x >= zbin)
|
|
|
|
{
|
|
|
|
//y = ((int)((x + round_ptr[rc!=0] / q1st) * quant_ptr[rc!=0] * q1st)) >> 16;
|
|
|
|
y = ((int)((x + round_ptr[rc!=0]) * quant_ptr[rc!=0])) >> 16;
|
|
|
|
x = (y ^ sz) - sz; // get the sign back
|
|
|
|
qcoeff_ptr[rc] = x; // write to destination
|
|
|
|
//dqcoeff_ptr[rc] = x * dequant_ptr[rc!=0] / q1st; // dequantized value
|
|
|
|
dqcoeff_ptr[rc] = x * dequant_ptr[rc!=0]; // dequantized value
|
|
|
|
dqcoeff_ptr[rc] = (dqcoeff_ptr[rc]+2)>>2;
|
|
|
|
|
|
|
|
if (y)
|
|
|
|
{
|
|
|
|
eob = i; // last nonzero coeffs
|
|
|
|
}
|
|
|
|
}
|
2011-02-14 23:18:18 +01:00
|
|
|
}
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
d->eob = eob + 1;
|
2011-02-14 23:18:18 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#endif //EXACT_FASTQUANT
|
|
|
|
|
|
|
|
#ifdef EXACT_QUANT
|
|
|
|
void vp8_regular_quantize_b_2x2(BLOCK *b, BLOCKD *d)
|
|
|
|
{
|
|
|
|
int i, rc, eob;
|
|
|
|
int zbin;
|
|
|
|
int x, y, z, sz;
|
|
|
|
short *zbin_boost_ptr = b->zrun_zbin_boost;
|
|
|
|
short *coeff_ptr = b->coeff;
|
|
|
|
short *zbin_ptr = b->zbin;
|
|
|
|
short *round_ptr = b->round;
|
|
|
|
short *quant_ptr = b->quant;
|
|
|
|
unsigned char *quant_shift_ptr = b->quant_shift;
|
|
|
|
short *qcoeff_ptr = d->qcoeff;
|
|
|
|
short *dqcoeff_ptr = d->dqcoeff;
|
|
|
|
short *dequant_ptr = d->dequant;
|
|
|
|
short zbin_oq_value = b->zbin_extra;
|
|
|
|
//double q2nd = 4;
|
|
|
|
vpx_memset(qcoeff_ptr, 0, 32);
|
|
|
|
vpx_memset(dqcoeff_ptr, 0, 32);
|
|
|
|
|
|
|
|
eob = -1;
|
|
|
|
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
for (i = 0; i < b->eob_max_offset_8x8; i++)
|
2011-02-14 23:18:18 +01:00
|
|
|
{
|
|
|
|
rc = vp8_default_zig_zag1d[i];
|
|
|
|
z = coeff_ptr[rc];
|
|
|
|
|
|
|
|
//zbin = (zbin_ptr[rc] + *zbin_boost_ptr + zbin_oq_value)/q2nd;
|
|
|
|
zbin = (zbin_ptr[rc] + *zbin_boost_ptr + zbin_oq_value);
|
|
|
|
|
|
|
|
zbin_boost_ptr ++;
|
|
|
|
sz = (z >> 31); // sign of z
|
|
|
|
x = (z ^ sz) - sz; // x = abs(z)
|
|
|
|
|
|
|
|
if (x >= zbin)
|
|
|
|
{
|
|
|
|
//x += (round_ptr[rc]/q2nd);
|
|
|
|
x += (round_ptr[rc]);
|
|
|
|
y = ((int)((int)(x * quant_ptr[rc]) >> 16) + x)
|
|
|
|
>> quant_shift_ptr[rc]; // quantize (x)
|
|
|
|
x = (y ^ sz) - sz; // get the sign back
|
|
|
|
qcoeff_ptr[rc] = x; // write to destination
|
|
|
|
//dqcoeff_ptr[rc] = x * dequant_ptr[rc]/q2nd; // dequantized value
|
|
|
|
dqcoeff_ptr[rc] = x * dequant_ptr[rc]; // dequantized value
|
2011-11-10 21:54:22 +01:00
|
|
|
|
|
|
|
|
2011-02-14 23:18:18 +01:00
|
|
|
if (y)
|
|
|
|
{
|
|
|
|
eob = i; // last nonzero coeffs
|
|
|
|
zbin_boost_ptr = &b->zrun_zbin_boost[0]; // reset zero runlength
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
d->eob = eob + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void vp8_regular_quantize_b_8x8(BLOCK *b, BLOCKD *d)
|
|
|
|
{
|
|
|
|
int i, rc, eob;
|
|
|
|
int zbin;
|
|
|
|
int x, y, z, sz;
|
|
|
|
short *zbin_boost_ptr = b->zrun_zbin_boost;
|
|
|
|
short *coeff_ptr = b->coeff;
|
|
|
|
short *zbin_ptr = b->zbin;
|
|
|
|
short *round_ptr = b->round;
|
|
|
|
short *quant_ptr = b->quant;
|
|
|
|
unsigned char *quant_shift_ptr = b->quant_shift;
|
|
|
|
short *qcoeff_ptr = d->qcoeff;
|
|
|
|
short *dqcoeff_ptr = d->dqcoeff;
|
|
|
|
short *dequant_ptr = d->dequant;
|
|
|
|
short zbin_oq_value = b->zbin_extra;
|
|
|
|
//double q1st = 2;
|
|
|
|
|
|
|
|
vpx_memset(qcoeff_ptr, 0, 64*sizeof(short));
|
|
|
|
vpx_memset(dqcoeff_ptr, 0, 64*sizeof(short));
|
|
|
|
|
|
|
|
eob = -1;
|
|
|
|
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
for (i = 0; i < b->eob_max_offset_8x8; i++)
|
2011-02-14 23:18:18 +01:00
|
|
|
{
|
|
|
|
|
|
|
|
rc = vp8_default_zig_zag1d_8x8[i];
|
|
|
|
z = coeff_ptr[rc];
|
|
|
|
|
|
|
|
//zbin = (zbin_ptr[rc!=0] + *zbin_boost_ptr + zbin_oq_value)/q1st;
|
|
|
|
zbin = (zbin_ptr[rc!=0] + *zbin_boost_ptr + zbin_oq_value);
|
|
|
|
|
|
|
|
zbin_boost_ptr ++;
|
|
|
|
sz = (z >> 31); // sign of z
|
|
|
|
x = (z ^ sz) - sz; // x = abs(z)
|
|
|
|
|
|
|
|
if (x >= zbin)
|
|
|
|
{
|
|
|
|
//x += (round_ptr[rc!=0]/q1st);
|
|
|
|
//y = ((int)(((int)(x * quant_ptr[rc!=0] * q1st) >> 16) + x))
|
|
|
|
// >> quant_shift_ptr[rc!=0]; // quantize (x)
|
|
|
|
x += (round_ptr[rc!=0]);
|
|
|
|
y = ((int)(((int)(x * quant_ptr[rc!=0]) >> 16) + x))
|
|
|
|
>> quant_shift_ptr[rc!=0]; // quantize (x)
|
|
|
|
x = (y ^ sz) - sz; // get the sign back
|
|
|
|
qcoeff_ptr[rc] = x; // write to destination
|
|
|
|
//dqcoeff_ptr[rc] = x * dequant_ptr[rc!=0] / q1st; // dequantized value
|
|
|
|
dqcoeff_ptr[rc] = x * dequant_ptr[rc!=0]; // dequantized value
|
|
|
|
|
|
|
|
if (y)
|
|
|
|
{
|
|
|
|
eob = i; // last nonzero coeffs
|
|
|
|
zbin_boost_ptr = &b->zrun_zbin_boost[0]; // reset zero runlength
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
d->eob = eob + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void vp8_strict_quantize_b_2x2(BLOCK *b, BLOCKD *d)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int rc;
|
|
|
|
int eob;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int z;
|
|
|
|
int sz;
|
|
|
|
short *coeff_ptr;
|
|
|
|
short *quant_ptr;
|
|
|
|
unsigned char *quant_shift_ptr;
|
|
|
|
short *qcoeff_ptr;
|
|
|
|
short *dqcoeff_ptr;
|
|
|
|
short *dequant_ptr;
|
|
|
|
//double q2nd = 4;
|
|
|
|
coeff_ptr = b->coeff;
|
|
|
|
quant_ptr = b->quant;
|
|
|
|
quant_shift_ptr = b->quant_shift;
|
|
|
|
qcoeff_ptr = d->qcoeff;
|
|
|
|
dqcoeff_ptr = d->dqcoeff;
|
|
|
|
dequant_ptr = d->dequant;
|
|
|
|
eob = - 1;
|
|
|
|
vpx_memset(qcoeff_ptr, 0, 32);
|
|
|
|
vpx_memset(dqcoeff_ptr, 0, 32);
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
int dq;
|
|
|
|
int round;
|
|
|
|
|
|
|
|
/*TODO: These arrays should be stored in zig-zag order.*/
|
|
|
|
rc = vp8_default_zig_zag1d[i];
|
|
|
|
z = coeff_ptr[rc];
|
|
|
|
//z = z * q2nd;
|
|
|
|
//dq = dequant_ptr[rc]/q2nd;
|
|
|
|
dq = dequant_ptr[rc];
|
|
|
|
round = dq >> 1;
|
|
|
|
/* Sign of z. */
|
|
|
|
sz = -(z < 0);
|
|
|
|
x = (z + sz) ^ sz;
|
|
|
|
x += round;
|
|
|
|
if (x >= dq)
|
|
|
|
{
|
|
|
|
/* Quantize x */
|
|
|
|
y = (((x * quant_ptr[rc]) >> 16) + x) >> quant_shift_ptr[rc];
|
|
|
|
/* Put the sign back. */
|
|
|
|
x = (y + sz) ^ sz;
|
|
|
|
/* Save * the * coefficient and its dequantized value. */
|
|
|
|
qcoeff_ptr[rc] = x;
|
|
|
|
dqcoeff_ptr[rc] = x * dq;
|
|
|
|
/* Remember the last non-zero coefficient. */
|
|
|
|
if (y)
|
|
|
|
eob = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
d->eob = eob + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void vp8_strict_quantize_b_8x8(BLOCK *b, BLOCKD *d)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int rc;
|
|
|
|
int eob;
|
|
|
|
int x;
|
|
|
|
int y;
|
|
|
|
int z;
|
|
|
|
int sz;
|
|
|
|
short *coeff_ptr;
|
|
|
|
short *quant_ptr;
|
|
|
|
unsigned char *quant_shift_ptr;
|
|
|
|
short *qcoeff_ptr;
|
|
|
|
short *dqcoeff_ptr;
|
|
|
|
short *dequant_ptr;
|
|
|
|
//double q1st = 2;
|
|
|
|
printf("call strict quantizer\n");
|
|
|
|
coeff_ptr = b->coeff;
|
|
|
|
quant_ptr = b->quant;
|
|
|
|
quant_shift_ptr = b->quant_shift;
|
|
|
|
qcoeff_ptr = d->qcoeff;
|
|
|
|
dqcoeff_ptr = d->dqcoeff;
|
|
|
|
dequant_ptr = d->dequant;
|
|
|
|
eob = - 1;
|
|
|
|
vpx_memset(qcoeff_ptr, 0, 64*sizeof(short));
|
|
|
|
vpx_memset(dqcoeff_ptr, 0, 64*sizeof(short));
|
|
|
|
for (i = 0; i < 64; i++)
|
|
|
|
{
|
|
|
|
int dq;
|
|
|
|
int round;
|
|
|
|
|
|
|
|
/*TODO: These arrays should be stored in zig-zag order.*/
|
|
|
|
rc = vp8_default_zig_zag1d_8x8[i];
|
|
|
|
z = coeff_ptr[rc];
|
|
|
|
//z = z * q1st;
|
|
|
|
//dq = dequant_ptr[rc!=0]/q1st;
|
|
|
|
dq = dequant_ptr[rc!=0];
|
|
|
|
round = dq >> 1;
|
|
|
|
/* Sign of z. */
|
|
|
|
sz = -(z < 0);
|
|
|
|
x = (z + sz) ^ sz;
|
|
|
|
x += round;
|
|
|
|
if (x >= dq)
|
|
|
|
{
|
|
|
|
/* Quantize x. */
|
|
|
|
y = ((int)(((int)((x * quant_ptr[rc!=0])) >> 16) + x)) >> quant_shift_ptr[rc!=0];
|
|
|
|
/* Put the sign back. */
|
|
|
|
x = (y + sz) ^ sz;
|
|
|
|
/* Save the coefficient and its dequantized value. * */
|
|
|
|
qcoeff_ptr[rc] = x;
|
|
|
|
dqcoeff_ptr[rc] = x * dq;
|
|
|
|
/* Remember the last non-zero coefficient. */
|
|
|
|
if (y)
|
|
|
|
eob = i;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
d->eob = eob + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
void vp8_regular_quantize_b_2x2(BLOCK *b, BLOCKD *d)
|
|
|
|
{
|
|
|
|
int i, rc, eob;
|
|
|
|
int zbin;
|
|
|
|
int x, y, z, sz;
|
|
|
|
short *zbin_boost_ptr = b->zrun_zbin_boost;
|
|
|
|
short *coeff_ptr = b->coeff;
|
|
|
|
short *zbin_ptr = b->zbin;
|
|
|
|
short *round_ptr = b->round;
|
|
|
|
short *quant_ptr = b->quant;
|
|
|
|
short *qcoeff_ptr = d->qcoeff;
|
|
|
|
short *dqcoeff_ptr = d->dqcoeff;
|
|
|
|
short *dequant_ptr = d->dequant;
|
|
|
|
short zbin_oq_value = b->zbin_extra;
|
|
|
|
//double q2nd = 4;
|
|
|
|
vpx_memset(qcoeff_ptr, 0, 32);
|
|
|
|
vpx_memset(dqcoeff_ptr, 0, 32);
|
|
|
|
|
|
|
|
eob = -1;
|
|
|
|
for (i = 0; i < 4; i++)
|
|
|
|
{
|
|
|
|
rc = vp8_default_zig_zag1d[i];
|
|
|
|
z = coeff_ptr[rc];
|
|
|
|
//zbin = (zbin_ptr[rc] + *zbin_boost_ptr + zbin_oq_value)/q2nd;
|
|
|
|
zbin = (zbin_ptr[rc] + *zbin_boost_ptr + zbin_oq_value);
|
|
|
|
zbin_boost_ptr ++;
|
|
|
|
sz = (z >> 31); // sign of z
|
|
|
|
x = (z ^ sz) - sz; // x = abs(z)
|
|
|
|
|
|
|
|
if (x >= zbin)
|
|
|
|
{
|
|
|
|
//y = (((x + round_ptr[rc]/q2nd) * quant_ptr[rc]*q2nd)) >> 16; // quantize (x)
|
|
|
|
y = (((x + round_ptr[rc]) * quant_ptr[rc])) >> 16; // quantize (x)
|
|
|
|
x = (y ^ sz) - sz; // get the sign back
|
|
|
|
qcoeff_ptr[rc] = x; // write to destination
|
|
|
|
//dqcoeff_ptr[rc] = x * dequant_ptr[rc]/q2nd; // dequantized value
|
|
|
|
dqcoeff_ptr[rc] = x * dequant_ptr[rc]; // dequantized value
|
|
|
|
|
|
|
|
if (y)
|
|
|
|
{
|
|
|
|
eob = i; // last nonzero coeffs
|
|
|
|
zbin_boost_ptr = &b->zrun_zbin_boost[0]; // reset zero runlength
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
d->eob = eob + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void vp8_regular_quantize_b_8x8(BLOCK *b, BLOCKD *d)
|
|
|
|
{
|
|
|
|
int i, rc, eob;
|
|
|
|
int zbin;
|
|
|
|
int x, y, z, sz;
|
|
|
|
short *zbin_boost_ptr = b->zrun_zbin_boost;
|
|
|
|
short *coeff_ptr = b->coeff;
|
|
|
|
short *zbin_ptr = b->zbin;
|
|
|
|
short *round_ptr = b->round;
|
|
|
|
short *quant_ptr = b->quant;
|
|
|
|
short *qcoeff_ptr = d->qcoeff;
|
|
|
|
short *dqcoeff_ptr = d->dqcoeff;
|
|
|
|
short *dequant_ptr = d->dequant;
|
|
|
|
short zbin_oq_value = b->zbin_extra;
|
|
|
|
//double q1st = 2;
|
|
|
|
vpx_memset(qcoeff_ptr, 0, 64*sizeof(short));
|
|
|
|
vpx_memset(dqcoeff_ptr, 0, 64*sizeof(short));
|
|
|
|
|
|
|
|
eob = -1;
|
|
|
|
for (i = 0; i < 64; i++)
|
|
|
|
{
|
|
|
|
|
|
|
|
rc = vp8_default_zig_zag1d_8x8[i];
|
|
|
|
z = coeff_ptr[rc];
|
|
|
|
//zbin = (zbin_ptr[rc!=0] + *zbin_boost_ptr + zbin_oq_value)/q1st;
|
|
|
|
zbin = (zbin_ptr[rc!=0] + *zbin_boost_ptr + zbin_oq_value);
|
|
|
|
zbin_boost_ptr ++;
|
|
|
|
sz = (z >> 31); // sign of z
|
|
|
|
x = (z ^ sz) - sz; // x = abs(z)
|
|
|
|
|
|
|
|
if (x >= zbin)
|
|
|
|
{
|
|
|
|
//y = ((x + round_ptr[rc!=0]/q1st) * quant_ptr[rc!=0] * q1st) >> 16;
|
|
|
|
y = ((x + round_ptr[rc!=0]) * quant_ptr[rc!=0]) >> 16;
|
|
|
|
x = (y ^ sz) - sz; // get the sign back
|
|
|
|
qcoeff_ptr[rc] = x; // write to destination
|
|
|
|
//dqcoeff_ptr[rc] = x * dequant_ptr[rc!=0]/q1st; // dequantized value
|
|
|
|
dqcoeff_ptr[rc] = x * dequant_ptr[rc!=0]; // dequantized value
|
|
|
|
|
|
|
|
if (y)
|
|
|
|
{
|
|
|
|
eob = i; // last nonzero coeffs
|
|
|
|
zbin_boost_ptr = &b->zrun_zbin_boost[0]; // reset zero runlength
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
d->eob = eob + 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //EXACT_QUANT
|
|
|
|
|
|
|
|
void vp8_quantize_mby_8x8(MACROBLOCK *x)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int has_2nd_order=(x->e_mbd.mode_info_context->mbmi.mode != B_PRED
|
|
|
|
&& x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
|
|
|
|
for(i = 0; i < 16; i ++)
|
|
|
|
{
|
|
|
|
x->e_mbd.block[i].eob = 0;
|
|
|
|
}
|
|
|
|
x->e_mbd.block[24].eob = 0;
|
|
|
|
for (i = 0; i < 16; i+=4)
|
|
|
|
x->quantize_b_8x8(&x->block[i], &x->e_mbd.block[i]);
|
|
|
|
|
|
|
|
if (has_2nd_order)
|
|
|
|
x->quantize_b_2x2(&x->block[24], &x->e_mbd.block[24]);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
void vp8_quantize_mb_8x8(MACROBLOCK *x)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int has_2nd_order=(x->e_mbd.mode_info_context->mbmi.mode != B_PRED
|
|
|
|
&& x->e_mbd.mode_info_context->mbmi.mode != SPLITMV);
|
|
|
|
for(i = 0; i < 25; i ++)
|
|
|
|
{
|
|
|
|
x->e_mbd.block[i].eob = 0;
|
|
|
|
}
|
|
|
|
for (i = 0; i < 24; i+=4)
|
|
|
|
x->quantize_b_8x8(&x->block[i], &x->e_mbd.block[i]);
|
|
|
|
|
|
|
|
if (has_2nd_order)
|
|
|
|
x->quantize_b_2x2(&x->block[24], &x->e_mbd.block[24]);
|
|
|
|
}
|
|
|
|
|
|
|
|
void vp8_quantize_mbuv_8x8(MACROBLOCK *x)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for(i = 16; i < 24; i ++)
|
|
|
|
{
|
|
|
|
x->e_mbd.block[i].eob = 0;
|
|
|
|
}
|
|
|
|
for (i = 16; i < 24; i+=4)
|
|
|
|
x->quantize_b_8x8(&x->block[i], &x->e_mbd.block[i]);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif //CONFIG_T8X8
|
|
|
|
|
2011-05-09 09:09:41 +02:00
|
|
|
/* quantize_b_pair function pointer in MACROBLOCK structure is set to one of
|
|
|
|
* these two C functions if corresponding optimized routine is not available.
|
|
|
|
* NEON optimized version implements currently the fast quantization for pair
|
|
|
|
* of blocks. */
|
|
|
|
void vp8_regular_quantize_b_pair(BLOCK *b1, BLOCK *b2, BLOCKD *d1, BLOCKD *d2)
|
|
|
|
{
|
|
|
|
vp8_regular_quantize_b(b1, d1);
|
|
|
|
vp8_regular_quantize_b(b2, d2);
|
|
|
|
}
|
|
|
|
|
|
|
|
void vp8_fast_quantize_b_pair_c(BLOCK *b1, BLOCK *b2, BLOCKD *d1, BLOCKD *d2)
|
|
|
|
{
|
|
|
|
vp8_fast_quantize_b_c(b1, d1);
|
|
|
|
vp8_fast_quantize_b_c(b2, d2);
|
|
|
|
}
|
|
|
|
|
2011-05-19 17:04:03 +02:00
|
|
|
|
|
|
|
#define EXACT_QUANT
|
|
|
|
#ifdef EXACT_QUANT
|
|
|
|
static void invert_quant(int improved_quant, short *quant,
|
|
|
|
unsigned char *shift, short d)
|
|
|
|
{
|
|
|
|
if(improved_quant)
|
|
|
|
{
|
|
|
|
unsigned t;
|
|
|
|
int l;
|
|
|
|
t = d;
|
|
|
|
for(l = 0; t > 1; l++)
|
|
|
|
t>>=1;
|
|
|
|
t = 1 + (1<<(16+l))/d;
|
|
|
|
*quant = (short)(t - (1<<16));
|
|
|
|
*shift = l;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
*quant = (1 << 16) / d;
|
|
|
|
*shift = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void vp8cx_init_quantizer(VP8_COMP *cpi)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int quant_val;
|
|
|
|
int Q;
|
2011-12-08 05:08:31 +01:00
|
|
|
int zbin_boost[16] = { 0, 0, 8, 10, 12, 14, 16, 20,
|
|
|
|
24, 28, 32, 36, 40, 44, 44, 44};
|
2011-12-02 15:57:21 +01:00
|
|
|
int qrounding_factor = 48;
|
|
|
|
|
2011-05-19 17:04:03 +02:00
|
|
|
for (Q = 0; Q < QINDEX_RANGE; Q++)
|
|
|
|
{
|
2011-12-08 05:08:31 +01:00
|
|
|
int qzbin_factor = (vp8_dc_quant(Q,0) < 148) ? 84 : 80;
|
2012-02-09 17:44:46 +01:00
|
|
|
|
2011-05-19 17:04:03 +02:00
|
|
|
// dc values
|
|
|
|
quant_val = vp8_dc_quant(Q, cpi->common.y1dc_delta_q);
|
|
|
|
cpi->Y1quant_fast[Q][0] = (1 << 16) / quant_val;
|
|
|
|
invert_quant(cpi->sf.improved_quant, cpi->Y1quant[Q] + 0,
|
|
|
|
cpi->Y1quant_shift[Q] + 0, quant_val);
|
2011-12-02 15:57:21 +01:00
|
|
|
cpi->Y1zbin[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
|
|
|
|
cpi->Y1round[Q][0] = (qrounding_factor * quant_val) >> 7;
|
2011-05-19 17:04:03 +02:00
|
|
|
cpi->common.Y1dequant[Q][0] = quant_val;
|
|
|
|
cpi->zrun_zbin_boost_y1[Q][0] = (quant_val * zbin_boost[0]) >> 7;
|
|
|
|
|
|
|
|
quant_val = vp8_dc2quant(Q, cpi->common.y2dc_delta_q);
|
|
|
|
cpi->Y2quant_fast[Q][0] = (1 << 16) / quant_val;
|
|
|
|
invert_quant(cpi->sf.improved_quant, cpi->Y2quant[Q] + 0,
|
|
|
|
cpi->Y2quant_shift[Q] + 0, quant_val);
|
2011-12-02 15:57:21 +01:00
|
|
|
cpi->Y2zbin[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
|
|
|
|
cpi->Y2round[Q][0] = (qrounding_factor * quant_val) >> 7;
|
2011-05-19 17:04:03 +02:00
|
|
|
cpi->common.Y2dequant[Q][0] = quant_val;
|
|
|
|
cpi->zrun_zbin_boost_y2[Q][0] = (quant_val * zbin_boost[0]) >> 7;
|
|
|
|
|
|
|
|
quant_val = vp8_dc_uv_quant(Q, cpi->common.uvdc_delta_q);
|
|
|
|
cpi->UVquant_fast[Q][0] = (1 << 16) / quant_val;
|
|
|
|
invert_quant(cpi->sf.improved_quant, cpi->UVquant[Q] + 0,
|
|
|
|
cpi->UVquant_shift[Q] + 0, quant_val);
|
2011-12-02 15:57:21 +01:00
|
|
|
cpi->UVzbin[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;;
|
|
|
|
cpi->UVround[Q][0] = (qrounding_factor * quant_val) >> 7;
|
2011-05-19 17:04:03 +02:00
|
|
|
cpi->common.UVdequant[Q][0] = quant_val;
|
|
|
|
cpi->zrun_zbin_boost_uv[Q][0] = (quant_val * zbin_boost[0]) >> 7;
|
|
|
|
|
|
|
|
// all the ac values = ;
|
|
|
|
for (i = 1; i < 16; i++)
|
|
|
|
{
|
|
|
|
int rc = vp8_default_zig_zag1d[i];
|
|
|
|
|
|
|
|
quant_val = vp8_ac_yquant(Q);
|
|
|
|
cpi->Y1quant_fast[Q][rc] = (1 << 16) / quant_val;
|
|
|
|
invert_quant(cpi->sf.improved_quant, cpi->Y1quant[Q] + rc,
|
|
|
|
cpi->Y1quant_shift[Q] + rc, quant_val);
|
2011-12-02 15:57:21 +01:00
|
|
|
cpi->Y1zbin[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7;
|
|
|
|
cpi->Y1round[Q][rc] = (qrounding_factor * quant_val) >> 7;
|
2011-05-19 17:04:03 +02:00
|
|
|
cpi->common.Y1dequant[Q][rc] = quant_val;
|
|
|
|
cpi->zrun_zbin_boost_y1[Q][i] = (quant_val * zbin_boost[i]) >> 7;
|
|
|
|
|
|
|
|
quant_val = vp8_ac2quant(Q, cpi->common.y2ac_delta_q);
|
|
|
|
cpi->Y2quant_fast[Q][rc] = (1 << 16) / quant_val;
|
|
|
|
invert_quant(cpi->sf.improved_quant, cpi->Y2quant[Q] + rc,
|
|
|
|
cpi->Y2quant_shift[Q] + rc, quant_val);
|
2011-12-02 15:57:21 +01:00
|
|
|
cpi->Y2zbin[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7;
|
|
|
|
cpi->Y2round[Q][rc] = (qrounding_factor * quant_val) >> 7;
|
2011-05-19 17:04:03 +02:00
|
|
|
cpi->common.Y2dequant[Q][rc] = quant_val;
|
|
|
|
cpi->zrun_zbin_boost_y2[Q][i] = (quant_val * zbin_boost[i]) >> 7;
|
|
|
|
|
|
|
|
quant_val = vp8_ac_uv_quant(Q, cpi->common.uvac_delta_q);
|
|
|
|
cpi->UVquant_fast[Q][rc] = (1 << 16) / quant_val;
|
|
|
|
invert_quant(cpi->sf.improved_quant, cpi->UVquant[Q] + rc,
|
|
|
|
cpi->UVquant_shift[Q] + rc, quant_val);
|
2011-12-02 15:57:21 +01:00
|
|
|
cpi->UVzbin[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7;
|
|
|
|
cpi->UVround[Q][rc] = (qrounding_factor * quant_val) >> 7;
|
2011-05-19 17:04:03 +02:00
|
|
|
cpi->common.UVdequant[Q][rc] = quant_val;
|
|
|
|
cpi->zrun_zbin_boost_uv[Q][i] = (quant_val * zbin_boost[i]) >> 7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#else
|
|
|
|
void vp8cx_init_quantizer(VP8_COMP *cpi)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int quant_val;
|
|
|
|
int Q;
|
|
|
|
int zbin_boost[16] = {0, 0, 8, 10, 12, 14, 16, 20, 24, 28, 32, 36, 40, 44, 44, 44};
|
2011-12-02 15:57:21 +01:00
|
|
|
int qrounding_factor = 48;
|
2011-05-19 17:04:03 +02:00
|
|
|
|
|
|
|
for (Q = 0; Q < QINDEX_RANGE; Q++)
|
|
|
|
{
|
2012-02-09 17:44:46 +01:00
|
|
|
int qzbin_factor = vp8_dc_quant(Q,0) < 148 ) ? 84: 80;
|
|
|
|
|
2011-05-19 17:04:03 +02:00
|
|
|
// dc values
|
|
|
|
quant_val = vp8_dc_quant(Q, cpi->common.y1dc_delta_q);
|
|
|
|
cpi->Y1quant[Q][0] = (1 << 16) / quant_val;
|
2011-12-02 15:57:21 +01:00
|
|
|
cpi->Y1zbin[Q][0] = ((qzbin_factors * quant_val) + 64) >> 7;
|
|
|
|
cpi->Y1round[Q][0] = (qrounding_factor * quant_val) >> 7;
|
2011-05-19 17:04:03 +02:00
|
|
|
cpi->common.Y1dequant[Q][0] = quant_val;
|
|
|
|
cpi->zrun_zbin_boost_y1[Q][0] = (quant_val * zbin_boost[0]) >> 7;
|
|
|
|
|
|
|
|
quant_val = vp8_dc2quant(Q, cpi->common.y2dc_delta_q);
|
|
|
|
cpi->Y2quant[Q][0] = (1 << 16) / quant_val;
|
2011-12-02 15:57:21 +01:00
|
|
|
cpi->Y2zbin[Q][0] = ((qzbin_factors * quant_val) + 64) >> 7;
|
|
|
|
cpi->Y2round[Q][0] = (qrounding_factor * quant_val) >> 7;
|
2011-05-19 17:04:03 +02:00
|
|
|
cpi->common.Y2dequant[Q][0] = quant_val;
|
|
|
|
cpi->zrun_zbin_boost_y2[Q][0] = (quant_val * zbin_boost[0]) >> 7;
|
|
|
|
|
|
|
|
quant_val = vp8_dc_uv_quant(Q, cpi->common.uvdc_delta_q);
|
|
|
|
cpi->UVquant[Q][0] = (1 << 16) / quant_val;
|
2011-12-02 15:57:21 +01:00
|
|
|
cpi->UVzbin[Q][0] = ((qzbin_factors * quant_val) + 64) >> 7;;
|
|
|
|
cpi->UVround[Q][0] = (qrounding_factor * quant_val) >> 7;
|
2011-05-19 17:04:03 +02:00
|
|
|
cpi->common.UVdequant[Q][0] = quant_val;
|
|
|
|
cpi->zrun_zbin_boost_uv[Q][0] = (quant_val * zbin_boost[0]) >> 7;
|
|
|
|
|
|
|
|
// all the ac values = ;
|
|
|
|
for (i = 1; i < 16; i++)
|
|
|
|
{
|
|
|
|
int rc = vp8_default_zig_zag1d[i];
|
|
|
|
|
|
|
|
quant_val = vp8_ac_yquant(Q);
|
|
|
|
cpi->Y1quant[Q][rc] = (1 << 16) / quant_val;
|
2011-12-02 15:57:21 +01:00
|
|
|
cpi->Y1zbin[Q][rc] = ((qzbin_factors * quant_val) + 64) >> 7;
|
|
|
|
cpi->Y1round[Q][rc] = (qrounding_factor * quant_val) >> 7;
|
2011-05-19 17:04:03 +02:00
|
|
|
cpi->common.Y1dequant[Q][rc] = quant_val;
|
|
|
|
cpi->zrun_zbin_boost_y1[Q][i] = (quant_val * zbin_boost[i]) >> 7;
|
|
|
|
|
|
|
|
quant_val = vp8_ac2quant(Q, cpi->common.y2ac_delta_q);
|
|
|
|
cpi->Y2quant[Q][rc] = (1 << 16) / quant_val;
|
2011-12-02 15:57:21 +01:00
|
|
|
cpi->Y2zbin[Q][rc] = ((qzbin_factors * quant_val) + 64) >> 7;
|
|
|
|
cpi->Y2round[Q][rc] = (qrounding_factors * quant_val) >> 7;
|
2011-05-19 17:04:03 +02:00
|
|
|
cpi->common.Y2dequant[Q][rc] = quant_val;
|
|
|
|
cpi->zrun_zbin_boost_y2[Q][i] = (quant_val * zbin_boost[i]) >> 7;
|
|
|
|
|
|
|
|
quant_val = vp8_ac_uv_quant(Q, cpi->common.uvac_delta_q);
|
|
|
|
cpi->UVquant[Q][rc] = (1 << 16) / quant_val;
|
2011-12-02 15:57:21 +01:00
|
|
|
cpi->UVzbin[Q][rc] = ((qzbin_factors * quant_val) + 64) >> 7;
|
|
|
|
cpi->UVround[Q][rc] = (qrounding_factors * quant_val) >> 7;
|
2011-05-19 17:04:03 +02:00
|
|
|
cpi->common.UVdequant[Q][rc] = quant_val;
|
|
|
|
cpi->zrun_zbin_boost_uv[Q][i] = (quant_val * zbin_boost[i]) >> 7;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
void vp8cx_mb_init_quantizer(VP8_COMP *cpi, MACROBLOCK *x)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int QIndex;
|
|
|
|
MACROBLOCKD *xd = &x->e_mbd;
|
|
|
|
int zbin_extra;
|
2011-09-14 19:20:25 +02:00
|
|
|
int segment_id = xd->mode_info_context->mbmi.segment_id;
|
2011-05-19 17:04:03 +02:00
|
|
|
|
2011-09-14 19:20:25 +02:00
|
|
|
// Select the baseline MB Q index allowing for any segment level change.
|
2011-10-05 12:26:00 +02:00
|
|
|
if ( segfeature_active( xd, segment_id, SEG_LVL_ALT_Q ) )
|
2011-05-19 17:04:03 +02:00
|
|
|
{
|
|
|
|
// Abs Value
|
|
|
|
if (xd->mb_segement_abs_delta == SEGMENT_ABSDATA)
|
2011-11-03 17:58:26 +01:00
|
|
|
QIndex = get_segdata( xd, segment_id, SEG_LVL_ALT_Q );
|
2011-05-19 17:04:03 +02:00
|
|
|
|
|
|
|
// Delta Value
|
|
|
|
else
|
|
|
|
{
|
2011-09-14 19:20:25 +02:00
|
|
|
QIndex = cpi->common.base_qindex +
|
2011-11-03 17:58:26 +01:00
|
|
|
get_segdata( xd, segment_id, SEG_LVL_ALT_Q );
|
2011-09-14 19:20:25 +02:00
|
|
|
|
|
|
|
// Clamp to valid range
|
|
|
|
QIndex = (QIndex >= 0) ? ((QIndex <= MAXQ) ? QIndex : MAXQ) : 0;
|
2011-05-19 17:04:03 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
QIndex = cpi->common.base_qindex;
|
|
|
|
|
|
|
|
// Y
|
|
|
|
zbin_extra = ( cpi->common.Y1dequant[QIndex][1] *
|
|
|
|
( cpi->zbin_over_quant +
|
|
|
|
cpi->zbin_mode_boost +
|
|
|
|
x->act_zbin_adj ) ) >> 7;
|
|
|
|
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
{
|
|
|
|
x->block[i].quant = cpi->Y1quant[QIndex];
|
|
|
|
x->block[i].quant_fast = cpi->Y1quant_fast[QIndex];
|
|
|
|
x->block[i].quant_shift = cpi->Y1quant_shift[QIndex];
|
|
|
|
x->block[i].zbin = cpi->Y1zbin[QIndex];
|
|
|
|
x->block[i].round = cpi->Y1round[QIndex];
|
|
|
|
x->e_mbd.block[i].dequant = cpi->common.Y1dequant[QIndex];
|
|
|
|
x->block[i].zrun_zbin_boost = cpi->zrun_zbin_boost_y1[QIndex];
|
|
|
|
x->block[i].zbin_extra = (short)zbin_extra;
|
2012-02-09 18:06:52 +01:00
|
|
|
|
2011-11-03 13:50:09 +01:00
|
|
|
// Segment max eob offset feature.
|
|
|
|
if ( segfeature_active( xd, segment_id, SEG_LVL_EOB ) )
|
|
|
|
{
|
|
|
|
x->block[i].eob_max_offset =
|
2011-11-03 17:58:26 +01:00
|
|
|
get_segdata( xd, segment_id, SEG_LVL_EOB );
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
#if CONFIG_T8X8
|
|
|
|
x->block[i].eob_max_offset_8x8 =
|
|
|
|
get_segdata( xd, segment_id, SEG_LVL_EOB );
|
|
|
|
#endif
|
2011-11-03 13:50:09 +01:00
|
|
|
}
|
|
|
|
else
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
{
|
2011-11-03 13:50:09 +01:00
|
|
|
x->block[i].eob_max_offset = 16;
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
#if CONFIG_T8X8
|
|
|
|
x->block[i].eob_max_offset_8x8 = 64;
|
|
|
|
#endif
|
|
|
|
}
|
2011-05-19 17:04:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// UV
|
|
|
|
zbin_extra = ( cpi->common.UVdequant[QIndex][1] *
|
|
|
|
( cpi->zbin_over_quant +
|
|
|
|
cpi->zbin_mode_boost +
|
|
|
|
x->act_zbin_adj ) ) >> 7;
|
|
|
|
|
|
|
|
for (i = 16; i < 24; i++)
|
|
|
|
{
|
|
|
|
x->block[i].quant = cpi->UVquant[QIndex];
|
|
|
|
x->block[i].quant_fast = cpi->UVquant_fast[QIndex];
|
|
|
|
x->block[i].quant_shift = cpi->UVquant_shift[QIndex];
|
|
|
|
x->block[i].zbin = cpi->UVzbin[QIndex];
|
|
|
|
x->block[i].round = cpi->UVround[QIndex];
|
|
|
|
x->e_mbd.block[i].dequant = cpi->common.UVdequant[QIndex];
|
|
|
|
x->block[i].zrun_zbin_boost = cpi->zrun_zbin_boost_uv[QIndex];
|
|
|
|
x->block[i].zbin_extra = (short)zbin_extra;
|
2012-02-09 18:06:52 +01:00
|
|
|
|
2011-11-03 13:50:09 +01:00
|
|
|
// Segment max eob offset feature.
|
|
|
|
if ( segfeature_active( xd, segment_id, SEG_LVL_EOB ) )
|
|
|
|
{
|
|
|
|
x->block[i].eob_max_offset =
|
2011-11-03 17:58:26 +01:00
|
|
|
get_segdata( xd, segment_id, SEG_LVL_EOB );
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
#if CONFIG_T8X8
|
|
|
|
x->block[i].eob_max_offset_8x8 =
|
|
|
|
get_segdata( xd, segment_id, SEG_LVL_EOB );
|
|
|
|
#endif
|
|
|
|
|
2011-11-03 13:50:09 +01:00
|
|
|
}
|
|
|
|
else
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
{
|
2011-11-03 13:50:09 +01:00
|
|
|
x->block[i].eob_max_offset = 16;
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
#if CONFIG_T8X8
|
|
|
|
x->block[i].eob_max_offset_8x8 = 64;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
2011-05-19 17:04:03 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// Y2
|
|
|
|
zbin_extra = ( cpi->common.Y2dequant[QIndex][1] *
|
|
|
|
( (cpi->zbin_over_quant / 2) +
|
|
|
|
cpi->zbin_mode_boost +
|
|
|
|
x->act_zbin_adj ) ) >> 7;
|
|
|
|
|
|
|
|
x->block[24].quant_fast = cpi->Y2quant_fast[QIndex];
|
|
|
|
x->block[24].quant = cpi->Y2quant[QIndex];
|
|
|
|
x->block[24].quant_shift = cpi->Y2quant_shift[QIndex];
|
|
|
|
x->block[24].zbin = cpi->Y2zbin[QIndex];
|
|
|
|
x->block[24].round = cpi->Y2round[QIndex];
|
|
|
|
x->e_mbd.block[24].dequant = cpi->common.Y2dequant[QIndex];
|
|
|
|
x->block[24].zrun_zbin_boost = cpi->zrun_zbin_boost_y2[QIndex];
|
|
|
|
x->block[24].zbin_extra = (short)zbin_extra;
|
|
|
|
|
2011-10-05 12:26:00 +02:00
|
|
|
// TBD perhaps not use for Y2
|
|
|
|
// Segment max eob offset feature.
|
|
|
|
if ( segfeature_active( xd, segment_id, SEG_LVL_EOB ) )
|
|
|
|
{
|
|
|
|
x->block[24].eob_max_offset =
|
2011-11-03 17:58:26 +01:00
|
|
|
get_segdata( xd, segment_id, SEG_LVL_EOB );
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
#if CONFIG_T8X8
|
|
|
|
x->block[24].eob_max_offset_8x8 =
|
|
|
|
get_segdata( xd, segment_id, SEG_LVL_EOB );
|
|
|
|
#endif
|
2011-10-05 12:26:00 +02:00
|
|
|
}
|
|
|
|
else
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
{
|
2011-10-05 12:26:00 +02:00
|
|
|
x->block[24].eob_max_offset = 16;
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
#if CONFIG_T8X8
|
2012-02-10 20:49:22 +01:00
|
|
|
x->block[24].eob_max_offset_8x8 = 4;
|
Improved coding using 8x8 transform
In summary, this commit encompasses a series of changes in attempt to
improve the 8x8 transform based coding to help overall compression
quality, please refer to the detailed commit history below for what
are the rationale underly the series of changes:
a. A frame level flag to indicate if 8x8 transform is used at all.
b. 8x8 transform is not used for key frames and small image size.
c. On inter coded frame, macroblocks using modes B_PRED, SPLIT_MV
and I8X8_PRED are forced to using 4x4 transform based coding, the
rest uses 8x8 transform based coding.
d. Encoder and decoder has the same assumption on the relationship
between prediction modes and transform size, therefore no signaling
is encoded in bitstream.
e. Mode decision process now calculate the rate and distortion scores
using their respective transforms.
Overall test results:
1. HD set
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120206.html
(avg psnr: 3.09% glb psnr: 3.22%, ssim: 3.90%)
2. Cif set:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120206.html
(avg psnr: -0.03%, glb psnr: -0.02%, ssim: -0.04%)
It should be noted here, as 8x8 transform coding itself is disabled
for cif size clips, the 0.03% loss is purely from the 1 bit/frame
flag overhead on if 8x8 transform is used or not for the frame.
---patch history for future reference---
Patch 1:
this commit tries to select transform size based on macroblock
prediction mode. If the size of a prediction mode is 16x16, then
the macroblock is forced to use 8x8 transform. If the prediction
mode is B_PRED, SPLITMV or I8X8_PRED, then the macroblock is forced
to use 4x4 transform. Tests on the following HD clips showed mixed
results: (all hd clips only used first 100 frames in the test)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_log.html
while the results are mixed and overall negative, it is interesting to
see 8x8 helped a few of the clips.
Patch 2:
this patch tries to hard-wire selection of transform size based on
prediction modes without using segmentation to signal the transform size.
encoder and decoder both takes the same assumption that all macroblocks
use 8x8 transform except when prediciton mode is B_PRED, I8X8_PRED or
SPLITMV. Test results are as follows:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cifmodebase8x8_0125.html
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdmodebased8x8_0125log.html
Interestingly, by removing the overhead or coding the segmentation, the
results on this limited HD set have turn positive on average.
Patch 3:
this patch disabled the usage of 8x8 transform on key frames, and kept the
logic from patch 2 for inter frames only. test results on HD set turned
decidedly positive with 8x8 transform enabled on inter frame with 16x16
prediction modes: (avg psnr: .81% glb psnr: .82 ssim: .55%)
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hdintermode8x8_0125.html
results on cif set still negative overall
Patch 4:
continued from last patch, but now in mode decision process, the rate and
distortion estimates are computed based on 8x8 transform results for MBs
with modes associated with 8x8 transform. This patch also fixed a problem
related to segment based eob coding when 8x8 transform is used. The patch
significantly improved the results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/hd8x8RDintermode.html
(avg psnr: 2.70% glb psnr: 2.76% ssim: 3.34%)
results on cif also improved, though they are still negative compared to
baseline that uses 4x4 transform only:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif8x8RDintermode.html
(avg psnr: -.78% glb psnr: -.86% ssim: -.19%)
Patch 5:
This patch does 3 things:
a. a bunch of decoder bug fixes, encodings and decodings were verified
to have matched recon buffer on a number of encodes on cif size mobile and
hd version of _pedestrian.
b. the patch further improved the rate distortion calculation of MBS that
use 8x8 transform. This provided some further gain on compression.
c. the patch also got the experimental work SEG_LVL_EOB to work with 8x8
transformed macroblock, test results indicates it improves the cif set
but hurt the HD set slightly.
Tests results on HD clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/HD_t8x8_20120201.html
(avg psnr: 3.19% glb psnr: 3.30% ssim: 3.93%)
Test results on cif clips:
http://www.corp.google.com/~yaowu/no_crawl/t8x8/cif_t8x8_20120201.html
(avg psnr: -.47% glb psnr: -.51% ssim: +.28%)
Patch 6:
Added a frame level flag to indicate if 8x8 transform is allowed at all.
temporarily the decision is based on frame size, can be optimized later
one. This get the cif results to basically unchanged, with one bit per
frame overhead on both cif and hd clips.
Patch 8:
Rebase and Merge to head by PGW.
Fixed some suspect 4s that look like hey should be 64s in regard
to segmented EOB. Perhaps #defines would be bette.
Bulit and tested without T8x8 enabled and produces unchanged
output.
Patch 9:
Corrected misalligned code/decode of "txfm_mode" bit.
Limited testing for correct encode and decode with
T8x8 configured on derf clips.
Change-Id: I156e1405d25f81579d579dff8ab9af53944ec49c
2012-02-10 01:12:23 +01:00
|
|
|
#endif
|
|
|
|
}
|
2011-10-05 12:26:00 +02:00
|
|
|
|
2011-05-19 17:04:03 +02:00
|
|
|
/* save this macroblock QIndex for vp8_update_zbin_extra() */
|
|
|
|
x->q_index = QIndex;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void vp8_update_zbin_extra(VP8_COMP *cpi, MACROBLOCK *x)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
int QIndex = x->q_index;
|
|
|
|
int zbin_extra;
|
|
|
|
|
|
|
|
// Y
|
|
|
|
zbin_extra = ( cpi->common.Y1dequant[QIndex][1] *
|
|
|
|
( cpi->zbin_over_quant +
|
|
|
|
cpi->zbin_mode_boost +
|
|
|
|
x->act_zbin_adj ) ) >> 7;
|
|
|
|
for (i = 0; i < 16; i++)
|
|
|
|
{
|
|
|
|
x->block[i].zbin_extra = (short)zbin_extra;
|
|
|
|
}
|
|
|
|
|
|
|
|
// UV
|
|
|
|
zbin_extra = ( cpi->common.UVdequant[QIndex][1] *
|
|
|
|
( cpi->zbin_over_quant +
|
|
|
|
cpi->zbin_mode_boost +
|
|
|
|
x->act_zbin_adj ) ) >> 7;
|
|
|
|
|
|
|
|
for (i = 16; i < 24; i++)
|
|
|
|
{
|
|
|
|
x->block[i].zbin_extra = (short)zbin_extra;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Y2
|
|
|
|
zbin_extra = ( cpi->common.Y2dequant[QIndex][1] *
|
|
|
|
( (cpi->zbin_over_quant / 2) +
|
|
|
|
cpi->zbin_mode_boost +
|
|
|
|
x->act_zbin_adj ) ) >> 7;
|
|
|
|
|
|
|
|
x->block[24].zbin_extra = (short)zbin_extra;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void vp8cx_frame_init_quantizer(VP8_COMP *cpi)
|
|
|
|
{
|
|
|
|
// Clear Zbin mode boost for default case
|
|
|
|
cpi->zbin_mode_boost = 0;
|
|
|
|
|
|
|
|
// MB level quantizer setup
|
|
|
|
vp8cx_mb_init_quantizer(cpi, &cpi->mb);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
void vp8_set_quantizer(struct VP8_COMP *cpi, int Q)
|
|
|
|
{
|
|
|
|
VP8_COMMON *cm = &cpi->common;
|
|
|
|
|
2012-01-20 01:56:46 +01:00
|
|
|
cm->base_qindex = Q;
|
|
|
|
|
2012-01-11 15:05:57 +01:00
|
|
|
// if any of the delta_q values are changing update flag will
|
|
|
|
// have to be set.
|
2011-05-19 17:04:03 +02:00
|
|
|
cm->y1dc_delta_q = 0;
|
|
|
|
cm->y2ac_delta_q = 0;
|
|
|
|
cm->uvdc_delta_q = 0;
|
|
|
|
cm->uvac_delta_q = 0;
|
2012-01-11 15:05:57 +01:00
|
|
|
cm->y2dc_delta_q = 0;
|
2011-05-19 17:04:03 +02:00
|
|
|
|
2012-01-11 15:05:57 +01:00
|
|
|
// quantizer has to be reinitialized if any delta_q changes.
|
|
|
|
// As there are not any here for now this is inactive code.
|
|
|
|
//if(update)
|
|
|
|
// vp8cx_init_quantizer(cpi);
|
2011-05-19 17:04:03 +02:00
|
|
|
}
|
2011-07-20 23:21:24 +02:00
|
|
|
|