Commit 646f831f authored by Yaowu Xu's avatar Yaowu Xu

Merge branch 'master' into nextgenv2

parents b831fafc 66129c72
......@@ -17,8 +17,8 @@
int vp10_get_pred_context_switchable_interp(const MACROBLOCKD *xd) {
// Note:
// The mode info data structure has a one element border above and to the
// left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0.
// left of the entries corresponding to real macroblocks.
// The prediction flags in these dummy entries are initialized to 0.
const MB_MODE_INFO *const left_mbmi = xd->left_mbmi;
const int left_type = xd->left_available && is_inter_block(left_mbmi) ?
left_mbmi->interp_filter : SWITCHABLE_FILTERS;
......@@ -70,8 +70,8 @@ int vp10_get_reference_mode_context(const VP10_COMMON *cm,
const int has_left = xd->left_available;
// Note:
// The mode info data structure has a one element border above and to the
// left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0.
// left of the entries corresponding to real macroblocks.
// The prediction flags in these dummy entries are initialized to 0.
if (has_above && has_left) { // both edges available
if (!has_second_ref(above_mbmi) && !has_second_ref(left_mbmi))
// neither edge uses comp pred (0/1)
......@@ -529,8 +529,8 @@ int vp10_get_pred_context_comp_ref_p(const VP10_COMMON *cm,
// Note:
// The mode info data structure has a one element border above and to the
// left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0.
// left of the entries corresponding to real macroblocks.
// The prediction flags in these dummy entries are initialized to 0.
const int fix_ref_idx = cm->ref_frame_sign_bias[cm->comp_fixed_ref];
const int var_ref_idx = !fix_ref_idx;
......@@ -1075,8 +1075,8 @@ int vp10_get_pred_context_single_ref_p1(const MACROBLOCKD *xd) {
const int has_left = xd->left_available;
// Note:
// The mode info data structure has a one element border above and to the
// left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0.
// left of the entries corresponding to real macroblocks.
// The prediction flags in these dummy entries are initialized to 0.
if (has_above && has_left) { // both edges available
const int above_intra = !is_inter_block(above_mbmi);
const int left_intra = !is_inter_block(left_mbmi);
......@@ -1142,8 +1142,8 @@ int vp10_get_pred_context_single_ref_p2(const MACROBLOCKD *xd) {
// Note:
// The mode info data structure has a one element border above and to the
// left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0.
// left of the entries corresponding to real macroblocks.
// The prediction flags in these dummy entries are initialized to 0.
if (has_above && has_left) { // both edges available
const int above_intra = !is_inter_block(above_mbmi);
const int left_intra = !is_inter_block(left_mbmi);
......
......@@ -17,8 +17,8 @@
int vp9_get_pred_context_switchable_interp(const MACROBLOCKD *xd) {
// Note:
// The mode info data structure has a one element border above and to the
// left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0.
// left of the entries corresponding to real macroblocks.
// The prediction flags in these dummy entries are initialized to 0.
const MODE_INFO *const left_mi = xd->left_mi;
const int left_type = xd->left_available && is_inter_block(left_mi) ?
left_mi->interp_filter : SWITCHABLE_FILTERS;
......@@ -70,8 +70,8 @@ int vp9_get_reference_mode_context(const VP9_COMMON *cm,
const int has_left = xd->left_available;
// Note:
// The mode info data structure has a one element border above and to the
// left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0.
// left of the entries corresponding to real macroblocks.
// The prediction flags in these dummy entries are initialized to 0.
if (has_above && has_left) { // both edges available
if (!has_second_ref(above_mi) && !has_second_ref(left_mi))
// neither edge uses comp pred (0/1)
......@@ -114,8 +114,8 @@ int vp9_get_pred_context_comp_ref_p(const VP9_COMMON *cm,
// Note:
// The mode info data structure has a one element border above and to the
// left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0.
// left of the entries corresponding to real macroblocks.
// The prediction flags in these dummy entries are initialized to 0.
const int fix_ref_idx = cm->ref_frame_sign_bias[cm->comp_fixed_ref];
const int var_ref_idx = !fix_ref_idx;
......@@ -195,8 +195,8 @@ int vp9_get_pred_context_single_ref_p1(const MACROBLOCKD *xd) {
// Note:
// The mode info data structure has a one element border above and to the
// left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0.
// left of the entries corresponding to real macroblocks.
// The prediction flags in these dummy entries are initialized to 0.
if (has_above && has_left) { // both edges available
const int above_intra = !is_inter_block(above_mi);
const int left_intra = !is_inter_block(left_mi);
......@@ -262,8 +262,8 @@ int vp9_get_pred_context_single_ref_p2(const MACROBLOCKD *xd) {
// Note:
// The mode info data structure has a one element border above and to the
// left of the entries correpsonding to real macroblocks.
// The prediction flags in these dummy entries are initialised to 0.
// left of the entries corresponding to real macroblocks.
// The prediction flags in these dummy entries are initialized to 0.
if (has_above && has_left) { // both edges available
const int above_intra = !is_inter_block(above_mi);
const int left_intra = !is_inter_block(left_mi);
......
......@@ -552,7 +552,7 @@ static void extend_and_predict(const uint8_t *buf_ptr1, int pre_buf_stride,
}
#endif // CONFIG_VP9_HIGHBITDEPTH
static void dec_build_inter_predictors(VP9Decoder *const pbi, MACROBLOCKD *xd,
static void dec_build_inter_predictors(VPxWorker *const worker, MACROBLOCKD *xd,
int plane, int bw, int bh, int x,
int y, int w, int h, int mi_x, int mi_y,
const InterpKernel *kernel,
......@@ -662,8 +662,8 @@ static void dec_build_inter_predictors(VP9Decoder *const pbi, MACROBLOCKD *xd,
// Wait until reference block is ready. Pad 7 more pixels as last 7
// pixels of each superblock row can be changed by next superblock row.
if (pbi->frame_parallel_decode)
vp9_frameworker_wait(pbi->frame_worker_owner, ref_frame_buf,
if (worker != NULL)
vp9_frameworker_wait(worker, ref_frame_buf,
VPXMAX(0, (y1 + 7)) << (plane == 0 ? 0 : 1));
// Skip border extension if block is inside the frame.
......@@ -689,11 +689,11 @@ static void dec_build_inter_predictors(VP9Decoder *const pbi, MACROBLOCKD *xd,
} else {
// Wait until reference block is ready. Pad 7 more pixels as last 7
// pixels of each superblock row can be changed by next superblock row.
if (pbi->frame_parallel_decode) {
const int y1 = (y0_16 + (h - 1) * ys) >> SUBPEL_BITS;
vp9_frameworker_wait(pbi->frame_worker_owner, ref_frame_buf,
VPXMAX(0, (y1 + 7)) << (plane == 0 ? 0 : 1));
}
if (worker != NULL) {
const int y1 = (y0_16 + (h - 1) * ys) >> SUBPEL_BITS;
vp9_frameworker_wait(worker, ref_frame_buf,
VPXMAX(0, (y1 + 7)) << (plane == 0 ? 0 : 1));
}
}
#if CONFIG_VP9_HIGHBITDEPTH
if (xd->cur_buf->flags & YV12_FLAG_HIGHBITDEPTH) {
......@@ -720,53 +720,60 @@ static void dec_build_inter_predictors_sb(VP9Decoder *const pbi,
const BLOCK_SIZE sb_type = mi->sb_type;
const int is_compound = has_second_ref(mi);
int ref;
int is_scaled;
VPxWorker *const fwo = pbi->frame_parallel_decode ?
pbi->frame_worker_owner : NULL;
for (ref = 0; ref < 1 + is_compound; ++ref) {
const MV_REFERENCE_FRAME frame = mi->ref_frame[ref];
RefBuffer *ref_buf = &pbi->common.frame_refs[frame - LAST_FRAME];
const struct scale_factors *const sf = &ref_buf->sf;
const int idx = ref_buf->idx;
BufferPool *const pool = pbi->common.buffer_pool;
RefCntBuffer *const ref_frame_buf = &pool->frame_bufs[idx];
xd->block_refs[ref] = ref_buf;
if (!vp9_is_valid_scale(&ref_buf->sf))
if (!vp9_is_valid_scale(sf))
vpx_internal_error(xd->error_info, VPX_CODEC_UNSUP_BITSTREAM,
"Reference frame has invalid dimensions");
vp9_setup_pre_planes(xd, ref, ref_buf->buf, mi_row, mi_col, &ref_buf->sf);
}
for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
struct macroblockd_plane *const pd = &xd->plane[plane];
struct buf_2d *const dst_buf = &pd->dst;
const int num_4x4_w = pd->n4_w;
const int num_4x4_h = pd->n4_h;
const int n4w_x4 = 4 * num_4x4_w;
const int n4h_x4 = 4 * num_4x4_h;
int ref;
for (ref = 0; ref < 1 + is_compound; ++ref) {
const struct scale_factors *const sf = &xd->block_refs[ref]->sf;
struct buf_2d *const pre_buf = &pd->pre[ref];
const int idx = xd->block_refs[ref]->idx;
BufferPool *const pool = pbi->common.buffer_pool;
RefCntBuffer *const ref_frame_buf = &pool->frame_bufs[idx];
const int is_scaled = vp9_is_scaled(sf);
if (sb_type < BLOCK_8X8) {
is_scaled = vp9_is_scaled(sf);
vp9_setup_pre_planes(xd, ref, ref_buf->buf, mi_row, mi_col, sf);
xd->block_refs[ref] = ref_buf;
if (sb_type < BLOCK_8X8) {
for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
struct macroblockd_plane *const pd = &xd->plane[plane];
struct buf_2d *const dst_buf = &pd->dst;
const int num_4x4_w = pd->n4_w;
const int num_4x4_h = pd->n4_h;
const int n4w_x4 = 4 * num_4x4_w;
const int n4h_x4 = 4 * num_4x4_h;
struct buf_2d *const pre_buf = &pd->pre[ref];
int i = 0, x, y;
for (y = 0; y < num_4x4_h; ++y) {
for (x = 0; x < num_4x4_w; ++x) {
const MV mv = average_split_mvs(pd, mi, ref, i++);
dec_build_inter_predictors(pbi, xd, plane, n4w_x4, n4h_x4,
dec_build_inter_predictors(fwo, xd, plane, n4w_x4, n4h_x4,
4 * x, 4 * y, 4, 4, mi_x, mi_y, kernel,
sf, pre_buf, dst_buf, &mv,
ref_frame_buf, is_scaled, ref);
}
}
} else {
const MV mv = mi->mv[ref].as_mv;
dec_build_inter_predictors(pbi, xd, plane, n4w_x4, n4h_x4,
}
} else {
const MV mv = mi->mv[ref].as_mv;
for (plane = 0; plane < MAX_MB_PLANE; ++plane) {
struct macroblockd_plane *const pd = &xd->plane[plane];
struct buf_2d *const dst_buf = &pd->dst;
const int num_4x4_w = pd->n4_w;
const int num_4x4_h = pd->n4_h;
const int n4w_x4 = 4 * num_4x4_w;
const int n4h_x4 = 4 * num_4x4_h;
struct buf_2d *const pre_buf = &pd->pre[ref];
dec_build_inter_predictors(fwo, xd, plane, n4w_x4, n4h_x4,
0, 0, n4w_x4, n4h_x4, mi_x, mi_y, kernel,
sf, pre_buf, dst_buf, &mv, ref_frame_buf,
is_scaled, ref);
sf, pre_buf, dst_buf, &mv,
ref_frame_buf, is_scaled, ref);
}
}
}
......
......@@ -320,11 +320,11 @@ void vp9_cyclic_refresh_postencode(VP9_COMP *const cpi) {
void vp9_cyclic_refresh_set_golden_update(VP9_COMP *const cpi) {
RATE_CONTROL *const rc = &cpi->rc;
CYCLIC_REFRESH *const cr = cpi->cyclic_refresh;
// Set minimum gf_interval for GF update to a multiple (== 2) of refresh
// period. Depending on past encoding stats, GF flag may be reset and update
// may not occur until next baseline_gf_interval.
// Set minimum gf_interval for GF update to a multiple of the refresh period,
// with some max limit. Depending on past encoding stats, GF flag may be
// reset and update may not occur until next baseline_gf_interval.
if (cr->percent_refresh > 0)
rc->baseline_gf_interval = 4 * (100 / cr->percent_refresh);
rc->baseline_gf_interval = VPXMIN(4 * (100 / cr->percent_refresh), 40);
else
rc->baseline_gf_interval = 40;
}
......
......@@ -11,29 +11,32 @@
#include "vp9/encoder/vp9_cost.h"
const unsigned int vp9_prob_cost[256] = {
2047, 2047, 1791, 1641, 1535, 1452, 1385, 1328, 1279, 1235, 1196, 1161,
1129, 1099, 1072, 1046, 1023, 1000, 979, 959, 940, 922, 905, 889,
873, 858, 843, 829, 816, 803, 790, 778, 767, 755, 744, 733,
723, 713, 703, 693, 684, 675, 666, 657, 649, 641, 633, 625,
617, 609, 602, 594, 587, 580, 573, 567, 560, 553, 547, 541,
534, 528, 522, 516, 511, 505, 499, 494, 488, 483, 477, 472,
467, 462, 457, 452, 447, 442, 437, 433, 428, 424, 419, 415,
410, 406, 401, 397, 393, 389, 385, 381, 377, 373, 369, 365,
361, 357, 353, 349, 346, 342, 338, 335, 331, 328, 324, 321,
317, 314, 311, 307, 304, 301, 297, 294, 291, 288, 285, 281,
278, 275, 272, 269, 266, 263, 260, 257, 255, 252, 249, 246,
243, 240, 238, 235, 232, 229, 227, 224, 221, 219, 216, 214,
211, 208, 206, 203, 201, 198, 196, 194, 191, 189, 186, 184,
181, 179, 177, 174, 172, 170, 168, 165, 163, 161, 159, 156,
154, 152, 150, 148, 145, 143, 141, 139, 137, 135, 133, 131,
129, 127, 125, 123, 121, 119, 117, 115, 113, 111, 109, 107,
105, 103, 101, 99, 97, 95, 93, 92, 90, 88, 86, 84,
82, 81, 79, 77, 75, 73, 72, 70, 68, 66, 65, 63,
61, 60, 58, 56, 55, 53, 51, 50, 48, 46, 45, 43,
41, 40, 38, 37, 35, 33, 32, 30, 29, 27, 25, 24,
22, 21, 19, 18, 16, 15, 13, 12, 10, 9, 7, 6,
4, 3, 1, 1};
/* round(-log2(i/256.) * (1 << VP9_PROB_COST_SHIFT))
Begins and ends with a bogus entry to satisfy use of prob=0 in the firstpass.
https://code.google.com/p/webm/issues/detail?id=1089 */
const uint16_t vp9_prob_cost[257] = {
4096, 4096, 3584, 3284, 3072, 2907, 2772, 2659, 2560, 2473, 2395, 2325,
2260, 2201, 2147, 2096, 2048, 2003, 1961, 1921, 1883, 1847, 1813, 1780,
1748, 1718, 1689, 1661, 1635, 1609, 1584, 1559, 1536, 1513, 1491, 1470,
1449, 1429, 1409, 1390, 1371, 1353, 1335, 1318, 1301, 1284, 1268, 1252,
1236, 1221, 1206, 1192, 1177, 1163, 1149, 1136, 1123, 1110, 1097, 1084,
1072, 1059, 1047, 1036, 1024, 1013, 1001, 990, 979, 968, 958, 947,
937, 927, 917, 907, 897, 887, 878, 868, 859, 850, 841, 832,
823, 814, 806, 797, 789, 780, 772, 764, 756, 748, 740, 732,
724, 717, 709, 702, 694, 687, 680, 673, 665, 658, 651, 644,
637, 631, 624, 617, 611, 604, 598, 591, 585, 578, 572, 566,
560, 554, 547, 541, 535, 530, 524, 518, 512, 506, 501, 495,
489, 484, 478, 473, 467, 462, 456, 451, 446, 441, 435, 430,
425, 420, 415, 410, 405, 400, 395, 390, 385, 380, 375, 371,
366, 361, 356, 352, 347, 343, 338, 333, 329, 324, 320, 316,
311, 307, 302, 298, 294, 289, 285, 281, 277, 273, 268, 264,
260, 256, 252, 248, 244, 240, 236, 232, 228, 224, 220, 216,
212, 209, 205, 201, 197, 194, 190, 186, 182, 179, 175, 171,
168, 164, 161, 157, 153, 150, 146, 143, 139, 136, 132, 129,
125, 122, 119, 115, 112, 109, 105, 102, 99, 95, 92, 89,
86, 82, 79, 76, 73, 70, 66, 63, 60, 57, 54, 51,
48, 45, 42, 38, 35, 32, 29, 26, 23, 20, 18, 15,
12, 9, 6, 3, 3};
static void cost(int *costs, vpx_tree tree, const vpx_prob *probs,
int i, int c) {
......
......@@ -12,21 +12,22 @@
#define VP9_ENCODER_VP9_COST_H_
#include "vpx_dsp/prob.h"
#include "vpx/vpx_integer.h"
#ifdef __cplusplus
extern "C" {
#endif
extern const unsigned int vp9_prob_cost[256];
extern const uint16_t vp9_prob_cost[257];
// The factor to scale from cost in bits to cost in vp9_prob_cost units.
#define VP9_PROB_COST_SHIFT 8
#define VP9_PROB_COST_SHIFT 9
#define vp9_cost_zero(prob) (vp9_prob_cost[prob])
#define vp9_cost_one(prob) vp9_cost_zero(vpx_complement(prob))
#define vp9_cost_one(prob) vp9_cost_zero(256 - (prob))
#define vp9_cost_bit(prob, bit) vp9_cost_zero((bit) ? vpx_complement(prob) \
#define vp9_cost_bit(prob, bit) vp9_cost_zero((bit) ? 256 - (prob) \
: (prob))
static INLINE unsigned int cost_branch256(const unsigned int ct[2],
......
......@@ -117,9 +117,9 @@ static int optimize_b(MACROBLOCK *mb, int plane, int block,
EXTRABIT e0;
int best, band, pt, i, final_eob;
#if CONFIG_VP9_HIGHBITDEPTH
const int16_t *cat6_high_cost = vp9_get_high_cost_table(xd->bd);
const int *cat6_high_cost = vp9_get_high_cost_table(xd->bd);
#else
const int16_t *cat6_high_cost = vp9_get_high_cost_table(8);
const int *cat6_high_cost = vp9_get_high_cost_table(8);
#endif
assert((!type && !plane) || (type && plane));
......
......@@ -373,9 +373,9 @@ static int cost_coeffs(MACROBLOCK *x,
int pt = combine_entropy_contexts(*A, *L);
int c, cost;
#if CONFIG_VP9_HIGHBITDEPTH
const int16_t *cat6_high_cost = vp9_get_high_cost_table(xd->bd);
const int *cat6_high_cost = vp9_get_high_cost_table(xd->bd);
#else
const int16_t *cat6_high_cost = vp9_get_high_cost_table(8);
const int *cat6_high_cost = vp9_get_high_cost_table(8);
#endif
// Check for consistency of tx_size with mode info
......
This diff is collapsed.
......@@ -75,25 +75,25 @@ extern const int16_t *vp9_dct_value_cost_ptr;
extern const TOKENVALUE *vp9_dct_value_tokens_ptr;
extern const TOKENVALUE *vp9_dct_cat_lt_10_value_tokens;
extern const int16_t vp9_cat6_low_cost[256];
extern const int16_t vp9_cat6_high_cost[128];
extern const int16_t vp9_cat6_high10_high_cost[512];
extern const int16_t vp9_cat6_high12_high_cost[2048];
static INLINE int16_t vp9_get_cost(int16_t token, EXTRABIT extrabits,
const int16_t *cat6_high_table) {
extern const int vp9_cat6_high_cost[64];
extern const int vp9_cat6_high10_high_cost[256];
extern const int vp9_cat6_high12_high_cost[1024];
static INLINE int vp9_get_cost(int16_t token, EXTRABIT extrabits,
const int *cat6_high_table) {
if (token != CATEGORY6_TOKEN)
return vp9_extra_bits[token].cost[extrabits];
return vp9_cat6_low_cost[extrabits & 0xff]
+ cat6_high_table[extrabits >> 8];
return vp9_extra_bits[token].cost[extrabits >> 1];
return vp9_cat6_low_cost[(extrabits >> 1) & 0xff]
+ cat6_high_table[extrabits >> 9];
}
#if CONFIG_VP9_HIGHBITDEPTH
static INLINE const int16_t* vp9_get_high_cost_table(int bit_depth) {
static INLINE const int* vp9_get_high_cost_table(int bit_depth) {
return bit_depth == 8 ? vp9_cat6_high_cost
: (bit_depth == 10 ? vp9_cat6_high10_high_cost :
vp9_cat6_high12_high_cost);
}
#else
static INLINE const int16_t* vp9_get_high_cost_table(int bit_depth) {
static INLINE const int* vp9_get_high_cost_table(int bit_depth) {
(void) bit_depth;
return vp9_cat6_high_cost;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment