Don't advertise CBR for MPEG-2 encoding
authorXiang, Haihao <haihao.xiang@intel.com>
Fri, 17 Jan 2014 08:46:52 +0000 (16:46 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Thu, 27 Feb 2014 02:30:26 +0000 (10:30 +0800)
Signed-off-by: Xiang, Haihao <haihao.xiang@intel.com>
src/gen6_mfc_common.c
src/i965_drv_video.c
src/i965_encoder.c

index 31573ba..26d8400 100644 (file)
@@ -391,6 +391,8 @@ void intel_mfc_brc_prepare(struct encode_state *encode_state,
     struct gen6_mfc_context *mfc_context = encoder_context->mfc_context;
 
     if (rate_control_mode == VA_RC_CBR) {
+        assert(encoder_context->codec != CODEC_MPEG2);
+
         /*Programing bit rate control */
         if ( mfc_context->bit_rate_control_context[SLICE_TYPE_I].MaxSizeInWord == 0 ) {
             intel_mfc_bit_rate_control_context_init(encode_state, mfc_context);
index ee8e7d4..8c5894c 100755 (executable)
@@ -527,7 +527,11 @@ i965_GetConfigAttributes(VADriverContextP ctx,
 
         case VAConfigAttribRateControl:
             if (entrypoint == VAEntrypointEncSlice) {
-                attrib_list[i].value = VA_RC_CBR | VA_RC_CQP;
+                attrib_list[i].value = VA_RC_CQP;
+
+                if (profile != VAProfileMPEG2Main &&
+                    profile != VAProfileMPEG2Simple)
+                    attrib_list[i].value |= VA_RC_CBR;
                 break;
             }
 
index 9bf133f..534591c 100644 (file)
@@ -367,6 +367,13 @@ intel_enc_hw_context_init(VADriverContextP ctx,
     for (i = 0; i < obj_config->num_attribs; i++) {
         if (obj_config->attrib_list[i].type == VAConfigAttribRateControl) {
             encoder_context->rate_control_mode = obj_config->attrib_list[i].value;
+
+            if (encoder_context->codec == CODEC_MPEG2 &&
+                encoder_context->rate_control_mode & VA_RC_CBR) {
+                WARN_ONCE("Don't support CBR for MPEG-2 encoding\n");
+                encoder_context->rate_control_mode &= ~VA_RC_CBR;
+            }
+
             break;
         }
     }