st/va: get rate control method from configattrib v2
authorBoyuan Zhang <boyuan.zhang@amd.com>
Thu, 21 Jul 2016 23:40:17 +0000 (19:40 -0400)
committerChristian König <christian.koenig@amd.com>
Mon, 25 Jul 2016 11:39:51 +0000 (13:39 +0200)
Rate control method is passed from app to driver through config attrib list.
That is why we need to store this rate control method to config. And later
on, we will pass this value to context->desc.h264enc.rate_ctrl.rate_ctrl_method.

v2 (chk): fix broken build and commit message

Signed-off-by: Boyuan Zhang <boyuan.zhang@amd.com>
Signed-off-by: Christian König <christian.koenig@amd.com>
src/gallium/state_trackers/va/config.c
src/gallium/state_trackers/va/context.c
src/gallium/state_trackers/va/va_private.h

index 7742087e9991a88c092c054b6225ae47d8308028..889ce38e6767265068f238dcf3a7337652b05a94 100644 (file)
@@ -202,6 +202,17 @@ vlVaCreateConfig(VADriverContextP ctx, VAProfile profile, VAEntrypoint entrypoin
 
    config->profile = p;
 
+   for (int i = 0; i <num_attribs ; i++) {
+      if (attrib_list[i].type == VAConfigAttribRateControl) {
+         if (attrib_list[i].value == VA_RC_CBR)
+            config->rc = PIPE_H264_ENC_RATE_CONTROL_METHOD_CONSTANT;
+         else if (attrib_list[i].value == VA_RC_VBR)
+            config->rc = PIPE_H264_ENC_RATE_CONTROL_METHOD_VARIABLE;
+         else
+            config->rc = PIPE_H264_ENC_RATE_CONTROL_METHOD_DISABLE;
+      }
+   }
+
    pipe_mutex_lock(drv->mutex);
    *config_id = handle_table_add(drv->htab, config);
    pipe_mutex_unlock(drv->mutex);
index 8882cbaf11658ee6cc389f299df60df7b4524361..65ba7db4de7e95647a901d5c60b6bd812ade84e3 100644 (file)
@@ -276,6 +276,8 @@ vlVaCreateContext(VADriverContextP ctx, VAConfigID config_id, int picture_width,
 
    context->desc.base.profile = config->profile;
    context->desc.base.entry_point = config->entrypoint;
+   if (config->entrypoint == PIPE_VIDEO_ENTRYPOINT_ENCODE)
+      context->desc.h264enc.rate_ctrl.rate_ctrl_method = config->rc;
 
    pipe_mutex_lock(drv->mutex);
    *context_id = handle_table_add(drv->htab, context);
index 520db4670581016b7550e7eb0f7161dfcdc57b1d..1addd87303aed4b2846a94ae97c7a72c47552c41 100644 (file)
@@ -229,6 +229,7 @@ typedef struct {
       struct pipe_vc1_picture_desc vc1;
       struct pipe_h264_picture_desc h264;
       struct pipe_h265_picture_desc h265;
+      struct pipe_h264_enc_picture_desc h264enc;
    } desc;
 
    struct {
@@ -246,6 +247,7 @@ typedef struct {
 typedef struct {
    enum pipe_video_profile profile;
    enum pipe_video_entrypoint entrypoint;
+   enum pipe_h264_enc_rate_control_method rc;
 } vlVaConfig;
 
 typedef struct {