Discussion:
[Libva-intel-driver][PATH 0/3] Save all common misc paramters in the common context
(too old to reply)
Xiang, Haihao
2016-11-25 08:22:13 UTC
Permalink
The patch series saves some misc parameters in the common context
because these parameters can be used for all codecs and cleans up the the
corresponding code in VDEnc.


Xiang, Haihao (1):
Don't parse Misc parameters in VDEnc

peng.chen (2):
Save ROI parameters in the common encoder context
Save other bitrate control parameters in the common encoder context

src/gen9_vdenc.c | 154 +++++++++--------------------------------------------
src/i965_encoder.c | 54 ++++++++++++++++++-
src/i965_encoder.h | 8 +++
3 files changed, 86 insertions(+), 130 deletions(-)
--
1.9.1
Xiang, Haihao
2016-11-25 08:22:14 UTC
Permalink
From: "peng.chen" <***@intel.com>

These parameters can be used for all codecs

Signed-off-by: peng.chen <***@intel.com>
Signed-off-by: Xiang, Haihao <***@intel.com>
---
src/i965_encoder.c | 40 ++++++++++++++++++++++++++++++++++++++++
src/i965_encoder.h | 6 ++++++
2 files changed, 46 insertions(+)

diff --git a/src/i965_encoder.c b/src/i965_encoder.c
index 4ef92eb..4a90dd4 100644
--- a/src/i965_encoder.c
+++ b/src/i965_encoder.c
@@ -438,6 +438,35 @@ intel_encoder_check_framerate_parameter(VADriverContextP ctx,
}
}

+static void
+intel_encoder_check_roi_parameter(VADriverContextP ctx,
+ struct intel_encoder_context *encoder_context,
+ VAEncMiscParameterBufferROI *misc)
+{
+ int i = 0;
+
+ encoder_context->brc.num_roi = MIN(misc->num_roi, I965_MAX_NUM_ROI_REGIONS);
+ encoder_context->brc.roi_max_delta_qp = misc->max_delta_qp;
+ encoder_context->brc.roi_min_delta_qp = misc->min_delta_qp;
+ encoder_context->brc.roi_value_is_qp_delta = 0;
+
+ if (encoder_context->rate_control_mode != VA_RC_CQP)
+ encoder_context->brc.roi_value_is_qp_delta = misc->roi_flags.bits.roi_value_is_qp_delta;
+
+ for (i = 0; i < encoder_context->brc.num_roi; i++) {
+ encoder_context->brc.roi[i].left = misc->roi->roi_rectangle.x;
+ encoder_context->brc.roi[i].right = encoder_context->brc.roi[i].left + misc->roi->roi_rectangle.width;
+ encoder_context->brc.roi[i].top = misc->roi->roi_rectangle.y;
+ encoder_context->brc.roi[i].bottom = encoder_context->brc.roi[i].top + misc->roi->roi_rectangle.height;
+ encoder_context->brc.roi[i].value = misc->roi->roi_value;
+
+ encoder_context->brc.roi[i].left /= 16;
+ encoder_context->brc.roi[i].right /= 16;
+ encoder_context->brc.roi[i].top /= 16;
+ encoder_context->brc.roi[i].bottom /= 16;
+ }
+}
+
static VAStatus
intel_encoder_check_brc_parameter(VADriverContextP ctx,
struct encode_state *encode_state,
@@ -481,6 +510,12 @@ intel_encoder_check_brc_parameter(VADriverContextP ctx,
(VAEncMiscParameterHRD *)misc_param->data);
break;

+ case VAEncMiscParameterTypeROI:
+ intel_encoder_check_roi_parameter(ctx,
+ encoder_context,
+ (VAEncMiscParameterBufferROI *)misc_param->data);
+ break;
+
default:
break;
}
@@ -1056,6 +1091,11 @@ intel_encoder_end_picture(VADriverContextP ctx,
encoder_context->mfc_pipeline(ctx, profile, encode_state, encoder_context);
encoder_context->num_frames_in_sequence++;
encoder_context->brc.need_reset = 0;
+ /*
+ * ROI is only available for the current frame, see the comment
+ * for VAEncROI in va.h
+ */
+ encoder_context->brc.num_roi = 0;

return VA_STATUS_SUCCESS;
}
diff --git a/src/i965_encoder.h b/src/i965_encoder.h
index ba31364..fe5a595 100644
--- a/src/i965_encoder.h
+++ b/src/i965_encoder.h
@@ -84,6 +84,12 @@ struct intel_encoder_context
unsigned int hrd_buffer_size;
unsigned int hrd_initial_buffer_fullness;
unsigned int need_reset;
+
+ unsigned int num_roi;
+ unsigned int roi_max_delta_qp;
+ unsigned int roi_min_delta_qp;
+ unsigned int roi_value_is_qp_delta;
+ struct intel_roi roi[I965_MAX_NUM_ROI_REGIONS];
} brc;

