[Libva] [Libva-intel-driver][PATCH 13/18] Save bitrate and framerate per temporal layer
Xiang, Haihao
haihao.xiang at intel.com
Tue Sep 6 15:46:00 UTC 2016
Signed-off-by: Xiang, Haihao <haihao.xiang at intel.com>
---
src/i965_encoder.c | 79 +++++++++++++++++++++++++++++++++---------------------
1 file changed, 48 insertions(+), 31 deletions(-)
diff --git a/src/i965_encoder.c b/src/i965_encoder.c
index 7bb369a..da62955 100644
--- a/src/i965_encoder.c
+++ b/src/i965_encoder.c
@@ -372,9 +372,17 @@ intel_encoder_check_rate_control_parameter(VADriverContextP ctx,
struct intel_encoder_context *encoder_context,
VAEncMiscParameterRateControl *misc)
{
+ int temporal_id = 0;
+
+ if (encoder_context->layer.num_layers >= 2)
+ temporal_id = misc->rc_flags.bits.temporal_id;
+
+ if (temporal_id >= encoder_context->layer.num_layers)
+ return;
+
// TODO: for VBR
- if (encoder_context->brc.bits_per_second[0] != misc->bits_per_second) {
- encoder_context->brc.bits_per_second[0] = misc->bits_per_second;
+ 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;
}
}
@@ -398,14 +406,21 @@ intel_encoder_check_framerate_parameter(VADriverContextP ctx,
VAEncMiscParameterFrameRate *misc)
{
int framerate_per_100s;
+ int temporal_id = 0;
+
+ if (encoder_context->layer.num_layers >= 2)
+ temporal_id = misc->framerate_flags.bits.temporal_id;
+
+ if (temporal_id >= encoder_context->layer.num_layers)
+ return;
if (misc->framerate & 0xffff0000)
framerate_per_100s = (misc->framerate & 0xffff) * 100 / ((misc->framerate >> 16) & 0xffff);
else
framerate_per_100s = misc->framerate * 100;
- if (encoder_context->brc.framerate_per_100s[0] != framerate_per_100s) {
- encoder_context->brc.framerate_per_100s[0] = framerate_per_100s;
+ if (encoder_context->brc.framerate_per_100s[temporal_id] != framerate_per_100s) {
+ encoder_context->brc.framerate_per_100s[temporal_id] = framerate_per_100s;
encoder_context->brc.need_reset = 1;
}
}
@@ -417,7 +432,7 @@ intel_encoder_check_brc_parameter(VADriverContextP ctx,
{
VAStatus ret;
VAEncMiscParameterBuffer *misc_param;
- int i;
+ int i, j;
if (!(encoder_context->rate_control_mode & (VA_RC_CBR | VA_RC_VBR)))
return VA_STATUS_SUCCESS;
@@ -428,32 +443,34 @@ intel_encoder_check_brc_parameter(VADriverContextP ctx,
return ret;
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;
-
- switch (misc_param->type) {
- case VAEncMiscParameterTypeFrameRate:
- intel_encoder_check_framerate_parameter(ctx,
- encoder_context,
- (VAEncMiscParameterFrameRate *)misc_param->data);
- break;
-
- case VAEncMiscParameterTypeRateControl:
- intel_encoder_check_rate_control_parameter(ctx,
- encoder_context,
- (VAEncMiscParameterRateControl *)misc_param->data);
- break;
-
- case VAEncMiscParameterTypeHRD:
- intel_encoder_check_hrd_parameter(ctx,
- encoder_context,
- (VAEncMiscParameterHRD *)misc_param->data);
- break;
-
- default:
- break;
+ for (j = 0; j < ARRAY_ELEMS(encode_state->misc_param[0]); j++) {
+ if (!encode_state->misc_param[i][j] || !encode_state->misc_param[i][j]->buffer)
+ continue;
+
+ misc_param = (VAEncMiscParameterBuffer *)encode_state->misc_param[i][j]->buffer;
+
+ switch (misc_param->type) {
+ case VAEncMiscParameterTypeFrameRate:
+ intel_encoder_check_framerate_parameter(ctx,
+ encoder_context,
+ (VAEncMiscParameterFrameRate *)misc_param->data);
+ break;
+
+ case VAEncMiscParameterTypeRateControl:
+ intel_encoder_check_rate_control_parameter(ctx,
+ encoder_context,
+ (VAEncMiscParameterRateControl *)misc_param->data);
+ break;
+
+ case VAEncMiscParameterTypeHRD:
+ intel_encoder_check_hrd_parameter(ctx,
+ encoder_context,
+ (VAEncMiscParameterHRD *)misc_param->data);
+ break;
+
+ default:
+ break;
+ }
}
}
--
1.9.1
More information about the Libva
mailing list