VP9_COMMON *cm);
void vp9_setup_scale_factors_for_frame(struct scale_factors *scale,
- YV12_BUFFER_CONFIG *other,
+ int other_w, int other_h,
int this_w, int this_h);
void vp9_build_inter_predictor(const uint8_t *src, int src_stride,
return val;
}
-static int scaled_buffer_offset(int x_offset,
- int y_offset,
- int stride,
+static int scaled_buffer_offset(int x_offset, int y_offset, int stride,
const struct scale_factors *scale) {
- if (scale)
- return scale->scale_value_y(y_offset, scale) * stride +
- scale->scale_value_x(x_offset, scale);
- return y_offset * stride + x_offset;
+ const int x = scale ? scale->scale_value_x(x_offset, scale) : x_offset;
+ const int y = scale ? scale->scale_value_y(y_offset, scale) : y_offset;
+ return y * stride + x;
}
static void setup_pred_plane(struct buf_2d *dst,
for (i = 0; i < ALLOWED_REFS_PER_FRAME; ++i) {
if (cm->active_ref_idx[i] >= NUM_YV12_BUFFERS) {
memset(&cm->active_ref_scale[i], 0, sizeof(cm->active_ref_scale[i]));
- continue;
+ } else {
+ YV12_BUFFER_CONFIG *fb = &cm->yv12_fb[cm->active_ref_idx[i]];
+ vp9_setup_scale_factors_for_frame(&cm->active_ref_scale[i],
+ fb->y_crop_width, fb->y_crop_height,
+ cm->width, cm->height);
}
-
- vp9_setup_scale_factors_for_frame(&cm->active_ref_scale[i],
- &cm->yv12_fb[cm->active_ref_idx[i]],
- cm->width, cm->height);
}
vp9_setup_interp_filters(&cpi->mb.e_mbd, DEFAULT_INTERP_FILTER, cm);
#if ALT_REF_MC_ENABLED
static int temporal_filter_find_matching_mb_c(VP9_COMP *cpi,
- YV12_BUFFER_CONFIG *arf_frame,
- YV12_BUFFER_CONFIG *frame_ptr,
- int mb_offset,
+ uint8_t *arf_frame_buf,
+ uint8_t *frame_ptr_buf,
+ int stride,
int error_thresh) {
MACROBLOCK *x = &cpi->mb;
MACROBLOCKD* const xd = &x->e_mbd;
best_ref_mv1_full.as_mv.row = best_ref_mv1.as_mv.row >> 3;
// Setup frame pointers
- x->plane[0].src.buf = arf_frame->y_buffer + mb_offset;
- x->plane[0].src.stride = arf_frame->y_stride;
- xd->plane[0].pre[0].buf = frame_ptr->y_buffer + mb_offset;
- xd->plane[0].pre[0].stride = arf_frame->y_stride;
+ x->plane[0].src.buf = arf_frame_buf;
+ x->plane[0].src.stride = stride;
+ xd->plane[0].pre[0].buf = frame_ptr_buf;
+ xd->plane[0].pre[0].stride = stride;
// Further step/diamond searches as necessary
if (cpi->Speed < 8) {
// Find best match in this frame by MC
err = temporal_filter_find_matching_mb_c
(cpi,
- cpi->frames[alt_ref_index],
- cpi->frames[frame],
- mb_y_offset,
+ cpi->frames[alt_ref_index]->y_buffer + mb_y_offset,
+ cpi->frames[frame]->y_buffer + mb_y_offset,
+ cpi->frames[frame]->y_stride,
THRESH_LOW);
#endif
// Assign higher weight to matching MB if it's error
}
void vp9_temporal_filter_prepare(VP9_COMP *cpi, int distance) {
+ VP9_COMMON *const cm = &cpi->common;
+
int frame = 0;
- int num_frames_backward = 0;
- int num_frames_forward = 0;
int frames_to_blur_backward = 0;
int frames_to_blur_forward = 0;
int frames_to_blur = 0;
int blur_type = cpi->oxcf.arnr_type;
int max_frames = cpi->active_arnr_frames;
- num_frames_backward = distance;
- num_frames_forward = vp9_lookahead_depth(cpi->lookahead)
- - (num_frames_backward + 1);
+ const int num_frames_backward = distance;
+ const int num_frames_forward = vp9_lookahead_depth(cpi->lookahead)
+ - (num_frames_backward + 1);
switch (blur_type) {
case 1:
- /////////////////////////////////////////
// Backward Blur
-
frames_to_blur_backward = num_frames_backward;
if (frames_to_blur_backward >= max_frames)
break;
case 2:
- /////////////////////////////////////////
// Forward Blur
frames_to_blur_forward = num_frames_forward;
case 3:
default:
- /////////////////////////////////////////
// Center Blur
frames_to_blur_forward = num_frames_forward;
frames_to_blur_backward = num_frames_backward;
// Setup scaling factors. Scaling on each of the arnr frames is not supported
vp9_setup_scale_factors_for_frame(&cpi->mb.e_mbd.scale_factor[0],
- &cpi->common.yv12_fb[cpi->common.new_fb_idx],
- cpi->common.width,
- cpi->common.height);
+ cm->yv12_fb[cm->new_fb_idx].y_crop_width,
+ cm->yv12_fb[cm->new_fb_idx].y_crop_height,
+ cm->width, cm->height);
cpi->mb.e_mbd.scale_factor_uv[0] = cpi->mb.e_mbd.scale_factor[0];
// Setup frame pointers, NULL indicates frame not included in filter
vpx_memset(cpi->frames, 0, max_frames * sizeof(YV12_BUFFER_CONFIG *));
for (frame = 0; frame < frames_to_blur; frame++) {
- int which_buffer = start_frame - frame;
+ int which_buffer = start_frame - frame;
struct lookahead_entry *buf = vp9_lookahead_peek(cpi->lookahead,
which_buffer);
cpi->frames[frames_to_blur - 1 - frame] = &buf->img;
}
- temporal_filter_iterate_c(
- cpi,
- frames_to_blur,
- frames_to_blur_backward,
- strength);
+ temporal_filter_iterate_c(cpi, frames_to_blur, frames_to_blur_backward,
+ strength);
}
void configure_arnr_filter(VP9_COMP *cpi, const unsigned int this_frame,