Commit d9f9a34b authored by clang-format's avatar clang-format Committed by James Zern

vp10/encoder: apply clang-format

Change-Id: I58a42ced5b8a4338524434ff3356850b89aa705a
parent 7feae8e8
......@@ -19,25 +19,27 @@
#include "vpx_dsp/vpx_dsp_common.h"
#include "vpx_ports/system_state.h"
#define AQ_C_SEGMENTS 5
#define DEFAULT_AQ2_SEG 3 // Neutral Q segment
#define AQ_C_SEGMENTS 5
#define DEFAULT_AQ2_SEG 3 // Neutral Q segment
#define AQ_C_STRENGTHS 3
static const double aq_c_q_adj_factor[AQ_C_STRENGTHS][AQ_C_SEGMENTS] =
{ {1.75, 1.25, 1.05, 1.00, 0.90},
{2.00, 1.50, 1.15, 1.00, 0.85},
{2.50, 1.75, 1.25, 1.00, 0.80} };
static const double aq_c_transitions[AQ_C_STRENGTHS][AQ_C_SEGMENTS] =
{ {0.15, 0.30, 0.55, 2.00, 100.0},
{0.20, 0.40, 0.65, 2.00, 100.0},
{0.25, 0.50, 0.75, 2.00, 100.0} };
static const double aq_c_var_thresholds[AQ_C_STRENGTHS][AQ_C_SEGMENTS] =
{ {-4.0, -3.0, -2.0, 100.00, 100.0},
{-3.5, -2.5, -1.5, 100.00, 100.0},
{-3.0, -2.0, -1.0, 100.00, 100.0} };
static const double aq_c_q_adj_factor[AQ_C_STRENGTHS][AQ_C_SEGMENTS] = {
{ 1.75, 1.25, 1.05, 1.00, 0.90 },
{ 2.00, 1.50, 1.15, 1.00, 0.85 },
{ 2.50, 1.75, 1.25, 1.00, 0.80 }
};
static const double aq_c_transitions[AQ_C_STRENGTHS][AQ_C_SEGMENTS] = {
{ 0.15, 0.30, 0.55, 2.00, 100.0 },
{ 0.20, 0.40, 0.65, 2.00, 100.0 },
{ 0.25, 0.50, 0.75, 2.00, 100.0 }
};
static const double aq_c_var_thresholds[AQ_C_STRENGTHS][AQ_C_SEGMENTS] = {
{ -4.0, -3.0, -2.0, 100.00, 100.0 },
{ -3.5, -2.5, -1.5, 100.00, 100.0 },
{ -3.0, -2.0, -1.0, 100.00, 100.0 }
};
#define DEFAULT_COMPLEXITY 64
static int get_aq_c_strength(int q_index, vpx_bit_depth_t bit_depth) {
// Approximate base quatizer (truncated to int)
const int base_quant = vp10_ac_quant(q_index, 0, bit_depth) / 4;
......@@ -81,14 +83,11 @@ void vp10_setup_in_frame_q_adj(VP10_COMP *cpi) {
for (segment = 0; segment < AQ_C_SEGMENTS; ++segment) {
int qindex_delta;
if (segment == DEFAULT_AQ2_SEG)
continue;
qindex_delta =
vp10_compute_qdelta_by_rate(&cpi->rc, cm->frame_type, cm->base_qindex,
aq_c_q_adj_factor[aq_strength][segment],
cm->bit_depth);
if (segment == DEFAULT_AQ2_SEG) continue;
qindex_delta = vp10_compute_qdelta_by_rate(
&cpi->rc, cm->frame_type, cm->base_qindex,
aq_c_q_adj_factor[aq_strength][segment], cm->bit_depth);
// For AQ complexity mode, we dont allow Q0 in a segment if the base
// Q is not 0. Q0 (lossless) implies 4x4 only and in AQ mode 2 a segment
......@@ -112,7 +111,7 @@ void vp10_setup_in_frame_q_adj(VP10_COMP *cpi) {
// The choice of segment for a block depends on the ratio of the projected
// bits for the block vs a target average and its spatial complexity.
void vp10_caq_select_segment(VP10_COMP *cpi, MACROBLOCK *mb, BLOCK_SIZE bs,
int mi_row, int mi_col, int projected_rate) {
int mi_row, int mi_col, int projected_rate) {
VP10_COMMON *const cm = &cpi->common;
const int mi_offset = mi_row * cm->mi_cols + mi_col;
......@@ -134,19 +133,18 @@ void vp10_caq_select_segment(VP10_COMP *cpi, MACROBLOCK *mb, BLOCK_SIZE bs,
const int aq_strength = get_aq_c_strength(cm->base_qindex, cm->bit_depth);
vpx_clear_system_state();
low_var_thresh = (cpi->oxcf.pass == 2)
? VPXMAX(cpi->twopass.mb_av_energy, MIN_DEFAULT_LV_THRESH)
: DEFAULT_LV_THRESH;
low_var_thresh = (cpi->oxcf.pass == 2) ? VPXMAX(cpi->twopass.mb_av_energy,
MIN_DEFAULT_LV_THRESH)
: DEFAULT_LV_THRESH;
vp10_setup_src_planes(mb, cpi->Source, mi_row, mi_col);
logvar = vp10_log_block_var(cpi, mb, bs);
segment = AQ_C_SEGMENTS - 1; // Just in case no break out below.
segment = AQ_C_SEGMENTS - 1; // Just in case no break out below.
for (i = 0; i < AQ_C_SEGMENTS; ++i) {
// Test rate against a threshold value and variance against a threshold.
// Increasing segment number (higher variance and complexity) = higher Q.
if ((projected_rate <
target_rate * aq_c_transitions[aq_strength][i]) &&
if ((projected_rate < target_rate * aq_c_transitions[aq_strength][i]) &&
(logvar < (low_var_thresh + aq_c_var_thresholds[aq_strength][i]))) {
segment = i;
break;
......
......@@ -8,7 +8,6 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef VP10_ENCODER_AQ_COMPLEXITY_H_
#define VP10_ENCODER_AQ_COMPLEXITY_H_
......@@ -23,8 +22,8 @@ struct macroblock;
// Select a segment for the current Block.
void vp10_caq_select_segment(struct VP10_COMP *cpi, struct macroblock *,
BLOCK_SIZE bs,
int mi_row, int mi_col, int projected_rate);
BLOCK_SIZE bs, int mi_row, int mi_col,
int projected_rate);
// This function sets up a set of segments with delta Q values around
// the baseline frame quantizer.
......
This diff is collapsed.
......@@ -8,7 +8,6 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef VP10_ENCODER_AQ_CYCLICREFRESH_H_
#define VP10_ENCODER_AQ_CYCLICREFRESH_H_
......@@ -20,9 +19,9 @@ extern "C" {
// The segment ids used in cyclic refresh: from base (no boost) to increasing
// boost (higher delta-qp).
#define CR_SEGMENT_ID_BASE 0
#define CR_SEGMENT_ID_BOOST1 1
#define CR_SEGMENT_ID_BOOST2 2
#define CR_SEGMENT_ID_BASE 0
#define CR_SEGMENT_ID_BOOST1 1
#define CR_SEGMENT_ID_BOOST2 2
// Maximum rate target ratio for setting segment delta-qp.
#define CR_MAX_RATE_TARGET_RATIO 4.0
......@@ -39,20 +38,20 @@ void vp10_cyclic_refresh_free(CYCLIC_REFRESH *cr);
// Estimate the bits, incorporating the delta-q from segment 1, after encoding
// the frame.
int vp10_cyclic_refresh_estimate_bits_at_q(const struct VP10_COMP *cpi,
double correction_factor);
double correction_factor);
// Estimate the bits per mb, for a given q = i and a corresponding delta-q
// (for segment 1), prior to encoding the frame.
int vp10_cyclic_refresh_rc_bits_per_mb(const struct VP10_COMP *cpi, int i,
double correction_factor);
double correction_factor);
// Prior to coding a given prediction block, of size bsize at (mi_row, mi_col),
// check if we should reset the segment_id, and update the cyclic_refresh map
// and segmentation map.
void vp10_cyclic_refresh_update_segment(struct VP10_COMP *const cpi,
MB_MODE_INFO *const mbmi,
int mi_row, int mi_col, BLOCK_SIZE bsize,
int64_t rate, int64_t dist, int skip);
MB_MODE_INFO *const mbmi, int mi_row,
int mi_col, BLOCK_SIZE bsize,
int64_t rate, int64_t dist, int skip);
// Update the segmentation map, and related quantities: cyclic refresh map,
// refresh sb_index, and target number of blocks to be refreshed.
......
......@@ -22,21 +22,20 @@
#define ENERGY_MIN (-4)
#define ENERGY_MAX (1)
#define ENERGY_SPAN (ENERGY_MAX - ENERGY_MIN + 1)
#define ENERGY_IN_BOUNDS(energy)\
#define ENERGY_SPAN (ENERGY_MAX - ENERGY_MIN + 1)
#define ENERGY_IN_BOUNDS(energy) \
assert((energy) >= ENERGY_MIN && (energy) <= ENERGY_MAX)
static const double rate_ratio[MAX_SEGMENTS] =
{2.5, 2.0, 1.5, 1.0, 0.75, 1.0, 1.0, 1.0};
static const int segment_id[ENERGY_SPAN] = {0, 1, 1, 2, 3, 4};
static const double rate_ratio[MAX_SEGMENTS] = { 2.5, 2.0, 1.5, 1.0,
0.75, 1.0, 1.0, 1.0 };
static const int segment_id[ENERGY_SPAN] = { 0, 1, 1, 2, 3, 4 };
#define SEGMENT_ID(i) segment_id[(i) - ENERGY_MIN]
#define SEGMENT_ID(i) segment_id[(i)-ENERGY_MIN]
DECLARE_ALIGNED(16, static const uint8_t,
vp10_all_zeros[MAX_SB_SIZE]) = {0};
DECLARE_ALIGNED(16, static const uint8_t, vp10_all_zeros[MAX_SB_SIZE]) = { 0 };
#if CONFIG_VP9_HIGHBITDEPTH
DECLARE_ALIGNED(16, static const uint16_t,
vp10_highbd_all_zeros[MAX_SB_SIZE]) = {0};
vp10_highbd_all_zeros[MAX_SB_SIZE]) = { 0 };
#endif
unsigned int vp10_vaq_segment_id(int energy) {
......@@ -64,7 +63,7 @@ void vp10_vaq_frame_setup(VP10_COMP *cpi) {
for (i = 0; i < MAX_SEGMENTS; ++i) {
int qindex_delta =
vp10_compute_qdelta_by_rate(&cpi->rc, cm->frame_type, cm->base_qindex,
rate_ratio[i], cm->bit_depth);
rate_ratio[i], cm->bit_depth);
// We don't allow qindex 0 in a segment if the base value is not 0.
// Q index 0 (lossless) implies 4x4 encoding only and in AQ mode a segment
......@@ -88,9 +87,9 @@ void vp10_vaq_frame_setup(VP10_COMP *cpi) {
/* TODO(agrange, paulwilkins): The block_variance calls the unoptimized versions
* of variance() and highbd_8_variance(). It should not.
*/
static void aq_variance(const uint8_t *a, int a_stride,
const uint8_t *b, int b_stride,
int w, int h, unsigned int *sse, int *sum) {
static void aq_variance(const uint8_t *a, int a_stride, const uint8_t *b,
int b_stride, int w, int h, unsigned int *sse,
int *sum) {
int i, j;
*sum = 0;
......@@ -109,9 +108,9 @@ static void aq_variance(const uint8_t *a, int a_stride,
}
#if CONFIG_VP9_HIGHBITDEPTH
static void aq_highbd_variance64(const uint8_t *a8, int a_stride,
const uint8_t *b8, int b_stride,
int w, int h, uint64_t *sse, uint64_t *sum) {
static void aq_highbd_variance64(const uint8_t *a8, int a_stride,
const uint8_t *b8, int b_stride, int w, int h,
uint64_t *sse, uint64_t *sum) {
int i, j;
uint16_t *a = CONVERT_TO_SHORTPTR(a8);
......@@ -130,9 +129,9 @@ static void aq_highbd_variance64(const uint8_t *a8, int a_stride,
}
}
static void aq_highbd_8_variance(const uint8_t *a8, int a_stride,
const uint8_t *b8, int b_stride,
int w, int h, unsigned int *sse, int *sum) {
static void aq_highbd_8_variance(const uint8_t *a8, int a_stride,
const uint8_t *b8, int b_stride, int w, int h,
unsigned int *sse, int *sum) {
uint64_t sse_long = 0;
uint64_t sum_long = 0;
aq_highbd_variance64(a8, a_stride, b8, b_stride, w, h, &sse_long, &sum_long);
......@@ -145,10 +144,10 @@ static unsigned int block_variance(VP10_COMP *cpi, MACROBLOCK *x,
BLOCK_SIZE bs) {
MACROBLOCKD *xd = &x->e_mbd;
unsigned int var, sse;
int right_overflow = (xd->mb_to_right_edge < 0) ?
((-xd->mb_to_right_edge) >> 3) : 0;
int bottom_overflow = (xd->mb_to_bottom_edge < 0) ?
((-xd->mb_to_bottom_edge) >> 3) : 0;
int right_overflow =
(xd->mb_to_right_edge < 0) ? ((-xd->mb_to_right_edge) >> 3) : 0;
int bottom_overflow =
(xd->mb_to_bottom_edge < 0) ? ((-xd->mb_to_bottom_edge) >> 3) : 0;
if (right_overflow || bottom_overflow) {
const int bw = 8 * num_8x8_blocks_wide_lookup[bs] - right_overflow;
......@@ -162,30 +161,27 @@ static unsigned int block_variance(VP10_COMP *cpi, MACROBLOCK *x,
sse >>= 2 * (xd->bd - 8);
avg >>= (xd->bd - 8);
} else {
aq_variance(x->plane[0].src.buf, x->plane[0].src.stride,
vp10_all_zeros, 0, bw, bh, &sse, &avg);
aq_variance(x->plane[0].src.buf, x->plane[0].src.stride, vp10_all_zeros,
0, bw, bh, &sse, &avg);
}
#else
aq_variance(x->plane[0].src.buf, x->plane[0].src.stride,
vp10_all_zeros, 0, bw, bh, &sse, &avg);
aq_variance(x->plane[0].src.buf, x->plane[0].src.stride, vp10_all_zeros, 0,
bw, bh, &sse, &avg);
#endif // CONFIG_VP9_HIGHBITDEPTH
var = sse - (((int64_t)avg * avg) / (bw * bh));
return (256 * var) / (bw * bh);
} else {
#if CONFIG_VP9_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf,
x->plane[0].src.stride,
CONVERT_TO_BYTEPTR(vp10_highbd_all_zeros),
0, &sse);
var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf, x->plane[0].src.stride,
CONVERT_TO_BYTEPTR(vp10_highbd_all_zeros), 0,
&sse);
} else {
var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf,
x->plane[0].src.stride,
var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf, x->plane[0].src.stride,
vp10_all_zeros, 0, &sse);
}
#else
var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf,
x->plane[0].src.stride,
var = cpi->fn_ptr[bs].vf(x->plane[0].src.buf, x->plane[0].src.stride,
vp10_all_zeros, 0, &sse);
#endif // CONFIG_VP9_HIGHBITDEPTH
return (256 * var) >> num_pels_log2_lookup[bs];
......@@ -204,7 +200,7 @@ int vp10_block_energy(VP10_COMP *cpi, MACROBLOCK *x, BLOCK_SIZE bs) {
double energy_midpoint;
vpx_clear_system_state();
energy_midpoint =
(cpi->oxcf.pass == 2) ? cpi->twopass.mb_av_energy : DEFAULT_E_MIDPOINT;
(cpi->oxcf.pass == 2) ? cpi->twopass.mb_av_energy : DEFAULT_E_MIDPOINT;
energy = vp10_log_block_var(cpi, x, bs) - energy_midpoint;
return clamp((int)round(energy), ENERGY_MIN, ENERGY_MAX);
}
......@@ -8,7 +8,6 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef VP10_ENCODER_AQ_VARIANCE_H_
#define VP10_ENCODER_AQ_VARIANCE_H_
......
......@@ -17,20 +17,17 @@
#include "vp10/common/blockd.h"
#include "vpx_dsp/txfm_common.h"
void vp10_fdct8x8_quant_neon(const int16_t *input, int stride,
int16_t* coeff_ptr, intptr_t n_coeffs,
int skip_block, const int16_t* zbin_ptr,
const int16_t* round_ptr, const int16_t* quant_ptr,
const int16_t* quant_shift_ptr,
int16_t* qcoeff_ptr, int16_t* dqcoeff_ptr,
const int16_t* dequant_ptr, uint16_t* eob_ptr,
const int16_t* scan_ptr,
const int16_t* iscan_ptr) {
void vp10_fdct8x8_quant_neon(
const int16_t *input, int stride, int16_t *coeff_ptr, intptr_t n_coeffs,
int skip_block, const int16_t *zbin_ptr, const int16_t *round_ptr,
const int16_t *quant_ptr, const int16_t *quant_shift_ptr,
int16_t *qcoeff_ptr, int16_t *dqcoeff_ptr, const int16_t *dequant_ptr,
uint16_t *eob_ptr, const int16_t *scan_ptr, const int16_t *iscan_ptr) {
int16_t temp_buffer[64];
(void)coeff_ptr;
vpx_fdct8x8_neon(input, temp_buffer, stride);
vp10_quantize_fp_neon(temp_buffer, n_coeffs, skip_block, zbin_ptr, round_ptr,
quant_ptr, quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr,
dequant_ptr, eob_ptr, scan_ptr, iscan_ptr);
quant_ptr, quant_shift_ptr, qcoeff_ptr, dqcoeff_ptr,
dequant_ptr, eob_ptr, scan_ptr, iscan_ptr);
}
......@@ -14,7 +14,7 @@
#include "./vp10_rtcd.h"
int64_t vp10_block_error_fp_neon(const int16_t *coeff, const int16_t *dqcoeff,
int block_size) {
int block_size) {
int64x2_t error = vdupq_n_s64(0);
assert(block_size >= 8);
......
......@@ -22,12 +22,12 @@
#include "vp10/encoder/rd.h"
void vp10_quantize_fp_neon(const int16_t *coeff_ptr, intptr_t count,
int skip_block, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, int16_t *qcoeff_ptr,
int16_t *dqcoeff_ptr, const int16_t *dequant_ptr,
uint16_t *eob_ptr,
const int16_t *scan, const int16_t *iscan) {
int skip_block, const int16_t *zbin_ptr,
const int16_t *round_ptr, const int16_t *quant_ptr,
const int16_t *quant_shift_ptr, int16_t *qcoeff_ptr,
int16_t *dqcoeff_ptr, const int16_t *dequant_ptr,
uint16_t *eob_ptr, const int16_t *scan,
const int16_t *iscan) {
// TODO(jingning) Decide the need of these arguments after the
// quantization process is completed.
(void)zbin_ptr;
......@@ -54,12 +54,12 @@ void vp10_quantize_fp_neon(const int16_t *coeff_ptr, intptr_t count,
const int16x8_t v_coeff = vld1q_s16(&coeff_ptr[0]);
const int16x8_t v_coeff_sign = vshrq_n_s16(v_coeff, 15);
const int16x8_t v_tmp = vabaq_s16(v_round, v_coeff, v_zero);
const int32x4_t v_tmp_lo = vmull_s16(vget_low_s16(v_tmp),
vget_low_s16(v_quant));
const int32x4_t v_tmp_hi = vmull_s16(vget_high_s16(v_tmp),
vget_high_s16(v_quant));
const int16x8_t v_tmp2 = vcombine_s16(vshrn_n_s32(v_tmp_lo, 16),
vshrn_n_s32(v_tmp_hi, 16));
const int32x4_t v_tmp_lo =
vmull_s16(vget_low_s16(v_tmp), vget_low_s16(v_quant));
const int32x4_t v_tmp_hi =
vmull_s16(vget_high_s16(v_tmp), vget_high_s16(v_quant));
const int16x8_t v_tmp2 =
vcombine_s16(vshrn_n_s32(v_tmp_lo, 16), vshrn_n_s32(v_tmp_hi, 16));
const uint16x8_t v_nz_mask = vceqq_s16(v_tmp2, v_zero);
const int16x8_t v_iscan_plus1 = vaddq_s16(v_iscan, v_one);
const int16x8_t v_nz_iscan = vbslq_s16(v_nz_mask, v_zero, v_iscan_plus1);
......@@ -79,12 +79,12 @@ void vp10_quantize_fp_neon(const int16_t *coeff_ptr, intptr_t count,
const int16x8_t v_coeff = vld1q_s16(&coeff_ptr[i]);
const int16x8_t v_coeff_sign = vshrq_n_s16(v_coeff, 15);
const int16x8_t v_tmp = vabaq_s16(v_round, v_coeff, v_zero);
const int32x4_t v_tmp_lo = vmull_s16(vget_low_s16(v_tmp),
vget_low_s16(v_quant));
const int32x4_t v_tmp_hi = vmull_s16(vget_high_s16(v_tmp),
vget_high_s16(v_quant));
const int16x8_t v_tmp2 = vcombine_s16(vshrn_n_s32(v_tmp_lo, 16),
vshrn_n_s32(v_tmp_hi, 16));
const int32x4_t v_tmp_lo =
vmull_s16(vget_low_s16(v_tmp), vget_low_s16(v_quant));
const int32x4_t v_tmp_hi =
vmull_s16(vget_high_s16(v_tmp), vget_high_s16(v_quant));
const int16x8_t v_tmp2 =
vcombine_s16(vshrn_n_s32(v_tmp_lo, 16), vshrn_n_s32(v_tmp_hi, 16));
const uint16x8_t v_nz_mask = vceqq_s16(v_tmp2, v_zero);
const int16x8_t v_iscan_plus1 = vaddq_s16(v_iscan, v_one);
const int16x8_t v_nz_iscan = vbslq_s16(v_nz_mask, v_zero, v_iscan_plus1);
......@@ -96,9 +96,8 @@ void vp10_quantize_fp_neon(const int16_t *coeff_ptr, intptr_t count,
vst1q_s16(&dqcoeff_ptr[i], v_dqcoeff);
}
{
const int16x4_t v_eobmax_3210 =
vmax_s16(vget_low_s16(v_eobmax_76543210),
vget_high_s16(v_eobmax_76543210));
const int16x4_t v_eobmax_3210 = vmax_s16(
vget_low_s16(v_eobmax_76543210), vget_high_s16(v_eobmax_76543210));
const int64x1_t v_eobmax_xx32 =
vshr_n_s64(vreinterpret_s64_s16(v_eobmax_3210), 32);
const int16x4_t v_eobmax_tmp =
......
This diff is collapsed.
......@@ -8,7 +8,6 @@
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef VP10_ENCODER_BITSTREAM_H_
#define VP10_ENCODER_BITSTREAM_H_
......
......@@ -51,7 +51,7 @@ typedef struct macroblock_plane {
/* The [2] dimension is for whether we skip the EOB node (i.e. if previous
* coefficient in this block was zero) or not. */
typedef unsigned int vp10_coeff_cost[PLANE_TYPES][REF_TYPES][COEF_BANDS][2]
[COEFF_CONTEXTS][ENTROPY_TOKENS];
[COEFF_CONTEXTS][ENTROPY_TOKENS];
typedef struct {
int_mv ref_mvs[MODE_CTX_REF_FRAMES][MAX_MV_REF_CANDIDATES];
......@@ -93,8 +93,8 @@ struct macroblock {
int rddiv;
int rdmult;
int mb_energy;
int * m_search_count_ptr;
int * ex_search_count_ptr;
int *m_search_count_ptr;
int *ex_search_count_ptr;
// These are set to their default values at the beginning, and then adjusted
// further in the encoding process.
......
......@@ -70,9 +70,9 @@ static int blockiness_vertical(const uint8_t *s, int sp, const uint8_t *r,
s_blockiness += horizontal_filter(s);
r_blockiness += horizontal_filter(r);
sum_0 += s[0];
sum_sq_0 += s[0]*s[0];
sum_sq_0 += s[0] * s[0];
sum_1 += s[-1];
sum_sq_1 += s[-1]*s[-1];
sum_sq_1 += s[-1] * s[-1];
}
var_0 = variance(sum_0, sum_sq_0, size);
var_1 = variance(sum_1, sum_sq_1, size);
......@@ -120,19 +120,19 @@ static int blockiness_horizontal(const uint8_t *s, int sp, const uint8_t *r,
// This function returns the blockiness for the entire frame currently by
// looking at all borders in steps of 4.
double vp10_get_blockiness(const unsigned char *img1, int img1_pitch,
const unsigned char *img2, int img2_pitch,
int width, int height ) {
const unsigned char *img2, int img2_pitch, int width,
int height) {
double blockiness = 0;
int i, j;
vpx_clear_system_state();
for (i = 0; i < height; i += 4, img1 += img1_pitch * 4,
img2 += img2_pitch * 4) {
for (i = 0; i < height;
i += 4, img1 += img1_pitch * 4, img2 += img2_pitch * 4) {
for (j = 0; j < width; j += 4) {
if (i > 0 && i < height && j > 0 && j < width) {
blockiness += blockiness_vertical(img1 + j, img1_pitch,
img2 + j, img2_pitch, 4);
blockiness += blockiness_horizontal(img1 + j, img1_pitch,
img2 + j, img2_pitch, 4);
blockiness +=
blockiness_vertical(img1 + j, img1_pitch, img2 + j, img2_pitch, 4);
blockiness += blockiness_horizontal(img1 + j, img1_pitch, img2 + j,
img2_pitch, 4);
}
}
}
......
......@@ -27,10 +27,10 @@ extern "C" {
#define ANS_METHOD_RANS 1
struct buffered_ans_symbol {
uint8_t method; // one of ANS_METHOD_UABS or ANS_METHOD_RANS
uint8_t method; // one of ANS_METHOD_UABS or ANS_METHOD_RANS
// TODO(aconverse): Should be possible to write this interms of start for ABS
AnsP10 val_start; // Boolean value for ABS, start in symbol cycle for Rans
AnsP10 prob; // Probability of this symbol
AnsP10 prob; // Probability of this symbol
};
struct BufAnsCoder {
......@@ -51,8 +51,8 @@ static INLINE void buf_ans_write_reset(struct BufAnsCoder *const c) {
c->offset = 0;
}
static INLINE void buf_uabs_write(struct BufAnsCoder *const c,
uint8_t val, AnsP8 prob) {
static INLINE void buf_uabs_write(struct BufAnsCoder *const c, uint8_t val,
AnsP8 prob) {
assert(c->offset <= c->size);
if (c->offset == c->size) {
vp10_buf_ans_grow(c);
......@@ -95,8 +95,8 @@ static INLINE void buf_uabs_write_bit(struct BufAnsCoder *c, int bit) {
buf_uabs_write(c, bit, 128);
}
static INLINE void buf_uabs_write_literal(struct BufAnsCoder *c,
int literal, int bits) {
static INLINE void buf_uabs_write_literal(struct BufAnsCoder *c, int literal,
int bits) {
int bit;
assert(bits < 31);
......
......@@ -12,10 +12,7 @@
#include "vp10/encoder/encoder.h"
static const BLOCK_SIZE square[MAX_SB_SIZE_LOG2 - 2] = {
BLOCK_8X8,
BLOCK_16X16,
BLOCK_32X32,
BLOCK_64X64,
BLOCK_8X8, BLOCK_16X16, BLOCK_32X32, BLOCK_64X64,
#if CONFIG_EXT_PARTITION
BLOCK_128X128,
#endif // CONFIG_EXT_PARTITION
......@@ -36,8 +33,7 @@ static void alloc_mode_context(VP10_COMMON *cm, int num_4x4_blk,
for (i = 0; i < MAX_MB_PLANE; ++i) {
#if CONFIG_VAR_TX
CHECK_MEM_ERROR(cm, ctx->blk_skip[i],
vpx_calloc(num_blk, sizeof(uint8_t)));
CHECK_MEM_ERROR(cm, ctx->blk_skip[i], vpx_calloc(num_blk, sizeof(uint8_t)));
#endif
for (k = 0; k < 3; ++k) {
CHECK_MEM_ERROR(cm, ctx->coeff[i][k],
......@@ -48,18 +44,18 @@ static void alloc_mode_context(VP10_COMMON *cm, int num_4x4_blk,
vpx_memalign(32, num_pix * sizeof(*ctx->dqcoeff[i][k])));
CHECK_MEM_ERROR(cm, ctx->eobs[i][k],
vpx_memalign(32, num_blk * sizeof(*ctx->eobs[i][k])));
ctx->coeff_pbuf[i][k] = ctx->coeff[i][k];
ctx->qcoeff_pbuf[i][k] = ctx->qcoeff[i][k];
ctx->coeff_pbuf[i][k] = ctx->coeff[i][k];
ctx->qcoeff_pbuf[i][k] = ctx->qcoeff[i][k];
ctx->dqcoeff_pbuf[i][k] = ctx->dqcoeff[i][k];
ctx->eobs_pbuf[i][k] = ctx->eobs[i][k];
ctx->eobs_pbuf[i][k] = ctx->eobs[i][k];
}
}
if (cm->allow_screen_content_tools) {
for (i = 0; i < 2; ++i) {
CHECK_MEM_ERROR(cm, ctx->color_index_map[i],
vpx_memalign(32,
num_pix * sizeof(*ctx->color_index_map[i])));
for (i = 0; i < 2; ++i) {
CHECK_MEM_ERROR(
cm, ctx->color_index_map[i],
vpx_memalign(32, num_pix * sizeof(*ctx->color_index_map[i])));
}
}
}
......@@ -93,29 +89,35 @@ static void alloc_tree_contexts(VP10_COMMON *cm, PC_TREE *tree,
int num_4x4_blk) {
#if CONFIG_EXT_PARTITION_TYPES
alloc_mode_context(cm, num_4x4_blk, PARTITION_NONE, &tree->none);
alloc_mode_context(cm, num_4x4_blk/2, PARTITION_HORZ, &tree->horizontal[0]);
alloc_mode_context(cm, num_4x4_blk/2, PARTITION_VERT, &tree->vertical[0]);
alloc_mode_context(cm, num_4x4_blk/2, PARTITION_VERT, &tree->horizontal[1]);
alloc_mode_context(cm, num_4x4_blk/2, PARTITION_VERT, &tree->vertical[1]);
alloc_mode_context(cm, num_4x4_blk / 2, PARTITION_HORZ, &tree->horizontal[0]);
alloc_mode_context(cm, num_4x4_blk / 2, PARTITION_VERT, &tree->vertical[0]);
alloc_mode_context(cm, num_4x4_blk / 2, PARTITION_VERT, &tree->horizontal[1]);
alloc_mode_context(cm, num_4x4_blk / 2, PARTITION_VERT, &tree->vertical[1]);
alloc_mode_context(cm, num_4x4_blk/4, PARTITION_HORZ_A,
alloc_mode_context(cm, num_4x4_blk / 4, PARTITION_HORZ_A,
&tree->horizontala[0]);
alloc_mode_context(cm, num_4x4_blk/4, PARTITION_HORZ_A,
alloc_mode_context(cm, num_4x4_blk / 4, PARTITION_HORZ_A,
&tree->horizontala[1]);
alloc_mode_context(cm, num_4x4_blk/2, PARTITION_HORZ_A,
alloc_mode_context(cm, num_4x4_blk / 2, PARTITION_HORZ_A,
&tree->horizontala[2]);
alloc_mode_context(cm, num_4x4_blk/2, PARTITION_HORZ_B,
alloc_mode_context(cm, num_4x4_blk / 2, PARTITION_HORZ_B,
&tree->horizontalb[0]);
alloc_mode_context(cm, num_4x4_blk/4, PARTITION_HORZ_B,
alloc_mode_context(cm, num_4x4_blk / 4, PARTITION_HORZ_B,
&tree->horizontalb[1]);
alloc_mode_context(cm, num_4x4_blk/4, PARTITION_HORZ_B,
alloc_mode_context(cm, num_4x4_blk / 4, PARTITION_HORZ_B,
&tree->horizontalb[2]);
alloc_mode_context(cm, num_4x4_blk/4, PARTITION_VERT_A, &tree->verticala[0]);
alloc_mode_context(cm, num_4x4_blk/4, PARTITION_VERT_A, &tree->verticala[1]);
alloc_mode_context(cm, num_4x4_blk/2, PARTITION_VERT_A, &tree->verticala[2]);
alloc_mode_context(cm, num_4x4_blk/2, PARTITION_VERT_B, &tree->verticalb[0]);
alloc_mode_context(cm, num_4x4_blk/4, PARTITION_VERT_B, &tree->verticalb[1]);
alloc_mode_context(cm, num_4x4_blk/4, PARTITION_VERT_B, &tree->verticalb[2]);
alloc_mode_context(cm, num_4x4_blk / 4, PARTITION_VERT_A,
&tree->verticala[0]);
alloc_mode_context(cm, num_4x4_blk / 4, PARTITION_VERT_A,
&tree->verticala[1]);
alloc_mode_context(cm, num_4x4_blk / 2, PARTITION_VERT_A,
&tree->verticala[2]);
alloc_mode_context(cm, num_4x4_blk / 2, PARTITION_VERT_B,
&tree->verticalb[0]);
alloc_mode_context(cm, num_4x4_blk / 4, PARTITION_VERT_B,
&tree->verticalb[1]);
alloc_mode_context(cm, num_4x4_blk / 4, PARTITION_VERT_B,
&tree->verticalb[2]);
#ifdef CONFIG_SUPERTX
alloc_mode_context(cm, num_4x4_blk, PARTITION_HORZ,
&tree->horizontal_supertx);
......@@ -132,8 +134,8 @@ static void alloc_tree_contexts(VP10_COMMON *cm, PC_TREE *tree,
#endif // CONFIG_SUPERTX
#else
alloc_mode_context(cm, num_4x4_blk, &tree->none);
alloc_mode_context(cm, num_4x4_blk/2, &tree->horizontal[0]);
alloc_mode_context(cm, num_4x4_blk/2, &tree->vertical[0]);
alloc_mode_context(cm, num_4x4_blk / 2, &tree->horizontal[0]);
alloc_mode_context(cm, num_4x4_blk / 2, &tree->vertical[0]);
#ifdef CONFIG_SUPERTX
alloc_mode_context(cm, num_4x4_blk, &tree->horizontal_supertx);
alloc_mode_context(cm, num_4x4_blk, &tree->vertical_supertx);
......@@ -141,8 +143,8 @@ static void alloc_tree_contexts(VP10_COMMON *cm, PC_TREE *tree,
#endif
if (num_4x4_blk > 4) {
alloc_mode_context(cm, num_4x4_blk/2, &tree->horizontal[1]);
alloc_mode_context(cm, num_4x4_blk/2, &tree->vertical[1]);
alloc_mode_context(cm, num_4x4_blk / 2, &tree->horizontal[1]);
alloc_mode_context(cm, num_4x4_blk / 2, &tree->vertical[1]);
} else {
memset(&tree->horizontal[1], 0, sizeof(tree->horizontal[1]));
memset(&tree->vertical[1], 0, sizeof(tree->vertical[1]));
......@@ -198,11 +200,11 @@ void vp10_setup_pc_tree(VP10_COMMON *cm, ThreadData *td) {
int nodes;
vpx_free(td->leaf_tree);
CHECK_MEM_ERROR(cm, td->leaf_tree, vpx_calloc(leaf_nodes,
sizeof(*td->leaf_tree)));
CHECK_MEM_ERROR(cm, td->leaf_tree,
vpx_calloc(leaf_nodes, sizeof(*td->leaf_tree)));
vpx_free(td->pc_tree);
CHECK_MEM_ERROR(cm, td->pc_tree, vpx_calloc(tree_nodes,