[Libva] [Libva-intel-driver][PATCH 11/18] Check temporal layer structure
Xiang, Haihao
haihao.xiang at intel.com
Wed Sep 7 07:05:35 UTC 2016
On Wed, 2016-09-07 at 14:08 +0800, Zhao Yakui wrote:
> On 09/06/2016 11:45 PM, Xiang, Haihao wrote:
> > Signed-off-by: Xiang, Haihao<haihao.xiang at intel.com>
> > ---
> > src/i965_encoder.c | 66
> > ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > src/i965_encoder.h | 9 ++++++++
> > 2 files changed, 75 insertions(+)
> >
> > diff --git a/src/i965_encoder.c b/src/i965_encoder.c
> > index 2ba5de7..1ba24e6 100644
> > --- a/src/i965_encoder.c
> > +++ b/src/i965_encoder.c
> > @@ -461,6 +461,66 @@
> > intel_encoder_check_brc_parameter(VADriverContextP ctx,
> > }
> >
> > static VAStatus
> > +intel_encoder_check_temporal_layer_structure(VADriverContextP ctx,
> > + struct encode_state
> > *encode_state,
> > + struct
> > intel_encoder_context *encoder_context)
> > +{
> > + VAEncMiscParameterBuffer* misc_param;
> > + VAEncMiscParameterTemporalLayerStructure *tls_paramter;
> > + unsigned int rate_control_mode = encoder_context-
> > >rate_control_mode;
> > + int i;
> > +
> > + if (!encoder_context->is_new_sequence)
> > + return VA_STATUS_SUCCESS;
> > +
> > + if (!(rate_control_mode& (VA_RC_CBR | VA_RC_VBR)))
> > + return VA_STATUS_SUCCESS;
> > +
> > + if (!encode_state-
> > >misc_param[VAEncMiscParameterTypeTemporalLayerStructure][0] ||
> > + !encode_state-
> > >misc_param[VAEncMiscParameterTypeTemporalLayerStructure][0]-
> > >buffer)
> > + return VA_STATUS_SUCCESS;
> > +
> > + misc_param = (VAEncMiscParameterBuffer*)encode_state-
> > >misc_param[VAEncMiscParameterTypeTemporalLayerStructure][0]-
> > >buffer;
> > + tls_paramter = (VAEncMiscParameterTemporalLayerStructure
> > *)misc_param->data;
> > +
> > + if (tls_paramter->number_of_layers<= 1)
> > + return VA_STATUS_SUCCESS;
> > +
> > + if (tls_paramter->number_of_layers>= MAX_TEMPORAL_LAYERS)
> > + return VA_STATUS_ERROR_INVALID_PARAMETER;
> > +
> > + if (tls_paramter->periodicity> 32 || tls_paramter-
> > >periodicity<= 1)
> > + return VA_STATUS_ERROR_INVALID_PARAMETER;
> > +
> > + for (i = 0; i< tls_paramter->number_of_layers; i++) {
> > + if (!encode_state-
> > >misc_param[VAEncMiscParameterTypeRateControl][i] ||
> > + !encode_state-
> > >misc_param[VAEncMiscParameterTypeRateControl][i]->buffer ||
> > + !encode_state-
> > >misc_param[VAEncMiscParameterTypeFrameRate][i] ||
> > + !encode_state-
> > >misc_param[VAEncMiscParameterTypeFrameRate][i]->buffer) {
> > +
> > + return VA_STATUS_ERROR_INVALID_PARAMETER;
> > + }
> > + }
> > +
> > + encoder_context->layer.size_frame_layer_ids = tls_paramter-
> > >periodicity;
> > + encoder_context->layer.num_layers = tls_paramter-
> > >number_of_layers;
> > +
> > + for (i = 0; i< encoder_context->layer.size_frame_layer_ids;
> > i++) {
> > + if (tls_paramter->layer_id[i]>= tls_paramter-
> > >number_of_layers)
> > + return VA_STATUS_ERROR_INVALID_PARAMETER;
> > +
> > + encoder_context->layer.frame_layer_ids[i] = tls_paramter-
> > >layer_id[i];
> > + }
> > +
> > + if (encoder_context->is_new_sequence)
> > + encoder_context->layer.curr_frame_layer_id = 0;
> > + else
> > + encoder_context->layer.curr_frame_layer_id =
> > encoder_context->layer.frame_layer_ids[(encoder_context-
> > >num_frames_in_sequence - 1) % encoder_context-
> > >layer.size_frame_layer_ids];
>
> It seems that the curr_frame_layer_id field is the indicator of
> temporal
> layer.
> But where is the curr_frame_layer_id updated?
> It seems that it is currently controlled by the
> encoder_context->is_new_sequence. Not sure whether it is wrong?
Thanks for catching the error. curr_frame_layer_id should be updated
per frame. I will update the patch.
Thanks
Haihao
>
> Thanks
> Yakui
>
> > +
> > + return VA_STATUS_SUCCESS;
> > +}
> > +
> > +static VAStatus
> > intel_encoder_check_misc_parameter(VADriverContextP ctx,
> > struct encode_state
> > *encode_state,
> > struct intel_encoder_context
> > *encoder_context)
> > @@ -481,6 +541,11 @@
> > intel_encoder_check_misc_parameter(VADriverContextP ctx,
> > }
> > }
> >
> > + ret = intel_encoder_check_temporal_layer_structure(ctx,
> > encode_state, encoder_context);
> > +
> > + if (ret)
> > + goto out;
> > +
> > ret = intel_encoder_check_brc_parameter(ctx, encode_state,
> > encoder_context);
> >
> > out:
> > @@ -1013,6 +1078,7 @@ intel_enc_hw_context_init(VADriverContextP
> > ctx,
> > encoder_context->rate_control_mode = VA_RC_NONE;
> > encoder_context->quality_level = ENCODER_DEFAULT_QUALITY;
> > encoder_context->quality_range = 1;
> > + encoder_context->layer.num_layers = 1;
> >
> > if (obj_config->entrypoint == VAEntrypointEncSliceLP)
> > encoder_context->low_power_mode = 1;
> > diff --git a/src/i965_encoder.h b/src/i965_encoder.h
> > index 808a336..66d3d1d 100644
> > --- a/src/i965_encoder.h
> > +++ b/src/i965_encoder.h
> > @@ -41,6 +41,8 @@
> > #define I965_BRC_VBR 2
> > #define I965_BRC_CQP 3
> >
> > +#define MAX_TEMPORAL_LAYERS 4
> > +
> > struct intel_roi
> > {
> > short left;
> > @@ -64,6 +66,13 @@ struct intel_encoder_context
> > unsigned int frame_height_in_mbs;
> >
> > struct {
> > + unsigned int num_layers;
> > + unsigned int size_frame_layer_ids;
> > + unsigned int frame_layer_ids[32];
> > + unsigned int curr_frame_layer_id;
> > + } layer;
> > +
> > + struct {
> > unsigned short gop_size;
> > unsigned short num_iframes_in_gop;
> > unsigned short num_pframes_in_gop;
>
More information about the Libva
mailing list