[Libva] [Libva-intel-driver][PATCH 07/18] Remove unused fields and code in H.264/VP8 BRC

Xiang, Haihao haihao.xiang at intel.com
Thu Sep 8 05:23:41 UTC 2016


On Wed, 2016-09-07 at 12:01 +0800, Zhao Yakui wrote:
> On 09/06/2016 11:41 PM, Xiang, Haihao wrote:
> > H.264 and VP8 share some data structures
> > 
> > Signed-off-by: Xiang, Haihao<haihao.xiang at intel.com>
> > ---
> >   src/gen6_mfc.h        |  6 ------
> >   src/gen6_mfc_common.c | 29 +++--------------------------
> >   src/gen8_mfc.c        | 35 +++--------------------------------
> >   3 files changed, 6 insertions(+), 64 deletions(-)
> > 
> > diff --git a/src/gen6_mfc.h b/src/gen6_mfc.h
> > index 702596b..3faaed8 100644
> > --- a/src/gen6_mfc.h
> > +++ b/src/gen6_mfc.h
> > @@ -220,16 +220,11 @@ struct gen6_mfc_context
> >           unsigned int QpPrimeY;
> >           unsigned int MaxQpNegModifier;
> >           unsigned int MaxQpPosModifier;
> > -        unsigned char MaxSizeInWord;
> > -        unsigned char TargetSizeInWord;
> >           unsigned char Correct[6];
> >           unsigned char GrowInit;
> >           unsigned char GrowResistance;
> >           unsigned char ShrinkInit;
> >           unsigned char ShrinkResistance;
> > -
> > -        unsigned int target_mb_size;
> > -        unsigned int target_frame_size;
> >       } bit_rate_control_context[3];      //INTERNAL: for I, P, B
> > frames
> 
> Please still keep it. Otherwise it will be added again for advanced 
> bit-rate control.
> 

No. We won't use it.

