-----Original Message----- From: Mark Thompson [mailto:s...@jkqxz.net] Sent: Thursday, January 19, 2017 7:25 AM To: libva@lists.freedesktop.org; Qu, Pengfei <pengfei...@intel.com> Subject: Re: [Libva] [PATCH v1 7/9] ENC: add VME pipeline for AVC encoder
On 13/01/17 09:24, Pengfei Qu wrote: > VME pipeline: > add resource and surface allocation and free function add init table > for frame mbbrc update add scaling kernel for AVC encoder add BRC init > reset kernel for AVC RC logic add BRC frame update-kernel for AVC RC > logic add BRC MB level update kernel for AVC RC logic add REF frame QA > caculation and MB level const data add MBENC kernel for AVC encoder > add ME kernel for AVC encoder add WP/SFD kernel for AVC encoder add > kernel init/destroy function for AVC encoder add kernel related > parameter check function for AVC add VME pipeline init prepare/run > function for AVC encoder > > Reviewed-by: Sean V Kelley<sea...@posteo.de> > Signed-off-by: Pengfei Qu <pengfei...@intel.com> > --- > src/gen9_avc_encoder.c | 5745 > ++++++++++++++++++++++++++++++++++++++++++++++++ > 1 file changed, 5745 insertions(+) > create mode 100755 src/gen9_avc_encoder.c > > diff --git a/src/gen9_avc_encoder.c b/src/gen9_avc_encoder.c new file > mode 100755 index 0000000..5caa9f4 > --- /dev/null > +++ b/src/gen9_avc_encoder.c > ... > + > +static void > +gen9_avc_update_misc_parameters(VADriverContextP ctx, > + struct encode_state *encode_state, > + struct intel_encoder_context > +*encoder_context) { > + struct encoder_vme_mfc_context * vme_context = (struct > encoder_vme_mfc_context *)encoder_context->vme_context; > + struct generic_enc_codec_state * generic_state = (struct > generic_enc_codec_state * )vme_context->generic_enc_state; > + int i; > + > + /* brc */ > + generic_state->max_bit_rate = > ALIGN(encoder_context->brc.bits_per_second[0], 1000) / 1000; > + generic_state->window_size = encoder_context->brc.window_size; > + generic_state->brc_need_reset = encoder_context->brc.need_reset; > + > + if (generic_state->internal_rate_mode == VA_RC_CBR) { > + generic_state->min_bit_rate = generic_state->max_bit_rate; > + generic_state->mb_brc_enabled = > + encoder_context->brc.mb_rate_control[0]; > + > + if (generic_state->target_bit_rate != generic_state->max_bit_rate) { > + generic_state->target_bit_rate = generic_state->max_bit_rate; > + generic_state->brc_need_reset = 1; > + } > + } else if (generic_state->internal_rate_mode == VA_RC_VBR) { > + generic_state->min_bit_rate = generic_state->max_bit_rate * (2 * > encoder_context->brc.target_percentage[0] - 100) / 100; > + generic_state->mb_brc_enabled = > + encoder_context->brc.mb_rate_control[0]; > + > + if (generic_state->target_bit_rate != generic_state->max_bit_rate * > encoder_context->brc.target_percentage[0] / 100) { > + generic_state->target_bit_rate = generic_state->max_bit_rate * > encoder_context->brc.target_percentage[0] / 100; > + generic_state->brc_need_reset = 1; > + } > + } > + > + /* frame rate */ > + generic_state->frames_per_100s = > + encoder_context->brc.framerate[0].num/encoder_context->brc.framerate > + [0].den * 100; The framerate need not be set in CQP mode - this crashes with a division by zero in that case. [Pengfei] sure. I will add check here to fix it. Also, it discards the fractional part of the framerate by rounding down before multiplying by 100 - is that deliberate? [Pengfei] I check the RC algorithm interface, it use 100x to do calculation. > + generic_state->frame_rate = > + encoder_context->brc.framerate[0].num/encoder_context->brc.framerate > + [0].den ; > + > + /* HRD */ > + if (generic_state->internal_rate_mode != VA_RC_CQP) > + { > + generic_state->vbv_buffer_size_in_bit = > encoder_context->brc.hrd_buffer_size;//misc->buffer_size; > + generic_state->init_vbv_buffer_fullness_in_bit = > encoder_context->brc.hrd_initial_buffer_fullness;//misc->initial_buffer_fullness; > + } > + > + /* ROI */ > + generic_state->num_roi = MIN(encoder_context->brc.num_roi, 3); > + if (generic_state->num_roi > 0) { > + generic_state->max_delta_qp = encoder_context->brc.roi_max_delta_qp; > + generic_state->min_delta_qp = > + encoder_context->brc.roi_min_delta_qp; > + > + for (i = 0; i < generic_state->num_roi; i++) { > + generic_state->roi[i].left = encoder_context->brc.roi[i].left; > + generic_state->roi[i].right = encoder_context->brc.roi[i].right; > + generic_state->roi[i].top = encoder_context->brc.roi[i].top; > + generic_state->roi[i].bottom = > encoder_context->brc.roi[i].bottom; > + generic_state->roi[i].value = > + encoder_context->brc.roi[i].value; > + > + generic_state->roi[i].left /= 16; > + generic_state->roi[i].right /= 16; > + generic_state->roi[i].top /= 16; > + generic_state->roi[i].bottom /= 16; > + } > + } > + > +} > + _______________________________________________ Libva mailing list Libva@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/libva