Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(63)

Side by Side Diff: source/libvpx/vp9/encoder/vp9_encodeframe.c

Issue 341293003: libvpx: Pull from upstream (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/deps/third_party/libvpx/
Patch Set: Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_encodeframe.h ('k') | source/libvpx/vp9/encoder/vp9_encodemb.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
63 128, 128, 128, 128, 128, 128, 128, 128, 63 128, 128, 128, 128, 128, 128, 128, 128,
64 128, 128, 128, 128, 128, 128, 128, 128, 64 128, 128, 128, 128, 128, 128, 128, 128,
65 128, 128, 128, 128, 128, 128, 128, 128, 65 128, 128, 128, 128, 128, 128, 128, 128,
66 128, 128, 128, 128, 128, 128, 128, 128, 66 128, 128, 128, 128, 128, 128, 128, 128,
67 128, 128, 128, 128, 128, 128, 128, 128, 67 128, 128, 128, 128, 128, 128, 128, 128,
68 128, 128, 128, 128, 128, 128, 128, 128, 68 128, 128, 128, 128, 128, 128, 128, 128,
69 128, 128, 128, 128, 128, 128, 128, 128, 69 128, 128, 128, 128, 128, 128, 128, 128,
70 128, 128, 128, 128, 128, 128, 128, 128 70 128, 128, 128, 128, 128, 128, 128, 128
71 }; 71 };
72 72
73 static void get_sse_sum_8x8(const uint8_t *src, int src_stride, 73 typedef struct {
74 const uint8_t *ref, int ref_stride, 74 unsigned int sse;
75 unsigned int *sse, int *sum) { 75 int sum;
76 variance(src, src_stride, ref, ref_stride, 8, 8, sse, sum); 76 unsigned int var;
77 } 77 } diff;
78
79 static void get_sse_sum_16x16(const uint8_t *src, int src_stride,
80 const uint8_t *ref, int ref_stride,
81 unsigned int *sse, int *sum) {
82 variance(src, src_stride, ref, ref_stride, 16, 16, sse, sum);
83 }
84 78
85 static unsigned int get_sby_perpixel_variance(VP9_COMP *cpi, 79 static unsigned int get_sby_perpixel_variance(VP9_COMP *cpi,
86 const struct buf_2d *ref, 80 const struct buf_2d *ref,
87 BLOCK_SIZE bs) { 81 BLOCK_SIZE bs) {
88 unsigned int sse; 82 unsigned int sse;
89 const unsigned int var = cpi->fn_ptr[bs].vf(ref->buf, ref->stride, 83 const unsigned int var = cpi->fn_ptr[bs].vf(ref->buf, ref->stride,
90 VP9_VAR_OFFS, 0, &sse); 84 VP9_VAR_OFFS, 0, &sse);
91 return ROUND_POWER_OF_TWO(var, num_pels_log2_lookup[bs]); 85 return ROUND_POWER_OF_TWO(var, num_pels_log2_lookup[bs]);
92 } 86 }
93 87
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 for (j = 0; j < 4; j++) { 471 for (j = 0; j < 4; j++) {
478 const int x16_idx = x32_idx + ((j & 1) << 4); 472 const int x16_idx = x32_idx + ((j & 1) << 4);
479 const int y16_idx = y32_idx + ((j >> 1) << 4); 473 const int y16_idx = y32_idx + ((j >> 1) << 4);
480 v16x16 *vst = &vt.split[i].split[j]; 474 v16x16 *vst = &vt.split[i].split[j];
481 for (k = 0; k < 4; k++) { 475 for (k = 0; k < 4; k++) {
482 int x_idx = x16_idx + ((k & 1) << 3); 476 int x_idx = x16_idx + ((k & 1) << 3);
483 int y_idx = y16_idx + ((k >> 1) << 3); 477 int y_idx = y16_idx + ((k >> 1) << 3);
484 unsigned int sse = 0; 478 unsigned int sse = 0;
485 int sum = 0; 479 int sum = 0;
486 if (x_idx < pixels_wide && y_idx < pixels_high) 480 if (x_idx < pixels_wide && y_idx < pixels_high)
487 get_sse_sum_8x8(s + y_idx * sp + x_idx, sp, 481 vp9_get8x8var(s + y_idx * sp + x_idx, sp,
488 d + y_idx * dp + x_idx, dp, &sse, &sum); 482 d + y_idx * dp + x_idx, dp, &sse, &sum);
489 fill_variance(sse, sum, 64, &vst->split[k].part_variances.none); 483 fill_variance(sse, sum, 64, &vst->split[k].part_variances.none);
490 } 484 }
491 } 485 }
492 } 486 }
493 // Fill the rest of the variance tree by summing split partition values. 487 // Fill the rest of the variance tree by summing split partition values.
494 for (i = 0; i < 4; i++) { 488 for (i = 0; i < 4; i++) {
495 for (j = 0; j < 4; j++) { 489 for (j = 0; j < 4; j++) {
496 fill_variance_tree(&vt.split[i].split[j], BLOCK_16X16); 490 fill_variance_tree(&vt.split[i].split[j], BLOCK_16X16);
497 } 491 }
498 fill_variance_tree(&vt.split[i], BLOCK_32X32); 492 fill_variance_tree(&vt.split[i], BLOCK_32X32);
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
546 BLOCK_8X8); 540 BLOCK_8X8);
547 } 541 }
548 } 542 }
549 #endif 543 #endif
550 } 544 }
551 } 545 }
552 } 546 }
553 } 547 }
554 } 548 }
555 549
556 // Original activity measure from Tim T's code.
557 static unsigned int tt_activity_measure(MACROBLOCK *x) {
558 unsigned int sse;
559 // TODO: This could also be done over smaller areas (8x8), but that would
560 // require extensive changes elsewhere, as lambda is assumed to be fixed
561 // over an entire MB in most of the code.
562 // Another option is to compute four 8x8 variances, and pick a single
563 // lambda using a non-linear combination (e.g., the smallest, or second
564 // smallest, etc.).
565 const unsigned int act = vp9_variance16x16(x->plane[0].src.buf,
566 x->plane[0].src.stride,
567 VP9_VAR_OFFS, 0, &sse) << 4;
568 // If the region is flat, lower the activity some more.
569 return act < (8 << 12) ? MIN(act, 5 << 12) : act;
570 }
571
572 static void update_state(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx, 550 static void update_state(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx,
573 int mi_row, int mi_col, BLOCK_SIZE bsize, 551 int mi_row, int mi_col, BLOCK_SIZE bsize,
574 int output_enabled) { 552 int output_enabled) {
575 int i, x_idx, y; 553 int i, x_idx, y;
576 VP9_COMMON *const cm = &cpi->common; 554 VP9_COMMON *const cm = &cpi->common;
577 RD_OPT *const rd_opt = &cpi->rd; 555 RD_OPT *const rd_opt = &cpi->rd;
578 MACROBLOCK *const x = &cpi->mb; 556 MACROBLOCK *const x = &cpi->mb;
579 MACROBLOCKD *const xd = &x->e_mbd; 557 MACROBLOCKD *const xd = &x->e_mbd;
580 struct macroblock_plane *const p = x->plane; 558 struct macroblock_plane *const p = x->plane;
581 struct macroblockd_plane *const pd = xd->plane; 559 struct macroblockd_plane *const pd = xd->plane;
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
712 690
713 // Set current frame pointer. 691 // Set current frame pointer.
714 x->e_mbd.cur_buf = src; 692 x->e_mbd.cur_buf = src;
715 693
716 for (i = 0; i < MAX_MB_PLANE; i++) 694 for (i = 0; i < MAX_MB_PLANE; i++)
717 setup_pred_plane(&x->plane[i].src, buffers[i], strides[i], mi_row, mi_col, 695 setup_pred_plane(&x->plane[i].src, buffers[i], strides[i], mi_row, mi_col,
718 NULL, x->e_mbd.plane[i].subsampling_x, 696 NULL, x->e_mbd.plane[i].subsampling_x,
719 x->e_mbd.plane[i].subsampling_y); 697 x->e_mbd.plane[i].subsampling_y);
720 } 698 }
721 699
700 static void set_mode_info_seg_skip(MACROBLOCK *x, TX_MODE tx_mode, int *rate,
701 int64_t *dist, BLOCK_SIZE bsize) {
702 MACROBLOCKD *const xd = &x->e_mbd;
703 MB_MODE_INFO *const mbmi = &xd->mi[0]->mbmi;
704 INTERP_FILTER filter_ref;
705
706 if (xd->up_available)
707 filter_ref = xd->mi[-xd->mi_stride]->mbmi.interp_filter;
708 else if (xd->left_available)
709 filter_ref = xd->mi[-1]->mbmi.interp_filter;
710 else
711 filter_ref = EIGHTTAP;
712
713 mbmi->sb_type = bsize;
714 mbmi->mode = ZEROMV;
715 mbmi->tx_size = MIN(max_txsize_lookup[bsize],
716 tx_mode_to_biggest_tx_size[tx_mode]);
717 mbmi->skip = 1;
718 mbmi->uv_mode = DC_PRED;
719 mbmi->ref_frame[0] = LAST_FRAME;
720 mbmi->ref_frame[1] = NONE;
721 mbmi->mv[0].as_int = 0;
722 mbmi->interp_filter = filter_ref;
723
724 xd->mi[0]->bmi[0].as_mv[0].as_int = 0;
725 x->skip = 1;
726 x->skip_encode = 1;
727
728 *rate = 0;
729 *dist = 0;
730 }
731
722 static void rd_pick_sb_modes(VP9_COMP *cpi, const TileInfo *const tile, 732 static void rd_pick_sb_modes(VP9_COMP *cpi, const TileInfo *const tile,
723 int mi_row, int mi_col, 733 int mi_row, int mi_col,
724 int *totalrate, int64_t *totaldist, 734 int *totalrate, int64_t *totaldist,
725 BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx, 735 BLOCK_SIZE bsize, PICK_MODE_CONTEXT *ctx,
726 int64_t best_rd, int block) { 736 int64_t best_rd, int block) {
727 VP9_COMMON *const cm = &cpi->common; 737 VP9_COMMON *const cm = &cpi->common;
728 MACROBLOCK *const x = &cpi->mb; 738 MACROBLOCK *const x = &cpi->mb;
729 MACROBLOCKD *const xd = &x->e_mbd; 739 MACROBLOCKD *const xd = &x->e_mbd;
730 MB_MODE_INFO *mbmi; 740 MB_MODE_INFO *mbmi;
731 struct macroblock_plane *const p = x->plane; 741 struct macroblock_plane *const p = x->plane;
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after
1213 1223
1214 for (i = 0; i < 4; i++) { 1224 for (i = 0; i < 4; i++) {
1215 diff d16[4]; 1225 diff d16[4];
1216 1226
1217 for (j = 0; j < 4; j++) { 1227 for (j = 0; j < 4; j++) {
1218 int b_mi_row = coord_lookup[i * 4 + j].row; 1228 int b_mi_row = coord_lookup[i * 4 + j].row;
1219 int b_mi_col = coord_lookup[i * 4 + j].col; 1229 int b_mi_col = coord_lookup[i * 4 + j].col;
1220 int b_offset = b_mi_row * MI_SIZE * src_stride + 1230 int b_offset = b_mi_row * MI_SIZE * src_stride +
1221 b_mi_col * MI_SIZE; 1231 b_mi_col * MI_SIZE;
1222 1232
1223 get_sse_sum_16x16(src + b_offset, src_stride, 1233 vp9_get16x16var(src + b_offset, src_stride,
1224 pre_src + b_offset, pre_stride, 1234 pre_src + b_offset, pre_stride,
1225 &d16[j].sse, &d16[j].sum); 1235 &d16[j].sse, &d16[j].sum);
1226 1236
1227 d16[j].var = d16[j].sse - 1237 d16[j].var = d16[j].sse -
1228 (((uint32_t)d16[j].sum * d16[j].sum) >> 8); 1238 (((uint32_t)d16[j].sum * d16[j].sum) >> 8);
1229 1239
1230 index = b_mi_row * mis + b_mi_col; 1240 index = b_mi_row * mis + b_mi_col;
1231 mi_8x8[index] = mi_upper_left + index; 1241 mi_8x8[index] = mi_upper_left + index;
1232 mi_8x8[index]->mbmi.sb_type = BLOCK_16X16; 1242 mi_8x8[index]->mbmi.sb_type = BLOCK_16X16;
1233 1243
1234 // TODO(yunqingwang): If d16[j].var is very large, use 8x8 partition 1244 // TODO(yunqingwang): If d16[j].var is very large, use 8x8 partition
1235 // size to further improve quality. 1245 // size to further improve quality.
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1290 src_stride = cpi->Source->y_stride; 1300 src_stride = cpi->Source->y_stride;
1291 src = cpi->Source->y_buffer + (mi_row * MI_SIZE) * src_stride + 1301 src = cpi->Source->y_buffer + (mi_row * MI_SIZE) * src_stride +
1292 (mi_col * MI_SIZE); 1302 (mi_col * MI_SIZE);
1293 pre_stride = cpi->Last_Source->y_stride; 1303 pre_stride = cpi->Last_Source->y_stride;
1294 pre = cpi->Last_Source->y_buffer + (mi_row * MI_SIZE) * pre_stride + 1304 pre = cpi->Last_Source->y_buffer + (mi_row * MI_SIZE) * pre_stride +
1295 (mi_col * MI_SIZE); 1305 (mi_col * MI_SIZE);
1296 1306
1297 if (row8x8_remaining >= MI_BLOCK_SIZE && 1307 if (row8x8_remaining >= MI_BLOCK_SIZE &&
1298 col8x8_remaining >= MI_BLOCK_SIZE) { 1308 col8x8_remaining >= MI_BLOCK_SIZE) {
1299 this_sad = cpi->fn_ptr[BLOCK_64X64].sdf(src, src_stride, 1309 this_sad = cpi->fn_ptr[BLOCK_64X64].sdf(src, src_stride,
1300 pre, pre_stride, 0x7fffffff); 1310 pre, pre_stride);
1301 threshold = (1 << 12); 1311 threshold = (1 << 12);
1302 } else { 1312 } else {
1303 int r, c; 1313 int r, c;
1304 for (r = 0; r < row8x8_remaining; r += 2) 1314 for (r = 0; r < row8x8_remaining; r += 2)
1305 for (c = 0; c < col8x8_remaining; c += 2) 1315 for (c = 0; c < col8x8_remaining; c += 2)
1306 this_sad += cpi->fn_ptr[BLOCK_16X16].sdf(src, src_stride, pre, 1316 this_sad += cpi->fn_ptr[BLOCK_16X16].sdf(src, src_stride,
1307 pre_stride, 0x7fffffff); 1317 pre, pre_stride);
1308 threshold = (row8x8_remaining * col8x8_remaining) << 6; 1318 threshold = (row8x8_remaining * col8x8_remaining) << 6;
1309 } 1319 }
1310 1320
1311 x->in_static_area = (this_sad < 2 * threshold); 1321 x->in_static_area = (this_sad < 2 * threshold);
1312 return x->in_static_area; 1322 return x->in_static_area;
1313 } 1323 }
1314 1324
1315 static int sb_has_motion(const VP9_COMMON *cm, MODE_INFO **prev_mi_8x8) { 1325 static int sb_has_motion(const VP9_COMMON *cm, MODE_INFO **prev_mi_8x8,
1326 const int motion_thresh) {
1316 const int mis = cm->mi_stride; 1327 const int mis = cm->mi_stride;
1317 int block_row, block_col; 1328 int block_row, block_col;
1318 1329
1319 if (cm->prev_mi) { 1330 if (cm->prev_mi) {
1320 for (block_row = 0; block_row < 8; ++block_row) { 1331 for (block_row = 0; block_row < 8; ++block_row) {
1321 for (block_col = 0; block_col < 8; ++block_col) { 1332 for (block_col = 0; block_col < 8; ++block_col) {
1322 const MODE_INFO *prev_mi = prev_mi_8x8[block_row * mis + block_col]; 1333 const MODE_INFO *prev_mi = prev_mi_8x8[block_row * mis + block_col];
1323 if (prev_mi) { 1334 if (prev_mi) {
1324 if (abs(prev_mi->mbmi.mv[0].as_mv.row) >= 8 || 1335 if (abs(prev_mi->mbmi.mv[0].as_mv.row) > motion_thresh ||
1325 abs(prev_mi->mbmi.mv[0].as_mv.col) >= 8) 1336 abs(prev_mi->mbmi.mv[0].as_mv.col) > motion_thresh)
1326 return 1; 1337 return 1;
1327 } 1338 }
1328 } 1339 }
1329 } 1340 }
1330 } 1341 }
1331 return 0; 1342 return 0;
1332 } 1343 }
1333 1344
1334 static void update_state_rt(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx, 1345 static void update_state_rt(VP9_COMP *cpi, PICK_MODE_CONTEXT *ctx,
1335 int mi_row, int mi_col, int bsize) { 1346 int mi_row, int mi_col, int bsize) {
(...skipping 16 matching lines...) Expand all
1352 if (is_inter_block(mbmi)) { 1363 if (is_inter_block(mbmi)) {
1353 vp9_update_mv_count(cm, xd); 1364 vp9_update_mv_count(cm, xd);
1354 1365
1355 if (cm->interp_filter == SWITCHABLE) { 1366 if (cm->interp_filter == SWITCHABLE) {
1356 const int pred_ctx = vp9_get_pred_context_switchable_interp(xd); 1367 const int pred_ctx = vp9_get_pred_context_switchable_interp(xd);
1357 ++cm->counts.switchable_interp[pred_ctx][mbmi->interp_filter]; 1368 ++cm->counts.switchable_interp[pred_ctx][mbmi->interp_filter];
1358 } 1369 }
1359 } 1370 }
1360 1371
1361 x->skip = ctx->skip; 1372 x->skip = ctx->skip;
1373 x->skip_txfm = mbmi->segment_id ? 0 : ctx->skip_txfm;
1362 } 1374 }
1363 1375
1364 static void encode_b_rt(VP9_COMP *cpi, const TileInfo *const tile, 1376 static void encode_b_rt(VP9_COMP *cpi, const TileInfo *const tile,
1365 TOKENEXTRA **tp, int mi_row, int mi_col, 1377 TOKENEXTRA **tp, int mi_row, int mi_col,
1366 int output_enabled, BLOCK_SIZE bsize, 1378 int output_enabled, BLOCK_SIZE bsize,
1367 PICK_MODE_CONTEXT *ctx) { 1379 PICK_MODE_CONTEXT *ctx) {
1368 1380
1369 1381
1370 set_offsets(cpi, tile, mi_row, mi_col, bsize); 1382 set_offsets(cpi, tile, mi_row, mi_col, bsize);
1371 update_state_rt(cpi, ctx, mi_row, mi_col, bsize); 1383 update_state_rt(cpi, ctx, mi_row, mi_col, bsize);
(...skipping 159 matching lines...) Expand 10 before | Expand all | Expand 10 after
1531 if (partition != PARTITION_NONE && !splits_below && 1543 if (partition != PARTITION_NONE && !splits_below &&
1532 mi_row + (mi_step >> 1) < cm->mi_rows && 1544 mi_row + (mi_step >> 1) < cm->mi_rows &&
1533 mi_col + (mi_step >> 1) < cm->mi_cols) { 1545 mi_col + (mi_step >> 1) < cm->mi_cols) {
1534 pc_tree->partitioning = PARTITION_NONE; 1546 pc_tree->partitioning = PARTITION_NONE;
1535 rd_pick_sb_modes(cpi, tile, mi_row, mi_col, &none_rate, &none_dist, bsize, 1547 rd_pick_sb_modes(cpi, tile, mi_row, mi_col, &none_rate, &none_dist, bsize,
1536 ctx, INT64_MAX, 0); 1548 ctx, INT64_MAX, 0);
1537 1549
1538 pl = partition_plane_context(xd, mi_row, mi_col, bsize); 1550 pl = partition_plane_context(xd, mi_row, mi_col, bsize);
1539 1551
1540 if (none_rate < INT_MAX) { 1552 if (none_rate < INT_MAX) {
1541 none_rate += x->partition_cost[pl][PARTITION_NONE]; 1553 none_rate += cpi->partition_cost[pl][PARTITION_NONE];
1542 none_rd = RDCOST(x->rdmult, x->rddiv, none_rate, none_dist); 1554 none_rd = RDCOST(x->rdmult, x->rddiv, none_rate, none_dist);
1543 } 1555 }
1544 1556
1545 restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize); 1557 restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize);
1546 mi_8x8[0]->mbmi.sb_type = bs_type; 1558 mi_8x8[0]->mbmi.sb_type = bs_type;
1547 pc_tree->partitioning = partition; 1559 pc_tree->partitioning = partition;
1548 } 1560 }
1549 } 1561 }
1550 1562
1551 switch (partition) { 1563 switch (partition) {
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after
1629 last_part_rate += rt; 1641 last_part_rate += rt;
1630 last_part_dist += dt; 1642 last_part_dist += dt;
1631 } 1643 }
1632 break; 1644 break;
1633 default: 1645 default:
1634 assert(0); 1646 assert(0);
1635 } 1647 }
1636 1648
1637 pl = partition_plane_context(xd, mi_row, mi_col, bsize); 1649 pl = partition_plane_context(xd, mi_row, mi_col, bsize);
1638 if (last_part_rate < INT_MAX) { 1650 if (last_part_rate < INT_MAX) {
1639 last_part_rate += x->partition_cost[pl][partition]; 1651 last_part_rate += cpi->partition_cost[pl][partition];
1640 last_part_rd = RDCOST(x->rdmult, x->rddiv, last_part_rate, last_part_dist); 1652 last_part_rd = RDCOST(x->rdmult, x->rddiv, last_part_rate, last_part_dist);
1641 } 1653 }
1642 1654
1643 if (do_partition_search 1655 if (do_partition_search
1644 && cpi->sf.adjust_partitioning_from_last_frame 1656 && cpi->sf.adjust_partitioning_from_last_frame
1645 && cpi->sf.partition_search_type == SEARCH_PARTITION 1657 && cpi->sf.partition_search_type == SEARCH_PARTITION
1646 && partition != PARTITION_SPLIT && bsize > BLOCK_8X8 1658 && partition != PARTITION_SPLIT && bsize > BLOCK_8X8
1647 && (mi_row + mi_step < cm->mi_rows || 1659 && (mi_row + mi_step < cm->mi_rows ||
1648 mi_row + (mi_step >> 1) == cm->mi_rows) 1660 mi_row + (mi_step >> 1) == cm->mi_rows)
1649 && (mi_col + mi_step < cm->mi_cols || 1661 && (mi_col + mi_step < cm->mi_cols ||
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1682 1694
1683 chosen_rate += rt; 1695 chosen_rate += rt;
1684 chosen_dist += dt; 1696 chosen_dist += dt;
1685 1697
1686 if (i != 3) 1698 if (i != 3)
1687 encode_sb(cpi, tile, tp, mi_row + y_idx, mi_col + x_idx, 0, 1699 encode_sb(cpi, tile, tp, mi_row + y_idx, mi_col + x_idx, 0,
1688 split_subsize, pc_tree->split[i]); 1700 split_subsize, pc_tree->split[i]);
1689 1701
1690 pl = partition_plane_context(xd, mi_row + y_idx, mi_col + x_idx, 1702 pl = partition_plane_context(xd, mi_row + y_idx, mi_col + x_idx,
1691 split_subsize); 1703 split_subsize);
1692 chosen_rate += x->partition_cost[pl][PARTITION_NONE]; 1704 chosen_rate += cpi->partition_cost[pl][PARTITION_NONE];
1693 } 1705 }
1694 pl = partition_plane_context(xd, mi_row, mi_col, bsize); 1706 pl = partition_plane_context(xd, mi_row, mi_col, bsize);
1695 if (chosen_rate < INT_MAX) { 1707 if (chosen_rate < INT_MAX) {
1696 chosen_rate += x->partition_cost[pl][PARTITION_SPLIT]; 1708 chosen_rate += cpi->partition_cost[pl][PARTITION_SPLIT];
1697 chosen_rd = RDCOST(x->rdmult, x->rddiv, chosen_rate, chosen_dist); 1709 chosen_rd = RDCOST(x->rdmult, x->rddiv, chosen_rate, chosen_dist);
1698 } 1710 }
1699 } 1711 }
1700 1712
1701 // If last_part is better set the partitioning to that. 1713 // If last_part is better set the partitioning to that.
1702 if (last_part_rd < chosen_rd) { 1714 if (last_part_rd < chosen_rd) {
1703 mi_8x8[0]->mbmi.sb_type = bsize; 1715 mi_8x8[0]->mbmi.sb_type = bsize;
1704 if (bsize >= BLOCK_8X8) 1716 if (bsize >= BLOCK_8X8)
1705 pc_tree->partitioning = partition; 1717 pc_tree->partitioning = partition;
1706 chosen_rate = last_part_rate; 1718 chosen_rate = last_part_rate;
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1870 MODE_INFO **mi_8x8 = xd->mi; 1882 MODE_INFO **mi_8x8 = xd->mi;
1871 const int left_in_image = xd->left_available && mi_8x8[-1]; 1883 const int left_in_image = xd->left_available && mi_8x8[-1];
1872 const int above_in_image = xd->up_available && 1884 const int above_in_image = xd->up_available &&
1873 mi_8x8[-xd->mi_stride]; 1885 mi_8x8[-xd->mi_stride];
1874 int row8x8_remaining = tile->mi_row_end - mi_row; 1886 int row8x8_remaining = tile->mi_row_end - mi_row;
1875 int col8x8_remaining = tile->mi_col_end - mi_col; 1887 int col8x8_remaining = tile->mi_col_end - mi_col;
1876 int bh, bw; 1888 int bh, bw;
1877 BLOCK_SIZE min_size = BLOCK_32X32; 1889 BLOCK_SIZE min_size = BLOCK_32X32;
1878 BLOCK_SIZE max_size = BLOCK_8X8; 1890 BLOCK_SIZE max_size = BLOCK_8X8;
1879 int bsl = mi_width_log2_lookup[BLOCK_64X64]; 1891 int bsl = mi_width_log2_lookup[BLOCK_64X64];
1880 int search_range_ctrl = (((mi_row + mi_col) >> bsl) + 1892 const int search_range_ctrl = (((mi_row + mi_col) >> bsl) +
1881 cpi->sf.chessboard_index) & 0x01; 1893 get_chessboard_index(cm)) % 2;
1882 // Trap case where we do not have a prediction. 1894 // Trap case where we do not have a prediction.
1883 if (search_range_ctrl && 1895 if (search_range_ctrl &&
1884 (left_in_image || above_in_image || cm->frame_type != KEY_FRAME)) { 1896 (left_in_image || above_in_image || cm->frame_type != KEY_FRAME)) {
1885 int block; 1897 int block;
1886 MODE_INFO **mi; 1898 MODE_INFO **mi;
1887 BLOCK_SIZE sb_type; 1899 BLOCK_SIZE sb_type;
1888 1900
1889 // Find the min and max partition sizes used in the left SB64. 1901 // Find the min and max partition sizes used in the left SB64.
1890 if (left_in_image) { 1902 if (left_in_image) {
1891 MODE_INFO *cur_mi; 1903 MODE_INFO *cur_mi;
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
2008 2020
2009 if (!x->in_active_map && (partition_horz_allowed || partition_vert_allowed)) 2021 if (!x->in_active_map && (partition_horz_allowed || partition_vert_allowed))
2010 do_split = 0; 2022 do_split = 0;
2011 // PARTITION_NONE 2023 // PARTITION_NONE
2012 if (partition_none_allowed) { 2024 if (partition_none_allowed) {
2013 rd_pick_sb_modes(cpi, tile, mi_row, mi_col, &this_rate, &this_dist, bsize, 2025 rd_pick_sb_modes(cpi, tile, mi_row, mi_col, &this_rate, &this_dist, bsize,
2014 ctx, best_rd, 0); 2026 ctx, best_rd, 0);
2015 if (this_rate != INT_MAX) { 2027 if (this_rate != INT_MAX) {
2016 if (bsize >= BLOCK_8X8) { 2028 if (bsize >= BLOCK_8X8) {
2017 pl = partition_plane_context(xd, mi_row, mi_col, bsize); 2029 pl = partition_plane_context(xd, mi_row, mi_col, bsize);
2018 this_rate += x->partition_cost[pl][PARTITION_NONE]; 2030 this_rate += cpi->partition_cost[pl][PARTITION_NONE];
2019 } 2031 }
2020 sum_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_dist); 2032 sum_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_dist);
2021 if (sum_rd < best_rd) { 2033 if (sum_rd < best_rd) {
2022 int64_t stop_thresh = 4096; 2034 int64_t stop_thresh = 4096;
2023 int64_t stop_thresh_rd; 2035 int64_t stop_thresh_rd;
2024 2036
2025 best_rate = this_rate; 2037 best_rate = this_rate;
2026 best_dist = this_dist; 2038 best_dist = this_dist;
2027 best_rd = sum_rd; 2039 best_rd = sum_rd;
2028 if (bsize >= BLOCK_8X8) 2040 if (bsize >= BLOCK_8X8)
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
2096 } else { 2108 } else {
2097 sum_rate += this_rate; 2109 sum_rate += this_rate;
2098 sum_dist += this_dist; 2110 sum_dist += this_dist;
2099 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); 2111 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist);
2100 } 2112 }
2101 } 2113 }
2102 } 2114 }
2103 2115
2104 if (sum_rd < best_rd && i == 4) { 2116 if (sum_rd < best_rd && i == 4) {
2105 pl = partition_plane_context(xd, mi_row, mi_col, bsize); 2117 pl = partition_plane_context(xd, mi_row, mi_col, bsize);
2106 sum_rate += x->partition_cost[pl][PARTITION_SPLIT]; 2118 sum_rate += cpi->partition_cost[pl][PARTITION_SPLIT];
2107 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); 2119 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist);
2108 if (sum_rd < best_rd) { 2120 if (sum_rd < best_rd) {
2109 best_rate = sum_rate; 2121 best_rate = sum_rate;
2110 best_dist = sum_dist; 2122 best_dist = sum_dist;
2111 best_rd = sum_rd; 2123 best_rd = sum_rd;
2112 pc_tree->partitioning = PARTITION_SPLIT; 2124 pc_tree->partitioning = PARTITION_SPLIT;
2113 } 2125 }
2114 } else { 2126 } else {
2115 // skip rectangular partition test when larger block size 2127 // skip rectangular partition test when larger block size
2116 // gives better rd cost 2128 // gives better rd cost
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
2150 if (this_rate == INT_MAX) { 2162 if (this_rate == INT_MAX) {
2151 sum_rd = INT64_MAX; 2163 sum_rd = INT64_MAX;
2152 } else { 2164 } else {
2153 sum_rate += this_rate; 2165 sum_rate += this_rate;
2154 sum_dist += this_dist; 2166 sum_dist += this_dist;
2155 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); 2167 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist);
2156 } 2168 }
2157 } 2169 }
2158 if (sum_rd < best_rd) { 2170 if (sum_rd < best_rd) {
2159 pl = partition_plane_context(xd, mi_row, mi_col, bsize); 2171 pl = partition_plane_context(xd, mi_row, mi_col, bsize);
2160 sum_rate += x->partition_cost[pl][PARTITION_HORZ]; 2172 sum_rate += cpi->partition_cost[pl][PARTITION_HORZ];
2161 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); 2173 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist);
2162 if (sum_rd < best_rd) { 2174 if (sum_rd < best_rd) {
2163 best_rd = sum_rd; 2175 best_rd = sum_rd;
2164 best_rate = sum_rate; 2176 best_rate = sum_rate;
2165 best_dist = sum_dist; 2177 best_dist = sum_dist;
2166 pc_tree->partitioning = PARTITION_HORZ; 2178 pc_tree->partitioning = PARTITION_HORZ;
2167 } 2179 }
2168 } 2180 }
2169 restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize); 2181 restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize);
2170 } 2182 }
(...skipping 28 matching lines...) Expand all
2199 if (this_rate == INT_MAX) { 2211 if (this_rate == INT_MAX) {
2200 sum_rd = INT64_MAX; 2212 sum_rd = INT64_MAX;
2201 } else { 2213 } else {
2202 sum_rate += this_rate; 2214 sum_rate += this_rate;
2203 sum_dist += this_dist; 2215 sum_dist += this_dist;
2204 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); 2216 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist);
2205 } 2217 }
2206 } 2218 }
2207 if (sum_rd < best_rd) { 2219 if (sum_rd < best_rd) {
2208 pl = partition_plane_context(xd, mi_row, mi_col, bsize); 2220 pl = partition_plane_context(xd, mi_row, mi_col, bsize);
2209 sum_rate += x->partition_cost[pl][PARTITION_VERT]; 2221 sum_rate += cpi->partition_cost[pl][PARTITION_VERT];
2210 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); 2222 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist);
2211 if (sum_rd < best_rd) { 2223 if (sum_rd < best_rd) {
2212 best_rate = sum_rate; 2224 best_rate = sum_rate;
2213 best_dist = sum_dist; 2225 best_dist = sum_dist;
2214 best_rd = sum_rd; 2226 best_rd = sum_rd;
2215 pc_tree->partitioning = PARTITION_VERT; 2227 pc_tree->partitioning = PARTITION_VERT;
2216 } 2228 }
2217 } 2229 }
2218 restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize); 2230 restore_context(cpi, mi_row, mi_col, a, l, sa, sl, bsize);
2219 } 2231 }
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
2261 vpx_memset(&xd->left_context, 0, sizeof(xd->left_context)); 2273 vpx_memset(&xd->left_context, 0, sizeof(xd->left_context));
2262 vpx_memset(xd->left_seg_context, 0, sizeof(xd->left_seg_context)); 2274 vpx_memset(xd->left_seg_context, 0, sizeof(xd->left_seg_context));
2263 2275
2264 // Code each SB in the row 2276 // Code each SB in the row
2265 for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end; 2277 for (mi_col = tile->mi_col_start; mi_col < tile->mi_col_end;
2266 mi_col += MI_BLOCK_SIZE) { 2278 mi_col += MI_BLOCK_SIZE) {
2267 int dummy_rate; 2279 int dummy_rate;
2268 int64_t dummy_dist; 2280 int64_t dummy_dist;
2269 2281
2270 int i; 2282 int i;
2271 MACROBLOCK *x = &cpi->mb;
2272 2283
2273 if (sf->adaptive_pred_interp_filter) { 2284 if (sf->adaptive_pred_interp_filter) {
2274 for (i = 0; i < 64; ++i) 2285 for (i = 0; i < 64; ++i)
2275 x->leaf_tree[i].pred_interp_filter = SWITCHABLE; 2286 cpi->leaf_tree[i].pred_interp_filter = SWITCHABLE;
2276 2287
2277 for (i = 0; i < 64; ++i) { 2288 for (i = 0; i < 64; ++i) {
2278 x->pc_tree[i].vertical[0].pred_interp_filter = SWITCHABLE; 2289 cpi->pc_tree[i].vertical[0].pred_interp_filter = SWITCHABLE;
2279 x->pc_tree[i].vertical[1].pred_interp_filter = SWITCHABLE; 2290 cpi->pc_tree[i].vertical[1].pred_interp_filter = SWITCHABLE;
2280 x->pc_tree[i].horizontal[0].pred_interp_filter = SWITCHABLE; 2291 cpi->pc_tree[i].horizontal[0].pred_interp_filter = SWITCHABLE;
2281 x->pc_tree[i].horizontal[1].pred_interp_filter = SWITCHABLE; 2292 cpi->pc_tree[i].horizontal[1].pred_interp_filter = SWITCHABLE;
2282 } 2293 }
2283 } 2294 }
2284 2295
2285 vp9_zero(cpi->mb.pred_mv); 2296 vp9_zero(cpi->mb.pred_mv);
2286 2297
2287 if ((sf->partition_search_type == SEARCH_PARTITION && 2298 if ((sf->partition_search_type == SEARCH_PARTITION &&
2288 sf->use_lastframe_partitioning) || 2299 sf->use_lastframe_partitioning) ||
2289 sf->partition_search_type == FIXED_PARTITION || 2300 sf->partition_search_type == FIXED_PARTITION ||
2290 sf->partition_search_type == VAR_BASED_PARTITION || 2301 sf->partition_search_type == VAR_BASED_PARTITION ||
2291 sf->partition_search_type == VAR_BASED_FIXED_PARTITION) { 2302 sf->partition_search_type == VAR_BASED_FIXED_PARTITION) {
2292 const int idx_str = cm->mi_stride * mi_row + mi_col; 2303 const int idx_str = cm->mi_stride * mi_row + mi_col;
2293 MODE_INFO **mi = cm->mi_grid_visible + idx_str; 2304 MODE_INFO **mi = cm->mi_grid_visible + idx_str;
2294 MODE_INFO **prev_mi = cm->prev_mi_grid_visible + idx_str; 2305 MODE_INFO **prev_mi = cm->prev_mi_grid_visible + idx_str;
2295 cpi->mb.source_variance = UINT_MAX; 2306 cpi->mb.source_variance = UINT_MAX;
2296 if (sf->partition_search_type == FIXED_PARTITION) { 2307 if (sf->partition_search_type == FIXED_PARTITION) {
2297 set_offsets(cpi, tile, mi_row, mi_col, BLOCK_64X64); 2308 set_offsets(cpi, tile, mi_row, mi_col, BLOCK_64X64);
2298 set_fixed_partitioning(cpi, tile, mi, mi_row, mi_col, 2309 set_fixed_partitioning(cpi, tile, mi, mi_row, mi_col,
2299 sf->always_this_block_size); 2310 sf->always_this_block_size);
2300 rd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64, 2311 rd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64,
2301 &dummy_rate, &dummy_dist, 1, x->pc_root); 2312 &dummy_rate, &dummy_dist, 1, cpi->pc_root);
2302 } else if (sf->partition_search_type == VAR_BASED_FIXED_PARTITION) { 2313 } else if (sf->partition_search_type == VAR_BASED_FIXED_PARTITION) {
2303 BLOCK_SIZE bsize; 2314 BLOCK_SIZE bsize;
2304 set_offsets(cpi, tile, mi_row, mi_col, BLOCK_64X64); 2315 set_offsets(cpi, tile, mi_row, mi_col, BLOCK_64X64);
2305 bsize = get_rd_var_based_fixed_partition(cpi, mi_row, mi_col); 2316 bsize = get_rd_var_based_fixed_partition(cpi, mi_row, mi_col);
2306 set_fixed_partitioning(cpi, tile, mi, mi_row, mi_col, bsize); 2317 set_fixed_partitioning(cpi, tile, mi, mi_row, mi_col, bsize);
2307 rd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64, 2318 rd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64,
2308 &dummy_rate, &dummy_dist, 1, x->pc_root); 2319 &dummy_rate, &dummy_dist, 1, cpi->pc_root);
2309 } else if (sf->partition_search_type == VAR_BASED_PARTITION) { 2320 } else if (sf->partition_search_type == VAR_BASED_PARTITION) {
2310 choose_partitioning(cpi, tile, mi_row, mi_col); 2321 choose_partitioning(cpi, tile, mi_row, mi_col);
2311 rd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64, 2322 rd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64,
2312 &dummy_rate, &dummy_dist, 1, x->pc_root); 2323 &dummy_rate, &dummy_dist, 1, cpi->pc_root);
2313 } else { 2324 } else {
2314 if ((cm->current_video_frame 2325 if ((cm->current_video_frame
2315 % sf->last_partitioning_redo_frequency) == 0 2326 % sf->last_partitioning_redo_frequency) == 0
2316 || cm->prev_mi == 0 2327 || cm->prev_mi == 0
2317 || cm->show_frame == 0 2328 || cm->show_frame == 0
2318 || cm->frame_type == KEY_FRAME 2329 || cm->frame_type == KEY_FRAME
2319 || cpi->rc.is_src_frame_alt_ref 2330 || cpi->rc.is_src_frame_alt_ref
2320 || ((sf->use_lastframe_partitioning == 2331 || ((sf->use_lastframe_partitioning ==
2321 LAST_FRAME_PARTITION_LOW_MOTION) && 2332 LAST_FRAME_PARTITION_LOW_MOTION) &&
2322 sb_has_motion(cm, prev_mi))) { 2333 sb_has_motion(cm, prev_mi, sf->lf_motion_threshold))) {
2323 // If required set upper and lower partition size limits 2334 // If required set upper and lower partition size limits
2324 if (sf->auto_min_max_partition_size) { 2335 if (sf->auto_min_max_partition_size) {
2325 set_offsets(cpi, tile, mi_row, mi_col, BLOCK_64X64); 2336 set_offsets(cpi, tile, mi_row, mi_col, BLOCK_64X64);
2326 rd_auto_partition_range(cpi, tile, mi_row, mi_col, 2337 rd_auto_partition_range(cpi, tile, mi_row, mi_col,
2327 &sf->min_partition_size, 2338 &sf->min_partition_size,
2328 &sf->max_partition_size); 2339 &sf->max_partition_size);
2329 } 2340 }
2330 rd_pick_partition(cpi, tile, tp, mi_row, mi_col, BLOCK_64X64, 2341 rd_pick_partition(cpi, tile, tp, mi_row, mi_col, BLOCK_64X64,
2331 &dummy_rate, &dummy_dist, 1, INT64_MAX, x->pc_root); 2342 &dummy_rate, &dummy_dist, 1, INT64_MAX,
2343 cpi->pc_root);
2332 } else { 2344 } else {
2333 if (sf->constrain_copy_partition && 2345 if (sf->constrain_copy_partition &&
2334 sb_has_motion(cm, prev_mi)) 2346 sb_has_motion(cm, prev_mi, sf->lf_motion_threshold))
2335 constrain_copy_partitioning(cpi, tile, mi, prev_mi, 2347 constrain_copy_partitioning(cpi, tile, mi, prev_mi,
2336 mi_row, mi_col, BLOCK_16X16); 2348 mi_row, mi_col, BLOCK_16X16);
2337 else 2349 else
2338 copy_partitioning(cm, mi, prev_mi); 2350 copy_partitioning(cm, mi, prev_mi);
2339 rd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64, 2351 rd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64,
2340 &dummy_rate, &dummy_dist, 1, x->pc_root); 2352 &dummy_rate, &dummy_dist, 1, cpi->pc_root);
2341 } 2353 }
2342 } 2354 }
2343 } else { 2355 } else {
2344 // If required set upper and lower partition size limits 2356 // If required set upper and lower partition size limits
2345 if (sf->auto_min_max_partition_size) { 2357 if (sf->auto_min_max_partition_size) {
2346 set_offsets(cpi, tile, mi_row, mi_col, BLOCK_64X64); 2358 set_offsets(cpi, tile, mi_row, mi_col, BLOCK_64X64);
2347 rd_auto_partition_range(cpi, tile, mi_row, mi_col, 2359 rd_auto_partition_range(cpi, tile, mi_row, mi_col,
2348 &sf->min_partition_size, 2360 &sf->min_partition_size,
2349 &sf->max_partition_size); 2361 &sf->max_partition_size);
2350 } 2362 }
2351 rd_pick_partition(cpi, tile, tp, mi_row, mi_col, BLOCK_64X64, 2363 rd_pick_partition(cpi, tile, tp, mi_row, mi_col, BLOCK_64X64,
2352 &dummy_rate, &dummy_dist, 1, INT64_MAX, x->pc_root); 2364 &dummy_rate, &dummy_dist, 1, INT64_MAX, cpi->pc_root);
2353 } 2365 }
2354 } 2366 }
2355 } 2367 }
2356 2368
2357 static void init_encode_frame_mb_context(VP9_COMP *cpi) { 2369 static void init_encode_frame_mb_context(VP9_COMP *cpi) {
2358 MACROBLOCK *const x = &cpi->mb; 2370 MACROBLOCK *const x = &cpi->mb;
2359 VP9_COMMON *const cm = &cpi->common; 2371 VP9_COMMON *const cm = &cpi->common;
2360 MACROBLOCKD *const xd = &x->e_mbd; 2372 MACROBLOCKD *const xd = &x->e_mbd;
2361 const int aligned_mi_cols = mi_cols_aligned_to_sb(cm->mi_cols); 2373 const int aligned_mi_cols = mi_cols_aligned_to_sb(cm->mi_cols);
2362 2374
2363 // Copy data over into macro block data structures. 2375 // Copy data over into macro block data structures.
2364 vp9_setup_src_planes(x, cpi->Source, 0, 0); 2376 vp9_setup_src_planes(x, cpi->Source, 0, 0);
2365 2377
2366 vp9_setup_block_planes(&x->e_mbd, cm->subsampling_x, cm->subsampling_y); 2378 vp9_setup_block_planes(&x->e_mbd, cm->subsampling_x, cm->subsampling_y);
2367 2379
2368 // Note: this memset assumes above_context[0], [1] and [2] 2380 // Note: this memset assumes above_context[0], [1] and [2]
2369 // are allocated as part of the same buffer. 2381 // are allocated as part of the same buffer.
2370 vpx_memset(xd->above_context[0], 0, 2382 vpx_memset(xd->above_context[0], 0,
2371 sizeof(*xd->above_context[0]) * 2383 sizeof(*xd->above_context[0]) *
2372 2 * aligned_mi_cols * MAX_MB_PLANE); 2384 2 * aligned_mi_cols * MAX_MB_PLANE);
2373 vpx_memset(xd->above_seg_context, 0, 2385 vpx_memset(xd->above_seg_context, 0,
2374 sizeof(*xd->above_seg_context) * aligned_mi_cols); 2386 sizeof(*xd->above_seg_context) * aligned_mi_cols);
2375 } 2387 }
2376 2388
2377 static void switch_lossless_mode(VP9_COMP *cpi, int lossless) {
2378 if (lossless) {
2379 // printf("Switching to lossless\n");
2380 cpi->mb.fwd_txm4x4 = vp9_fwht4x4;
2381 cpi->mb.e_mbd.itxm_add = vp9_iwht4x4_add;
2382 cpi->mb.optimize = 0;
2383 cpi->common.lf.filter_level = 0;
2384 cpi->zbin_mode_boost_enabled = 0;
2385 cpi->common.tx_mode = ONLY_4X4;
2386 } else {
2387 // printf("Not lossless\n");
2388 cpi->mb.fwd_txm4x4 = vp9_fdct4x4;
2389 cpi->mb.e_mbd.itxm_add = vp9_idct4x4_add;
2390 }
2391 }
2392
2393 static int check_dual_ref_flags(VP9_COMP *cpi) { 2389 static int check_dual_ref_flags(VP9_COMP *cpi) {
2394 const int ref_flags = cpi->ref_frame_flags; 2390 const int ref_flags = cpi->ref_frame_flags;
2395 2391
2396 if (vp9_segfeature_active(&cpi->common.seg, 1, SEG_LVL_REF_FRAME)) { 2392 if (vp9_segfeature_active(&cpi->common.seg, 1, SEG_LVL_REF_FRAME)) {
2397 return 0; 2393 return 0;
2398 } else { 2394 } else {
2399 return (!!(ref_flags & VP9_GOLD_FLAG) + !!(ref_flags & VP9_LAST_FLAG) 2395 return (!!(ref_flags & VP9_GOLD_FLAG) + !!(ref_flags & VP9_LAST_FLAG)
2400 + !!(ref_flags & VP9_ALT_FLAG)) >= 2; 2396 + !!(ref_flags & VP9_ALT_FLAG)) >= 2;
2401 } 2397 }
2402 } 2398 }
2403 2399
2404 static void reset_skip_txfm_size(VP9_COMMON *cm, TX_SIZE txfm_max) { 2400 static void reset_skip_tx_size(VP9_COMMON *cm, TX_SIZE max_tx_size) {
2405 int mi_row, mi_col; 2401 int mi_row, mi_col;
2406 const int mis = cm->mi_stride; 2402 const int mis = cm->mi_stride;
2407 MODE_INFO **mi_ptr = cm->mi_grid_visible; 2403 MODE_INFO **mi_ptr = cm->mi_grid_visible;
2408 2404
2409 for (mi_row = 0; mi_row < cm->mi_rows; ++mi_row, mi_ptr += mis) { 2405 for (mi_row = 0; mi_row < cm->mi_rows; ++mi_row, mi_ptr += mis) {
2410 for (mi_col = 0; mi_col < cm->mi_cols; ++mi_col) { 2406 for (mi_col = 0; mi_col < cm->mi_cols; ++mi_col) {
2411 if (mi_ptr[mi_col]->mbmi.tx_size > txfm_max) 2407 if (mi_ptr[mi_col]->mbmi.tx_size > max_tx_size)
2412 mi_ptr[mi_col]->mbmi.tx_size = txfm_max; 2408 mi_ptr[mi_col]->mbmi.tx_size = max_tx_size;
2413 } 2409 }
2414 } 2410 }
2415 } 2411 }
2416 2412
2417 static MV_REFERENCE_FRAME get_frame_type(const VP9_COMP *cpi) { 2413 static MV_REFERENCE_FRAME get_frame_type(const VP9_COMP *cpi) {
2418 if (frame_is_intra_only(&cpi->common)) 2414 if (frame_is_intra_only(&cpi->common))
2419 return INTRA_FRAME; 2415 return INTRA_FRAME;
2420 else if (cpi->rc.is_src_frame_alt_ref && cpi->refresh_golden_frame) 2416 else if (cpi->rc.is_src_frame_alt_ref && cpi->refresh_golden_frame)
2421 return ALTREF_FRAME; 2417 return ALTREF_FRAME;
2422 else if (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame) 2418 else if (cpi->refresh_golden_frame || cpi->refresh_alt_ref_frame)
2423 return LAST_FRAME; 2419 return LAST_FRAME;
2424 else 2420 else
2425 return GOLDEN_FRAME; 2421 return GOLDEN_FRAME;
2426 } 2422 }
2427 2423
2428 static TX_MODE select_tx_mode(const VP9_COMP *cpi) { 2424 static TX_MODE select_tx_mode(const VP9_COMP *cpi) {
2429 if (cpi->oxcf.lossless) { 2425 if (cpi->mb.e_mbd.lossless) {
2430 return ONLY_4X4; 2426 return ONLY_4X4;
2431 } else if (cpi->common.current_video_frame == 0) { 2427 } else if (cpi->common.current_video_frame == 0) {
2432 return TX_MODE_SELECT; 2428 return TX_MODE_SELECT;
2433 } else { 2429 } else {
2434 if (cpi->sf.tx_size_search_method == USE_LARGESTALL) { 2430 if (cpi->sf.tx_size_search_method == USE_LARGESTALL) {
2435 return ALLOW_32X32; 2431 return ALLOW_32X32;
2436 } else if (cpi->sf.tx_size_search_method == USE_FULL_RD) { 2432 } else if (cpi->sf.tx_size_search_method == USE_FULL_RD) {
2437 const RD_OPT *const rd_opt = &cpi->rd; 2433 const RD_OPT *const rd_opt = &cpi->rd;
2438 const MV_REFERENCE_FRAME frame_type = get_frame_type(cpi); 2434 const MV_REFERENCE_FRAME frame_type = get_frame_type(cpi);
2439 return rd_opt->tx_select_threshes[frame_type][ALLOW_32X32] > 2435 return rd_opt->tx_select_threshes[frame_type][ALLOW_32X32] >
2440 rd_opt->tx_select_threshes[frame_type][TX_MODE_SELECT] ? 2436 rd_opt->tx_select_threshes[frame_type][TX_MODE_SELECT] ?
2441 ALLOW_32X32 : TX_MODE_SELECT; 2437 ALLOW_32X32 : TX_MODE_SELECT;
2438 } else if (cpi->sf.tx_size_search_method == USE_TX_8X8) {
2439 return ALLOW_8X8;
2442 } else { 2440 } else {
2443 unsigned int total = 0; 2441 unsigned int total = 0;
2444 int i; 2442 int i;
2445 for (i = 0; i < TX_SIZES; ++i) 2443 for (i = 0; i < TX_SIZES; ++i)
2446 total += cpi->tx_stepdown_count[i]; 2444 total += cpi->tx_stepdown_count[i];
2447 2445
2448 if (total) { 2446 if (total) {
2449 const double fraction = (double)cpi->tx_stepdown_count[0] / total; 2447 const double fraction = (double)cpi->tx_stepdown_count[0] / total;
2450 return fraction > 0.90 ? ALLOW_32X32 : TX_MODE_SELECT; 2448 return fraction > 0.90 ? ALLOW_32X32 : TX_MODE_SELECT;
2451 } else { 2449 } else {
2452 return cpi->common.tx_mode; 2450 return cpi->common.tx_mode;
2453 } 2451 }
2454 } 2452 }
2455 } 2453 }
2456 } 2454 }
2457 2455
2458 // Start RTC Exploration
2459 typedef enum {
2460 BOTH_ZERO = 0,
2461 ZERO_PLUS_PREDICTED = 1,
2462 BOTH_PREDICTED = 2,
2463 NEW_PLUS_NON_INTRA = 3,
2464 BOTH_NEW = 4,
2465 INTRA_PLUS_NON_INTRA = 5,
2466 BOTH_INTRA = 6,
2467 INVALID_CASE = 9
2468 } motion_vector_context;
2469
2470 static void set_mode_info(MB_MODE_INFO *mbmi, BLOCK_SIZE bsize, 2456 static void set_mode_info(MB_MODE_INFO *mbmi, BLOCK_SIZE bsize,
2471 PREDICTION_MODE mode) { 2457 PREDICTION_MODE mode) {
2472 mbmi->mode = mode; 2458 mbmi->mode = mode;
2473 mbmi->uv_mode = mode; 2459 mbmi->uv_mode = mode;
2474 mbmi->mv[0].as_int = 0; 2460 mbmi->mv[0].as_int = 0;
2475 mbmi->mv[1].as_int = 0; 2461 mbmi->mv[1].as_int = 0;
2476 mbmi->ref_frame[0] = INTRA_FRAME; 2462 mbmi->ref_frame[0] = INTRA_FRAME;
2477 mbmi->ref_frame[1] = NONE; 2463 mbmi->ref_frame[1] = NONE;
2478 mbmi->tx_size = max_txsize_lookup[bsize]; 2464 mbmi->tx_size = max_txsize_lookup[bsize];
2479 mbmi->skip = 0; 2465 mbmi->skip = 0;
2480 mbmi->sb_type = bsize; 2466 mbmi->sb_type = bsize;
2481 mbmi->segment_id = 0; 2467 mbmi->segment_id = 0;
2482 } 2468 }
2483 2469
2484 static void nonrd_pick_sb_modes(VP9_COMP *cpi, const TileInfo *const tile, 2470 static void nonrd_pick_sb_modes(VP9_COMP *cpi, const TileInfo *const tile,
2485 int mi_row, int mi_col, 2471 int mi_row, int mi_col,
2486 int *rate, int64_t *dist, 2472 int *rate, int64_t *dist,
2487 BLOCK_SIZE bsize) { 2473 BLOCK_SIZE bsize) {
2488 VP9_COMMON *const cm = &cpi->common; 2474 VP9_COMMON *const cm = &cpi->common;
2489 MACROBLOCK *const x = &cpi->mb; 2475 MACROBLOCK *const x = &cpi->mb;
2490 MACROBLOCKD *const xd = &x->e_mbd; 2476 MACROBLOCKD *const xd = &x->e_mbd;
2477 MB_MODE_INFO *mbmi;
2491 set_offsets(cpi, tile, mi_row, mi_col, bsize); 2478 set_offsets(cpi, tile, mi_row, mi_col, bsize);
2492 xd->mi[0]->mbmi.sb_type = bsize; 2479 mbmi = &xd->mi[0]->mbmi;
2480 mbmi->sb_type = bsize;
2493 2481
2494 if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cm->seg.enabled) { 2482 if (cpi->oxcf.aq_mode == CYCLIC_REFRESH_AQ && cm->seg.enabled) {
2495 if (xd->mi[0]->mbmi.segment_id && x->in_static_area) 2483 if (mbmi->segment_id && x->in_static_area)
2496 x->rdmult = vp9_cyclic_refresh_get_rdmult(cpi->cyclic_refresh); 2484 x->rdmult = vp9_cyclic_refresh_get_rdmult(cpi->cyclic_refresh);
2497 } 2485 }
2498 2486
2499 if (!frame_is_intra_only(cm)) { 2487 if (!frame_is_intra_only(cm)) {
2500 vp9_pick_inter_mode(cpi, x, tile, mi_row, mi_col, 2488 if (vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP))
2501 rate, dist, bsize); 2489 set_mode_info_seg_skip(x, cm->tx_mode, rate, dist, bsize);
2490 else
2491 vp9_pick_inter_mode(cpi, x, tile, mi_row, mi_col, rate, dist, bsize);
2502 } else { 2492 } else {
2503 set_mode_info(&xd->mi[0]->mbmi, bsize, DC_PRED); 2493 set_mode_info(&xd->mi[0]->mbmi, bsize, DC_PRED);
2504 } 2494 }
2505 duplicate_mode_info_in_sb(cm, xd, mi_row, mi_col, bsize); 2495 duplicate_mode_info_in_sb(cm, xd, mi_row, mi_col, bsize);
2506 } 2496 }
2507 2497
2508 static void fill_mode_info_sb(VP9_COMMON *cm, MACROBLOCK *x, 2498 static void fill_mode_info_sb(VP9_COMMON *cm, MACROBLOCK *x,
2509 int mi_row, int mi_col, 2499 int mi_row, int mi_col,
2510 BLOCK_SIZE bsize, BLOCK_SIZE subsize, 2500 BLOCK_SIZE bsize, BLOCK_SIZE subsize,
2511 PC_TREE *pc_tree) { 2501 PC_TREE *pc_tree) {
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
2617 } 2607 }
2618 2608
2619 if (!x->in_active_map && (partition_horz_allowed || partition_vert_allowed)) 2609 if (!x->in_active_map && (partition_horz_allowed || partition_vert_allowed))
2620 do_split = 0; 2610 do_split = 0;
2621 2611
2622 // PARTITION_NONE 2612 // PARTITION_NONE
2623 if (partition_none_allowed) { 2613 if (partition_none_allowed) {
2624 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, 2614 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col,
2625 &this_rate, &this_dist, bsize); 2615 &this_rate, &this_dist, bsize);
2626 ctx->mic.mbmi = xd->mi[0]->mbmi; 2616 ctx->mic.mbmi = xd->mi[0]->mbmi;
2617 ctx->skip_txfm = x->skip_txfm;
2627 2618
2628 if (this_rate != INT_MAX) { 2619 if (this_rate != INT_MAX) {
2629 int pl = partition_plane_context(xd, mi_row, mi_col, bsize); 2620 int pl = partition_plane_context(xd, mi_row, mi_col, bsize);
2630 this_rate += x->partition_cost[pl][PARTITION_NONE]; 2621 this_rate += cpi->partition_cost[pl][PARTITION_NONE];
2631 sum_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_dist); 2622 sum_rd = RDCOST(x->rdmult, x->rddiv, this_rate, this_dist);
2632 if (sum_rd < best_rd) { 2623 if (sum_rd < best_rd) {
2633 int64_t stop_thresh = 4096; 2624 int64_t stop_thresh = 4096;
2634 int64_t stop_thresh_rd; 2625 int64_t stop_thresh_rd;
2635 2626
2636 best_rate = this_rate; 2627 best_rate = this_rate;
2637 best_dist = this_dist; 2628 best_dist = this_dist;
2638 best_rd = sum_rd; 2629 best_rd = sum_rd;
2639 if (bsize >= BLOCK_8X8) 2630 if (bsize >= BLOCK_8X8)
2640 pc_tree->partitioning = PARTITION_NONE; 2631 pc_tree->partitioning = PARTITION_NONE;
(...skipping 17 matching lines...) Expand all
2658 } 2649 }
2659 } 2650 }
2660 2651
2661 // store estimated motion vector 2652 // store estimated motion vector
2662 store_pred_mv(x, ctx); 2653 store_pred_mv(x, ctx);
2663 2654
2664 // PARTITION_SPLIT 2655 // PARTITION_SPLIT
2665 sum_rd = 0; 2656 sum_rd = 0;
2666 if (do_split) { 2657 if (do_split) {
2667 int pl = partition_plane_context(xd, mi_row, mi_col, bsize); 2658 int pl = partition_plane_context(xd, mi_row, mi_col, bsize);
2668 sum_rate += x->partition_cost[pl][PARTITION_SPLIT]; 2659 sum_rate += cpi->partition_cost[pl][PARTITION_SPLIT];
2669 subsize = get_subsize(bsize, PARTITION_SPLIT); 2660 subsize = get_subsize(bsize, PARTITION_SPLIT);
2670 for (i = 0; i < 4 && sum_rd < best_rd; ++i) { 2661 for (i = 0; i < 4 && sum_rd < best_rd; ++i) {
2671 const int x_idx = (i & 1) * ms; 2662 const int x_idx = (i & 1) * ms;
2672 const int y_idx = (i >> 1) * ms; 2663 const int y_idx = (i >> 1) * ms;
2673 2664
2674 if (mi_row + y_idx >= cm->mi_rows || mi_col + x_idx >= cm->mi_cols) 2665 if (mi_row + y_idx >= cm->mi_rows || mi_col + x_idx >= cm->mi_cols)
2675 continue; 2666 continue;
2676 load_pred_mv(x, ctx); 2667 load_pred_mv(x, ctx);
2677 nonrd_pick_partition(cpi, tile, tp, mi_row + y_idx, mi_col + x_idx, 2668 nonrd_pick_partition(cpi, tile, tp, mi_row + y_idx, mi_col + x_idx,
2678 subsize, &this_rate, &this_dist, 0, 2669 subsize, &this_rate, &this_dist, 0,
(...skipping 24 matching lines...) Expand all
2703 // PARTITION_HORZ 2694 // PARTITION_HORZ
2704 if (partition_horz_allowed && do_rect) { 2695 if (partition_horz_allowed && do_rect) {
2705 subsize = get_subsize(bsize, PARTITION_HORZ); 2696 subsize = get_subsize(bsize, PARTITION_HORZ);
2706 if (cpi->sf.adaptive_motion_search) 2697 if (cpi->sf.adaptive_motion_search)
2707 load_pred_mv(x, ctx); 2698 load_pred_mv(x, ctx);
2708 2699
2709 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, 2700 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col,
2710 &this_rate, &this_dist, subsize); 2701 &this_rate, &this_dist, subsize);
2711 2702
2712 pc_tree->horizontal[0].mic.mbmi = xd->mi[0]->mbmi; 2703 pc_tree->horizontal[0].mic.mbmi = xd->mi[0]->mbmi;
2704 pc_tree->horizontal[0].skip_txfm = x->skip_txfm;
2713 2705
2714 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); 2706 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist);
2715 2707
2716 if (sum_rd < best_rd && mi_row + ms < cm->mi_rows) { 2708 if (sum_rd < best_rd && mi_row + ms < cm->mi_rows) {
2717 load_pred_mv(x, ctx); 2709 load_pred_mv(x, ctx);
2718 nonrd_pick_sb_modes(cpi, tile, mi_row + ms, mi_col, 2710 nonrd_pick_sb_modes(cpi, tile, mi_row + ms, mi_col,
2719 &this_rate, &this_dist, subsize); 2711 &this_rate, &this_dist, subsize);
2720 2712
2721 pc_tree->horizontal[1].mic.mbmi = xd->mi[0]->mbmi; 2713 pc_tree->horizontal[1].mic.mbmi = xd->mi[0]->mbmi;
2714 pc_tree->horizontal[1].skip_txfm = x->skip_txfm;
2722 2715
2723 if (this_rate == INT_MAX) { 2716 if (this_rate == INT_MAX) {
2724 sum_rd = INT64_MAX; 2717 sum_rd = INT64_MAX;
2725 } else { 2718 } else {
2726 int pl = partition_plane_context(xd, mi_row, mi_col, bsize); 2719 int pl = partition_plane_context(xd, mi_row, mi_col, bsize);
2727 this_rate += x->partition_cost[pl][PARTITION_HORZ]; 2720 this_rate += cpi->partition_cost[pl][PARTITION_HORZ];
2728 sum_rate += this_rate; 2721 sum_rate += this_rate;
2729 sum_dist += this_dist; 2722 sum_dist += this_dist;
2730 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); 2723 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist);
2731 } 2724 }
2732 } 2725 }
2733 if (sum_rd < best_rd) { 2726 if (sum_rd < best_rd) {
2734 best_rd = sum_rd; 2727 best_rd = sum_rd;
2735 best_rate = sum_rate; 2728 best_rate = sum_rate;
2736 best_dist = sum_dist; 2729 best_dist = sum_dist;
2737 pc_tree->partitioning = PARTITION_HORZ; 2730 pc_tree->partitioning = PARTITION_HORZ;
2738 } 2731 }
2739 } 2732 }
2740 2733
2741 // PARTITION_VERT 2734 // PARTITION_VERT
2742 if (partition_vert_allowed && do_rect) { 2735 if (partition_vert_allowed && do_rect) {
2743 subsize = get_subsize(bsize, PARTITION_VERT); 2736 subsize = get_subsize(bsize, PARTITION_VERT);
2744 2737
2745 if (cpi->sf.adaptive_motion_search) 2738 if (cpi->sf.adaptive_motion_search)
2746 load_pred_mv(x, ctx); 2739 load_pred_mv(x, ctx);
2747 2740
2748 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, 2741 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col,
2749 &this_rate, &this_dist, subsize); 2742 &this_rate, &this_dist, subsize);
2750 pc_tree->vertical[0].mic.mbmi = xd->mi[0]->mbmi; 2743 pc_tree->vertical[0].mic.mbmi = xd->mi[0]->mbmi;
2744 pc_tree->vertical[0].skip_txfm = x->skip_txfm;
2751 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); 2745 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist);
2752 if (sum_rd < best_rd && mi_col + ms < cm->mi_cols) { 2746 if (sum_rd < best_rd && mi_col + ms < cm->mi_cols) {
2753 load_pred_mv(x, ctx); 2747 load_pred_mv(x, ctx);
2754 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col + ms, 2748 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col + ms,
2755 &this_rate, &this_dist, subsize); 2749 &this_rate, &this_dist, subsize);
2756 pc_tree->vertical[1].mic.mbmi = xd->mi[0]->mbmi; 2750 pc_tree->vertical[1].mic.mbmi = xd->mi[0]->mbmi;
2751 pc_tree->vertical[1].skip_txfm = x->skip_txfm;
2757 if (this_rate == INT_MAX) { 2752 if (this_rate == INT_MAX) {
2758 sum_rd = INT64_MAX; 2753 sum_rd = INT64_MAX;
2759 } else { 2754 } else {
2760 int pl = partition_plane_context(xd, mi_row, mi_col, bsize); 2755 int pl = partition_plane_context(xd, mi_row, mi_col, bsize);
2761 this_rate += x->partition_cost[pl][PARTITION_VERT]; 2756 this_rate += cpi->partition_cost[pl][PARTITION_VERT];
2762 sum_rate += this_rate; 2757 sum_rate += this_rate;
2763 sum_dist += this_dist; 2758 sum_dist += this_dist;
2764 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist); 2759 sum_rd = RDCOST(x->rdmult, x->rddiv, sum_rate, sum_dist);
2765 } 2760 }
2766 } 2761 }
2767 if (sum_rd < best_rd) { 2762 if (sum_rd < best_rd) {
2768 best_rate = sum_rate; 2763 best_rate = sum_rate;
2769 best_dist = sum_dist; 2764 best_dist = sum_dist;
2770 best_rd = sum_rd; 2765 best_rd = sum_rd;
2771 pc_tree->partitioning = PARTITION_VERT; 2766 pc_tree->partitioning = PARTITION_VERT;
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
2835 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols) 2830 if (mi_row >= cm->mi_rows || mi_col >= cm->mi_cols)
2836 return; 2831 return;
2837 2832
2838 subsize = (bsize >= BLOCK_8X8) ? mi[0]->mbmi.sb_type : BLOCK_4X4; 2833 subsize = (bsize >= BLOCK_8X8) ? mi[0]->mbmi.sb_type : BLOCK_4X4;
2839 partition = partition_lookup[bsl][subsize]; 2834 partition = partition_lookup[bsl][subsize];
2840 2835
2841 switch (partition) { 2836 switch (partition) {
2842 case PARTITION_NONE: 2837 case PARTITION_NONE:
2843 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, totrate, totdist, subsize); 2838 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, totrate, totdist, subsize);
2844 pc_tree->none.mic.mbmi = xd->mi[0]->mbmi; 2839 pc_tree->none.mic.mbmi = xd->mi[0]->mbmi;
2840 pc_tree->none.skip_txfm = x->skip_txfm;
2845 break; 2841 break;
2846 case PARTITION_VERT: 2842 case PARTITION_VERT:
2847 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, totrate, totdist, subsize); 2843 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, totrate, totdist, subsize);
2848 pc_tree->vertical[0].mic.mbmi = xd->mi[0]->mbmi; 2844 pc_tree->vertical[0].mic.mbmi = xd->mi[0]->mbmi;
2845 pc_tree->vertical[0].skip_txfm = x->skip_txfm;
2849 if (mi_col + hbs < cm->mi_cols) { 2846 if (mi_col + hbs < cm->mi_cols) {
2850 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col + hbs, 2847 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col + hbs,
2851 &rate, &dist, subsize); 2848 &rate, &dist, subsize);
2852 pc_tree->vertical[1].mic.mbmi = xd->mi[0]->mbmi; 2849 pc_tree->vertical[1].mic.mbmi = xd->mi[0]->mbmi;
2850 pc_tree->vertical[1].skip_txfm = x->skip_txfm;
2853 if (rate != INT_MAX && dist != INT64_MAX && 2851 if (rate != INT_MAX && dist != INT64_MAX &&
2854 *totrate != INT_MAX && *totdist != INT64_MAX) { 2852 *totrate != INT_MAX && *totdist != INT64_MAX) {
2855 *totrate += rate; 2853 *totrate += rate;
2856 *totdist += dist; 2854 *totdist += dist;
2857 } 2855 }
2858 } 2856 }
2859 break; 2857 break;
2860 case PARTITION_HORZ: 2858 case PARTITION_HORZ:
2861 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, totrate, totdist, subsize); 2859 nonrd_pick_sb_modes(cpi, tile, mi_row, mi_col, totrate, totdist, subsize);
2862 pc_tree->horizontal[0].mic.mbmi = xd->mi[0]->mbmi; 2860 pc_tree->horizontal[0].mic.mbmi = xd->mi[0]->mbmi;
2861 pc_tree->horizontal[0].skip_txfm = x->skip_txfm;
2863 if (mi_row + hbs < cm->mi_rows) { 2862 if (mi_row + hbs < cm->mi_rows) {
2864 nonrd_pick_sb_modes(cpi, tile, mi_row + hbs, mi_col, 2863 nonrd_pick_sb_modes(cpi, tile, mi_row + hbs, mi_col,
2865 &rate, &dist, subsize); 2864 &rate, &dist, subsize);
2866 pc_tree->horizontal[1].mic.mbmi = mi[0]->mbmi; 2865 pc_tree->horizontal[1].mic.mbmi = xd->mi[0]->mbmi;
2866 pc_tree->horizontal[1].skip_txfm = x->skip_txfm;
2867 if (rate != INT_MAX && dist != INT64_MAX && 2867 if (rate != INT_MAX && dist != INT64_MAX &&
2868 *totrate != INT_MAX && *totdist != INT64_MAX) { 2868 *totrate != INT_MAX && *totdist != INT64_MAX) {
2869 *totrate += rate; 2869 *totrate += rate;
2870 *totdist += dist; 2870 *totdist += dist;
2871 } 2871 }
2872 } 2872 }
2873 break; 2873 break;
2874 case PARTITION_SPLIT: 2874 case PARTITION_SPLIT:
2875 subsize = get_subsize(bsize, PARTITION_SPLIT); 2875 subsize = get_subsize(bsize, PARTITION_SPLIT);
2876 nonrd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, 2876 nonrd_use_partition(cpi, tile, mi, tp, mi_row, mi_col,
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
2937 2937
2938 x->in_static_area = 0; 2938 x->in_static_area = 0;
2939 x->source_variance = UINT_MAX; 2939 x->source_variance = UINT_MAX;
2940 vp9_zero(x->pred_mv); 2940 vp9_zero(x->pred_mv);
2941 2941
2942 // Set the partition type of the 64X64 block 2942 // Set the partition type of the 64X64 block
2943 switch (cpi->sf.partition_search_type) { 2943 switch (cpi->sf.partition_search_type) {
2944 case VAR_BASED_PARTITION: 2944 case VAR_BASED_PARTITION:
2945 choose_partitioning(cpi, tile, mi_row, mi_col); 2945 choose_partitioning(cpi, tile, mi_row, mi_col);
2946 nonrd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64, 2946 nonrd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64,
2947 1, &dummy_rate, &dummy_dist, x->pc_root); 2947 1, &dummy_rate, &dummy_dist, cpi->pc_root);
2948 break; 2948 break;
2949 case SOURCE_VAR_BASED_PARTITION: 2949 case SOURCE_VAR_BASED_PARTITION:
2950 set_source_var_based_partition(cpi, tile, mi, mi_row, mi_col); 2950 set_source_var_based_partition(cpi, tile, mi, mi_row, mi_col);
2951 nonrd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64, 2951 nonrd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64,
2952 1, &dummy_rate, &dummy_dist, x->pc_root); 2952 1, &dummy_rate, &dummy_dist, cpi->pc_root);
2953 break; 2953 break;
2954 case VAR_BASED_FIXED_PARTITION: 2954 case VAR_BASED_FIXED_PARTITION:
2955 case FIXED_PARTITION: 2955 case FIXED_PARTITION:
2956 bsize = cpi->sf.partition_search_type == FIXED_PARTITION ? 2956 bsize = cpi->sf.partition_search_type == FIXED_PARTITION ?
2957 cpi->sf.always_this_block_size : 2957 cpi->sf.always_this_block_size :
2958 get_nonrd_var_based_fixed_partition(cpi, mi_row, mi_col); 2958 get_nonrd_var_based_fixed_partition(cpi, mi_row, mi_col);
2959 set_fixed_partitioning(cpi, tile, mi, mi_row, mi_col, bsize); 2959 set_fixed_partitioning(cpi, tile, mi, mi_row, mi_col, bsize);
2960 nonrd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64, 2960 nonrd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, BLOCK_64X64,
2961 1, &dummy_rate, &dummy_dist, x->pc_root); 2961 1, &dummy_rate, &dummy_dist, cpi->pc_root);
2962 break; 2962 break;
2963 case REFERENCE_PARTITION: 2963 case REFERENCE_PARTITION:
2964 if (cpi->sf.partition_check || 2964 if (cpi->sf.partition_check ||
2965 !is_background(cpi, tile, mi_row, mi_col)) { 2965 !is_background(cpi, tile, mi_row, mi_col)) {
2966 set_modeinfo_offsets(cm, xd, mi_row, mi_col); 2966 set_modeinfo_offsets(cm, xd, mi_row, mi_col);
2967 auto_partition_range(cpi, tile, mi_row, mi_col, 2967 auto_partition_range(cpi, tile, mi_row, mi_col,
2968 &cpi->sf.min_partition_size, 2968 &cpi->sf.min_partition_size,
2969 &cpi->sf.max_partition_size); 2969 &cpi->sf.max_partition_size);
2970 nonrd_pick_partition(cpi, tile, tp, mi_row, mi_col, BLOCK_64X64, 2970 nonrd_pick_partition(cpi, tile, tp, mi_row, mi_col, BLOCK_64X64,
2971 &dummy_rate, &dummy_dist, 1, INT64_MAX, 2971 &dummy_rate, &dummy_dist, 1, INT64_MAX,
2972 x->pc_root); 2972 cpi->pc_root);
2973 } else { 2973 } else {
2974 copy_partitioning(cm, mi, prev_mi); 2974 copy_partitioning(cm, mi, prev_mi);
2975 nonrd_use_partition(cpi, tile, mi, tp, mi_row, mi_col, 2975 nonrd_use_partition(cpi, tile, mi, tp, mi_row, mi_col,
2976 BLOCK_64X64, 1, &dummy_rate, &dummy_dist, 2976 BLOCK_64X64, 1, &dummy_rate, &dummy_dist,
2977 x->pc_root); 2977 cpi->pc_root);
2978 } 2978 }
2979 break; 2979 break;
2980 default: 2980 default:
2981 assert(0); 2981 assert(0);
2982 } 2982 }
2983 } 2983 }
2984 } 2984 }
2985 // end RTC play code 2985 // end RTC play code
2986 2986
2987 static int get_skip_encode_frame(const VP9_COMMON *cm) { 2987 static int get_skip_encode_frame(const VP9_COMMON *cm) {
2988 unsigned int intra_count = 0, inter_count = 0; 2988 unsigned int intra_count = 0, inter_count = 0;
2989 int j; 2989 int j;
2990 2990
2991 for (j = 0; j < INTRA_INTER_CONTEXTS; ++j) { 2991 for (j = 0; j < INTRA_INTER_CONTEXTS; ++j) {
2992 intra_count += cm->counts.intra_inter[j][0]; 2992 intra_count += cm->counts.intra_inter[j][0];
2993 inter_count += cm->counts.intra_inter[j][1]; 2993 inter_count += cm->counts.intra_inter[j][1];
2994 } 2994 }
2995 2995
2996 return (intra_count << 2) < inter_count && 2996 return (intra_count << 2) < inter_count &&
2997 cm->frame_type != KEY_FRAME && 2997 cm->frame_type != KEY_FRAME &&
2998 cm->show_frame; 2998 cm->show_frame;
2999 } 2999 }
3000 3000
3001 static void encode_tiles(VP9_COMP *cpi) {
3002 const VP9_COMMON *const cm = &cpi->common;
3003 const int tile_cols = 1 << cm->log2_tile_cols;
3004 const int tile_rows = 1 << cm->log2_tile_rows;
3005 int tile_col, tile_row;
3006 TOKENEXTRA *tok = cpi->tok;
3007
3008 for (tile_row = 0; tile_row < tile_rows; ++tile_row) {
3009 for (tile_col = 0; tile_col < tile_cols; ++tile_col) {
3010 TileInfo tile;
3011 TOKENEXTRA *old_tok = tok;
3012 int mi_row;
3013
3014 vp9_tile_init(&tile, cm, tile_row, tile_col);
3015 for (mi_row = tile.mi_row_start; mi_row < tile.mi_row_end;
3016 mi_row += MI_BLOCK_SIZE) {
3017 if (cpi->sf.use_nonrd_pick_mode && cm->frame_type != KEY_FRAME)
3018 encode_nonrd_sb_row(cpi, &tile, mi_row, &tok);
3019 else
3020 encode_rd_sb_row(cpi, &tile, mi_row, &tok);
3021 }
3022 cpi->tok_count[tile_row][tile_col] = (unsigned int)(tok - old_tok);
3023 assert(tok - cpi->tok <= get_token_alloc(cm->mb_rows, cm->mb_cols));
3024 }
3025 }
3026 }
3027
3001 static void encode_frame_internal(VP9_COMP *cpi) { 3028 static void encode_frame_internal(VP9_COMP *cpi) {
3002 SPEED_FEATURES *const sf = &cpi->sf; 3029 SPEED_FEATURES *const sf = &cpi->sf;
3003 RD_OPT *const rd_opt = &cpi->rd; 3030 RD_OPT *const rd_opt = &cpi->rd;
3004 MACROBLOCK *const x = &cpi->mb; 3031 MACROBLOCK *const x = &cpi->mb;
3005 VP9_COMMON *const cm = &cpi->common; 3032 VP9_COMMON *const cm = &cpi->common;
3006 MACROBLOCKD *const xd = &x->e_mbd; 3033 MACROBLOCKD *const xd = &x->e_mbd;
3007 3034
3008 xd->mi = cm->mi_grid_visible; 3035 xd->mi = cm->mi_grid_visible;
3009 xd->mi[0] = cm->mi; 3036 xd->mi[0] = cm->mi;
3010 3037
3011 vp9_zero(cm->counts); 3038 vp9_zero(cm->counts);
3012 vp9_zero(cpi->coef_counts); 3039 vp9_zero(cpi->coef_counts);
3013 vp9_zero(cpi->tx_stepdown_count); 3040 vp9_zero(cpi->tx_stepdown_count);
3014 vp9_zero(rd_opt->comp_pred_diff); 3041 vp9_zero(rd_opt->comp_pred_diff);
3015 vp9_zero(rd_opt->filter_diff); 3042 vp9_zero(rd_opt->filter_diff);
3016 vp9_zero(rd_opt->tx_select_diff); 3043 vp9_zero(rd_opt->tx_select_diff);
3017 vp9_zero(rd_opt->tx_select_threshes); 3044 vp9_zero(rd_opt->tx_select_threshes);
3018 3045
3019 cm->tx_mode = select_tx_mode(cpi);
3020
3021 cpi->mb.e_mbd.lossless = cm->base_qindex == 0 && 3046 cpi->mb.e_mbd.lossless = cm->base_qindex == 0 &&
3022 cm->y_dc_delta_q == 0 && 3047 cm->y_dc_delta_q == 0 &&
3023 cm->uv_dc_delta_q == 0 && 3048 cm->uv_dc_delta_q == 0 &&
3024 cm->uv_ac_delta_q == 0; 3049 cm->uv_ac_delta_q == 0;
3025 switch_lossless_mode(cpi, cpi->mb.e_mbd.lossless); 3050
3051 cm->tx_mode = select_tx_mode(cpi);
3052
3053 cpi->mb.fwd_txm4x4 = cpi->mb.e_mbd.lossless ? vp9_fwht4x4 : vp9_fdct4x4;
3054 cpi->mb.itxm_add = cpi->mb.e_mbd.lossless ? vp9_iwht4x4_add : vp9_idct4x4_add;
3055
3056 if (cpi->mb.e_mbd.lossless) {
3057 cpi->mb.optimize = 0;
3058 cpi->common.lf.filter_level = 0;
3059 cpi->zbin_mode_boost_enabled = 0;
3060 }
3026 3061
3027 vp9_frame_init_quantizer(cpi); 3062 vp9_frame_init_quantizer(cpi);
3028 3063
3029 vp9_initialize_rd_consts(cpi); 3064 vp9_initialize_rd_consts(cpi);
3030 vp9_initialize_me_consts(cpi, cm->base_qindex); 3065 vp9_initialize_me_consts(cpi, cm->base_qindex);
3031 init_encode_frame_mb_context(cpi); 3066 init_encode_frame_mb_context(cpi);
3032 set_prev_mi(cm); 3067 set_prev_mi(cm);
3033 3068
3069 x->skip_txfm = 0;
3034 if (sf->use_nonrd_pick_mode) { 3070 if (sf->use_nonrd_pick_mode) {
3035 // Initialize internal buffer pointers for rtc coding, where non-RD 3071 // Initialize internal buffer pointers for rtc coding, where non-RD
3036 // mode decision is used and hence no buffer pointer swap needed. 3072 // mode decision is used and hence no buffer pointer swap needed.
3037 int i; 3073 int i;
3038 struct macroblock_plane *const p = x->plane; 3074 struct macroblock_plane *const p = x->plane;
3039 struct macroblockd_plane *const pd = xd->plane; 3075 struct macroblockd_plane *const pd = xd->plane;
3040 PICK_MODE_CONTEXT *ctx = &x->pc_root->none; 3076 PICK_MODE_CONTEXT *ctx = &cpi->pc_root->none;
3041 3077
3042 for (i = 0; i < MAX_MB_PLANE; ++i) { 3078 for (i = 0; i < MAX_MB_PLANE; ++i) {
3043 p[i].coeff = ctx->coeff_pbuf[i][0]; 3079 p[i].coeff = ctx->coeff_pbuf[i][0];
3044 p[i].qcoeff = ctx->qcoeff_pbuf[i][0]; 3080 p[i].qcoeff = ctx->qcoeff_pbuf[i][0];
3045 pd[i].dqcoeff = ctx->dqcoeff_pbuf[i][0]; 3081 pd[i].dqcoeff = ctx->dqcoeff_pbuf[i][0];
3046 p[i].eobs = ctx->eobs_pbuf[i][0]; 3082 p[i].eobs = ctx->eobs_pbuf[i][0];
3047 } 3083 }
3048 vp9_zero(x->zcoeff_blk); 3084 vp9_zero(x->zcoeff_blk);
3049 3085
3050 if (sf->partition_search_type == SOURCE_VAR_BASED_PARTITION && 3086 if (sf->partition_search_type == SOURCE_VAR_BASED_PARTITION &&
(...skipping 17 matching lines...) Expand all
3068 if (cpi->use_large_partition_rate < 15) 3104 if (cpi->use_large_partition_rate < 15)
3069 sf->partition_search_type = FIXED_PARTITION; 3105 sf->partition_search_type = FIXED_PARTITION;
3070 } 3106 }
3071 } 3107 }
3072 } 3108 }
3073 3109
3074 { 3110 {
3075 struct vpx_usec_timer emr_timer; 3111 struct vpx_usec_timer emr_timer;
3076 vpx_usec_timer_start(&emr_timer); 3112 vpx_usec_timer_start(&emr_timer);
3077 3113
3078 { 3114 encode_tiles(cpi);
3079 // Take tiles into account and give start/end MB
3080 int tile_col, tile_row;
3081 TOKENEXTRA *tp = cpi->tok;
3082 const int tile_cols = 1 << cm->log2_tile_cols;
3083 const int tile_rows = 1 << cm->log2_tile_rows;
3084
3085 for (tile_row = 0; tile_row < tile_rows; tile_row++) {
3086 for (tile_col = 0; tile_col < tile_cols; tile_col++) {
3087 TileInfo tile;
3088 TOKENEXTRA *tp_old = tp;
3089 int mi_row;
3090
3091 // For each row of SBs in the frame
3092 vp9_tile_init(&tile, cm, tile_row, tile_col);
3093 for (mi_row = tile.mi_row_start;
3094 mi_row < tile.mi_row_end; mi_row += MI_BLOCK_SIZE) {
3095 if (sf->use_nonrd_pick_mode && cm->frame_type != KEY_FRAME)
3096 encode_nonrd_sb_row(cpi, &tile, mi_row, &tp);
3097 else
3098 encode_rd_sb_row(cpi, &tile, mi_row, &tp);
3099 }
3100 cpi->tok_count[tile_row][tile_col] = (unsigned int)(tp - tp_old);
3101 assert(tp - cpi->tok <= get_token_alloc(cm->mb_rows, cm->mb_cols));
3102 }
3103 }
3104 }
3105 3115
3106 vpx_usec_timer_mark(&emr_timer); 3116 vpx_usec_timer_mark(&emr_timer);
3107 cpi->time_encode_sb_row += vpx_usec_timer_elapsed(&emr_timer); 3117 cpi->time_encode_sb_row += vpx_usec_timer_elapsed(&emr_timer);
3108 } 3118 }
3109 3119
3110 sf->skip_encode_frame = sf->skip_encode_sb ? get_skip_encode_frame(cm) : 0; 3120 sf->skip_encode_frame = sf->skip_encode_sb ? get_skip_encode_frame(cm) : 0;
3111 3121
3112 #if 0 3122 #if 0
3113 // Keep record of the total distortion this time around for future use 3123 // Keep record of the total distortion this time around for future use
3114 cpi->last_frame_distortion = cpi->frame_distortion; 3124 cpi->last_frame_distortion = cpi->frame_distortion;
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
3238 count8x8_8x8p += cm->counts.tx.p8x8[i][TX_8X8]; 3248 count8x8_8x8p += cm->counts.tx.p8x8[i][TX_8X8];
3239 3249
3240 count16x16_16x16p += cm->counts.tx.p16x16[i][TX_16X16]; 3250 count16x16_16x16p += cm->counts.tx.p16x16[i][TX_16X16];
3241 count16x16_lp += cm->counts.tx.p32x32[i][TX_16X16]; 3251 count16x16_lp += cm->counts.tx.p32x32[i][TX_16X16];
3242 count32x32 += cm->counts.tx.p32x32[i][TX_32X32]; 3252 count32x32 += cm->counts.tx.p32x32[i][TX_32X32];
3243 } 3253 }
3244 3254
3245 if (count4x4 == 0 && count16x16_lp == 0 && count16x16_16x16p == 0 && 3255 if (count4x4 == 0 && count16x16_lp == 0 && count16x16_16x16p == 0 &&
3246 count32x32 == 0) { 3256 count32x32 == 0) {
3247 cm->tx_mode = ALLOW_8X8; 3257 cm->tx_mode = ALLOW_8X8;
3248 reset_skip_txfm_size(cm, TX_8X8); 3258 reset_skip_tx_size(cm, TX_8X8);
3249 } else if (count8x8_8x8p == 0 && count16x16_16x16p == 0 && 3259 } else if (count8x8_8x8p == 0 && count16x16_16x16p == 0 &&
3250 count8x8_lp == 0 && count16x16_lp == 0 && count32x32 == 0) { 3260 count8x8_lp == 0 && count16x16_lp == 0 && count32x32 == 0) {
3251 cm->tx_mode = ONLY_4X4; 3261 cm->tx_mode = ONLY_4X4;
3252 reset_skip_txfm_size(cm, TX_4X4); 3262 reset_skip_tx_size(cm, TX_4X4);
3253 } else if (count8x8_lp == 0 && count16x16_lp == 0 && count4x4 == 0) { 3263 } else if (count8x8_lp == 0 && count16x16_lp == 0 && count4x4 == 0) {
3254 cm->tx_mode = ALLOW_32X32; 3264 cm->tx_mode = ALLOW_32X32;
3255 } else if (count32x32 == 0 && count8x8_lp == 0 && count4x4 == 0) { 3265 } else if (count32x32 == 0 && count8x8_lp == 0 && count4x4 == 0) {
3256 cm->tx_mode = ALLOW_16X16; 3266 cm->tx_mode = ALLOW_16X16;
3257 reset_skip_txfm_size(cm, TX_16X16); 3267 reset_skip_tx_size(cm, TX_16X16);
3258 } 3268 }
3259 } 3269 }
3260 } else { 3270 } else {
3261 cm->reference_mode = SINGLE_REFERENCE; 3271 cm->reference_mode = SINGLE_REFERENCE;
3262 cm->interp_filter = SWITCHABLE; 3272 cm->interp_filter = SWITCHABLE;
3263 encode_frame_internal(cpi); 3273 encode_frame_internal(cpi);
3264 } 3274 }
3265 } 3275 }
3266 3276
3267 static void sum_intra_stats(FRAME_COUNTS *counts, const MODE_INFO *mi) { 3277 static void sum_intra_stats(FRAME_COUNTS *counts, const MODE_INFO *mi) {
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
3308 MACROBLOCK *const x = &cpi->mb; 3318 MACROBLOCK *const x = &cpi->mb;
3309 MACROBLOCKD *const xd = &x->e_mbd; 3319 MACROBLOCKD *const xd = &x->e_mbd;
3310 MODE_INFO **mi_8x8 = xd->mi; 3320 MODE_INFO **mi_8x8 = xd->mi;
3311 MODE_INFO *mi = mi_8x8[0]; 3321 MODE_INFO *mi = mi_8x8[0];
3312 MB_MODE_INFO *mbmi = &mi->mbmi; 3322 MB_MODE_INFO *mbmi = &mi->mbmi;
3313 unsigned int segment_id = mbmi->segment_id; 3323 unsigned int segment_id = mbmi->segment_id;
3314 const int mis = cm->mi_stride; 3324 const int mis = cm->mi_stride;
3315 const int mi_width = num_8x8_blocks_wide_lookup[bsize]; 3325 const int mi_width = num_8x8_blocks_wide_lookup[bsize];
3316 const int mi_height = num_8x8_blocks_high_lookup[bsize]; 3326 const int mi_height = num_8x8_blocks_high_lookup[bsize];
3317 3327
3318 x->skip_recode = !x->select_txfm_size && mbmi->sb_type >= BLOCK_8X8 && 3328 x->skip_recode = !x->select_tx_size && mbmi->sb_type >= BLOCK_8X8 &&
3319 cpi->oxcf.aq_mode != COMPLEXITY_AQ && 3329 cpi->oxcf.aq_mode != COMPLEXITY_AQ &&
3320 cpi->oxcf.aq_mode != CYCLIC_REFRESH_AQ && 3330 cpi->oxcf.aq_mode != CYCLIC_REFRESH_AQ &&
3321 cpi->sf.allow_skip_recode; 3331 cpi->sf.allow_skip_recode;
3322 3332
3323 x->skip_optimize = ctx->is_coded; 3333 x->skip_optimize = ctx->is_coded;
3324 ctx->is_coded = 1; 3334 ctx->is_coded = 1;
3325 x->use_lp32x32fdct = cpi->sf.use_lp32x32fdct; 3335 x->use_lp32x32fdct = cpi->sf.use_lp32x32fdct;
3326 x->skip_encode = (!output_enabled && cpi->sf.skip_encode_frame && 3336 x->skip_encode = (!output_enabled && cpi->sf.skip_encode_frame &&
3327 x->q_index < QIDX_SKIP_THRESH); 3337 x->q_index < QIDX_SKIP_THRESH);
3328 3338
(...skipping 26 matching lines...) Expand all
3355 &xd->block_refs[ref]->sf); 3365 &xd->block_refs[ref]->sf);
3356 } 3366 }
3357 vp9_build_inter_predictors_sb(xd, mi_row, mi_col, MAX(bsize, BLOCK_8X8)); 3367 vp9_build_inter_predictors_sb(xd, mi_row, mi_col, MAX(bsize, BLOCK_8X8));
3358 3368
3359 if (!x->skip) { 3369 if (!x->skip) {
3360 mbmi->skip = 1; 3370 mbmi->skip = 1;
3361 vp9_encode_sb(x, MAX(bsize, BLOCK_8X8)); 3371 vp9_encode_sb(x, MAX(bsize, BLOCK_8X8));
3362 vp9_tokenize_sb(cpi, t, !output_enabled, MAX(bsize, BLOCK_8X8)); 3372 vp9_tokenize_sb(cpi, t, !output_enabled, MAX(bsize, BLOCK_8X8));
3363 } else { 3373 } else {
3364 mbmi->skip = 1; 3374 mbmi->skip = 1;
3365 if (output_enabled) 3375 if (output_enabled &&
3376 !vp9_segfeature_active(&cm->seg, mbmi->segment_id, SEG_LVL_SKIP))
3366 cm->counts.skip[vp9_get_skip_context(xd)][1]++; 3377 cm->counts.skip[vp9_get_skip_context(xd)][1]++;
3367 reset_skip_context(xd, MAX(bsize, BLOCK_8X8)); 3378 reset_skip_context(xd, MAX(bsize, BLOCK_8X8));
3368 } 3379 }
3369 } 3380 }
3370 3381
3371 if (output_enabled) { 3382 if (output_enabled) {
3372 if (cm->tx_mode == TX_MODE_SELECT && 3383 if (cm->tx_mode == TX_MODE_SELECT &&
3373 mbmi->sb_type >= BLOCK_8X8 && 3384 mbmi->sb_type >= BLOCK_8X8 &&
3374 !(is_inter_block(mbmi) && 3385 !(is_inter_block(mbmi) &&
3375 (mbmi->skip || 3386 (mbmi->skip ||
(...skipping 11 matching lines...) Expand all
3387 tx_size = (bsize >= BLOCK_8X8) ? mbmi->tx_size : TX_4X4; 3398 tx_size = (bsize >= BLOCK_8X8) ? mbmi->tx_size : TX_4X4;
3388 } 3399 }
3389 3400
3390 for (y = 0; y < mi_height; y++) 3401 for (y = 0; y < mi_height; y++)
3391 for (x = 0; x < mi_width; x++) 3402 for (x = 0; x < mi_width; x++)
3392 if (mi_col + x < cm->mi_cols && mi_row + y < cm->mi_rows) 3403 if (mi_col + x < cm->mi_cols && mi_row + y < cm->mi_rows)
3393 mi_8x8[mis * y + x]->mbmi.tx_size = tx_size; 3404 mi_8x8[mis * y + x]->mbmi.tx_size = tx_size;
3394 } 3405 }
3395 } 3406 }
3396 } 3407 }
OLDNEW
« no previous file with comments | « source/libvpx/vp9/encoder/vp9_encodeframe.h ('k') | source/libvpx/vp9/encoder/vp9_encodemb.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698