[Libva] [Libva-intel-driver][PATCH v2 03/18] Add some new internal variables for a new sequence

Xiang, Haihao haihao.xiang at intel.com
Thu Sep 8 14:44:50 UTC 2016


Currently these variables are used only for H.264 encoding

v2: rename frame_width_in_mbs and frame_height_in_mbs to
frame_width_in_pixel and frame_height_in_pixel. It moves
WIDTH_IN_MACROBLOCKS() and HEIGHT_IN_MACROBLOCKS() from gen9_vdenc.h
to i965_encoder.h so that the two macros can be used in
other codecs.

Signed-off-by: Xiang, Haihao <haihao.xiang at intel.com>
---
 src/gen9_vdenc.h   | 3 ---
 src/i965_encoder.c | 7 +++++++
 src/i965_encoder.h | 7 +++++++
 3 files changed, 14 insertions(+), 3 deletions(-)

diff --git a/src/gen9_vdenc.h b/src/gen9_vdenc.h
index 6812525..e790497 100644
--- a/src/gen9_vdenc.h
+++ b/src/gen9_vdenc.h
@@ -80,9 +80,6 @@ struct encode_state;
 #define VDENC_LUTMODE_REF_ID                    0x0A
 #define VDENC_LUTMODE_INTRA_CHROMA              0x0B
 
-#define WIDTH_IN_MACROBLOCKS(width)             (ALIGN(width, 16) >> 4)
-#define HEIGHT_IN_MACROBLOCKS(height)           (ALIGN(height, 16) >> 4)
-
 struct gen9_mfx_avc_img_state
 {
     union {
diff --git a/src/i965_encoder.c b/src/i965_encoder.c
index 7d9c083..7eee29c 100644
--- a/src/i965_encoder.c
+++ b/src/i965_encoder.c
@@ -382,6 +382,12 @@ intel_encoder_check_avc_parameter(VADriverContextP ctx,
      */
     encoder_context->is_new_sequence = (pic_param->pic_fields.bits.idr_pic_flag && seq_param);
 
+    if (encoder_context->is_new_sequence) {
+        encoder_context->num_frames_in_sequence = 0;
+        encoder_context->frame_width_in_pixel = seq_param->picture_width_in_mbs * 16;
+        encoder_context->frame_height_in_pixel = seq_param->picture_height_in_mbs * 16;
+    }
+
     return VA_STATUS_SUCCESS;
 
 error:
@@ -782,6 +788,7 @@ intel_encoder_end_picture(VADriverContextP ctx,
     }
 
     encoder_context->mfc_pipeline(ctx, profile, encode_state, encoder_context);
+    encoder_context->num_frames_in_sequence++;
 
     return VA_STATUS_SUCCESS;
 }
diff --git a/src/i965_encoder.h b/src/i965_encoder.h
index bec83e3..79bfa4b 100644
--- a/src/i965_encoder.h
+++ b/src/i965_encoder.h
@@ -41,6 +41,9 @@
 #define I965_BRC_VBR	                2
 #define I965_BRC_CQP	                3
 
+#define WIDTH_IN_MACROBLOCKS(width)     (ALIGN(width, 16) >> 4)
+#define HEIGHT_IN_MACROBLOCKS(height)   (ALIGN(height, 16) >> 4)
+
 struct intel_roi
 {
     short left;
@@ -59,6 +62,10 @@ struct intel_encoder_context
     unsigned int rate_control_mode;
     unsigned int quality_level;
     unsigned int quality_range;
+    unsigned int num_frames_in_sequence;
+    unsigned int frame_width_in_pixel;
+    unsigned int frame_height_in_pixel;
+
     void *vme_context;
     void *mfc_context;
     void *enc_priv_state;
-- 
1.9.1



More information about the Libva mailing list