| OLD | NEW | 
|---|
| 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 | 
| 11 #include <limits.h> | 11 #include <limits.h> | 
| 12 | 12 | 
|  | 13 #include "./vp9_rtcd.h" | 
|  | 14 #include "./vpx_dsp_rtcd.h" | 
|  | 15 | 
| 13 #include "vpx_mem/vpx_mem.h" | 16 #include "vpx_mem/vpx_mem.h" | 
| 14 #include "vp9/encoder/vp9_segmentation.h" | 17 #include "vp9/encoder/vp9_segmentation.h" | 
| 15 #include "vp9/encoder/vp9_mcomp.h" | 18 #include "vp9/encoder/vp9_mcomp.h" | 
| 16 #include "vp9/common/vp9_blockd.h" | 19 #include "vp9/common/vp9_blockd.h" | 
| 17 #include "vp9/common/vp9_reconinter.h" | 20 #include "vp9/common/vp9_reconinter.h" | 
| 18 #include "vp9/common/vp9_reconintra.h" | 21 #include "vp9/common/vp9_reconintra.h" | 
| 19 #include "vp9/common/vp9_systemdependent.h" | 22 #include "vp9/common/vp9_systemdependent.h" | 
| 20 | 23 | 
| 21 | 24 | 
| 22 static unsigned int do_16x16_motion_iteration(VP9_COMP *cpi, | 25 static unsigned int do_16x16_motion_iteration(VP9_COMP *cpi, | 
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 56     int distortion; | 59     int distortion; | 
| 57     unsigned int sse; | 60     unsigned int sse; | 
| 58     cpi->find_fractional_mv_step( | 61     cpi->find_fractional_mv_step( | 
| 59         x, dst_mv, ref_mv, cpi->common.allow_high_precision_mv, x->errorperbit, | 62         x, dst_mv, ref_mv, cpi->common.allow_high_precision_mv, x->errorperbit, | 
| 60         &v_fn_ptr, 0, mv_sf->subpel_iters_per_step, | 63         &v_fn_ptr, 0, mv_sf->subpel_iters_per_step, | 
| 61         cond_cost_list(cpi, cost_list), | 64         cond_cost_list(cpi, cost_list), | 
| 62         NULL, NULL, | 65         NULL, NULL, | 
| 63         &distortion, &sse, NULL, 0, 0); | 66         &distortion, &sse, NULL, 0, 0); | 
| 64   } | 67   } | 
| 65 | 68 | 
| 66   xd->mi[0].src_mi->mbmi.mode = NEWMV; | 69   xd->mi[0]->mbmi.mode = NEWMV; | 
| 67   xd->mi[0].src_mi->mbmi.mv[0].as_mv = *dst_mv; | 70   xd->mi[0]->mbmi.mv[0].as_mv = *dst_mv; | 
| 68 | 71 | 
| 69   vp9_build_inter_predictors_sby(xd, mb_row, mb_col, BLOCK_16X16); | 72   vp9_build_inter_predictors_sby(xd, mb_row, mb_col, BLOCK_16X16); | 
| 70 | 73 | 
| 71   /* restore UMV window */ | 74   /* restore UMV window */ | 
| 72   x->mv_col_min = tmp_col_min; | 75   x->mv_col_min = tmp_col_min; | 
| 73   x->mv_col_max = tmp_col_max; | 76   x->mv_col_max = tmp_col_max; | 
| 74   x->mv_row_min = tmp_row_min; | 77   x->mv_row_min = tmp_row_min; | 
| 75   x->mv_row_max = tmp_row_max; | 78   x->mv_row_max = tmp_row_max; | 
| 76 | 79 | 
| 77   return vp9_sad16x16(x->plane[0].src.buf, x->plane[0].src.stride, | 80   return vpx_sad16x16(x->plane[0].src.buf, x->plane[0].src.stride, | 
| 78           xd->plane[0].dst.buf, xd->plane[0].dst.stride); | 81                       xd->plane[0].dst.buf, xd->plane[0].dst.stride); | 
| 79 } | 82 } | 
| 80 | 83 | 
| 81 static int do_16x16_motion_search(VP9_COMP *cpi, const MV *ref_mv, | 84 static int do_16x16_motion_search(VP9_COMP *cpi, const MV *ref_mv, | 
| 82                                   int_mv *dst_mv, int mb_row, int mb_col) { | 85                                   int_mv *dst_mv, int mb_row, int mb_col) { | 
| 83   MACROBLOCK *const x = &cpi->td.mb; | 86   MACROBLOCK *const x = &cpi->td.mb; | 
| 84   MACROBLOCKD *const xd = &x->e_mbd; | 87   MACROBLOCKD *const xd = &x->e_mbd; | 
| 85   unsigned int err, tmp_err; | 88   unsigned int err, tmp_err; | 
| 86   MV tmp_mv; | 89   MV tmp_mv; | 
| 87 | 90 | 
| 88   // Try zero MV first | 91   // Try zero MV first | 
| 89   // FIXME should really use something like near/nearest MV and/or MV prediction | 92   // FIXME should really use something like near/nearest MV and/or MV prediction | 
| 90   err = vp9_sad16x16(x->plane[0].src.buf, x->plane[0].src.stride, | 93   err = vpx_sad16x16(x->plane[0].src.buf, x->plane[0].src.stride, | 
| 91                      xd->plane[0].pre[0].buf, xd->plane[0].pre[0].stride); | 94                      xd->plane[0].pre[0].buf, xd->plane[0].pre[0].stride); | 
| 92   dst_mv->as_int = 0; | 95   dst_mv->as_int = 0; | 
| 93 | 96 | 
| 94   // Test last reference frame using the previous best mv as the | 97   // Test last reference frame using the previous best mv as the | 
| 95   // starting point (best reference) for the search | 98   // starting point (best reference) for the search | 
| 96   tmp_err = do_16x16_motion_iteration(cpi, ref_mv, &tmp_mv, mb_row, mb_col); | 99   tmp_err = do_16x16_motion_iteration(cpi, ref_mv, &tmp_mv, mb_row, mb_col); | 
| 97   if (tmp_err < err) { | 100   if (tmp_err < err) { | 
| 98     err = tmp_err; | 101     err = tmp_err; | 
| 99     dst_mv->as_mv = tmp_mv; | 102     dst_mv->as_mv = tmp_mv; | 
| 100   } | 103   } | 
| (...skipping 15 matching lines...) Expand all  Loading... | 
| 116   return err; | 119   return err; | 
| 117 } | 120 } | 
| 118 | 121 | 
| 119 static int do_16x16_zerozero_search(VP9_COMP *cpi, int_mv *dst_mv) { | 122 static int do_16x16_zerozero_search(VP9_COMP *cpi, int_mv *dst_mv) { | 
| 120   MACROBLOCK *const x = &cpi->td.mb; | 123   MACROBLOCK *const x = &cpi->td.mb; | 
| 121   MACROBLOCKD *const xd = &x->e_mbd; | 124   MACROBLOCKD *const xd = &x->e_mbd; | 
| 122   unsigned int err; | 125   unsigned int err; | 
| 123 | 126 | 
| 124   // Try zero MV first | 127   // Try zero MV first | 
| 125   // FIXME should really use something like near/nearest MV and/or MV prediction | 128   // FIXME should really use something like near/nearest MV and/or MV prediction | 
| 126   err = vp9_sad16x16(x->plane[0].src.buf, x->plane[0].src.stride, | 129   err = vpx_sad16x16(x->plane[0].src.buf, x->plane[0].src.stride, | 
| 127                      xd->plane[0].pre[0].buf, xd->plane[0].pre[0].stride); | 130                      xd->plane[0].pre[0].buf, xd->plane[0].pre[0].stride); | 
| 128 | 131 | 
| 129   dst_mv->as_int = 0; | 132   dst_mv->as_int = 0; | 
| 130 | 133 | 
| 131   return err; | 134   return err; | 
| 132 } | 135 } | 
| 133 static int find_best_16x16_intra(VP9_COMP *cpi, PREDICTION_MODE *pbest_mode) { | 136 static int find_best_16x16_intra(VP9_COMP *cpi, PREDICTION_MODE *pbest_mode) { | 
| 134   MACROBLOCK   *const x  = &cpi->td.mb; | 137   MACROBLOCK   *const x  = &cpi->td.mb; | 
| 135   MACROBLOCKD *const xd = &x->e_mbd; | 138   MACROBLOCKD *const xd = &x->e_mbd; | 
| 136   PREDICTION_MODE best_mode = -1, mode; | 139   PREDICTION_MODE best_mode = -1, mode; | 
| 137   unsigned int best_err = INT_MAX; | 140   unsigned int best_err = INT_MAX; | 
| 138 | 141 | 
| 139   // calculate SATD for each intra prediction mode; | 142   // calculate SATD for each intra prediction mode; | 
| 140   // we're intentionally not doing 4x4, we just want a rough estimate | 143   // we're intentionally not doing 4x4, we just want a rough estimate | 
| 141   for (mode = DC_PRED; mode <= TM_PRED; mode++) { | 144   for (mode = DC_PRED; mode <= TM_PRED; mode++) { | 
| 142     unsigned int err; | 145     unsigned int err; | 
| 143 | 146 | 
| 144     xd->mi[0].src_mi->mbmi.mode = mode; | 147     xd->mi[0]->mbmi.mode = mode; | 
| 145     vp9_predict_intra_block(xd, 0, 2, TX_16X16, mode, | 148     vp9_predict_intra_block(xd, 0, 2, TX_16X16, mode, | 
| 146                             x->plane[0].src.buf, x->plane[0].src.stride, | 149                             x->plane[0].src.buf, x->plane[0].src.stride, | 
| 147                             xd->plane[0].dst.buf, xd->plane[0].dst.stride, | 150                             xd->plane[0].dst.buf, xd->plane[0].dst.stride, | 
| 148                             0, 0, 0); | 151                             0, 0, 0); | 
| 149     err = vp9_sad16x16(x->plane[0].src.buf, x->plane[0].src.stride, | 152     err = vpx_sad16x16(x->plane[0].src.buf, x->plane[0].src.stride, | 
| 150                        xd->plane[0].dst.buf, xd->plane[0].dst.stride); | 153                        xd->plane[0].dst.buf, xd->plane[0].dst.stride); | 
| 151 | 154 | 
| 152     // find best | 155     // find best | 
| 153     if (err < best_err) { | 156     if (err < best_err) { | 
| 154       best_err  = err; | 157       best_err  = err; | 
| 155       best_mode = mode; | 158       best_mode = mode; | 
| 156     } | 159     } | 
| 157   } | 160   } | 
| 158 | 161 | 
| 159   if (pbest_mode) | 162   if (pbest_mode) | 
| (...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 240 | 243 | 
| 241   vp9_zero(mi_local); | 244   vp9_zero(mi_local); | 
| 242   // Set up limit values for motion vectors to prevent them extending outside | 245   // Set up limit values for motion vectors to prevent them extending outside | 
| 243   // the UMV borders. | 246   // the UMV borders. | 
| 244   x->mv_row_min     = -BORDER_MV_PIXELS_B16; | 247   x->mv_row_min     = -BORDER_MV_PIXELS_B16; | 
| 245   x->mv_row_max     = (cm->mb_rows - 1) * 8 + BORDER_MV_PIXELS_B16; | 248   x->mv_row_max     = (cm->mb_rows - 1) * 8 + BORDER_MV_PIXELS_B16; | 
| 246   xd->up_available  = 0; | 249   xd->up_available  = 0; | 
| 247   xd->plane[0].dst.stride  = buf->y_stride; | 250   xd->plane[0].dst.stride  = buf->y_stride; | 
| 248   xd->plane[0].pre[0].stride  = buf->y_stride; | 251   xd->plane[0].pre[0].stride  = buf->y_stride; | 
| 249   xd->plane[1].dst.stride = buf->uv_stride; | 252   xd->plane[1].dst.stride = buf->uv_stride; | 
| 250   xd->mi[0].src_mi = &mi_local; | 253   xd->mi[0] = &mi_local; | 
| 251   mi_local.mbmi.sb_type = BLOCK_16X16; | 254   mi_local.mbmi.sb_type = BLOCK_16X16; | 
| 252   mi_local.mbmi.ref_frame[0] = LAST_FRAME; | 255   mi_local.mbmi.ref_frame[0] = LAST_FRAME; | 
| 253   mi_local.mbmi.ref_frame[1] = NONE; | 256   mi_local.mbmi.ref_frame[1] = NONE; | 
| 254 | 257 | 
| 255   for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) { | 258   for (mb_row = 0; mb_row < cm->mb_rows; mb_row++) { | 
| 256     MV gld_left_mv = gld_top_mv; | 259     MV gld_left_mv = gld_top_mv; | 
| 257     int mb_y_in_offset  = mb_y_offset; | 260     int mb_y_in_offset  = mb_y_offset; | 
| 258     int arf_y_in_offset = arf_y_offset; | 261     int arf_y_in_offset = arf_y_offset; | 
| 259     int gld_y_in_offset = gld_y_offset; | 262     int gld_y_in_offset = gld_y_offset; | 
| 260 | 263 | 
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 382   // being a GF - so exit if we don't look ahead beyond that | 385   // being a GF - so exit if we don't look ahead beyond that | 
| 383   if (n_frames <= cpi->rc.frames_till_gf_update_due) | 386   if (n_frames <= cpi->rc.frames_till_gf_update_due) | 
| 384     return; | 387     return; | 
| 385 | 388 | 
| 386   if (n_frames > MAX_LAG_BUFFERS) | 389   if (n_frames > MAX_LAG_BUFFERS) | 
| 387     n_frames = MAX_LAG_BUFFERS; | 390     n_frames = MAX_LAG_BUFFERS; | 
| 388 | 391 | 
| 389   cpi->mbgraph_n_frames = n_frames; | 392   cpi->mbgraph_n_frames = n_frames; | 
| 390   for (i = 0; i < n_frames; i++) { | 393   for (i = 0; i < n_frames; i++) { | 
| 391     MBGRAPH_FRAME_STATS *frame_stats = &cpi->mbgraph_stats[i]; | 394     MBGRAPH_FRAME_STATS *frame_stats = &cpi->mbgraph_stats[i]; | 
| 392     vpx_memset(frame_stats->mb_stats, 0, | 395     memset(frame_stats->mb_stats, 0, | 
| 393                cm->mb_rows * cm->mb_cols * | 396            cm->mb_rows * cm->mb_cols * sizeof(*cpi->mbgraph_stats[i].mb_stats)); | 
| 394                sizeof(*cpi->mbgraph_stats[i].mb_stats)); |  | 
| 395   } | 397   } | 
| 396 | 398 | 
| 397   // do motion search to find contribution of each reference to data | 399   // do motion search to find contribution of each reference to data | 
| 398   // later on in this GF group | 400   // later on in this GF group | 
| 399   // FIXME really, the GF/last MC search should be done forward, and | 401   // FIXME really, the GF/last MC search should be done forward, and | 
| 400   // the ARF MC search backwards, to get optimal results for MV caching | 402   // the ARF MC search backwards, to get optimal results for MV caching | 
| 401   for (i = 0; i < n_frames; i++) { | 403   for (i = 0; i < n_frames; i++) { | 
| 402     MBGRAPH_FRAME_STATS *frame_stats = &cpi->mbgraph_stats[i]; | 404     MBGRAPH_FRAME_STATS *frame_stats = &cpi->mbgraph_stats[i]; | 
| 403     struct lookahead_entry *q_cur = vp9_lookahead_peek(cpi->lookahead, i); | 405     struct lookahead_entry *q_cur = vp9_lookahead_peek(cpi->lookahead, i); | 
| 404 | 406 | 
| 405     assert(q_cur != NULL); | 407     assert(q_cur != NULL); | 
| 406 | 408 | 
| 407     update_mbgraph_frame_stats(cpi, frame_stats, &q_cur->img, | 409     update_mbgraph_frame_stats(cpi, frame_stats, &q_cur->img, | 
| 408                                golden_ref, cpi->Source); | 410                                golden_ref, cpi->Source); | 
| 409   } | 411   } | 
| 410 | 412 | 
| 411   vp9_clear_system_state(); | 413   vp9_clear_system_state(); | 
| 412 | 414 | 
| 413   separate_arf_mbs(cpi); | 415   separate_arf_mbs(cpi); | 
| 414 } | 416 } | 
| OLD | NEW | 
|---|