void *vme_context;
--
1.9.1
Zhao Yakui
2016-11-28 07:03:10 UTC
Permalink
Post by Xiang, Haihao
These parameters can be used for all codecs
---
src/i965_encoder.c | 40 ++++++++++++++++++++++++++++++++++++++++
src/i965_encoder.h | 6 ++++++
2 files changed, 46 insertions(+)
diff --git a/src/i965_encoder.c b/src/i965_encoder.c
index 4ef92eb..4a90dd4 100644
--- a/src/i965_encoder.c
+++ b/src/i965_encoder.c
@@ -438,6 +438,35 @@ intel_encoder_check_framerate_parameter(VADriverContextP ctx,
}
}
+static void
+intel_encoder_check_roi_parameter(VADriverContextP ctx,
+ struct intel_encoder_context *encoder_context,
+ VAEncMiscParameterBufferROI *misc)
+{
+ int i = 0;
+
+ encoder_context->brc.num_roi = MIN(misc->num_roi, I965_MAX_NUM_ROI_REGIONS);
+ encoder_context->brc.roi_max_delta_qp = misc->max_delta_qp;
+ encoder_context->brc.roi_min_delta_qp = misc->min_delta_qp;
+ encoder_context->brc.roi_value_is_qp_delta = 0;
+
+ if (encoder_context->rate_control_mode != VA_RC_CQP)
+ encoder_context->brc.roi_value_is_qp_delta = misc->roi_flags.bits.roi_value_is_qp_delta;
+
+ for (i = 0; i< encoder_context->brc.num_roi; i++) {
+ encoder_context->brc.roi[i].left = misc->roi->roi_rectangle.x;
+ encoder_context->brc.roi[i].right = encoder_context->brc.roi[i].left + misc->roi->roi_rectangle.width;
+ encoder_context->brc.roi[i].top = misc->roi->roi_rectangle.y;
+ encoder_context->brc.roi[i].bottom = encoder_context->brc.roi[i].top + misc->roi->roi_rectangle.height;
+ encoder_context->brc.roi[i].value = misc->roi->roi_value;
+
+ encoder_context->brc.roi[i].left /= 16;
+ encoder_context->brc.roi[i].right /= 16;
+ encoder_context->brc.roi[i].top /= 16;
+ encoder_context->brc.roi[i].bottom /= 16;
The above alignment is only for H264.
But for the other codec(for example: HEVC/VP9), it will use the
different alignment.

So I think that the above alignment had better be handled for specific
codec.
Post by Xiang, Haihao
+ }
+}
+
static VAStatus
intel_encoder_check_brc_parameter(VADriverContextP ctx,
struct encode_state *encode_state,
@@ -481,6 +510,12 @@ intel_encoder_check_brc_parameter(VADriverContextP ctx,
(VAEncMiscParameterHRD *)misc_param->data);
break;
+ intel_encoder_check_roi_parameter(ctx,
+ encoder_context,
+ (VAEncMiscParameterBufferROI *)misc_param->data);
+ break;
+
break;
}
@@ -1056,6 +1091,11 @@ intel_encoder_end_picture(VADriverContextP ctx,
encoder_context->mfc_pipeline(ctx, profile, encode_state, encoder_context);
encoder_context->num_frames_in_sequence++;
encoder_context->brc.need_reset = 0;
+ /*
+ * ROI is only available for the current frame, see the comment
+ * for VAEncROI in va.h
+ */
+ encoder_context->brc.num_roi = 0;
return VA_STATUS_SUCCESS;
}
diff --git a/src/i965_encoder.h b/src/i965_encoder.h
index ba31364..fe5a595 100644
--- a/src/i965_encoder.h
+++ b/src/i965_encoder.h
@@ -84,6 +84,12 @@ struct intel_encoder_context
unsigned int hrd_buffer_size;
unsigned int hrd_initial_buffer_fullness;
unsigned int need_reset;
+
+ unsigned int num_roi;
+ unsigned int roi_max_delta_qp;
+ unsigned int roi_min_delta_qp;
+ unsigned int roi_value_is_qp_delta;
+ struct intel_roi roi[I965_MAX_NUM_ROI_REGIONS];
} brc;
void *vme_context;
Xiang, Haihao
2016-11-25 08:22:16 UTC
Permalink
Instead we can use the parameters saved in the common encoder context.
It also corrects frame rate used in VDEnc