> > 
> >       struct {
> > @@ -257,7 +252,6 @@ struct gen6_mfc_context
> >       //HRD control context
> >       struct {
> >           int i_bit_rate_value;
> > -        int i_cpb_size_value;
> > 
> >           int i_initial_cpb_removal_delay;
> >           int i_cpb_removal_delay;
> > diff --git a/src/gen6_mfc_common.c b/src/gen6_mfc_common.c
> > index ca89bd3..1f712e0 100644
> > --- a/src/gen6_mfc_common.c
> > +++ b/src/gen6_mfc_common.c
> > @@ -71,20 +71,8 @@ intel_mfc_bit_rate_control_context_init(struct
> > encode_state *encode_state,
> >                                           struct
> > intel_encoder_context *encoder_context)
> >   {
> >       struct gen6_mfc_context *mfc_context = encoder_context-
> > >mfc_context;
> > -    int width_in_mbs = encoder_context->frame_width_in_mbs;
> > -    int height_in_mbs = encoder_context->frame_height_in_mbs;
> > -    float fps =  encoder_context->brc.framerate_per_100s / 100.0;
> > -    int inter_mb_size = encoder_context->brc.bits_per_second * 1.0
> > / (fps+4.0) / width_in_mbs / height_in_mbs;
> > -    int intra_mb_size = inter_mb_size * 5.0;
> >       int i;
> > 
> > -    mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_I].target_mb_size =
> > intra_mb_size;
> > -    mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_I].target_frame_size =
> > intra_mb_size * width_in_mbs * height_in_mbs;
> > -    mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_P].target_mb_size =
> > inter_mb_size;
> > -    mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_P].target_frame_size =
> > inter_mb_size * width_in_mbs * height_in_mbs;
> > -    mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_B].target_mb_size =
> > inter_mb_size;
> > -    mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_B].target_frame_size =
> > inter_mb_size * width_in_mbs * height_in_mbs;
> > -
> >       for(i = 0 ; i<  3; i++) {
> >           mfc_context->bit_rate_control_context[i].QpPrimeY = 26;
> >           mfc_context->bit_rate_control_context[i].MaxQpNegModifier 
> > = 6;
> > @@ -101,14 +89,6 @@ intel_mfc_bit_rate_control_context_init(struct
> > encode_state *encode_state,
> >           mfc_context->bit_rate_control_context[i].Correct[4] = 4;
> >           mfc_context->bit_rate_control_context[i].Correct[5] = 8;
> >       }
> > -
> > -    mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_I].TargetSizeInWord =
> > (intra_mb_size + 16)/ 16;
> > -    mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_P].TargetSizeInWord =
> > (inter_mb_size + 16)/ 16;
> > -    mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_B].TargetSizeInWord =
> > (inter_mb_size + 16)/ 16;
> > -
> > -    mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_I].MaxSizeInWord =
> > mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_I].TargetSizeInWord * 1.5;
> > -    mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_P].MaxSizeInWord =
> > mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_P].TargetSizeInWord * 1.5;
> > -    mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_B].MaxSizeInWord =
> > mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_B].TargetSizeInWord * 1.5;
> >   }
> > 
> >   static void intel_mfc_brc_init(struct encode_state *encode_state,
> > @@ -317,8 +297,7 @@ static void intel_mfc_hrd_context_init(struct
> > encode_state *encode_state,
> >       // current we only support CBR mode.
> >       if (rate_control_mode == VA_RC_CBR) {
> >           mfc_context->vui_hrd.i_bit_rate_value =
> > target_bit_rate>>  10;
> > -        mfc_context->vui_hrd.i_cpb_size_value = (target_bit_rate *
> > 8)>>  10;
> > -        mfc_context->vui_hrd.i_initial_cpb_removal_delay =
> > mfc_context->vui_hrd.i_cpb_size_value * 0.5 * 1024 /
> > target_bit_rate * 90000;
> > +        mfc_context->vui_hrd.i_initial_cpb_removal_delay =
> > ((target_bit_rate * 8)>>  10) * 0.5 * 1024 / target_bit_rate *
> > 90000;
> >           mfc_context->vui_hrd.i_cpb_removal_delay = 2;
> >           mfc_context->vui_hrd.i_frame_number = 0;
> > 
> > @@ -362,7 +341,6 @@ void intel_mfc_brc_prepare(struct encode_state
> > *encode_state,
> >                              struct intel_encoder_context
> > *encoder_context)
> >   {
> >       unsigned int rate_control_mode = encoder_context-
> > >rate_control_mode;
> > -    struct gen6_mfc_context *mfc_context = encoder_context-
> > >mfc_context;
> > 
> >       if (encoder_context->codec != CODEC_H264&&
> >           encoder_context->codec != CODEC_H264_MVC)
> > @@ -370,14 +348,13 @@ void intel_mfc_brc_prepare(struct
> > encode_state *encode_state,
> > 
> >       if (rate_control_mode == VA_RC_CBR) {
> >           /*Programing bit rate control */
> > -        if ((mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_I].MaxSizeInWord == 0) ||
> > -            encoder_context->brc.need_reset) {
> > +        if (encoder_context->brc.need_reset) {
> >               intel_mfc_bit_rate_control_context_init(encode_state,
> > encoder_context);
> >               intel_mfc_brc_init(encode_state, encoder_context);
> >           }
> > 
> >           /*Programing HRD control */
> > -        if ((mfc_context->vui_hrd.i_cpb_size_value == 0) ||
> > encoder_context->brc.need_reset)
> > +        if (encoder_context->brc.need_reset)
> >               intel_mfc_hrd_context_init(encode_state,
> > encoder_context);
> >       }
> >   }
> > diff --git a/src/gen8_mfc.c b/src/gen8_mfc.c
> > index fc11e63..409259b 100644
> > --- a/src/gen8_mfc.c
> > +++ b/src/gen8_mfc.c
> > @@ -3319,31 +3319,6 @@ static int
> > gen8_mfc_vp8_qindex_estimate(struct encode_state *encode_state,
> >       return target_qindex;
> >   }
> > 
> > -static void
> > -gen8_mfc_vp8_bit_rate_control_context_init(struct encode_state
> > *encode_state,
> > -                                        struct gen6_mfc_context
> > *mfc_context)
> > -{
> > -    VAEncSequenceParameterBufferVP8 *seq_param =
> > (VAEncSequenceParameterBufferVP8 *)encode_state->seq_param_ext-
> > >buffer;
> > -    VAEncMiscParameterBuffer *misc_param_frame_rate_buffer =
> > (VAEncMiscParameterBuffer*)encode_state-
> > >misc_param[VAEncMiscParameterTypeFrameRate]->buffer;
> > -    VAEncMiscParameterFrameRate* param_frame_rate =
> > (VAEncMiscParameterFrameRate*)misc_param_frame_rate_buffer->data;
> > -    int width_in_mbs = ALIGN(seq_param->frame_width, 16) / 16;
> > -    int height_in_mbs = ALIGN(seq_param->frame_height, 16) / 16;
> > -    float fps = param_frame_rate->framerate;
> > -    int inter_mb_size = seq_param->bits_per_second * 1.0 /
> > (fps+4.0) / width_in_mbs / height_in_mbs;
> > -    int intra_mb_size = inter_mb_size * 5.0;
> > -
> > -    mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_I].target_mb_size =
> > intra_mb_size;
> > -    mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_I].target_frame_size =
> > intra_mb_size * width_in_mbs * height_in_mbs;
> > -    mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_P].target_mb_size =
> > inter_mb_size;
> > -    mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_P].target_frame_size =
> > inter_mb_size * width_in_mbs * height_in_mbs;
> > -
> > -    mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_I].TargetSizeInWord =
> > (intra_mb_size + 16)/ 16;
> > -    mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_P].TargetSizeInWord =
> > (inter_mb_size + 16)/ 16;
> > -
> > -    mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_I].MaxSizeInWord =
> > mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_I].TargetSizeInWord * 1.5;
> > -    mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_P].MaxSizeInWord =
> > mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_P].TargetSizeInWord * 1.5;
> > -}
> > -
> >   static void gen8_mfc_vp8_brc_init(struct encode_state
> > *encode_state,
> >                                  struct intel_encoder_context*
> > encoder_context)
> >   {
> > @@ -3516,8 +3491,7 @@ static void
> > gen8_mfc_vp8_hrd_context_init(struct encode_state *encode_state,
> >       // current we only support CBR mode.
> >       if (rate_control_mode == VA_RC_CBR) {
> >           mfc_context->vui_hrd.i_bit_rate_value =
> > target_bit_rate>>  10;
> > -        mfc_context->vui_hrd.i_cpb_size_value = (target_bit_rate *
> > 8)>>  10;
> > -        mfc_context->vui_hrd.i_initial_cpb_removal_delay =
> > mfc_context->vui_hrd.i_cpb_size_value * 0.5 * 1024 /
> > target_bit_rate * 90000;
> > +        mfc_context->vui_hrd.i_initial_cpb_removal_delay =
> > ((target_bit_rate * 8)>>  10) * 0.5 * 1024 / target_bit_rate *
> > 90000;
> >           mfc_context->vui_hrd.i_cpb_removal_delay = 2;
> >           mfc_context->vui_hrd.i_frame_number = 0;
> > 
> > @@ -3577,7 +3551,6 @@ static void gen8_mfc_vp8_brc_prepare(struct
> > encode_state *encode_state,
> >                              struct intel_encoder_context
> > *encoder_context)
> >   {
> >       unsigned int rate_control_mode = encoder_context-
> > >rate_control_mode;
> > -    struct gen6_mfc_context *mfc_context = encoder_context-
> > >mfc_context;
> > 
> >       if (rate_control_mode == VA_RC_CBR) {
> >           bool brc_updated;
> > @@ -3586,14 +3559,12 @@ static void gen8_mfc_vp8_brc_prepare(struct
> > encode_state *encode_state,
> >           brc_updated =
> > gen8_mfc_vp8_brc_updated_check(encode_state, encoder_context);
> > 
> >           /*Programing bit rate control */
> > -        if ((mfc_context-
> > >bit_rate_control_context[SLICE_TYPE_I].MaxSizeInWord == 0) ||
> > -             brc_updated) {
> > -            gen8_mfc_vp8_bit_rate_control_context_init(encode_stat
> > e, mfc_context);
> > +        if (brc_updated) {
> >               gen8_mfc_vp8_brc_init(encode_state, encoder_context);
> >           }
> > 
> >           /*Programing HRD control */
> > -        if ((mfc_context->vui_hrd.i_cpb_size_value == 0) ||
> > brc_updated )
> > +        if (brc_updated)
> >               gen8_mfc_vp8_hrd_context_init(encode_state,
> > encoder_context);
> >       }
> >   }
> 


More information about the Libva mailing list