Merge "vpx_mem: remove REPLACE_BUILTIN_FUNCTIONS"
diff --git a/PATENTS b/PATENTS
index 79d17d7..caedf60 100644
--- a/PATENTS
+++ b/PATENTS
@@ -17,7 +17,7 @@
enforcement activity against any entity (including a cross-claim or
counterclaim in a lawsuit) alleging that any of these implementations of WebM
or any code incorporated within any of these implementations of WebM
-constitutes direct or contributory patent infringement, or inducement of
+constitute direct or contributory patent infringement, or inducement of
patent infringement, then any patent rights granted to you under this License
for these implementations of WebM shall terminate as of the date such
litigation is filed.
diff --git a/vp9/common/vp9_debugmodes.c b/vp9/common/vp9_debugmodes.c
index 03fded0..3d80103 100644
--- a/vp9/common/vp9_debugmodes.c
+++ b/vp9/common/vp9_debugmodes.c
@@ -25,7 +25,7 @@
static void print_mi_data(VP9_COMMON *cm, FILE *file, const char *descriptor,
size_t member_offset) {
int mi_row, mi_col;
- MODE_INFO *mi = cm->mi;
+ MODE_INFO **mi = cm->mi_grid_visible;
int rows = cm->mi_rows;
int cols = cm->mi_cols;
char prefix = descriptor[0];
@@ -35,7 +35,7 @@
fprintf(file, "%c ", prefix);
for (mi_col = 0; mi_col < cols; mi_col++) {
fprintf(file, "%2d ",
- *((int*) ((char *) (&mi->mbmi) +
+ *((int*) ((char *) (&mi[0]->mbmi) +
member_offset)));
mi++;
}
@@ -49,7 +49,7 @@
int mi_row;
int mi_col;
FILE *mvs = fopen(file, "a");
- MODE_INFO *mi = cm->mi;
+ MODE_INFO **mi = cm->mi_grid_visible;
int rows = cm->mi_rows;
int cols = cm->mi_cols;
@@ -64,7 +64,7 @@
for (mi_row = 0; mi_row < rows; mi_row++) {
fprintf(mvs, "S ");
for (mi_col = 0; mi_col < cols; mi_col++) {
- fprintf(mvs, "%2d ", mi->mbmi.skip);
+ fprintf(mvs, "%2d ", mi[0]->mbmi.skip);
mi++;
}
fprintf(mvs, "\n");
@@ -74,12 +74,12 @@
// output motion vectors.
log_frame_info(cm, "Vectors ", mvs);
- mi = cm->mi;
+ mi = cm->mi_grid_visible;
for (mi_row = 0; mi_row < rows; mi_row++) {
fprintf(mvs, "V ");
for (mi_col = 0; mi_col < cols; mi_col++) {
- fprintf(mvs, "%4d:%4d ", mi->mbmi.mv[0].as_mv.row,
- mi->mbmi.mv[0].as_mv.col);
+ fprintf(mvs, "%4d:%4d ", mi[0]->mbmi.mv[0].as_mv.row,
+ mi[0]->mbmi.mv[0].as_mv.col);
mi++;
}
fprintf(mvs, "\n");
diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h
index d722620..36446be 100644
--- a/vp9/common/vp9_onyxc_int.h
+++ b/vp9/common/vp9_onyxc_int.h
@@ -184,6 +184,8 @@
int y_dc_delta_q;
int uv_dc_delta_q;
int uv_ac_delta_q;
+ int16_t y_dequant[MAX_SEGMENTS][2];
+ int16_t uv_dequant[MAX_SEGMENTS][2];
/* We allocate a MODE_INFO struct for each macroblock, together with
an extra row on top and column on the left to simplify prediction. */
diff --git a/vp9/decoder/vp9_decodeframe.c b/vp9/decoder/vp9_decodeframe.c
index b6f51ab..63be601 100644
--- a/vp9/decoder/vp9_decodeframe.c
+++ b/vp9/decoder/vp9_decodeframe.c
@@ -293,8 +293,7 @@
MACROBLOCKD *xd;
FRAME_COUNTS *counts;
vp9_reader *r;
- const int16_t *const y_dequant;
- const int16_t *const uv_dequant;
+ int seg_id;
};
static void predict_and_reconstruct_intra_block(int plane, int block,
@@ -307,8 +306,6 @@
MODE_INFO *const mi = xd->mi[0];
const PREDICTION_MODE mode = (plane == 0) ? get_y_mode(mi, block)
: mi->mbmi.uv_mode;
- const int16_t *const dequant = (plane == 0) ? args->y_dequant
- : args->uv_dequant;
int x, y;
uint8_t *dst;
txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &x, &y);
@@ -322,7 +319,7 @@
if (!mi->mbmi.skip) {
const int eob = vp9_decode_block_tokens(cm, xd, args->counts, plane, block,
plane_bsize, x, y, tx_size,
- args->r, dequant);
+ args->r, args->seg_id);
inverse_transform_block(xd, plane, block, tx_size, dst, pd->dst.stride,
eob);
}
@@ -334,8 +331,7 @@
vp9_reader *r;
FRAME_COUNTS *counts;
int *eobtotal;
- const int16_t *const y_dequant;
- const int16_t *const uv_dequant;
+ int seg_id;
};
static void reconstruct_inter_block(int plane, int block,
@@ -345,12 +341,10 @@
VP9_COMMON *const cm = args->cm;
MACROBLOCKD *const xd = args->xd;
struct macroblockd_plane *const pd = &xd->plane[plane];
- const int16_t *const dequant = (plane == 0) ? args->y_dequant
- : args->uv_dequant;
int x, y, eob;
txfrm_block_to_raster_xy(plane_bsize, tx_size, block, &x, &y);
eob = vp9_decode_block_tokens(cm, xd, args->counts, plane, block, plane_bsize,
- x, y, tx_size, args->r, dequant);
+ x, y, tx_size, args->r, args->seg_id);
inverse_transform_block(xd, plane, block, tx_size,
&pd->dst.buf[4 * y * pd->dst.stride + 4 * x],
pd->dst.stride, eob);
@@ -392,8 +386,6 @@
vp9_reader *r, BLOCK_SIZE bsize) {
VP9_COMMON *const cm = &pbi->common;
const int less8x8 = bsize < BLOCK_8X8;
- int16_t y_dequant[2], uv_dequant[2];
- int qindex = cm->base_qindex;
MB_MODE_INFO *mbmi = set_offsets(cm, xd, tile, bsize, mi_row, mi_col);
vp9_read_mode_info(pbi, xd, counts, tile, mi_row, mi_col, r);
@@ -402,17 +394,10 @@
if (mbmi->skip) {
reset_skip_context(xd, bsize);
- } else if (cm->seg.enabled) {
- qindex = vp9_get_qindex(&cm->seg, mbmi->segment_id, cm->base_qindex);
}
- y_dequant[0] = vp9_dc_quant(qindex, cm->y_dc_delta_q, cm->bit_depth);
- y_dequant[1] = vp9_ac_quant(qindex, 0, cm->bit_depth);
- uv_dequant[0] = vp9_dc_quant(qindex, cm->uv_dc_delta_q, cm->bit_depth);
- uv_dequant[1] = vp9_ac_quant(qindex, cm->uv_ac_delta_q, cm->bit_depth);
-
if (!is_inter_block(mbmi)) {
- struct intra_args arg = {cm, xd, counts, r , y_dequant, uv_dequant};
+ struct intra_args arg = {cm, xd, counts, r, mbmi->segment_id};
vp9_foreach_transformed_block(xd, bsize,
predict_and_reconstruct_intra_block, &arg);
} else {
@@ -422,8 +407,7 @@
// Reconstruction
if (!mbmi->skip) {
int eobtotal = 0;
- struct inter_args arg = {cm, xd, r, counts, &eobtotal, y_dequant,
- uv_dequant};
+ struct inter_args arg = {cm, xd, r, counts, &eobtotal, mbmi->segment_id};
vp9_foreach_transformed_block(xd, bsize, reconstruct_inter_block, &arg);
if (!less8x8 && eobtotal == 0)
mbmi->skip = 1; // skip loopfilter
@@ -647,11 +631,39 @@
cm->y_dc_delta_q == 0 &&
cm->uv_dc_delta_q == 0 &&
cm->uv_ac_delta_q == 0;
+
#if CONFIG_VP9_HIGHBITDEPTH
xd->bd = (int)cm->bit_depth;
#endif
}
+static void setup_segmentation_dequant(VP9_COMMON *const cm) {
+ // Build y/uv dequant values based on segmentation.
+ if (cm->seg.enabled) {
+ int i;
+ for (i = 0; i < MAX_SEGMENTS; ++i) {
+ const int qindex = vp9_get_qindex(&cm->seg, i, cm->base_qindex);
+ cm->y_dequant[i][0] = vp9_dc_quant(qindex, cm->y_dc_delta_q,
+ cm->bit_depth);
+ cm->y_dequant[i][1] = vp9_ac_quant(qindex, 0, cm->bit_depth);
+ cm->uv_dequant[i][0] = vp9_dc_quant(qindex, cm->uv_dc_delta_q,
+ cm->bit_depth);
+ cm->uv_dequant[i][1] = vp9_ac_quant(qindex, cm->uv_ac_delta_q,
+ cm->bit_depth);
+ }
+ } else {
+ const int qindex = cm->base_qindex;
+ // When segmentation is disabled, only the first value is used. The
+ // remaining are don't cares.
+ cm->y_dequant[0][0] = vp9_dc_quant(qindex, cm->y_dc_delta_q, cm->bit_depth);
+ cm->y_dequant[0][1] = vp9_ac_quant(qindex, 0, cm->bit_depth);
+ cm->uv_dequant[0][0] = vp9_dc_quant(qindex, cm->uv_dc_delta_q,
+ cm->bit_depth);
+ cm->uv_dequant[0][1] = vp9_ac_quant(qindex, cm->uv_ac_delta_q,
+ cm->bit_depth);
+ }
+}
+
static INTERP_FILTER read_interp_filter(struct vp9_read_bit_buffer *rb) {
const INTERP_FILTER literal_to_filter[] = { EIGHTTAP_SMOOTH,
EIGHTTAP,
@@ -1486,6 +1498,7 @@
setup_loopfilter(&cm->lf, rb);
setup_quantization(cm, &pbi->mb, rb);
setup_segmentation(&cm->seg, rb);
+ setup_segmentation_dequant(cm);
setup_tile_info(cm, rb);
sz = vp9_rb_read_literal(rb, 16);
diff --git a/vp9/decoder/vp9_detokenize.c b/vp9/decoder/vp9_detokenize.c
index f0bb2ce..bb8c66f 100644
--- a/vp9/decoder/vp9_detokenize.c
+++ b/vp9/decoder/vp9_detokenize.c
@@ -205,8 +205,10 @@
FRAME_COUNTS *counts, int plane, int block,
BLOCK_SIZE plane_bsize, int x, int y,
TX_SIZE tx_size, vp9_reader *r,
- const int16_t *const dequant) {
+ int seg_id) {
struct macroblockd_plane *const pd = &xd->plane[plane];
+ const int16_t *const dequant = (plane == 0) ? cm->y_dequant[seg_id]
+ : cm->uv_dequant[seg_id];
const int ctx = get_entropy_context(tx_size, pd->above_context + x,
pd->left_context + y);
const scan_order *so = get_scan(xd, tx_size, pd->plane_type, block);
diff --git a/vp9/decoder/vp9_detokenize.h b/vp9/decoder/vp9_detokenize.h
index 6682b5e..86126b6 100644
--- a/vp9/decoder/vp9_detokenize.h
+++ b/vp9/decoder/vp9_detokenize.h
@@ -23,7 +23,7 @@
FRAME_COUNTS *counts, int plane, int block,
BLOCK_SIZE plane_bsize, int x, int y,
TX_SIZE tx_size, vp9_reader *r,
- const int16_t *const dequant);
+ int seg_id);
#ifdef __cplusplus
} // extern "C"
diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c
index 08cb5d3..4d1964d 100644
--- a/vp9/encoder/vp9_encodeframe.c
+++ b/vp9/encoder/vp9_encodeframe.c
@@ -432,11 +432,12 @@
// Check vertical split.
if (mi_row + block_height / 2 < cm->mi_rows) {
+ BLOCK_SIZE subsize = get_subsize(bsize, PARTITION_VERT);
get_variance(&vt.part_variances->vert[0]);
get_variance(&vt.part_variances->vert[1]);
if (vt.part_variances->vert[0].variance < threshold &&
- vt.part_variances->vert[1].variance < threshold) {
- BLOCK_SIZE subsize = get_subsize(bsize, PARTITION_VERT);
+ vt.part_variances->vert[1].variance < threshold &&
+ get_plane_block_size(subsize, &xd->plane[1]) < BLOCK_INVALID) {
set_block_size(cpi, xd, mi_row, mi_col, subsize);
set_block_size(cpi, xd, mi_row, mi_col + block_width / 2, subsize);
return 1;
@@ -444,11 +445,12 @@
}
// Check horizontal split.
if (mi_col + block_width / 2 < cm->mi_cols) {
+ BLOCK_SIZE subsize = get_subsize(bsize, PARTITION_HORZ);
get_variance(&vt.part_variances->horz[0]);
get_variance(&vt.part_variances->horz[1]);
if (vt.part_variances->horz[0].variance < threshold &&
- vt.part_variances->horz[1].variance < threshold) {
- BLOCK_SIZE subsize = get_subsize(bsize, PARTITION_HORZ);
+ vt.part_variances->horz[1].variance < threshold &&
+ get_plane_block_size(subsize, &xd->plane[1]) < BLOCK_INVALID) {
set_block_size(cpi, xd, mi_row, mi_col, subsize);
set_block_size(cpi, xd, mi_row + block_height / 2, mi_col, subsize);
return 1;
diff --git a/vpx_ports/x86.h b/vpx_ports/x86.h
index ae349fb..7d93710 100644
--- a/vpx_ports/x86.h
+++ b/vpx_ports/x86.h
@@ -152,7 +152,7 @@
x86_simd_caps(void) {
unsigned int flags = 0;
unsigned int mask = ~0;
- unsigned int reg_eax, reg_ebx, reg_ecx, reg_edx;
+ unsigned int max_cpuid_val, reg_eax, reg_ebx, reg_ecx, reg_edx;
char *env;
(void)reg_ebx;
@@ -168,9 +168,9 @@
mask = strtol(env, NULL, 0);
/* Ensure that the CPUID instruction supports extended features */
- cpuid(0, 0, reg_eax, reg_ebx, reg_ecx, reg_edx);
+ cpuid(0, 0, max_cpuid_val, reg_ebx, reg_ecx, reg_edx);
- if (reg_eax < 1)
+ if (max_cpuid_val < 1)
return 0;
/* Get the standard feature flags */
@@ -193,10 +193,12 @@
if ((xgetbv() & 0x6) == 0x6) {
flags |= HAS_AVX;
- /* Get the leaf 7 feature flags. Needed to check for AVX2 support */
- cpuid(7, 0, reg_eax, reg_ebx, reg_ecx, reg_edx);
+ if (max_cpuid_val >= 7) {
+ /* Get the leaf 7 feature flags. Needed to check for AVX2 support */
+ cpuid(7, 0, reg_eax, reg_ebx, reg_ecx, reg_edx);
- if (reg_ebx & BIT(5)) flags |= HAS_AVX2;
+ if (reg_ebx & BIT(5)) flags |= HAS_AVX2;
+ }
}
}