| Index: source/libvpx/vp8/encoder/temporal_filter.c
|
| ===================================================================
|
| --- source/libvpx/vp8/encoder/temporal_filter.c (revision 96967)
|
| +++ source/libvpx/vp8/encoder/temporal_filter.c (working copy)
|
| @@ -24,7 +24,6 @@
|
| #include "segmentation.h"
|
| #include "vp8/common/g_common.h"
|
| #include "vpx_scale/yv12extend.h"
|
| -#include "vp8/common/postproc.h"
|
| #include "vpx_mem/vpx_mem.h"
|
| #include "vp8/common/swapyv12buffer.h"
|
| #include "vp8/common/threading.h"
|
| @@ -149,17 +148,15 @@
|
| )
|
| {
|
| MACROBLOCK *x = &cpi->mb;
|
| - int thissme;
|
| int step_param;
|
| int further_steps;
|
| - int n = 0;
|
| int sadpb = x->sadperbit16;
|
| int bestsme = INT_MAX;
|
| - int num00 = 0;
|
|
|
| BLOCK *b = &x->block[0];
|
| BLOCKD *d = &x->e_mbd.block[0];
|
| - MV best_ref_mv1 = {0,0};
|
| + int_mv best_ref_mv1;
|
| + int_mv best_ref_mv1_full; /* full-pixel value of best_ref_mv1 */
|
|
|
| int *mvcost[2] = { &dummy_cost[mv_max+1], &dummy_cost[mv_max+1] };
|
| int *mvsadcost[2] = { &dummy_cost[mv_max+1], &dummy_cost[mv_max+1] };
|
| @@ -172,6 +169,10 @@
|
| int pre = d->pre;
|
| int pre_stride = d->pre_stride;
|
|
|
| + best_ref_mv1.as_int = 0;
|
| + best_ref_mv1_full.as_mv.col = best_ref_mv1.as_mv.col >>3;
|
| + best_ref_mv1_full.as_mv.row = best_ref_mv1.as_mv.row >>3;
|
| +
|
| // Setup frame pointers
|
| b->base_src = &arf_frame->y_buffer;
|
| b->src_stride = arf_frame->y_stride;
|
| @@ -195,72 +196,25 @@
|
| further_steps = 0;
|
| }
|
|
|
| - if (1/*cpi->sf.search_method == HEX*/)
|
| - {
|
| - // TODO Check that the 16x16 vf & sdf are selected here
|
| - bestsme = vp8_hex_search(x, b, d,
|
| - &best_ref_mv1, &d->bmi.mv.as_mv,
|
| - step_param,
|
| - sadpb/*x->errorperbit*/,
|
| - &num00, &cpi->fn_ptr[BLOCK_16X16],
|
| - mvsadcost, mvcost, &best_ref_mv1);
|
| - }
|
| - else
|
| - {
|
| - int mv_x, mv_y;
|
| + /*cpi->sf.search_method == HEX*/
|
| + // TODO Check that the 16x16 vf & sdf are selected here
|
| + bestsme = vp8_hex_search(x, b, d,
|
| + &best_ref_mv1_full, &d->bmi.mv,
|
| + step_param,
|
| + sadpb,
|
| + &cpi->fn_ptr[BLOCK_16X16],
|
| + mvsadcost, mvcost, &best_ref_mv1);
|
|
|
| - bestsme = cpi->diamond_search_sad(x, b, d,
|
| - &best_ref_mv1, &d->bmi.mv.as_mv,
|
| - step_param,
|
| - sadpb / 2/*x->errorperbit*/,
|
| - &num00, &cpi->fn_ptr[BLOCK_16X16],
|
| - mvsadcost, mvcost, &best_ref_mv1); //sadpb < 9
|
| -
|
| - // Further step/diamond searches as necessary
|
| - n = 0;
|
| - //further_steps = (cpi->sf.max_step_search_steps - 1) - step_param;
|
| -
|
| - n = num00;
|
| - num00 = 0;
|
| -
|
| - while (n < further_steps)
|
| - {
|
| - n++;
|
| -
|
| - if (num00)
|
| - num00--;
|
| - else
|
| - {
|
| - thissme = cpi->diamond_search_sad(x, b, d,
|
| - &best_ref_mv1, &d->bmi.mv.as_mv,
|
| - step_param + n,
|
| - sadpb / 4/*x->errorperbit*/,
|
| - &num00, &cpi->fn_ptr[BLOCK_16X16],
|
| - mvsadcost, mvcost, &best_ref_mv1); //sadpb = 9
|
| -
|
| - if (thissme < bestsme)
|
| - {
|
| - bestsme = thissme;
|
| - mv_y = d->bmi.mv.as_mv.row;
|
| - mv_x = d->bmi.mv.as_mv.col;
|
| - }
|
| - else
|
| - {
|
| - d->bmi.mv.as_mv.row = mv_y;
|
| - d->bmi.mv.as_mv.col = mv_x;
|
| - }
|
| - }
|
| - }
|
| - }
|
| -
|
| #if ALT_REF_SUBPEL_ENABLED
|
| // Try sub-pixel MC?
|
| //if (bestsme > error_thresh && bestsme < INT_MAX)
|
| {
|
| + int distortion;
|
| + unsigned int sse;
|
| bestsme = cpi->find_fractional_mv_step(x, b, d,
|
| - &d->bmi.mv.as_mv, &best_ref_mv1,
|
| + &d->bmi.mv, &best_ref_mv1,
|
| x->errorperbit, &cpi->fn_ptr[BLOCK_16X16],
|
| - mvcost);
|
| + mvcost, &distortion, &sse);
|
| }
|
| #endif
|
|
|
| @@ -290,7 +244,6 @@
|
| unsigned int filter_weight;
|
| int mb_cols = cpi->common.mb_cols;
|
| int mb_rows = cpi->common.mb_rows;
|
| - int MBs = cpi->common.MBs;
|
| int mb_y_offset = 0;
|
| int mb_uv_offset = 0;
|
| DECLARE_ALIGNED_ARRAY(16, unsigned int, accumulator, 16*16 + 8*8 + 8*8);
|
| @@ -308,26 +261,33 @@
|
| for (mb_row = 0; mb_row < mb_rows; mb_row++)
|
| {
|
| #if ALT_REF_MC_ENABLED
|
| - // Reduced search extent by 3 for 6-tap filter & smaller UMV border
|
| - cpi->mb.mv_row_min = -((mb_row * 16) + (VP8BORDERINPIXELS - 19));
|
| + // Source frames are extended to 16 pixels. This is different than
|
| + // L/A/G reference frames that have a border of 32 (VP8BORDERINPIXELS)
|
| + // A 6 tap filter is used for motion search. This requires 2 pixels
|
| + // before and 3 pixels after. So the largest Y mv on a border would
|
| + // then be 16 - 3. The UV blocks are half the size of the Y and
|
| + // therefore only extended by 8. The largest mv that a UV block
|
| + // can support is 8 - 3. A UV mv is half of a Y mv.
|
| + // (16 - 3) >> 1 == 6 which is greater than 8 - 3.
|
| + // To keep the mv in play for both Y and UV planes the max that it
|
| + // can be on a border is therefore 16 - 5.
|
| + cpi->mb.mv_row_min = -((mb_row * 16) + (16 - 5));
|
| cpi->mb.mv_row_max = ((cpi->common.mb_rows - 1 - mb_row) * 16)
|
| - + (VP8BORDERINPIXELS - 19);
|
| + + (16 - 5);
|
| #endif
|
|
|
| for (mb_col = 0; mb_col < mb_cols; mb_col++)
|
| {
|
| - int i, j, k, w;
|
| - int weight_cap;
|
| + int i, j, k;
|
| int stride;
|
|
|
| vpx_memset(accumulator, 0, 384*sizeof(unsigned int));
|
| vpx_memset(count, 0, 384*sizeof(unsigned short));
|
|
|
| #if ALT_REF_MC_ENABLED
|
| - // Reduced search extent by 3 for 6-tap filter & smaller UMV border
|
| - cpi->mb.mv_col_min = -((mb_col * 16) + (VP8BORDERINPIXELS - 19));
|
| + cpi->mb.mv_col_min = -((mb_col * 16) + (16 - 5));
|
| cpi->mb.mv_col_max = ((cpi->common.mb_cols - 1 - mb_col) * 16)
|
| - + (VP8BORDERINPIXELS - 19);
|
| + + (16 - 5);
|
| #endif
|
|
|
| for (frame = 0; frame < frame_count; frame++)
|
| @@ -406,8 +366,8 @@
|
| }
|
|
|
| // Normalize filter output to produce AltRef frame
|
| - dst1 = cpi->alt_ref_buffer.source_buffer.y_buffer;
|
| - stride = cpi->alt_ref_buffer.source_buffer.y_stride;
|
| + dst1 = cpi->alt_ref_buffer.y_buffer;
|
| + stride = cpi->alt_ref_buffer.y_stride;
|
| byte = mb_y_offset;
|
| for (i = 0,k = 0; i < 16; i++)
|
| {
|
| @@ -426,9 +386,9 @@
|
| byte += stride - 16;
|
| }
|
|
|
| - dst1 = cpi->alt_ref_buffer.source_buffer.u_buffer;
|
| - dst2 = cpi->alt_ref_buffer.source_buffer.v_buffer;
|
| - stride = cpi->alt_ref_buffer.source_buffer.uv_stride;
|
| + dst1 = cpi->alt_ref_buffer.u_buffer;
|
| + dst2 = cpi->alt_ref_buffer.v_buffer;
|
| + stride = cpi->alt_ref_buffer.uv_stride;
|
| byte = mb_uv_offset;
|
| for (i = 0,k = 256; i < 8; i++)
|
| {
|
| @@ -471,7 +431,8 @@
|
|
|
| void vp8_temporal_filter_prepare_c
|
| (
|
| - VP8_COMP *cpi
|
| + VP8_COMP *cpi,
|
| + int distance
|
| )
|
| {
|
| int frame = 0;
|
| @@ -482,7 +443,6 @@
|
| int frames_to_blur_forward = 0;
|
| int frames_to_blur = 0;
|
| int start_frame = 0;
|
| - unsigned int filtered = 0;
|
|
|
| int strength = cpi->oxcf.arnr_strength;
|
|
|
| @@ -490,13 +450,10 @@
|
|
|
| int max_frames = cpi->active_arnr_frames;
|
|
|
| - num_frames_backward = cpi->last_alt_ref_sei - cpi->source_encode_index;
|
| + num_frames_backward = distance;
|
| + num_frames_forward = vp8_lookahead_depth(cpi->lookahead)
|
| + - (num_frames_backward + 1);
|
|
|
| - if (num_frames_backward < 0)
|
| - num_frames_backward += cpi->oxcf.lag_in_frames;
|
| -
|
| - num_frames_forward = cpi->oxcf.lag_in_frames - (num_frames_backward + 1);
|
| -
|
| switch (blur_type)
|
| {
|
| case 1:
|
| @@ -547,8 +504,7 @@
|
| break;
|
| }
|
|
|
| - start_frame = (cpi->last_alt_ref_sei
|
| - + frames_to_blur_forward) % cpi->oxcf.lag_in_frames;
|
| + start_frame = distance + frames_to_blur_forward;
|
|
|
| #ifdef DEBUGFWG
|
| // DEBUG FWG
|
| @@ -569,12 +525,9 @@
|
| for (frame = 0; frame < frames_to_blur; frame++)
|
| {
|
| int which_buffer = start_frame - frame;
|
| -
|
| - if (which_buffer < 0)
|
| - which_buffer += cpi->oxcf.lag_in_frames;
|
| -
|
| - cpi->frames[frames_to_blur-1-frame]
|
| - = &cpi->src_buffer[which_buffer].source_buffer;
|
| + struct lookahead_entry* buf = vp8_lookahead_peek(cpi->lookahead,
|
| + which_buffer);
|
| + cpi->frames[frames_to_blur-1-frame] = &buf->img;
|
| }
|
|
|
| vp8_temporal_filter_iterate_c (
|
|
|