1 /* 2 INTEL CONFIDENTIAL 3 Copyright 2009 Intel Corporation All Rights Reserved. 4 The source code contained or described herein and all documents related to the source code ("Material") are owned by Intel Corporation or its suppliers or licensors. Title to the Material remains with Intel Corporation or its suppliers and licensors. The Material contains trade secrets and proprietary and confidential information of Intel or its suppliers and licensors. The Material is protected by worldwide copyright and trade secret laws and treaty provisions. No part of the Material may be used, copied, reproduced, modified, published, uploaded, posted, transmitted, distributed, or disclosed in any way without Intel’s prior express written permission. 5 6 No license under any patent, copyright, trade secret or other intellectual property right is granted to or conferred upon you by disclosure or delivery of the Materials, either expressly, by implication, inducement, estoppel or otherwise. Any license under such intellectual property rights must be express and approved by Intel in writing. 7 */ 8 9 #ifndef __MIX_VIDEOFORMATENC_H264_H__ 10 #define __MIX_VIDEOFORMATENC_H264_H__ 11 12 #include "mixvideoformatenc.h" 13 #include "mixvideoframe_private.h" 14 15 #define MIX_VIDEO_ENC_H264_SURFACE_NUM 20 16 17 #define min(X,Y) (((X) < (Y)) ? (X) : (Y)) 18 #define max(X,Y) (((X) > (Y)) ? (X) : (Y)) 19 20 /* 21 * Type macros. 22 */ 23 #define MIX_TYPE_VIDEOFORMATENC_H264 (mix_videoformatenc_h264_get_type ()) 24 #define MIX_VIDEOFORMATENC_H264(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIX_TYPE_VIDEOFORMATENC_H264, MixVideoFormatEnc_H264)) 25 #define MIX_IS_VIDEOFORMATENC_H264(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIX_TYPE_VIDEOFORMATENC_H264)) 26 #define MIX_VIDEOFORMATENC_H264_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MIX_TYPE_VIDEOFORMATENC_H264, MixVideoFormatEnc_H264Class)) 27 #define MIX_IS_VIDEOFORMATENC_H264_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MIX_TYPE_VIDEOFORMATENC_H264)) 28 #define MIX_VIDEOFORMATENC_H264_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MIX_TYPE_VIDEOFORMATENC_H264, MixVideoFormatEnc_H264Class)) 29 30 typedef struct _MixVideoFormatEnc_H264 MixVideoFormatEnc_H264; 31 typedef struct _MixVideoFormatEnc_H264Class MixVideoFormatEnc_H264Class; 32 33 struct _MixVideoFormatEnc_H264 { 34 /*< public > */ 35 MixVideoFormatEnc parent; 36 37 VABufferID coded_buf; 38 VABufferID seq_param_buf; 39 VABufferID pic_param_buf; 40 VABufferID slice_param_buf; 41 VASurfaceID * ci_shared_surfaces; 42 VASurfaceID * surfaces; 43 guint surface_num; 44 45 MixVideoFrame *cur_fame; //current input frame to be encoded; 46 MixVideoFrame *ref_fame; //reference frame 47 MixVideoFrame *rec_fame; //reconstructed frame; 48 49 guint basic_unit_size; //for rate control 50 guint disable_deblocking_filter_idc; 51 MixDelimiterType delimiter_type; 52 guint slice_num; 53 guint va_rcmode; 54 55 guint encoded_frames; 56 gboolean pic_skipped; 57 58 gboolean is_intra; 59 60 guint coded_buf_size; 61 62 /*< public > */ 63 }; 64 65 /** 66 * MixVideoFormatEnc_H264Class: 67 * 68 * MI-X Video object class 69 */ 70 struct _MixVideoFormatEnc_H264Class { 71 /*< public > */ 72 MixVideoFormatEncClass parent_class; 73 74 /* class members */ 75 76 /*< public > */ 77 }; 78 79 /** 80 * mix_videoformatenc_h264_get_type: 81 * @returns: type 82 * 83 * Get the type of object. 84 */ 85 GType mix_videoformatenc_h264_get_type(void); 86 87 /** 88 * mix_videoformatenc_h264_new: 89 * @returns: A newly allocated instance of #MixVideoFormatEnc_H264 90 * 91 * Use this method to create new instance of #MixVideoFormatEnc_H264 92 */ 93 MixVideoFormatEnc_H264 *mix_videoformatenc_h264_new(void); 94 95 /** 96 * mix_videoformatenc_h264_ref: 97 * @mix: object to add reference 98 * @returns: the MixVideoFormatEnc_H264 instance where reference count has been increased. 99 * 100 * Add reference count. 101 */ 102 MixVideoFormatEnc_H264 *mix_videoformatenc_h264_ref(MixVideoFormatEnc_H264 * mix); 103 104 /** 105 * mix_videoformatenc_h264_unref: 106 * @obj: object to unref. 107 * 108 * Decrement reference count of the object. 109 */ 110 #define mix_videoformatenc_h264_unref(obj) g_object_unref (G_OBJECT(obj)) 111 112 /* Class Methods */ 113 114 /* H.264 vmethods */ 115 MIX_RESULT mix_videofmtenc_h264_getcaps(MixVideoFormatEnc *mix, GString *msg); 116 MIX_RESULT mix_videofmtenc_h264_initialize(MixVideoFormatEnc *mix, 117 MixVideoConfigParamsEnc * config_params_enc, 118 MixFrameManager * frame_mgr, 119 MixBufferPool * input_buf_pool, 120 MixSurfacePool ** surface_pool, 121 VADisplay va_display); 122 MIX_RESULT mix_videofmtenc_h264_encode(MixVideoFormatEnc *mix, MixBuffer * bufin[], 123 gint bufincnt, MixIOVec * iovout[], gint iovoutcnt, 124 MixVideoEncodeParams * encode_params); 125 MIX_RESULT mix_videofmtenc_h264_flush(MixVideoFormatEnc *mix); 126 MIX_RESULT mix_videofmtenc_h264_eos(MixVideoFormatEnc *mix); 127 MIX_RESULT mix_videofmtenc_h264_deinitialize(MixVideoFormatEnc *mix); 128 MIX_RESULT mix_videofmtenc_h264_get_max_encoded_buf_size (MixVideoFormatEnc *mix, guint * max_size); 129 130 /* Local Methods */ 131 132 MIX_RESULT mix_videofmtenc_h264_process_encode (MixVideoFormatEnc_H264 *mix, MixBuffer * bufin, 133 MixIOVec * iovout); 134 MIX_RESULT mix_videofmtenc_h264_AnnexB_to_length_prefixed ( 135 guint8 * bufin, guint bufin_len, guint8* bufout, guint *bufout_len); 136 137 #endif /* __MIX_VIDEOFORMATENC_H264_H__ */ 138