Merge "Consistent usage of ROUND_POWER_OF_TWO macro." into experimental
This commit is contained in:
Коммит
3edbc77ae3
|
@ -25,23 +25,27 @@
|
|||
#define MIN(x, y) (((x) < (y)) ? (x) : (y))
|
||||
#define MAX(x, y) (((x) > (y)) ? (x) : (y))
|
||||
|
||||
/* Only need this for fixed-size arrays, for structs just assign. */
|
||||
#define ROUND_POWER_OF_TWO(value, n) (((value) + (1 << ((n) - 1))) >> (n))
|
||||
|
||||
#define vp9_copy(Dest, Src) { \
|
||||
assert(sizeof(Dest) == sizeof(Src)); \
|
||||
vpx_memcpy(Dest, Src, sizeof(Src)); \
|
||||
/* If we don't want to use ROUND_POWER_OF_TWO macro
|
||||
static INLINE int16_t round_power_of_two(int16_t value, int n) {
|
||||
return (value + (1 << (n - 1))) >> n;
|
||||
}*/
|
||||
|
||||
// Only need this for fixed-size arrays, for structs just assign.
|
||||
#define vp9_copy(dest, src) { \
|
||||
assert(sizeof(dest) == sizeof(src)); \
|
||||
vpx_memcpy(dest, src, sizeof(src)); \
|
||||
}
|
||||
|
||||
/* Use this for variably-sized arrays. */
|
||||
|
||||
#define vp9_copy_array(Dest, Src, N) { \
|
||||
assert(sizeof(*Dest) == sizeof(*Src)); \
|
||||
vpx_memcpy(Dest, Src, N * sizeof(*Src)); \
|
||||
// Use this for variably-sized arrays.
|
||||
#define vp9_copy_array(dest, src, n) { \
|
||||
assert(sizeof(*dest) == sizeof(*src)); \
|
||||
vpx_memcpy(dest, src, n * sizeof(*src)); \
|
||||
}
|
||||
|
||||
#define vp9_zero(Dest) vpx_memset(&Dest, 0, sizeof(Dest));
|
||||
|
||||
#define vp9_zero_array(Dest, N) vpx_memset(Dest, 0, N * sizeof(*Dest));
|
||||
#define vp9_zero(dest) vpx_memset(&dest, 0, sizeof(dest));
|
||||
#define vp9_zero_array(dest, n) vpx_memset(dest, 0, n * sizeof(*dest));
|
||||
|
||||
static INLINE uint8_t clip_pixel(int val) {
|
||||
return (val > 255) ? 255u : (val < 0) ? 0u : val;
|
||||
|
|
|
@ -15,17 +15,12 @@
|
|||
|
||||
#include "./vpx_config.h"
|
||||
#include "vpx/vpx_integer.h"
|
||||
|
||||
#define ROUND_POWER_OF_TWO(value, n) (((value) + (1 << ((n) - 1))) >> (n))
|
||||
|
||||
/* If we don't want to use ROUND_POWER_OF_TWO macro
|
||||
static INLINE int16_t round_power_of_two(int16_t value, int n) {
|
||||
return (value + (1 << (n - 1))) >> n;
|
||||
}*/
|
||||
#include "vp9/common/vp9_common.h"
|
||||
|
||||
// Constants and Macros used by all idct/dct functions
|
||||
#define DCT_CONST_BITS 14
|
||||
#define DCT_CONST_ROUNDING (1 << (DCT_CONST_BITS - 1))
|
||||
|
||||
// Constants are round(16384 * cos(k*Pi/64)) where k = 1 to 31.
|
||||
// Note: sin(k*Pi/64) = cos((32-k)*Pi/64)
|
||||
static const int cospi_1_64 = 16364;
|
||||
|
@ -67,13 +62,13 @@ static const int sinpi_3_9 = 13377;
|
|||
static const int sinpi_4_9 = 15212;
|
||||
|
||||
static INLINE int dct_const_round_shift(int input) {
|
||||
int rv = (input + DCT_CONST_ROUNDING) >> DCT_CONST_BITS;
|
||||
int rv = ROUND_POWER_OF_TWO(input, DCT_CONST_BITS);
|
||||
assert(INT16_MIN <= rv && rv <= INT16_MAX);
|
||||
return rv;
|
||||
}
|
||||
|
||||
static INLINE int dct_32_round(int input) {
|
||||
int rv = (input + DCT_CONST_ROUNDING) >> DCT_CONST_BITS;
|
||||
int rv = ROUND_POWER_OF_TWO(input, DCT_CONST_BITS);
|
||||
assert(-131072 <= rv && rv <= 131071);
|
||||
return rv;
|
||||
}
|
||||
|
|
|
@ -9,20 +9,19 @@
|
|||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
#include "./vpx_config.h"
|
||||
#include "vp9_rtcd.h"
|
||||
#include "vp9/common/vp9_reconintra.h"
|
||||
#include "vpx_mem/vpx_mem.h"
|
||||
|
||||
/* For skip_recon_mb(), add vp9_build_intra_predictors_mby_s(MACROBLOCKD *xd)
|
||||
* and vp9_build_intra_predictors_mbuv_s(MACROBLOCKD *xd).
|
||||
*/
|
||||
// For skip_recon_mb(), add vp9_build_intra_predictors_mby_s(MACROBLOCKD *xd)
|
||||
// and vp9_build_intra_predictors_mbuv_s(MACROBLOCKD *xd).
|
||||
|
||||
/* Using multiplication and shifting instead of division in diagonal prediction.
|
||||
* iscale table is calculated from ((1<<16) + (i+2)/2) / (i+2) and used as
|
||||
* ((A + B) * iscale[i] + (1<<15)) >> 16;
|
||||
* where A and B are weighted pixel values.
|
||||
*/
|
||||
// Using multiplication and shifting instead of division in diagonal prediction.
|
||||
// iscale table is calculated from ((1 << 16) + (i + 2) / 2) / (i+2) and used as
|
||||
// ((A + B) * iscale[i] + (1 << 15)) >> 16;
|
||||
// where A and B are weighted pixel values.
|
||||
static const unsigned int iscale[64] = {
|
||||
32768, 21845, 16384, 13107, 10923, 9362, 8192, 7282,
|
||||
6554, 5958, 5461, 5041, 4681, 4369, 4096, 3855,
|
||||
|
@ -34,101 +33,107 @@ static const unsigned int iscale[64] = {
|
|||
1130, 1111, 1092, 1074, 1057, 1040, 1024, 1008,
|
||||
};
|
||||
|
||||
static INLINE int iscale_round(int value, int i) {
|
||||
return ROUND_POWER_OF_TWO(value * iscale[i], 16);
|
||||
}
|
||||
|
||||
static void d27_predictor(uint8_t *ypred_ptr, int y_stride, int n,
|
||||
uint8_t *yabove_row, uint8_t *yleft_col) {
|
||||
int r, c, h, w, v;
|
||||
int a, b;
|
||||
int r, c;
|
||||
|
||||
r = 0;
|
||||
for (c = 0; c < n - 2; c++) {
|
||||
if (c & 1)
|
||||
a = yleft_col[r + 1];
|
||||
else
|
||||
a = (yleft_col[r] + yleft_col[r + 1] + 1) >> 1;
|
||||
b = yabove_row[c + 2];
|
||||
ypred_ptr[c] = ((2 * a + (c + 1) * b) * iscale[1+c] + (1<<15)) >> 16;
|
||||
int a = c & 1 ? yleft_col[r + 1]
|
||||
: ROUND_POWER_OF_TWO(yleft_col[r] + yleft_col[r + 1], 1);
|
||||
int b = yabove_row[c + 2];
|
||||
ypred_ptr[c] = iscale_round(2 * a + (c + 1) * b, 1 + c);
|
||||
}
|
||||
|
||||
for (r = 1; r < n / 2 - 1; r++) {
|
||||
for (c = 0; c < n - 2 - 2 * r; c++) {
|
||||
if (c & 1)
|
||||
a = yleft_col[r + 1];
|
||||
else
|
||||
a = (yleft_col[r] + yleft_col[r + 1] + 1) >> 1;
|
||||
b = ypred_ptr[(r - 1) * y_stride + c + 2];
|
||||
ypred_ptr[r * y_stride + c] =
|
||||
((2 * a + (c + 1) * b) * iscale[1+c] + (1<<15)) >> 16;
|
||||
int a = c & 1 ? yleft_col[r + 1]
|
||||
: ROUND_POWER_OF_TWO(yleft_col[r] + yleft_col[r + 1], 1);
|
||||
int b = ypred_ptr[(r - 1) * y_stride + c + 2];
|
||||
ypred_ptr[r * y_stride + c] = iscale_round(2 * a + (c + 1) * b, 1 + c);
|
||||
}
|
||||
}
|
||||
for (; r < n - 1; ++r) {
|
||||
|
||||
for (; r < n - 1; r++) {
|
||||
for (c = 0; c < n; c++) {
|
||||
v = (c & 1 ? yleft_col[r + 1] : (yleft_col[r] + yleft_col[r + 1] + 1) >> 1);
|
||||
h = r - c / 2;
|
||||
int v = c & 1 ? yleft_col[r + 1]
|
||||
: ROUND_POWER_OF_TWO(yleft_col[r] + yleft_col[r + 1], 1);
|
||||
int h = r - c / 2;
|
||||
ypred_ptr[h * y_stride + c] = v;
|
||||
}
|
||||
}
|
||||
|
||||
c = 0;
|
||||
r = n - 1;
|
||||
ypred_ptr[r * y_stride] = (ypred_ptr[(r - 1) * y_stride] +
|
||||
yleft_col[r] + 1) >> 1;
|
||||
ypred_ptr[r * y_stride] = ROUND_POWER_OF_TWO(ypred_ptr[(r - 1) * y_stride] +
|
||||
yleft_col[r], 1);
|
||||
for (r = n - 2; r >= n / 2; --r) {
|
||||
w = c + (n - 1 - r) * 2;
|
||||
ypred_ptr[r * y_stride + w] = (ypred_ptr[(r - 1) * y_stride + w] +
|
||||
ypred_ptr[r * y_stride + w - 1] + 1) >> 1;
|
||||
int w = c + (n - 1 - r) * 2;
|
||||
ypred_ptr[r * y_stride + w] =
|
||||
ROUND_POWER_OF_TWO(ypred_ptr[(r - 1) * y_stride + w] +
|
||||
ypred_ptr[r * y_stride + w - 1], 1);
|
||||
}
|
||||
|
||||
for (c = 1; c < n; c++) {
|
||||
for (r = n - 1; r >= n / 2 + c / 2; --r) {
|
||||
w = c + (n - 1 - r) * 2;
|
||||
ypred_ptr[r * y_stride + w] = (ypred_ptr[(r - 1) * y_stride + w] +
|
||||
ypred_ptr[r * y_stride + w - 1] + 1) >> 1;
|
||||
int w = c + (n - 1 - r) * 2;
|
||||
ypred_ptr[r * y_stride + w] =
|
||||
ROUND_POWER_OF_TWO(ypred_ptr[(r - 1) * y_stride + w] +
|
||||
ypred_ptr[r * y_stride + w - 1], 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void d63_predictor(uint8_t *ypred_ptr, int y_stride, int n,
|
||||
uint8_t *yabove_row, uint8_t *yleft_col) {
|
||||
int r, c, h, w, v;
|
||||
int a, b;
|
||||
int r, c;
|
||||
|
||||
c = 0;
|
||||
for (r = 0; r < n - 2; r++) {
|
||||
if (r & 1)
|
||||
a = yabove_row[c + 1];
|
||||
else
|
||||
a = (yabove_row[c] + yabove_row[c + 1] + 1) >> 1;
|
||||
b = yleft_col[r + 2];
|
||||
ypred_ptr[r * y_stride] = ((2 * a + (r + 1) * b) * iscale[1+r] +
|
||||
(1<<15)) >> 16;
|
||||
int a = r & 1 ? yabove_row[c + 1]
|
||||
: ROUND_POWER_OF_TWO(yabove_row[c] + yabove_row[c + 1], 1);
|
||||
int b = yleft_col[r + 2];
|
||||
ypred_ptr[r * y_stride] = iscale_round(2 * a + (r + 1) * b, 1 + r);
|
||||
}
|
||||
|
||||
for (c = 1; c < n / 2 - 1; c++) {
|
||||
for (r = 0; r < n - 2 - 2 * c; r++) {
|
||||
if (r & 1)
|
||||
a = yabove_row[c + 1];
|
||||
else
|
||||
a = (yabove_row[c] + yabove_row[c + 1] + 1) >> 1;
|
||||
b = ypred_ptr[(r + 2) * y_stride + c - 1];
|
||||
ypred_ptr[r * y_stride + c] = ((2 * a + (c + 1) * b) * iscale[1+c] +
|
||||
(1<<15)) >> 16;
|
||||
int a = r & 1 ? yabove_row[c + 1]
|
||||
: ROUND_POWER_OF_TWO(yabove_row[c] + yabove_row[c + 1], 1);
|
||||
int b = ypred_ptr[(r + 2) * y_stride + c - 1];
|
||||
ypred_ptr[r * y_stride + c] = iscale_round(2 * a + (c + 1) * b, 1 + c);
|
||||
}
|
||||
}
|
||||
|
||||
for (; c < n - 1; ++c) {
|
||||
for (r = 0; r < n; r++) {
|
||||
v = (r & 1 ? yabove_row[c + 1] : (yabove_row[c] + yabove_row[c + 1] + 1) >> 1);
|
||||
w = c - r / 2;
|
||||
int v = r & 1 ? yabove_row[c + 1]
|
||||
: ROUND_POWER_OF_TWO(yabove_row[c] + yabove_row[c + 1], 1);
|
||||
int w = c - r / 2;
|
||||
ypred_ptr[r * y_stride + w] = v;
|
||||
}
|
||||
}
|
||||
|
||||
r = 0;
|
||||
c = n - 1;
|
||||
ypred_ptr[c] = (ypred_ptr[(c - 1)] + yabove_row[c] + 1) >> 1;
|
||||
ypred_ptr[c] = ROUND_POWER_OF_TWO(ypred_ptr[(c - 1)] + yabove_row[c], 1);
|
||||
for (c = n - 2; c >= n / 2; --c) {
|
||||
h = r + (n - 1 - c) * 2;
|
||||
ypred_ptr[h * y_stride + c] = (ypred_ptr[h * y_stride + c - 1] +
|
||||
ypred_ptr[(h - 1) * y_stride + c] + 1) >> 1;
|
||||
int h = r + (n - 1 - c) * 2;
|
||||
ypred_ptr[h * y_stride + c] =
|
||||
ROUND_POWER_OF_TWO(ypred_ptr[h * y_stride + c - 1] +
|
||||
ypred_ptr[(h - 1) * y_stride + c], 1);
|
||||
}
|
||||
|
||||
for (r = 1; r < n; r++) {
|
||||
for (c = n - 1; c >= n / 2 + r / 2; --c) {
|
||||
h = r + (n - 1 - c) * 2;
|
||||
ypred_ptr[h * y_stride + c] = (ypred_ptr[h * y_stride + c - 1] +
|
||||
ypred_ptr[(h - 1) * y_stride + c] + 1) >> 1;
|
||||
int h = r + (n - 1 - c) * 2;
|
||||
ypred_ptr[h * y_stride + c] =
|
||||
ROUND_POWER_OF_TWO(ypred_ptr[h * y_stride + c - 1] +
|
||||
ypred_ptr[(h - 1) * y_stride + c], 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -136,27 +141,28 @@ static void d63_predictor(uint8_t *ypred_ptr, int y_stride, int n,
|
|||
static void d45_predictor(uint8_t *ypred_ptr, int y_stride, int n,
|
||||
uint8_t *yabove_row, uint8_t *yleft_col) {
|
||||
int r, c;
|
||||
|
||||
for (r = 0; r < n - 1; ++r) {
|
||||
for (c = 0; c <= r; ++c) {
|
||||
ypred_ptr[(r - c) * y_stride + c] =
|
||||
((yabove_row[r + 1] * (c + 1) +
|
||||
yleft_col[r + 1] * (r - c + 1)) * iscale[r] + (1<<15)) >> 16;
|
||||
ypred_ptr[(r - c) * y_stride + c] = iscale_round(
|
||||
yabove_row[r + 1] * (c + 1) + yleft_col[r + 1] * (r - c + 1), r);
|
||||
}
|
||||
}
|
||||
|
||||
for (c = 0; c <= r; ++c) {
|
||||
int yabove_ext = yabove_row[r]; // clip_pixel(2 * yabove_row[r] -
|
||||
// yabove_row[r - 1]);
|
||||
int yleft_ext = yleft_col[r]; // clip_pixel(2 * yleft_col[r] -
|
||||
// yleft_col[r-1]);
|
||||
ypred_ptr[(r - c) * y_stride + c] =
|
||||
((yabove_ext * (c + 1) +
|
||||
yleft_ext * (r - c + 1)) * iscale[r] + (1<<15)) >> 16;
|
||||
iscale_round(yabove_ext * (c + 1) + yleft_ext * (r - c + 1), r);
|
||||
}
|
||||
for (r = 1; r < n; ++r) {
|
||||
for (c = n - r; c < n; ++c) {
|
||||
const int yabove_ext = ypred_ptr[(r - 1) * y_stride + c];
|
||||
const int yleft_ext = ypred_ptr[r * y_stride + c - 1];
|
||||
ypred_ptr[r * y_stride + c] = (yabove_ext + yleft_ext + 1) >> 1;
|
||||
ypred_ptr[r * y_stride + c] =
|
||||
ROUND_POWER_OF_TWO(yabove_ext + yleft_ext, 1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -165,7 +171,7 @@ static void d117_predictor(uint8_t *ypred_ptr, int y_stride, int n,
|
|||
uint8_t *yabove_row, uint8_t *yleft_col) {
|
||||
int r, c;
|
||||
for (c = 0; c < n; c++)
|
||||
ypred_ptr[c] = (yabove_row[c - 1] + yabove_row[c] + 1) >> 1;
|
||||
ypred_ptr[c] = ROUND_POWER_OF_TWO(yabove_row[c - 1] + yabove_row[c], 1);
|
||||
ypred_ptr += y_stride;
|
||||
for (c = 0; c < n; c++)
|
||||
ypred_ptr[c] = yabove_row[c - 1];
|
||||
|
@ -199,9 +205,10 @@ static void d135_predictor(uint8_t *ypred_ptr, int y_stride, int n,
|
|||
static void d153_predictor(uint8_t *ypred_ptr, int y_stride, int n,
|
||||
uint8_t *yabove_row, uint8_t *yleft_col) {
|
||||
int r, c;
|
||||
ypred_ptr[0] = (yabove_row[-1] + yleft_col[0] + 1) >> 1;
|
||||
ypred_ptr[0] = ROUND_POWER_OF_TWO(yabove_row[-1] + yleft_col[0], 1);
|
||||
for (r = 1; r < n; r++)
|
||||
ypred_ptr[r * y_stride] = (yleft_col[r - 1] + yleft_col[r] + 1) >> 1;
|
||||
ypred_ptr[r * y_stride] =
|
||||
ROUND_POWER_OF_TWO(yleft_col[r - 1] + yleft_col[r], 1);
|
||||
ypred_ptr++;
|
||||
ypred_ptr[0] = yabove_row[-1];
|
||||
for (r = 1; r < n; r++)
|
||||
|
@ -268,6 +275,20 @@ void vp9_recon_intra_mbuv(MACROBLOCKD *xd) {
|
|||
}
|
||||
}
|
||||
|
||||
static INLINE int log2_minus_1(int n) {
|
||||
switch (n) {
|
||||
case 4: return 1;
|
||||
case 8: return 2;
|
||||
case 16: return 3;
|
||||
case 32: return 4;
|
||||
case 64: return 5;
|
||||
default:
|
||||
assert(0);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void vp9_build_intra_predictors_internal(uint8_t *src, int src_stride,
|
||||
uint8_t *ypred_ptr,
|
||||
int y_stride, int mode, int bsize,
|
||||
|
@ -313,22 +334,7 @@ void vp9_build_intra_predictors_internal(uint8_t *src, int src_stride,
|
|||
int i;
|
||||
int shift;
|
||||
int average = 0;
|
||||
int log2_bsize_minus_1;
|
||||
|
||||
assert(bsize == 4 || bsize == 8 || bsize == 16 || bsize == 32 ||
|
||||
bsize == 64);
|
||||
if (bsize == 4) {
|
||||
log2_bsize_minus_1 = 1;
|
||||
} else if (bsize == 8) {
|
||||
log2_bsize_minus_1 = 2;
|
||||
} else if (bsize == 16) {
|
||||
log2_bsize_minus_1 = 3;
|
||||
} else if (bsize == 32) {
|
||||
log2_bsize_minus_1 = 4;
|
||||
} else {
|
||||
assert(bsize == 64);
|
||||
log2_bsize_minus_1 = 5;
|
||||
}
|
||||
int log2_bsize_minus_1 = log2_minus_1(bsize);
|
||||
|
||||
if (up_available || left_available) {
|
||||
if (up_available) {
|
||||
|
@ -343,7 +349,7 @@ void vp9_build_intra_predictors_internal(uint8_t *src, int src_stride,
|
|||
}
|
||||
}
|
||||
shift = log2_bsize_minus_1 + up_available + left_available;
|
||||
expected_dc = (average + (1 << (shift - 1))) >> shift;
|
||||
expected_dc = ROUND_POWER_OF_TWO(average, shift);
|
||||
} else {
|
||||
expected_dc = 128;
|
||||
}
|
||||
|
@ -354,21 +360,19 @@ void vp9_build_intra_predictors_internal(uint8_t *src, int src_stride,
|
|||
}
|
||||
}
|
||||
break;
|
||||
case V_PRED: {
|
||||
case V_PRED:
|
||||
for (r = 0; r < bsize; r++) {
|
||||
memcpy(ypred_ptr, yabove_row, bsize);
|
||||
ypred_ptr += y_stride;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case H_PRED: {
|
||||
break;
|
||||
case H_PRED:
|
||||
for (r = 0; r < bsize; r++) {
|
||||
vpx_memset(ypred_ptr, yleft_col[r], bsize);
|
||||
ypred_ptr += y_stride;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case TM_PRED: {
|
||||
break;
|
||||
case TM_PRED:
|
||||
for (r = 0; r < bsize; r++) {
|
||||
for (c = 0; c < bsize; c++) {
|
||||
ypred_ptr[c] = clip_pixel(yleft_col[r] + yabove_row[c] - ytop_left);
|
||||
|
@ -376,32 +380,25 @@ void vp9_build_intra_predictors_internal(uint8_t *src, int src_stride,
|
|||
|
||||
ypred_ptr += y_stride;
|
||||
}
|
||||
}
|
||||
break;
|
||||
case D45_PRED: {
|
||||
break;
|
||||
case D45_PRED:
|
||||
d45_predictor(ypred_ptr, y_stride, bsize, yabove_row, yleft_col);
|
||||
}
|
||||
break;
|
||||
case D135_PRED: {
|
||||
break;
|
||||
case D135_PRED:
|
||||
d135_predictor(ypred_ptr, y_stride, bsize, yabove_row, yleft_col);
|
||||
}
|
||||
break;
|
||||
case D117_PRED: {
|
||||
break;
|
||||
case D117_PRED:
|
||||
d117_predictor(ypred_ptr, y_stride, bsize, yabove_row, yleft_col);
|
||||
}
|
||||
break;
|
||||
case D153_PRED: {
|
||||
break;
|
||||
case D153_PRED:
|
||||
d153_predictor(ypred_ptr, y_stride, bsize, yabove_row, yleft_col);
|
||||
}
|
||||
break;
|
||||
case D27_PRED: {
|
||||
break;
|
||||
case D27_PRED:
|
||||
d27_predictor(ypred_ptr, y_stride, bsize, yabove_row, yleft_col);
|
||||
}
|
||||
break;
|
||||
case D63_PRED: {
|
||||
break;
|
||||
case D63_PRED:
|
||||
d63_predictor(ypred_ptr, y_stride, bsize, yabove_row, yleft_col);
|
||||
}
|
||||
break;
|
||||
break;
|
||||
case I8X8_PRED:
|
||||
case B_PRED:
|
||||
case NEARESTMV:
|
||||
|
|
|
@ -564,8 +564,7 @@ void vp9_regular_quantize_b_4x4_pair(MACROBLOCK *x, int b_idx1, int b_idx2) {
|
|||
vp9_regular_quantize_b_4x4(x, b_idx2);
|
||||
}
|
||||
|
||||
static void invert_quant(int16_t *quant,
|
||||
uint8_t *shift, int d) {
|
||||
static void invert_quant(int16_t *quant, uint8_t *shift, int d) {
|
||||
unsigned t;
|
||||
int l;
|
||||
t = d;
|
||||
|
@ -579,56 +578,52 @@ static void invert_quant(int16_t *quant,
|
|||
void vp9_init_quantizer(VP9_COMP *cpi) {
|
||||
int i;
|
||||
int quant_val;
|
||||
int Q;
|
||||
int q;
|
||||
|
||||
static const int zbin_boost[16] = { 0, 0, 0, 8, 8, 8, 10, 12,
|
||||
14, 16, 20, 24, 28, 32, 36, 40 };
|
||||
|
||||
for (Q = 0; Q < QINDEX_RANGE; Q++) {
|
||||
int qzbin_factor = (vp9_dc_quant(Q, 0) < 148) ? 84 : 80;
|
||||
for (q = 0; q < QINDEX_RANGE; q++) {
|
||||
int qzbin_factor = (vp9_dc_quant(q, 0) < 148) ? 84 : 80;
|
||||
int qrounding_factor = 48;
|
||||
if (Q == 0) {
|
||||
if (q == 0) {
|
||||
qzbin_factor = 64;
|
||||
qrounding_factor = 64;
|
||||
}
|
||||
// dc values
|
||||
quant_val = vp9_dc_quant(Q, cpi->common.y1dc_delta_q);
|
||||
invert_quant(cpi->Y1quant[Q] + 0,
|
||||
cpi->Y1quant_shift[Q] + 0, quant_val);
|
||||
cpi->Y1zbin[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
|
||||
cpi->Y1round[Q][0] = (qrounding_factor * quant_val) >> 7;
|
||||
cpi->common.Y1dequant[Q][0] = quant_val;
|
||||
cpi->zrun_zbin_boost_y1[Q][0] = (quant_val * zbin_boost[0]) >> 7;
|
||||
quant_val = vp9_dc_quant(q, cpi->common.y1dc_delta_q);
|
||||
invert_quant(cpi->Y1quant[q] + 0, cpi->Y1quant_shift[q] + 0, quant_val);
|
||||
cpi->Y1zbin[q][0] = ROUND_POWER_OF_TWO(qzbin_factor * quant_val, 7);
|
||||
cpi->Y1round[q][0] = (qrounding_factor * quant_val) >> 7;
|
||||
cpi->common.Y1dequant[q][0] = quant_val;
|
||||
cpi->zrun_zbin_boost_y1[q][0] = (quant_val * zbin_boost[0]) >> 7;
|
||||
|
||||
quant_val = vp9_dc_uv_quant(Q, cpi->common.uvdc_delta_q);
|
||||
invert_quant(cpi->UVquant[Q] + 0,
|
||||
cpi->UVquant_shift[Q] + 0, quant_val);
|
||||
cpi->UVzbin[Q][0] = ((qzbin_factor * quant_val) + 64) >> 7;
|
||||
cpi->UVround[Q][0] = (qrounding_factor * quant_val) >> 7;
|
||||
cpi->common.UVdequant[Q][0] = quant_val;
|
||||
cpi->zrun_zbin_boost_uv[Q][0] = (quant_val * zbin_boost[0]) >> 7;
|
||||
quant_val = vp9_dc_uv_quant(q, cpi->common.uvdc_delta_q);
|
||||
invert_quant(cpi->UVquant[q] + 0, cpi->UVquant_shift[q] + 0, quant_val);
|
||||
cpi->UVzbin[q][0] = ROUND_POWER_OF_TWO(qzbin_factor * quant_val, 7);
|
||||
cpi->UVround[q][0] = (qrounding_factor * quant_val) >> 7;
|
||||
cpi->common.UVdequant[q][0] = quant_val;
|
||||
cpi->zrun_zbin_boost_uv[q][0] = (quant_val * zbin_boost[0]) >> 7;
|
||||
|
||||
// all the 4x4 ac values =;
|
||||
for (i = 1; i < 16; i++) {
|
||||
int rc = vp9_default_zig_zag1d_4x4[i];
|
||||
|
||||
quant_val = vp9_ac_yquant(Q);
|
||||
invert_quant(cpi->Y1quant[Q] + rc,
|
||||
cpi->Y1quant_shift[Q] + rc, quant_val);
|
||||
cpi->Y1zbin[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7;
|
||||
cpi->Y1round[Q][rc] = (qrounding_factor * quant_val) >> 7;
|
||||
cpi->common.Y1dequant[Q][rc] = quant_val;
|
||||
cpi->zrun_zbin_boost_y1[Q][i] =
|
||||
((quant_val * zbin_boost[i]) + 64) >> 7;
|
||||
quant_val = vp9_ac_yquant(q);
|
||||
invert_quant(cpi->Y1quant[q] + rc, cpi->Y1quant_shift[q] + rc, quant_val);
|
||||
cpi->Y1zbin[q][rc] = ROUND_POWER_OF_TWO(qzbin_factor * quant_val, 7);
|
||||
cpi->Y1round[q][rc] = (qrounding_factor * quant_val) >> 7;
|
||||
cpi->common.Y1dequant[q][rc] = quant_val;
|
||||
cpi->zrun_zbin_boost_y1[q][i] =
|
||||
ROUND_POWER_OF_TWO(quant_val * zbin_boost[i], 7);
|
||||
|
||||
quant_val = vp9_ac_uv_quant(Q, cpi->common.uvac_delta_q);
|
||||
invert_quant(cpi->UVquant[Q] + rc,
|
||||
cpi->UVquant_shift[Q] + rc, quant_val);
|
||||
cpi->UVzbin[Q][rc] = ((qzbin_factor * quant_val) + 64) >> 7;
|
||||
cpi->UVround[Q][rc] = (qrounding_factor * quant_val) >> 7;
|
||||
cpi->common.UVdequant[Q][rc] = quant_val;
|
||||
cpi->zrun_zbin_boost_uv[Q][i] =
|
||||
((quant_val * zbin_boost[i]) + 64) >> 7;
|
||||
quant_val = vp9_ac_uv_quant(q, cpi->common.uvac_delta_q);
|
||||
invert_quant(cpi->UVquant[q] + rc, cpi->UVquant_shift[q] + rc, quant_val);
|
||||
cpi->UVzbin[q][rc] = ROUND_POWER_OF_TWO(qzbin_factor * quant_val, 7);
|
||||
cpi->UVround[q][rc] = (qrounding_factor * quant_val) >> 7;
|
||||
cpi->common.UVdequant[q][rc] = quant_val;
|
||||
cpi->zrun_zbin_boost_uv[q][i] =
|
||||
ROUND_POWER_OF_TWO(quant_val * zbin_boost[i], 7);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче