Commit 237ce872 authored by Dmitry Kovalev's avatar Dmitry Kovalev
Browse files

Adding get_frame_new_buffer() function to replace duplicated code.

Change-Id: I6e0e19231a48364c1de7dfab730b121ab227f111
parent 8a74a9e2
...@@ -224,6 +224,10 @@ static YV12_BUFFER_CONFIG *get_frame_ref_buffer(VP9_COMMON *cm, int ref) { ...@@ -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]]; 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) { static int get_free_fb(VP9_COMMON *cm) {
int i; int i;
for (i = 0; i < NUM_YV12_BUFFERS; i++) for (i = 0; i < NUM_YV12_BUFFERS; i++)
......
...@@ -317,7 +317,7 @@ static void set_offsets(VP9D_COMP *pbi, BLOCK_SIZE bsize, ...@@ -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 // 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); 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, 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) { ...@@ -650,7 +650,7 @@ static void apply_frame_size(VP9D_COMP *pbi, int width, int height) {
vp9_update_frame_size(cm); 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, cm->subsampling_x, cm->subsampling_y,
VP9BORDERINPIXELS); VP9BORDERINPIXELS);
} }
...@@ -694,14 +694,13 @@ static void decode_tile(VP9D_COMP *pbi, vp9_reader *r, int tile_col) { ...@@ -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; const int num_threads = pbi->oxcf.max_threads;
VP9_COMMON *const cm = &pbi->common; VP9_COMMON *const cm = &pbi->common;
int mi_row, mi_col; int mi_row, mi_col;
YV12_BUFFER_CONFIG *const fb = &cm->yv12_fb[cm->new_fb_idx];
MACROBLOCKD *xd = &pbi->mb; MACROBLOCKD *xd = &pbi->mb;
xd->mi_stream = pbi->mi_streams[tile_col]; xd->mi_stream = pbi->mi_streams[tile_col];
if (pbi->do_loopfilter_inline) { if (pbi->do_loopfilter_inline) {
LFWorkerData *const lf_data = (LFWorkerData*)pbi->lf_worker.data1; 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->cm = cm;
lf_data->xd = pbi->mb; lf_data->xd = pbi->mb;
lf_data->stop = 0; lf_data->stop = 0;
...@@ -1093,7 +1092,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) { ...@@ -1093,7 +1092,7 @@ int vp9_decode_frame(VP9D_COMP *pbi, const uint8_t **p_data_end) {
cm, error_handler }; cm, error_handler };
const size_t first_partition_size = read_uncompressed_header(pbi, &rb); const size_t first_partition_size = read_uncompressed_header(pbi, &rb);
const int keyframe = cm->frame_type == KEY_FRAME; 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; const int tile_cols = 1 << cm->log2_tile_cols;
int tile_col; int tile_col;
......
...@@ -263,7 +263,7 @@ static void swap_frame_buffers(VP9D_COMP *pbi) { ...@@ -263,7 +263,7 @@ static void swap_frame_buffers(VP9D_COMP *pbi) {
++ref_index; ++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]--; cm->fb_idx_ref_cnt[cm->new_fb_idx]--;
// Invalidate these references until the next frame starts. // Invalidate these references until the next frame starts.
......
...@@ -282,7 +282,7 @@ static void build_activity_map(VP9_COMP *cpi) { ...@@ -282,7 +282,7 @@ static void build_activity_map(VP9_COMP *cpi) {
VP9_COMMON * const cm = &cpi->common; VP9_COMMON * const cm = &cpi->common;
#if ALT_ACT_MEASURE #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_yoffset;
int recon_y_stride = new_yv12->y_stride; int recon_y_stride = new_yv12->y_stride;
#endif #endif
...@@ -1836,7 +1836,7 @@ static void init_encode_frame_mb_context(VP9_COMP *cpi) { ...@@ -1836,7 +1836,7 @@ static void init_encode_frame_mb_context(VP9_COMP *cpi) {
// TODO(jkoleszar): are these initializations required? // TODO(jkoleszar): are these initializations required?
setup_pre_planes(xd, 0, &cm->yv12_fb[cm->ref_frame_map[cpi->lst_fb_idx]], setup_pre_planes(xd, 0, &cm->yv12_fb[cm->ref_frame_map[cpi->lst_fb_idx]],
0, 0, NULL); 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); setup_block_dptrs(&x->e_mbd, cm->subsampling_x, cm->subsampling_y);
......
...@@ -486,8 +486,8 @@ void vp9_first_pass(VP9_COMP *cpi) { ...@@ -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 lst_yv12_idx = cm->ref_frame_map[cpi->lst_fb_idx];
const int gld_yv12_idx = cm->ref_frame_map[cpi->gld_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 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 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_y_stride = lst_yv12->y_stride;
const int recon_uv_stride = lst_yv12->uv_stride; const int recon_uv_stride = lst_yv12->uv_stride;
int64_t intra_error = 0; int64_t intra_error = 0;
......
...@@ -194,8 +194,8 @@ static void update_mbgraph_mb_stats ...@@ -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.buf = buf->y_buffer + mb_y_offset;
x->plane[0].src.stride = buf->y_stride; 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.buf = get_frame_new_buffer(cm)->y_buffer + mb_y_offset;
xd->plane[0].dst.stride = cm->yv12_fb[cm->new_fb_idx].y_stride; xd->plane[0].dst.stride = get_frame_new_buffer(cm)->y_stride;
// do intra 16x16 prediction // do intra 16x16 prediction
intra_error = find_best_16x16_intra(cpi, mb_y_offset, intra_error = find_best_16x16_intra(cpi, mb_y_offset,
......
...@@ -2669,8 +2669,7 @@ static void output_frame_level_debug_stats(VP9_COMP *cpi) { ...@@ -2669,8 +2669,7 @@ static void output_frame_level_debug_stats(VP9_COMP *cpi) {
vp9_clear_system_state(); // __asm emms; vp9_clear_system_state(); // __asm emms;
recon_err = vp9_calc_ss_err(cpi->Source, recon_err = vp9_calc_ss_err(cpi->Source, get_frame_new_buffer(cm));
&cm->yv12_fb[cm->new_fb_idx]);
if (cpi->twopass.total_left_stats.coded_error != 0.0) if (cpi->twopass.total_left_stats.coded_error != 0.0)
fprintf(f, "%10d %10d %10d %10d %10d %10d %10d %10d %10d" 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, ...@@ -3169,8 +3168,7 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi,
// Special case handling for forced key frames // Special case handling for forced key frames
if ((cm->frame_type == KEY_FRAME) && cpi->this_key_frame_forced) { if ((cm->frame_type == KEY_FRAME) && cpi->this_key_frame_forced) {
int last_q = q; int last_q = q;
int kf_err = vp9_calc_ss_err(cpi->Source, int kf_err = vp9_calc_ss_err(cpi->Source, get_frame_new_buffer(cm));
&cm->yv12_fb[cm->new_fb_idx]);
int high_err_target = cpi->ambient_err; int high_err_target = cpi->ambient_err;
int low_err_target = cpi->ambient_err >> 1; int low_err_target = cpi->ambient_err >> 1;
...@@ -3306,14 +3304,13 @@ static void encode_frame_to_data_rate(VP9_COMP *cpi, ...@@ -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 // fixed interval. Note the reconstruction error if it is the frame before
// the force key frame // the force key frame
if (cpi->next_key_frame_forced && (cpi->twopass.frames_to_key == 0)) { if (cpi->next_key_frame_forced && (cpi->twopass.frames_to_key == 0)) {
cpi->ambient_err = vp9_calc_ss_err(cpi->Source, cpi->ambient_err = vp9_calc_ss_err(cpi->Source, get_frame_new_buffer(cm));
&cm->yv12_fb[cm->new_fb_idx]);
} }
if (cm->frame_type == KEY_FRAME) if (cm->frame_type == KEY_FRAME)
cpi->refresh_last_frame = 1; 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 WRITE_RECON_BUFFER
if (cm->show_frame) if (cm->show_frame)
...@@ -3912,7 +3909,7 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags, ...@@ -3912,7 +3909,7 @@ int vp9_get_compressed_data(VP9_PTR ptr, unsigned int *frame_flags,
cm->frame_flags = *frame_flags; cm->frame_flags = *frame_flags;
// Reset the frame pointers to the current frame size // 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->width, cm->height,
cm->subsampling_x, cm->subsampling_y, cm->subsampling_x, cm->subsampling_y,
VP9BORDERINPIXELS); VP9BORDERINPIXELS);
......
...@@ -438,8 +438,8 @@ void vp9_temporal_filter_prepare(VP9_COMP *cpi, int distance) { ...@@ -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 // Setup scaling factors. Scaling on each of the arnr frames is not supported
vp9_setup_scale_factors_for_frame(&scale, &scale_comm, vp9_setup_scale_factors_for_frame(&scale, &scale_comm,
cm->yv12_fb[cm->new_fb_idx].y_crop_width, get_frame_new_buffer(cm)->y_crop_width,
cm->yv12_fb[cm->new_fb_idx].y_crop_height, get_frame_new_buffer(cm)->y_crop_height,
cm->width, cm->height); cm->width, cm->height);
// Setup frame pointers, NULL indicates frame not included in filter // Setup frame pointers, NULL indicates frame not included in filter
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment