From: Dmitry Kovalev Date: Thu, 24 Oct 2013 19:20:35 +0000 (-0700) Subject: Adding get_frame_new_buffer() function to replace duplicated code. X-Git-Tag: v1.3.0~137^2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=237ce8724ad933cc6f003fa13dceca9787698600;p=platform%2Fupstream%2Flibvpx.git Adding get_frame_new_buffer() function to replace duplicated code. Change-Id: I6e0e19231a48364c1de7dfab730b121ab227f111 --- diff --git a/vp9/common/vp9_onyxc_int.h b/vp9/common/vp9_onyxc_int.h index 603c996..41fa6b3 100644 --- a/vp9/common/vp9_onyxc_int.h +++ b/vp9/common/vp9_onyxc_int.h @@ -224,6 +224,10 @@ static YV12_BUFFER_CONFIG *get_frame_ref_buffer(VP9_COMMON *cm, int ref) { return &cm->yv12_fb[cm->active_ref_idx[ref]]; } +static YV12_BUFFER_CONFIG *get_frame_new_buffer(VP9_COMMON *cm) { + return &cm->yv12_fb[cm->new_fb_idx]; +} + static int get_free_fb(VP9_COMMON *cm) { int i; for (i = 0; i < NUM_YV12_BUFFERS; i++) diff --git a/vp9/decoder/vp9_decodframe.c b/vp9/decoder/vp9_decodframe.c index d4dcfbc..f2cdd5a 100644 --- a/vp9/decoder/vp9_decodframe.c +++ b/vp9/decoder/vp9_decodframe.c @@ -317,7 +317,7 @@ static void set_offsets(VP9D_COMP *pbi, BLOCK_SIZE bsize, // as they are always compared to values that are in 1/8th pel units set_mi_row_col(cm, xd, mi_row, bh, mi_col, bw); - setup_dst_planes(xd, &cm->yv12_fb[cm->new_fb_idx], mi_row, mi_col); + setup_dst_planes(xd, get_frame_new_buffer(cm), mi_row, mi_col); } static void set_ref(VP9_COMMON *const cm, MACROBLOCKD *const xd, @@ -650,7 +650,7 @@ static void apply_frame_size(VP9D_COMP *pbi, int width, int height) { vp9_update_frame_size(cm); } - vp9_realloc_frame_buffer(&cm->yv12_fb[cm->new_fb_idx], cm->width, cm->height, + vp9_realloc_frame_buffer(get_frame_new_buffer(cm), cm->width, cm->height, cm->subsampling_x, cm->subsampling_y, VP9BORDERINPIXELS); } @@ -694,14 +694,13 @@ static void decode_tile(VP9D_COMP *pbi, vp9_reader *r, int tile_col) { const int num_threads = pbi->oxcf.max_threads; VP9_COMMON *const cm = &pbi->common; int mi_row, mi_col; - YV12_BUFFER_CONFIG *const fb = &cm->yv12_fb[cm->new_fb_idx]; MACROBLOCKD *xd = &pbi->mb; xd->mi_stream = pbi->mi_streams[tile_col]; if (pbi->do_loopfilter_inline) { LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1; - lf_data->frame_buffer = fb; + lf_data->frame_buffer = get_frame_new_buffer(cm); lf_data->cm = cm; lf_data->xd = pbi->mb; lf_data->stop = 0; @@ -1093,7 +1092,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { cm, error_handler }; const size_t first_partition_size = read_uncompressed_header(pbi, &rb); const int keyframe = cm->frame_type == KEY_FRAME; - YV12_BUFFER_CONFIG *new_fb = &cm->yv12_fb[cm->new_fb_idx]; + YV12_BUFFER_CONFIG *new_fb = get_frame_new_buffer(cm); const int tile_cols = 1 << cm->log2_tile_cols; int tile_col; diff --git a/vp9/decoder/vp9_onyxd_if.c b/vp9/decoder/vp9_onyxd_if.c index ae4e07e..03456b8 100644 --- a/vp9/decoder/vp9_onyxd_if.c +++ b/vp9/decoder/vp9_onyxd_if.c @@ -263,7 +263,7 @@ static void swap_frame_buffers(VP9D_COMP *pbi) { ++ref_index; } - cm->frame_to_show = &cm->yv12_fb[cm->new_fb_idx]; + cm->frame_to_show = get_frame_new_buffer(cm); cm->fb_idx_ref_cnt[cm->new_fb_idx]--; // Invalidate these references until the next frame starts. diff --git a/vp9/encoder/vp9_encodeframe.c b/vp9/encoder/vp9_encodeframe.c index 57a0b34..d66c813 100644 --- a/vp9/encoder/vp9_encodeframe.c +++ b/vp9/encoder/vp9_encodeframe.c @@ -282,7 +282,7 @@ static void build_activity_map(VP9_COMP *cpi) { VP9_COMMON * const cm = &cpi->common; #if ALT_ACT_MEASURE - YV12_BUFFER_CONFIG *new_yv12 = &cm->yv12_fb[cm->new_fb_idx]; + YV12_BUFFER_CONFIG *new_yv12 = get_frame_new_buffer(cm); int recon_yoffset; int recon_y_stride = new_yv12->y_stride; #endif @@ -1836,7 +1836,7 @@ static void init_encode_frame_mb_context(VP9_COMP *cpi) { // TODO(jkoleszar): are these initializations required? setup_pre_planes(xd, 0, &cm->yv12_fb[cm->ref_frame_map[cpi->lst_fb_idx]], 0, 0, NULL); - setup_dst_planes(xd, &cm->yv12_fb[cm->new_fb_idx], 0, 0); + setup_dst_planes(xd, get_frame_new_buffer(cm), 0, 0); setup_block_dptrs(&x->e_mbd, cm->subsampling_x, cm->subsampling_y); diff --git a/vp9/encoder/vp9_firstpass.c b/vp9/encoder/vp9_firstpass.c index caf4162..dc323a2 100644 --- a/vp9/encoder/vp9_firstpass.c +++ b/vp9/encoder/vp9_firstpass.c @@ -486,8 +486,8 @@ void vp9_first_pass(VP9_COMP *cpi) { const int lst_yv12_idx = cm->ref_frame_map[cpi->lst_fb_idx]; const int gld_yv12_idx = cm->ref_frame_map[cpi->gld_fb_idx]; YV12_BUFFER_CONFIG *const lst_yv12 = &cm->yv12_fb[lst_yv12_idx]; - YV12_BUFFER_CONFIG *const new_yv12 = &cm->yv12_fb[cm->new_fb_idx]; YV12_BUFFER_CONFIG *const gld_yv12 = &cm->yv12_fb[gld_yv12_idx]; + YV12_BUFFER_CONFIG *const new_yv12 = get_frame_new_buffer(cm); const int recon_y_stride = lst_yv12->y_stride; const int recon_uv_stride = lst_yv12->uv_stride; int64_t intra_error = 0; diff --git a/vp9/encoder/vp9_mbgraph.c b/vp9/encoder/vp9_mbgraph.c index 6443631..7b605b2 100644 --- a/vp9/encoder/vp9_mbgraph.c +++ b/vp9/encoder/vp9_mbgraph.c @@ -194,8 +194,8 @@ static void update_mbgraph_mb_stats 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, diff --git a/vp9/encoder/vp9_onyx_if.c b/vp9/encoder/vp9_onyx_if.c index afd6fc5..0be170f 100644 --- a/vp9/encoder/vp9_onyx_if.c +++ b/vp9/encoder/vp9_onyx_if.c @@ -2669,8 +2669,7 @@ static void output_frame_level_debug_stats(VP9_COMP *cpi) { vp9_clear_system_state(); // __asm emms; - recon_err = vp9_calc_ss_err(cpi->Source, - &cm->yv12_fb[cm->new_fb_idx]); + recon_err = vp9_calc_ss_err(cpi->Source, get_frame_new_buffer(cm)); if (cpi->twopass.total_left_stats.coded_error != 0.0) fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d %10d" @@ -3169,8 +3168,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, // Special case handling for forced key frames if ((cm->frame_type == KEY_FRAME) && cpi->this_key_frame_forced) { int last_q = q; - int kf_err = vp9_calc_ss_err(cpi->Source, - &cm->yv12_fb[cm->new_fb_idx]); + int kf_err = vp9_calc_ss_err(cpi->Source, get_frame_new_buffer(cm)); int high_err_target = cpi->ambient_err; int low_err_target = cpi->ambient_err >> 1; @@ -3306,14 +3304,13 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, // fixed interval. Note the reconstruction error if it is the frame before // the force key frame if (cpi->next_key_frame_forced && (cpi->twopass.frames_to_key == 0)) { - cpi->ambient_err = vp9_calc_ss_err(cpi->Source, - &cm->yv12_fb[cm->new_fb_idx]); + cpi->ambient_err = vp9_calc_ss_err(cpi->Source, get_frame_new_buffer(cm)); } if (cm->frame_type == KEY_FRAME) cpi->refresh_last_frame = 1; - cm->frame_to_show = &cm->yv12_fb[cm->new_fb_idx]; + cm->frame_to_show = get_frame_new_buffer(cm); #if WRITE_RECON_BUFFER if (cm->show_frame) @@ -3912,7 +3909,7 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags, cm->frame_flags = *frame_flags; // Reset the frame pointers to the current frame size - vp9_realloc_frame_buffer(&cm->yv12_fb[cm->new_fb_idx], + vp9_realloc_frame_buffer(get_frame_new_buffer(cm), cm->width, cm->height, cm->subsampling_x, cm->subsampling_y, VP9BORDERINPIXELS); diff --git a/vp9/encoder/vp9_temporal_filter.c b/vp9/encoder/vp9_temporal_filter.c index 15aef5f..2cace03 100644 --- a/vp9/encoder/vp9_temporal_filter.c +++ b/vp9/encoder/vp9_temporal_filter.c @@ -438,8 +438,8 @@ 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(&scale, &scale_comm, - cm->yv12_fb[cm->new_fb_idx].y_crop_width, - cm->yv12_fb[cm->new_fb_idx].y_crop_height, + get_frame_new_buffer(cm)->y_crop_width, + get_frame_new_buffer(cm)->y_crop_height, cm->width, cm->height); // Setup frame pointers, NULL indicates frame not included in filter