From: Dmitry Kovalev Date: Wed, 8 May 2013 21:11:47 +0000 (-0700) Subject: Eliminating several YV12_BUFFER_CONFIG usages. X-Git-Tag: v1.3.0~1106^2~23^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=81f33bc091bc293831e6f9b0190161eae88c3e82;p=platform%2Fupstream%2Flibvpx.git Eliminating several YV12_BUFFER_CONFIG usages. Change-Id: Ia85b987c935d545920dcae5a6f44136b1a08a008 --- diff --git a/vp9/common/vp9_reconinter.c b/vp9/common/vp9_reconinter.c index 65a9093..0f5cbf4 100644 --- a/vp9/common/vp9_reconinter.c +++ b/vp9/common/vp9_reconinter.c @@ -18,11 +18,8 @@ #include "vp9/common/vp9_reconintra.h" 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) { - int other_h = other->y_crop_height; - int other_w = other->y_crop_width; - scale->x_num = other_w; scale->x_den = this_w; scale->x_offset_q4 = 0; // calculated per-mb diff --git a/vp9/common/vp9_reconinter.h b/vp9/common/vp9_reconinter.h index 3c04779..f34ec49 100644 --- a/vp9/common/vp9_reconinter.h +++ b/vp9/common/vp9_reconinter.h @@ -35,7 +35,7 @@ void vp9_setup_interp_filters(MACROBLOCKD *xd, 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, @@ -67,14 +67,11 @@ static int unscaled_value(int val, const struct scale_factors *scale) { 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, diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c index f244358..3a8f3e0 100644 --- a/vp9/decoder/vp9_decodframe.c +++ b/vp9/decoder/vp9_decodframe.c @@ -1014,7 +1014,9 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { if (mapped_ref >= NUM_YV12_BUFFERS) memset(sf, 0, sizeof(*sf)); else - vp9_setup_scale_factors_for_frame(sf, fb, pc->width, pc->height); + vp9_setup_scale_factors_for_frame(sf, + fb->y_crop_width, fb->y_crop_height, + pc->width, pc->height); } // Read the sign bias for each reference frame buffer. diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c index 5fdbbef..774bc5f 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -3851,12 +3851,12 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags, 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); diff --git a/vp9/encoder/vp9_temporal_filter.c b/vp9/encoder/vp9_temporal_filter.c index d272cbb..12837a5 100644 --- a/vp9/encoder/vp9_temporal_filter.c +++ b/vp9/encoder/vp9_temporal_filter.c @@ -118,9 +118,9 @@ void vp9_temporal_filter_apply_c(uint8_t *frame1, #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; @@ -141,10 +141,10 @@ static int temporal_filter_find_matching_mb_c(VP9_COMP *cpi, 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) { @@ -260,9 +260,9 @@ static void temporal_filter_iterate_c(VP9_COMP *cpi, // 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 @@ -360,10 +360,10 @@ static void temporal_filter_iterate_c(VP9_COMP *cpi, } 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; @@ -373,15 +373,13 @@ void vp9_temporal_filter_prepare(VP9_COMP *cpi, int distance) { 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) @@ -391,7 +389,6 @@ void vp9_temporal_filter_prepare(VP9_COMP *cpi, int distance) { break; case 2: - ///////////////////////////////////////// // Forward Blur frames_to_blur_forward = num_frames_forward; @@ -404,7 +401,6 @@ void vp9_temporal_filter_prepare(VP9_COMP *cpi, int distance) { case 3: default: - ///////////////////////////////////////// // Center Blur frames_to_blur_forward = num_frames_forward; frames_to_blur_backward = num_frames_backward; @@ -444,25 +440,22 @@ void vp9_temporal_filter_prepare(VP9_COMP *cpi, int distance) { // 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,