On 12/06/2016 02:02 AM, Mark Thompson wrote:
Signed-off-by: Mark Thompson<s...@jkqxz.net>
Good work. This patch looks good to me. Add: Reviewed-by: Zhao Yakui <yakui.z...@intel.com> Thanks
--- Tested on Kaby Lake. Someone who has access to the manuals should make sure that the framerate numerator/denominator actually works there as I am guessing it does. Removes the frame_rate field in struct gen9_vp9_brc_curbe_param, because there is no longer a sensible value to set it to (and also it's not read anywhere). If it is needed, it wants to be replaced by the two parts of the fraction. src/gen9_vp9_encoder.c | 45 ++++++++++++++++++++++++++++++++++----------- src/gen9_vp9_encoder.h | 4 ++-- 2 files changed, 36 insertions(+), 13 deletions(-) diff --git a/src/gen9_vp9_encoder.c b/src/gen9_vp9_encoder.c index 3ea1537..8ff1b9b 100644 --- a/src/gen9_vp9_encoder.c +++ b/src/gen9_vp9_encoder.c @@ -1201,8 +1201,8 @@ void gen9_vp9_set_curbe_brc(VADriverContextP ctx, VP9_BRC_KBPS; cmd->dw9.min_bit_rate = (vp9_state->min_bit_rate + VP9_BRC_KBPS - 1) / VP9_BRC_KBPS * VP9_BRC_KBPS; - cmd->dw10.frame_ratem = vp9_state->frame_rate; - cmd->dw11.frame_rated = 1; + cmd->dw10.frame_ratem = vp9_state->frame_rate_num; + cmd->dw11.frame_rated = vp9_state->frame_rate_den; cmd->dw14.avbr_accuracy = 30; cmd->dw14.avbr_convergence = 150; @@ -1235,7 +1235,7 @@ void gen9_vp9_set_curbe_brc(VADriverContextP ctx, cmd->dw17.enable_dynamic_scaling = vp9_state->dys_in_use; cmd->dw17.brc_overshoot_cbr_pct = 150; - dInputBitsPerFrame = (double)(cmd->dw8.max_bit_rate) / (vp9_state->frame_rate); + dInputBitsPerFrame = ((double)cmd->dw8.max_bit_rate * vp9_state->frame_rate_den) / (vp9_state->frame_rate_num); dbps_ratio = dInputBitsPerFrame / ((double)(vp9_state->vbv_buffer_size_in_bit) / 30); if (dbps_ratio< 0.1) dbps_ratio = 0.1; @@ -1423,7 +1423,6 @@ gen9_vp9_brc_init_reset_kernel(VADriverContextP ctx, brc_initreset_curbe.initbrc = !vp9_state->brc_inited; brc_initreset_curbe.mbbrc_enabled = 0; brc_initreset_curbe.ref_frame_flag = vp9_state->ref_frame_flag; - brc_initreset_curbe.frame_rate = vp9_state->frame_rate; vme_context->pfn_set_curbe_brc(ctx, encode_state, gpe_context, @@ -1523,7 +1522,6 @@ gen9_vp9_brc_intra_dist_kernel(VADriverContextP ctx, brc_intra_dist_curbe.initbrc = !vp9_state->brc_inited; brc_intra_dist_curbe.mbbrc_enabled = 0; brc_intra_dist_curbe.ref_frame_flag = vp9_state->ref_frame_flag; - brc_intra_dist_curbe.frame_rate = vp9_state->frame_rate; vme_context->pfn_set_curbe_brc(ctx, encode_state, gpe_context, @@ -3964,10 +3962,17 @@ gen9_encode_vp9_check_parameter(VADriverContextP ctx, encode_state->misc_param[VAEncMiscParameterTypeFrameRate][0]->buffer; misc_param_fr = (VAEncMiscParameterFrameRate *)misc_param->data; - vp9_state->frame_rate = misc_param_fr->framerate; + if (misc_param_fr->framerate& 0xffff0000) { + vp9_state->frame_rate_num = misc_param_fr->framerate>> 16& 0xffff; + vp9_state->frame_rate_den = misc_param_fr->framerate& 0xffff; + } else { + vp9_state->frame_rate_num = misc_param_fr->framerate; + vp9_state->frame_rate_den = 1; + } } else { /* Assign the default frame rate */ - vp9_state->frame_rate = 30; + vp9_state->frame_rate_num = 30; + vp9_state->frame_rate_den = 1; } /* RC misc will override HRD parameter */ @@ -3999,10 +4004,17 @@ gen9_encode_vp9_check_parameter(VADriverContextP ctx, encode_state->misc_param[VAEncMiscParameterTypeFrameRate][0]->buffer; misc_param_fr = (VAEncMiscParameterFrameRate *)misc_param->data; - vp9_state->frame_rate = misc_param_fr->framerate; + if (misc_param_fr->framerate& 0xffff0000) { + vp9_state->frame_rate_num = misc_param_fr->framerate>> 16& 0xffff; + vp9_state->frame_rate_den = misc_param_fr->framerate& 0xffff; + } else { + vp9_state->frame_rate_num = misc_param_fr->framerate; + vp9_state->frame_rate_den = 1; + } } else { /* Assign the default frame rate */ - vp9_state->frame_rate = 30; + vp9_state->frame_rate_num = 30; + vp9_state->frame_rate_den = 1; } if (vp9_state->brc_flag_check& VP9_BRC_RC) { @@ -4031,14 +4043,25 @@ gen9_encode_vp9_check_parameter(VADriverContextP ctx, /* If the parameter related with RC is changed. Reset BRC */ if (vp9_state->brc_flag_check& VP9_BRC_FR) { VAEncMiscParameterFrameRate *misc_param_fr; + uint32_t num, den; misc_param = (VAEncMiscParameterBuffer *) encode_state->misc_param[VAEncMiscParameterTypeFrameRate][0]->buffer; misc_param_fr = (VAEncMiscParameterFrameRate *)misc_param->data; - if (vp9_state->frame_rate != misc_param_fr->framerate) { + if (misc_param_fr->framerate& 0xffff0000) { + num = misc_param_fr->framerate>> 16& 0xffff; + den = misc_param_fr->framerate& 0xffff; + } else { + num = misc_param_fr->framerate; + den = 1; + } + + if (vp9_state->frame_rate_num != num || + vp9_state->frame_rate_den != den) { vp9_state->brc_reset = 1; - vp9_state->frame_rate = misc_param_fr->framerate; + vp9_state->frame_rate_num = num; + vp9_state->frame_rate_den = den; } } diff --git a/src/gen9_vp9_encoder.h b/src/gen9_vp9_encoder.h index ad2d875..260b8d5 100644 --- a/src/gen9_vp9_encoder.h +++ b/src/gen9_vp9_encoder.h @@ -1552,7 +1552,6 @@ struct gen9_vp9_brc_curbe_param int32_t brc_num_pak_passes; bool multi_ref_qp_check; int16_t frame_number; - int32_t frame_rate; VP9_MEDIA_STATE_TYPE media_state_type; }; @@ -1925,7 +1924,8 @@ struct gen9_vp9_state { unsigned long init_vbv_buffer_fullness_in_bit; unsigned long vbv_buffer_size_in_bit; int frame_number; - uint32_t frame_rate; + uint32_t frame_rate_num; + uint32_t frame_rate_den; uint8_t ref_frame_flag; uint8_t dys_ref_frame_flag; uint8_t picture_coding_type;
_______________________________________________ Libva mailing list Libva@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libva