Signed-off-by: Xiang, Haihao <***@intel.com>
---
src/gen9_vdenc.c | 154 +++++++++----------------------------------------------
1 file changed, 25 insertions(+), 129 deletions(-)

diff --git a/src/gen9_vdenc.c b/src/gen9_vdenc.c
index c8cdca0..56b8b33 100644
--- a/src/gen9_vdenc.c
+++ b/src/gen9_vdenc.c
@@ -838,133 +838,42 @@ map_44_lut_value(unsigned int v, unsigned char max)
}

static void
-gen9_vdenc_update_rate_control_parameters(VADriverContextP ctx,
- struct intel_encoder_context *encoder_context,
- VAEncMiscParameterRateControl *misc)
-{
- struct gen9_vdenc_context *vdenc_context = encoder_context->mfc_context;
-
- vdenc_context->max_bit_rate = ALIGN(misc->bits_per_second, 1000) / 1000;
- vdenc_context->mb_brc_enabled = 0;
-
- if (vdenc_context->internal_rate_mode == I965_BRC_CBR) {
- vdenc_context->min_bit_rate = vdenc_context->max_bit_rate;
- vdenc_context->mb_brc_enabled = (misc->rc_flags.bits.mb_rate_control < 2);
-
- if (vdenc_context->target_bit_rate != vdenc_context->max_bit_rate) {
- vdenc_context->target_bit_rate = vdenc_context->max_bit_rate;
- vdenc_context->brc_need_reset = 1;
- }
- } else if (vdenc_context->internal_rate_mode == I965_BRC_VBR) {
- vdenc_context->min_bit_rate = vdenc_context->max_bit_rate * (2 * misc->target_percentage - 100) / 100;
- vdenc_context->mb_brc_enabled = (misc->rc_flags.bits.mb_rate_control < 2);
-
- if (vdenc_context->target_bit_rate != vdenc_context->max_bit_rate * misc->target_percentage / 100) {
- vdenc_context->target_bit_rate = vdenc_context->max_bit_rate * misc->target_percentage / 100;
- vdenc_context->brc_need_reset = 1;
- }
- }
-}
-
-static void
-gen9_vdenc_update_hrd_parameters(VADriverContextP ctx,
- struct intel_encoder_context *encoder_context,
- VAEncMiscParameterHRD *misc)
-{
- struct gen9_vdenc_context *vdenc_context = encoder_context->mfc_context;
-
- if (vdenc_context->internal_rate_mode == I965_BRC_CQP)
- return;
-
- vdenc_context->vbv_buffer_size_in_bit = misc->buffer_size;
- vdenc_context->init_vbv_buffer_fullness_in_bit = misc->initial_buffer_fullness;
-}
-
-static void
-gen9_vdenc_update_framerate_parameters(VADriverContextP ctx,
- struct intel_encoder_context *encoder_context,
- VAEncMiscParameterFrameRate *misc)
-{
- struct gen9_vdenc_context *vdenc_context = encoder_context->mfc_context;
-
- vdenc_context->frames_per_100s = misc->framerate; /* misc->framerate is multiple of 100 */
-}
-
-static void
-gen9_vdenc_update_roi_parameters(VADriverContextP ctx,
- struct intel_encoder_context *encoder_context,
- VAEncMiscParameterBufferROI *misc)
-{
- struct gen9_vdenc_context *vdenc_context = encoder_context->mfc_context;
- int i;
-
- if (!misc || !misc->roi) {
- vdenc_context->num_roi = 0;
- return;
- }
-
- vdenc_context->num_roi = MIN(misc->num_roi, 3);
- vdenc_context->max_delta_qp = misc->max_delta_qp;
- vdenc_context->min_delta_qp = misc->min_delta_qp;
- vdenc_context->vdenc_streamin_enable = (vdenc_context->num_roi == 0);
-
- for (i = 0; i < vdenc_context->num_roi; i++) {
- vdenc_context->roi[i].left = misc->roi->roi_rectangle.x;
- vdenc_context->roi[i].right = vdenc_context->roi[i].left + misc->roi->roi_rectangle.width;
- vdenc_context->roi[i].top = misc->roi->roi_rectangle.y;
- vdenc_context->roi[i].bottom = vdenc_context->roi[i].top + misc->roi->roi_rectangle.height;
- vdenc_context->roi[i].value = misc->roi->roi_value;
-
- vdenc_context->roi[i].left /= 16;
- vdenc_context->roi[i].right /= 16;
- vdenc_context->roi[i].top /= 16;
- vdenc_context->roi[i].bottom /= 16;
- }
-}
-
-static void
gen9_vdenc_update_misc_parameters(VADriverContextP ctx,
struct encode_state *encode_state,
struct intel_encoder_context *encoder_context)
{
- int i;
- VAEncMiscParameterBuffer *misc_param;
-
- for (i = 0; i < ARRAY_ELEMS(encode_state->misc_param); i++) {
- if (!encode_state->misc_param[i][0] || !encode_state->misc_param[i][0]->buffer)
- continue;
-
- misc_param = (VAEncMiscParameterBuffer *)encode_state->misc_param[i][0]->buffer;
+ struct gen9_vdenc_context *vdenc_context = encoder_context->mfc_context;

- switch (misc_param->type) {
- case VAEncMiscParameterTypeFrameRate:
- gen9_vdenc_update_framerate_parameters(ctx,
- encoder_context,
- (VAEncMiscParameterFrameRate *)misc_param->data);
- break;
+ vdenc_context->gop_size = encoder_context->brc.gop_size;
+ vdenc_context->ref_dist = encoder_context->brc.num_bframes_in_gop + 1;

- case VAEncMiscParameterTypeRateControl:
- gen9_vdenc_update_rate_control_parameters(ctx,
- encoder_context,
- (VAEncMiscParameterRateControl *)misc_param->data);
- break;
+ if (vdenc_context->internal_rate_mode != I965_BRC_CQP &&
+ encoder_context->brc.need_reset) {
+ /* So far, vdenc doesn't support temporal layer */
+ vdenc_context->frames_per_100s = encoder_context->brc.framerate_per_100s[0];

- case VAEncMiscParameterTypeHRD:
- gen9_vdenc_update_hrd_parameters(ctx,
- encoder_context,
- (VAEncMiscParameterHRD *)misc_param->data);
- break;
+ vdenc_context->vbv_buffer_size_in_bit = encoder_context->brc.hrd_buffer_size;
+ vdenc_context->init_vbv_buffer_fullness_in_bit = encoder_context->brc.hrd_initial_buffer_fullness;

- case VAEncMiscParameterTypeROI:
- gen9_vdenc_update_roi_parameters(ctx,
- encoder_context,
- (VAEncMiscParameterBufferROI *)misc_param->data);
- break;
+ vdenc_context->max_bit_rate = ALIGN(encoder_context->brc.bits_per_second[0], 1000) / 1000;
+ vdenc_context->mb_brc_enabled = encoder_context->brc.mb_rate_control;
+ vdenc_context->brc_need_reset = (vdenc_context->brc_initted && encoder_context->brc.need_reset);

- default:
- break;
+ if (vdenc_context->internal_rate_mode == I965_BRC_CBR) {
+ vdenc_context->min_bit_rate = vdenc_context->max_bit_rate;
+ vdenc_context->target_bit_rate = vdenc_context->max_bit_rate;
+ } else {
+ assert(vdenc_context->internal_rate_mode == I965_BRC_VBR);
+ vdenc_context->min_bit_rate = vdenc_context->max_bit_rate * (2 * encoder_context->brc.target_percentage - 100) / 100;
+ vdenc_context->target_bit_rate = vdenc_context->max_bit_rate * encoder_context->brc.target_percentage / 100;
}
}
+
+ vdenc_context->num_roi = MIN(encoder_context->brc.num_roi, 3);
+ vdenc_context->max_delta_qp = encoder_context->brc.roi_max_delta_qp;
+ vdenc_context->min_delta_qp = encoder_context->brc.roi_min_delta_qp;
+ vdenc_context->vdenc_streamin_enable = !!vdenc_context->num_roi;
+ memcpy(vdenc_context->roi, encoder_context->brc.roi, sizeof(struct intel_roi) * vdenc_context->num_roi);
}

static void
@@ -994,19 +903,6 @@ gen9_vdenc_update_parameters(VADriverContextP ctx,
vdenc_context->down_scaled_height_4x = ((vdenc_context->down_scaled_height_in_mb4x + 1) >> 1) * 16;
vdenc_context->down_scaled_height_4x = ALIGN(vdenc_context->down_scaled_height_4x, 32) << 1;

- if (vdenc_context->internal_rate_mode == I965_BRC_CBR) {
- vdenc_context->target_bit_rate = ALIGN(seq_param->bits_per_second, 1000) / 1000;
- vdenc_context->max_bit_rate = ALIGN(seq_param->bits_per_second, 1000) / 1000;
- vdenc_context->min_bit_rate = ALIGN(seq_param->bits_per_second, 1000) / 1000;
- }
-
- vdenc_context->init_vbv_buffer_fullness_in_bit = seq_param->bits_per_second;
- vdenc_context->vbv_buffer_size_in_bit = (uint64_t)seq_param->bits_per_second << 1;
- vdenc_context->frames_per_100s = 3000; /* 30fps */
- vdenc_context->gop_size = seq_param->intra_period;
- vdenc_context->ref_dist = seq_param->ip_period;
- vdenc_context->vdenc_streamin_enable = 0;
-
gen9_vdenc_update_misc_parameters(ctx, encode_state, encoder_context);

vdenc_context->current_pass = 0;
--
1.9.1
Xiang, Haihao
2016-11-25 08:22:15 UTC
Permalink
From: "peng.chen" <***@intel.com>

These parameters can be used for all codecs

Signed-off-by: peng.chen <***@intel.com>
Signed-off-by: Xiang, Haihao <***@intel.com>
---
src/i965_encoder.c | 14 +++++++++++++-
src/i965_encoder.h | 2 ++
2 files changed, 15 insertions(+), 1 deletion(-)

diff --git a/src/i965_encoder.c b/src/i965_encoder.c
index 4a90dd4..78b982a 100644
--- a/src/i965_encoder.c
+++ b/src/i965_encoder.c
@@ -393,11 +393,23 @@ intel_encoder_check_rate_control_parameter(VADriverContextP ctx,
if (temporal_id >= encoder_context->layer.num_layers)
return;

- // TODO: for VBR
+ if (misc->rc_flags.bits.reset)
+ encoder_context->brc.need_reset = 1;
+
if (encoder_context->brc.bits_per_second[temporal_id] != misc->bits_per_second) {
encoder_context->brc.bits_per_second[temporal_id] = misc->bits_per_second;
encoder_context->brc.need_reset = 1;
}
+
+ if (encoder_context->brc.mb_rate_control != misc->rc_flags.bits.mb_rate_control) {
+ encoder_context->brc.mb_rate_control = misc->rc_flags.bits.mb_rate_control;
+ encoder_context->brc.need_reset = 1;
+ }
+
+ if (encoder_context->brc.target_percentage != misc->target_percentage) {
+ encoder_context->brc.target_percentage = misc->target_percentage;
+ encoder_context->brc.need_reset = 1;
+ }
}

static void
diff --git a/src/i965_encoder.h b/src/i965_encoder.h
index fe5a595..500a9ff 100644
--- a/src/i965_encoder.h
+++ b/src/i965_encoder.h
@@ -81,6 +81,8 @@ struct intel_encoder_context
unsigned short num_bframes_in_gop;
unsigned int bits_per_second[MAX_TEMPORAL_LAYERS];
unsigned int framerate_per_100s[MAX_TEMPORAL_LAYERS];
+ unsigned int mb_rate_control;
+ unsigned int target_percentage;
unsigned int hrd_buffer_size;
unsigned int hrd_initial_buffer_fullness;
unsigned int need_reset;
--
1.9.1
Zhao Yakui
2016-11-28 07:09:19 UTC
Permalink
Post by Xiang, Haihao
These parameters can be used for all codecs
---
src/i965_encoder.c | 14 +++++++++++++-
src/i965_encoder.h | 2 ++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/i965_encoder.c b/src/i965_encoder.c
index 4a90dd4..78b982a 100644
--- a/src/i965_encoder.c
+++ b/src/i965_encoder.c
@@ -393,11 +393,23 @@ intel_encoder_check_rate_control_parameter(VADriverContextP ctx,
if (temporal_id>= encoder_context->layer.num_layers)
return;
- // TODO: for VBR
+ if (misc->rc_flags.bits.reset)
+ encoder_context->brc.need_reset = 1;
+
if (encoder_context->brc.bits_per_second[temporal_id] != misc->bits_per_second) {
encoder_context->brc.bits_per_second[temporal_id] = misc->bits_per_second;
encoder_context->brc.need_reset = 1;
}
+
+ if (encoder_context->brc.mb_rate_control != misc->rc_flags.bits.mb_rate_control) {
+ encoder_context->brc.mb_rate_control = misc->rc_flags.bits.mb_rate_control;
+ encoder_context->brc.need_reset = 1;
+ }
+
+ if (encoder_context->brc.target_percentage != misc->target_percentage) {
+ encoder_context->brc.target_percentage = misc->target_percentage;
+ encoder_context->brc.need_reset = 1;
+ }
Is the mb_rate_control/target_percentage defined per temporal_layer instead?

Thanks
Yakui
Post by Xiang, Haihao
}
static void
diff --git a/src/i965_encoder.h b/src/i965_encoder.h
index fe5a595..500a9ff 100644
--- a/src/i965_encoder.h
+++ b/src/i965_encoder.h
@@ -81,6 +81,8 @@ struct intel_encoder_context
unsigned short num_bframes_in_gop;
unsigned int bits_per_second[MAX_TEMPORAL_LAYERS];
unsigned int framerate_per_100s[MAX_TEMPORAL_LAYERS];
+ unsigned int mb_rate_control;
+ unsigned int target_percentage;
unsigned int hrd_buffer_size;
unsigned int hrd_initial_buffer_fullness;
unsigned int need_reset;
Xiang, Haihao
2016-11-28 07:22:02 UTC
Permalink
Post by Zhao Yakui
Post by Xiang, Haihao
These parameters can be used for all codecs
---
  src/i965_encoder.c | 14 +++++++++++++-
  src/i965_encoder.h |  2 ++
  2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/i965_encoder.c b/src/i965_encoder.c
index 4a90dd4..78b982a 100644
--- a/src/i965_encoder.c
+++ b/src/i965_encoder.c
@@ -393,11 +393,23 @@
intel_encoder_check_rate_control_parameter(VADriverContextP ctx,
      if (temporal_id>= encoder_context->layer.num_layers)
          return;
-    // TODO: for VBR
+    if (misc->rc_flags.bits.reset)
+        encoder_context->brc.need_reset = 1;
+
      if (encoder_context->brc.bits_per_second[temporal_id] !=
misc->bits_per_second) {
          encoder_context->brc.bits_per_second[temporal_id] = misc-
Post by Xiang, Haihao
bits_per_second;
          encoder_context->brc.need_reset = 1;
      }
+
+    if (encoder_context->brc.mb_rate_control != misc-
Post by Xiang, Haihao
rc_flags.bits.mb_rate_control) {
+        encoder_context->brc.mb_rate_control = misc-
Post by Xiang, Haihao
rc_flags.bits.mb_rate_control;
+        encoder_context->brc.need_reset = 1;
+    }
+
+    if (encoder_context->brc.target_percentage != misc-
Post by Xiang, Haihao
target_percentage) {
+        encoder_context->brc.target_percentage = misc-
Post by Xiang, Haihao
target_percentage;
+        encoder_context->brc.need_reset = 1;
+    }
Is the mb_rate_control/target_percentage defined per temporal_layer instead?
It makes sense that all layers use the same values for
mb_rate_control/target_percentage for all layers.
Post by Zhao Yakui
Thanks
    Yakui
Post by Xiang, Haihao
  }
  static void
diff --git a/src/i965_encoder.h b/src/i965_encoder.h
index fe5a595..500a9ff 100644
--- a/src/i965_encoder.h
+++ b/src/i965_encoder.h
@@ -81,6 +81,8 @@ struct intel_encoder_context
          unsigned short num_bframes_in_gop;
          unsigned int bits_per_second[MAX_TEMPORAL_LAYERS];
          unsigned int framerate_per_100s[MAX_TEMPORAL_LAYERS];
+        unsigned int mb_rate_control;
+        unsigned int target_percentage;
          unsigned int hrd_buffer_size;
          unsigned int hrd_initial_buffer_fullness;
          unsigned int need_reset;
Zhao Yakui
2016-11-28 07:36:30 UTC
Permalink
Post by Xiang, Haihao
Post by Zhao Yakui
Post by Xiang, Haihao
These parameters can be used for all codecs
---
src/i965_encoder.c | 14 +++++++++++++-
src/i965_encoder.h | 2 ++
2 files changed, 15 insertions(+), 1 deletion(-)
diff --git a/src/i965_encoder.c b/src/i965_encoder.c
index 4a90dd4..78b982a 100644
--- a/src/i965_encoder.c
+++ b/src/i965_encoder.c
@@ -393,11 +393,23 @@
intel_encoder_check_rate_control_parameter(VADriverContextP ctx,
if (temporal_id>= encoder_context->layer.num_layers)
return;
- // TODO: for VBR
+ if (misc->rc_flags.bits.reset)
+ encoder_context->brc.need_reset = 1;
+
if (encoder_context->brc.bits_per_second[temporal_id] !=
misc->bits_per_second) {
encoder_context->brc.bits_per_second[temporal_id] = misc-
Post by Xiang, Haihao
bits_per_second;
encoder_context->brc.need_reset = 1;
}
+
+ if (encoder_context->brc.mb_rate_control != misc-
Post by Xiang, Haihao
rc_flags.bits.mb_rate_control) {
+ encoder_context->brc.mb_rate_control = misc-
Post by Xiang, Haihao
rc_flags.bits.mb_rate_control;
+ encoder_context->brc.need_reset = 1;
+ }
+
+ if (encoder_context->brc.target_percentage != misc-
Post by Xiang, Haihao
target_percentage) {
+ encoder_context->brc.target_percentage = misc-
Post by Xiang, Haihao
target_percentage;
+ encoder_context->brc.need_reset = 1;
+ }
Is the mb_rate_control/target_percentage defined per temporal_layer instead?
It makes sense that all layers use the same values for
mb_rate_control/target_percentage for all layers.
From the viewpoint of upper middleware, it can pass the same
mb_rate_ctrl/target_percentage
for all the layers.
But for the driver, it can record these info for every layer. In such
case it allows that every layer owns its BRC policy based on its parameter.

Thanks
Yakui
Post by Xiang, Haihao
Post by Zhao Yakui
Thanks
Yakui
Post by Xiang, Haihao
}
static void
diff --git a/src/i965_encoder.h b/src/i965_encoder.h
index fe5a595..500a9ff 100644
--- a/src/i965_encoder.h
+++ b/src/i965_encoder.h
@@ -81,6 +81,8 @@ struct intel_encoder_context
unsigned short num_bframes_in_gop;
unsigned int bits_per_second[MAX_TEMPORAL_LAYERS];
unsigned int framerate_per_100s[MAX_TEMPORAL_LAYERS];
+ unsigned int mb_rate_control;
+ unsigned int target_percentage;
unsigned int hrd_buffer_size;
unsigned int hrd_initial_buffer_fullness;
unsigned int need_reset;
Loading...