diff options
author | Zhao Yakui <yakui.zhao@intel.com> | 2013-01-14 10:45:14 +0800 |
---|---|---|
committer | Xiang, Haihao <haihao.xiang@intel.com> | 2013-01-17 13:08:40 +0800 |
commit | 54845cc2557f224ebb0fd66ce3629daf63aad021 (patch) | |
tree | 65ddd10cdd507c6bbafa8a8501ad532bea916c5f /src/gen6_mfc_common.c | |
parent | 74194dfb52c87bc50289ff0c2714480e3c52fd35 (diff) | |
download | vaapi-intel-driver-54845cc2557f224ebb0fd66ce3629daf63aad021.tar.gz vaapi-intel-driver-54845cc2557f224ebb0fd66ce3629daf63aad021.tar.bz2 vaapi-intel-driver-54845cc2557f224ebb0fd66ce3629daf63aad021.zip |
Use the common scoreboard code on Ivy/Haswell to remove the duplicated code
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Diffstat (limited to 'src/gen6_mfc_common.c')
-rw-r--r-- | src/gen6_mfc_common.c | 171 |
1 files changed, 171 insertions, 0 deletions
diff --git a/src/gen6_mfc_common.c b/src/gen6_mfc_common.c index 329058e..1796003 100644 --- a/src/gen6_mfc_common.c +++ b/src/gen6_mfc_common.c @@ -818,3 +818,174 @@ void intel_vme_update_mbmv_cost(VADriverContextP ctx, } } } + + +#define MB_SCOREBOARD_A (1 << 0) +#define MB_SCOREBOARD_B (1 << 1) +#define MB_SCOREBOARD_C (1 << 2) +void +gen7_vme_scoreboard_init(VADriverContextP ctx, struct gen6_vme_context *vme_context) +{ + vme_context->gpe_context.vfe_desc5.scoreboard0.enable = 1; + vme_context->gpe_context.vfe_desc5.scoreboard0.type = SCOREBOARD_STALLING; + vme_context->gpe_context.vfe_desc5.scoreboard0.mask = (MB_SCOREBOARD_A | + MB_SCOREBOARD_B | + MB_SCOREBOARD_C); + + /* In VME prediction the current mb depends on the neighbour + * A/B/C macroblock. So the left/up/up-right dependency should + * be considered. + */ + vme_context->gpe_context.vfe_desc6.scoreboard1.delta_x0 = -1; + vme_context->gpe_context.vfe_desc6.scoreboard1.delta_y0 = 0; + vme_context->gpe_context.vfe_desc6.scoreboard1.delta_x1 = 0; + vme_context->gpe_context.vfe_desc6.scoreboard1.delta_y1 = -1; + vme_context->gpe_context.vfe_desc6.scoreboard1.delta_x2 = 1; + vme_context->gpe_context.vfe_desc6.scoreboard1.delta_y2 = -1; + + vme_context->gpe_context.vfe_desc7.dword = 0; + return; +} + +/* check whether the mb of (x_index, y_index) is out of bound */ +static inline int loop_in_bounds(int x_index, int y_index, int first_mb, int num_mb, int mb_width, int mb_height) +{ + int mb_index; + if (x_index < 0 || x_index >= mb_width) + return -1; + if (y_index < 0 || y_index >= mb_height) + return -1; + + mb_index = y_index * mb_width + x_index; + if (mb_index < first_mb || mb_index > (first_mb + num_mb)) + return -1; + return 0; +} + +void +gen7_vme_walker_fill_vme_batchbuffer(VADriverContextP ctx, + struct encode_state *encode_state, + int mb_width, int mb_height, + int kernel, + int transform_8x8_mode_flag, + struct intel_encoder_context *encoder_context) +{ + struct gen6_vme_context *vme_context = encoder_context->vme_context; + int mb_x = 0, mb_y = 0; + int mb_row; + int s; + unsigned int *command_ptr; + int temp; + + +#define USE_SCOREBOARD (1 << 21) + + dri_bo_map(vme_context->vme_batchbuffer.bo, 1); + command_ptr = vme_context->vme_batchbuffer.bo->virtual; + + for (s = 0; s < encode_state->num_slice_params_ext; s++) { + VAEncSliceParameterBufferH264 *pSliceParameter = (VAEncSliceParameterBufferH264 *)encode_state->slice_params_ext[s]->buffer; + int first_mb = pSliceParameter->macroblock_address; + int num_mb = pSliceParameter->num_macroblocks; + unsigned int mb_intra_ub, score_dep; + int x_outer, y_outer, x_inner, y_inner; + + x_outer = first_mb % mb_width; + y_outer = first_mb / mb_width; + mb_row = y_outer; + + for (; x_outer < (mb_width -2 ) && !loop_in_bounds(x_outer, y_outer, first_mb, num_mb, mb_width, mb_height); ) { + x_inner = x_outer; + y_inner = y_outer; + for (; !loop_in_bounds(x_inner, y_inner, first_mb, num_mb, mb_width, mb_height);) { + mb_intra_ub = 0; + score_dep = 0; + if (x_inner != 0) { + mb_intra_ub |= INTRA_PRED_AVAIL_FLAG_AE; + score_dep |= MB_SCOREBOARD_A; + } + if (y_inner != mb_row) { + mb_intra_ub |= INTRA_PRED_AVAIL_FLAG_B; + score_dep |= MB_SCOREBOARD_B; + if (x_inner != 0) + mb_intra_ub |= INTRA_PRED_AVAIL_FLAG_D; + if (x_inner != (mb_width -1)) { + mb_intra_ub |= INTRA_PRED_AVAIL_FLAG_C; + score_dep |= MB_SCOREBOARD_C; + } + } + + *command_ptr++ = (CMD_MEDIA_OBJECT | (8 - 2)); + *command_ptr++ = kernel; + *command_ptr++ = USE_SCOREBOARD; + /* Indirect data */ + *command_ptr++ = 0; + /* the (X, Y) term of scoreboard */ + *command_ptr++ = ((y_inner << 16) | x_inner); + *command_ptr++ = score_dep; + /*inline data */ + *command_ptr++ = (mb_width << 16 | y_inner << 8 | x_inner); + *command_ptr++ = ((1 << 18) | (1 << 16) | transform_8x8_mode_flag | (mb_intra_ub << 8)); + x_inner -= 2; + y_inner += 1; + } + x_outer += 1; + } + + x_outer = mb_width - 2; + y_outer = first_mb / mb_width; + temp = 0; + for (;!loop_in_bounds(x_outer, y_outer, first_mb, num_mb, mb_width, mb_height); ) { + y_inner = y_outer; + x_inner = x_outer; + for (; !loop_in_bounds(x_inner, y_inner, first_mb, num_mb, mb_width, mb_height);) { + mb_intra_ub = 0; + score_dep = 0; + if (x_inner != 0) { + mb_intra_ub |= INTRA_PRED_AVAIL_FLAG_AE; + score_dep |= MB_SCOREBOARD_A; + } + if (y_inner != mb_row) { + mb_intra_ub |= INTRA_PRED_AVAIL_FLAG_B; + score_dep |= MB_SCOREBOARD_B; + if (x_inner != 0) + mb_intra_ub |= INTRA_PRED_AVAIL_FLAG_D; + + if (x_inner != (mb_width -1)) { + mb_intra_ub |= INTRA_PRED_AVAIL_FLAG_C; + score_dep |= MB_SCOREBOARD_C; + } + } + + *command_ptr++ = (CMD_MEDIA_OBJECT | (8 - 2)); + *command_ptr++ = kernel; + *command_ptr++ = USE_SCOREBOARD; + /* Indirect data */ + *command_ptr++ = 0; + /* the (X, Y) term of scoreboard */ + *command_ptr++ = ((y_inner << 16) | x_inner); + *command_ptr++ = score_dep; + /*inline data */ + *command_ptr++ = (mb_width << 16 | y_inner << 8 | x_inner); + *command_ptr++ = ((1 << 18) | (1 << 16) | transform_8x8_mode_flag | (mb_intra_ub << 8)); + + x_inner -= 2; + y_inner += 1; + } + temp++; + if (temp == 2) { + y_outer += 1; + temp = 0; + x_outer = mb_width - 2; + } else { + x_outer++; + } + } + } + + *command_ptr++ = 0; + *command_ptr++ = MI_BATCH_BUFFER_END; + + dri_bo_unmap(vme_context->vme_batchbuffer.bo); +} + |