OSDN Git Service

Add some new internal variables for a new sequence
authorXiang, Haihao <haihao.xiang@intel.com>
Tue, 13 Sep 2016 08:02:32 +0000 (16:02 +0800)
committerXiang, Haihao <haihao.xiang@intel.com>
Mon, 31 Oct 2016 01:58:57 +0000 (09:58 +0800)
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@intel.com>
Tested-by: Luo, Focus <focus.luo@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
(cherry picked from commit a069eff77a715804318011a69304a6c7d1afab17)

src/gen9_vdenc.h
src/i965_encoder.c
src/i965_encoder.h

index 6812525..e790497 100644 (file)
@@ -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 {
index 7d9c083..7eee29c 100644 (file)
@@ -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;
 }
index bec83e3..79bfa4b 100644 (file)
@@ -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;