| Index: source/libvpx/vp9/encoder/vp9_mbgraph.c
|
| ===================================================================
|
| --- source/libvpx/vp9/encoder/vp9_mbgraph.c (revision 232232)
|
| +++ source/libvpx/vp9/encoder/vp9_mbgraph.c (working copy)
|
| @@ -10,15 +10,18 @@
|
|
|
| #include <limits.h>
|
|
|
| -#include <vpx_mem/vpx_mem.h>
|
| -#include <vp9/encoder/vp9_encodeintra.h>
|
| -#include <vp9/encoder/vp9_rdopt.h>
|
| -#include <vp9/common/vp9_blockd.h>
|
| -#include <vp9/common/vp9_reconinter.h>
|
| -#include <vp9/common/vp9_reconintra.h>
|
| -#include <vp9/common/vp9_systemdependent.h>
|
| -#include <vp9/encoder/vp9_segmentation.h>
|
| +#include "vpx_mem/vpx_mem.h"
|
| +#include "vp9/encoder/vp9_encodeintra.h"
|
| +#include "vp9/encoder/vp9_rdopt.h"
|
| +#include "vp9/encoder/vp9_segmentation.h"
|
| +#include "vp9/encoder/vp9_mcomp.h"
|
| +#include "vp9/common/vp9_blockd.h"
|
| +#include "vp9/common/vp9_reconinter.h"
|
| +#include "vp9/common/vp9_reconintra.h"
|
| +#include "vp9/common/vp9_systemdependent.h"
|
|
|
| +
|
| +
|
| static unsigned int do_16x16_motion_iteration(VP9_COMP *cpi,
|
| int_mv *ref_mv,
|
| int_mv *dst_mv,
|
| @@ -46,9 +49,9 @@
|
| ref_full.as_mv.row = ref_mv->as_mv.row >> 3;
|
|
|
| /*cpi->sf.search_method == HEX*/
|
| - best_err = vp9_hex_search(x, &ref_full, step_param, x->errorperbit,
|
| + best_err = vp9_hex_search(x, &ref_full.as_mv, step_param, x->errorperbit,
|
| 0, &v_fn_ptr,
|
| - 0, ref_mv, dst_mv);
|
| + 0, &ref_mv->as_mv, &dst_mv->as_mv);
|
|
|
| // Try sub-pixel MC
|
| // if (bestsme > error_thresh && bestsme < INT_MAX)
|
| @@ -57,7 +60,8 @@
|
| unsigned int sse;
|
| best_err = cpi->find_fractional_mv_step(
|
| x,
|
| - dst_mv, ref_mv,
|
| + &dst_mv->as_mv, &ref_mv->as_mv,
|
| + cpi->common.allow_high_precision_mv,
|
| x->errorperbit, &v_fn_ptr,
|
| 0, cpi->sf.subpel_iters_per_step, NULL, NULL,
|
| & distortion, &sse);
|
| @@ -100,7 +104,8 @@
|
| dst_mv->as_int = tmp_mv.as_int;
|
| }
|
|
|
| - // If the current best reference mv is not centred on 0,0 then do a 0,0 based search as well
|
| + // If the current best reference mv is not centered on 0,0 then do a 0,0
|
| + // based search as well.
|
| if (ref_mv->as_int) {
|
| unsigned int tmp_err;
|
| int_mv zero_ref_mv, tmp_mv;
|
| @@ -145,7 +150,7 @@
|
| for (mode = DC_PRED; mode <= TM_PRED; mode++) {
|
| unsigned int err;
|
|
|
| - xd->this_mi->mbmi.mode = mode;
|
| + xd->mi_8x8[0]->mbmi.mode = mode;
|
| vp9_predict_intra_block(xd, 0, 2, TX_16X16, mode,
|
| x->plane[0].src.buf, x->plane[0].src.stride,
|
| xd->plane[0].dst.buf, xd->plane[0].dst.stride);
|
| @@ -189,8 +194,8 @@
|
| x->plane[0].src.buf = buf->y_buffer + mb_y_offset;
|
| x->plane[0].src.stride = buf->y_stride;
|
|
|
| - xd->plane[0].dst.buf = cm->yv12_fb[cm->new_fb_idx].y_buffer + mb_y_offset;
|
| - xd->plane[0].dst.stride = cm->yv12_fb[cm->new_fb_idx].y_stride;
|
| + xd->plane[0].dst.buf = get_frame_new_buffer(cm)->y_buffer + mb_y_offset;
|
| + xd->plane[0].dst.stride = get_frame_new_buffer(cm)->y_stride;
|
|
|
| // do intra 16x16 prediction
|
| intra_error = find_best_16x16_intra(cpi, mb_y_offset,
|
| @@ -214,7 +219,8 @@
|
| stats->ref[GOLDEN_FRAME].m.mv.as_int = 0;
|
| }
|
|
|
| - // Alt-ref frame MV search, if it exists and is different than last/golden frame
|
| + // Do an Alt-ref frame MV search, if it exists and is different than
|
| + // last/golden frame.
|
| if (alt_ref) {
|
| int a_motion_error;
|
| xd->plane[0].pre[0].buf = alt_ref->y_buffer + mb_y_offset;
|
| @@ -243,17 +249,17 @@
|
| int_mv arf_top_mv, gld_top_mv;
|
| MODE_INFO mi_local = { { 0 } };
|
|
|
| - // Set up limit values for motion vectors to prevent them extending outside the UMV borders
|
| + // Set up limit values for motion vectors to prevent them extending outside
|
| + // the UMV borders.
|
| arf_top_mv.as_int = 0;
|
| gld_top_mv.as_int = 0;
|
| - x->mv_row_min = -(VP9BORDERINPIXELS - 8 - VP9_INTERP_EXTEND);
|
| - x->mv_row_max = (cm->mb_rows - 1) * 8 + VP9BORDERINPIXELS
|
| - - 8 - VP9_INTERP_EXTEND;
|
| + x->mv_row_min = -BORDER_MV_PIXELS_B16;
|
| + x->mv_row_max = (cm->mb_rows - 1) * 8 + BORDER_MV_PIXELS_B16;
|
| xd->up_available = 0;
|
| xd->plane[0].dst.stride = buf->y_stride;
|
| xd->plane[0].pre[0].stride = buf->y_stride;
|
| xd->plane[1].dst.stride = buf->uv_stride;
|
| - xd->this_mi = &mi_local;
|
| + xd->mi_8x8[0] = &mi_local;
|
| mi_local.mbmi.sb_type = BLOCK_16X16;
|
| mi_local.mbmi.ref_frame[0] = LAST_FRAME;
|
| mi_local.mbmi.ref_frame[1] = NONE;
|
| @@ -264,12 +270,12 @@
|
| int arf_y_in_offset = arf_y_offset;
|
| int gld_y_in_offset = gld_y_offset;
|
|
|
| - // Set up limit values for motion vectors to prevent them extending outside the UMV borders
|
| + // Set up limit values for motion vectors to prevent them extending outside
|
| + // the UMV borders.
|
| arf_left_mv.as_int = arf_top_mv.as_int;
|
| gld_left_mv.as_int = gld_top_mv.as_int;
|
| - x->mv_col_min = -(VP9BORDERINPIXELS - 8 - VP9_INTERP_EXTEND);
|
| - x->mv_col_max = (cm->mb_cols - 1) * 8 + VP9BORDERINPIXELS
|
| - - 8 - VP9_INTERP_EXTEND;
|
| + x->mv_col_min = -BORDER_MV_PIXELS_B16;
|
| + x->mv_col_max = (cm->mb_cols - 1) * 8 + BORDER_MV_PIXELS_B16;
|
| xd->left_available = 0;
|
|
|
| for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) {
|
| @@ -307,6 +313,7 @@
|
| static void separate_arf_mbs(VP9_COMP *cpi) {
|
| VP9_COMMON *const cm = &cpi->common;
|
| int mb_col, mb_row, offset, i;
|
| + int mi_row, mi_col;
|
| int ncnt[4] = { 0 };
|
| int n_frames = cpi->mbgraph_n_frames;
|
|
|
| @@ -343,22 +350,17 @@
|
| }
|
| }
|
|
|
| - for (offset = 0, mb_row = 0; mb_row < cm->mb_rows;
|
| - offset += cm->mb_cols, mb_row++) {
|
| - for (mb_col = 0; mb_col < cm->mb_cols; mb_col++) {
|
| + // arf_not_zz is indexed by MB, but this loop is indexed by MI to avoid out
|
| + // of bound access in segmentation_map
|
| + for (mi_row = 0; mi_row < cm->mi_rows; mi_row++) {
|
| + for (mi_col = 0; mi_col < cm->mi_cols; mi_col++) {
|
| // If any of the blocks in the sequence failed then the MB
|
| // goes in segment 0
|
| - if (arf_not_zz[offset + mb_col]) {
|
| + if (arf_not_zz[mi_row/2*cm->mb_cols + mi_col/2]) {
|
| ncnt[0]++;
|
| - cpi->segmentation_map[offset * 4 + 2 * mb_col] = 0;
|
| - cpi->segmentation_map[offset * 4 + 2 * mb_col + 1] = 0;
|
| - cpi->segmentation_map[offset * 4 + 2 * mb_col + cm->mi_cols] = 0;
|
| - cpi->segmentation_map[offset * 4 + 2 * mb_col + cm->mi_cols + 1] = 0;
|
| + cpi->segmentation_map[mi_row * cm->mi_cols + mi_col] = 0;
|
| } else {
|
| - cpi->segmentation_map[offset * 4 + 2 * mb_col] = 1;
|
| - cpi->segmentation_map[offset * 4 + 2 * mb_col + 1] = 1;
|
| - cpi->segmentation_map[offset * 4 + 2 * mb_col + cm->mi_cols] = 1;
|
| - cpi->segmentation_map[offset * 4 + 2 * mb_col + cm->mi_cols + 1] = 1;
|
| + cpi->segmentation_map[mi_row * cm->mi_cols + mi_col] = 1;
|
| ncnt[1]++;
|
| }
|
| }
|
| @@ -369,7 +371,7 @@
|
| if (1) {
|
| // Note % of blocks that are marked as static
|
| if (cm->MBs)
|
| - cpi->static_mb_pct = (ncnt[1] * 100) / cm->MBs;
|
| + cpi->static_mb_pct = (ncnt[1] * 100) / (cm->mi_rows * cm->mi_cols);
|
|
|
| // This error case should not be reachable as this function should
|
| // never be called with the common data structure uninitialized.
|
| @@ -406,7 +408,8 @@
|
| for (i = 0; i < n_frames; i++) {
|
| MBGRAPH_FRAME_STATS *frame_stats = &cpi->mbgraph_stats[i];
|
| vpx_memset(frame_stats->mb_stats, 0,
|
| - cm->mb_rows * cm->mb_cols * sizeof(*cpi->mbgraph_stats[i].mb_stats));
|
| + cm->mb_rows * cm->mb_cols *
|
| + sizeof(*cpi->mbgraph_stats[i].mb_stats));
|
| }
|
|
|
| // do motion search to find contribution of each reference to data
|
|
|