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_H__ 10 #define __MIX_VIDEOFORMATENC_H__ 11 12 #include <va/va.h> 13 #include <glib-object.h> 14 #include "mixvideodef.h" 15 #include "mixdrmparams.h" 16 #include "mixvideoconfigparamsenc.h" 17 #include "mixvideoframe.h" 18 #include "mixframemanager.h" 19 #include "mixsurfacepool.h" 20 #include "mixbuffer.h" 21 #include "mixbufferpool.h" 22 #include "mixvideoformatqueue.h" 23 #include "mixvideoencodeparams.h" 24 25 /* 26 * Type macros. 27 */ 28 #define MIX_TYPE_VIDEOFORMATENC (mix_videoformatenc_get_type ()) 29 #define MIX_VIDEOFORMATENC(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), MIX_TYPE_VIDEOFORMATENC, MixVideoFormatEnc)) 30 #define MIX_IS_VIDEOFORMATENC(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), MIX_TYPE_VIDEOFORMATENC)) 31 #define MIX_VIDEOFORMATENC_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), MIX_TYPE_VIDEOFORMATENC, MixVideoFormatEncClass)) 32 #define MIX_IS_VIDEOFORMATENC_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), MIX_TYPE_VIDEOFORMATENC)) 33 #define MIX_VIDEOFORMATENC_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), MIX_TYPE_VIDEOFORMATENC, MixVideoFormatEncClass)) 34 35 typedef struct _MixVideoFormatEnc MixVideoFormatEnc; 36 typedef struct _MixVideoFormatEncClass MixVideoFormatEncClass; 37 38 /* vmethods typedef */ 39 40 /* TODO: change return type and method parameters */ 41 typedef MIX_RESULT (*MixVideoFmtEncGetCapsFunc)(MixVideoFormatEnc *mix, GString *msg); 42 typedef MIX_RESULT (*MixVideoFmtEncInitializeFunc)(MixVideoFormatEnc *mix, 43 MixVideoConfigParamsEnc* config_params_enc, 44 MixFrameManager * frame_mgr, 45 MixBufferPool * input_buf_pool, 46 MixSurfacePool ** surface_pool, 47 VADisplay va_display); 48 typedef MIX_RESULT (*MixVideoFmtEncodeFunc)(MixVideoFormatEnc *mix, MixBuffer * bufin[], 49 gint bufincnt, MixIOVec * iovout[], gint iovoutcnt, 50 MixVideoEncodeParams * encode_params); 51 typedef MIX_RESULT (*MixVideoFmtEncFlushFunc)(MixVideoFormatEnc *mix); 52 typedef MIX_RESULT (*MixVideoFmtEncEndOfStreamFunc)(MixVideoFormatEnc *mix); 53 typedef MIX_RESULT (*MixVideoFmtEncDeinitializeFunc)(MixVideoFormatEnc *mix); 54 typedef MIX_RESULT (*MixVideoFmtEncGetMaxEncodedBufSizeFunc) (MixVideoFormatEnc *mix, guint *max_size); 55 56 struct _MixVideoFormatEnc { 57 /*< public > */ 58 GObject parent; 59 60 /*< public > */ 61 62 /*< private > */ 63 GMutex *objectlock; 64 gboolean initialized; 65 MixFrameManager *framemgr; 66 MixSurfacePool *surfacepool; 67 VADisplay va_display; 68 VAContextID va_context; 69 VAConfigID va_config; 70 GString *mime_type; 71 72 guint frame_rate_num; 73 guint frame_rate_denom; 74 guint picture_width; 75 guint picture_height; 76 77 guint initial_qp; 78 guint min_qp; 79 guint intra_period; 80 guint bitrate; 81 82 gboolean share_buf_mode; 83 gulong * ci_frame_id; 84 guint ci_frame_num; 85 86 gulong drawable; 87 gboolean need_display; 88 89 VAProfile va_profile; 90 VAEntrypoint va_entrypoint; 91 guint va_format; 92 guint va_rcmode; 93 94 95 MixBufferPool *inputbufpool; 96 GQueue *inputbufqueue; 97 }; 98 99 /** 100 * MixVideoFormatEncClass: 101 * 102 * MI-X Video object class 103 */ 104 struct _MixVideoFormatEncClass { 105 /*< public > */ 106 GObjectClass parent_class; 107 108 /* class members */ 109 110 /*< public > */ 111 MixVideoFmtEncGetCapsFunc getcaps; 112 MixVideoFmtEncInitializeFunc initialize; 113 MixVideoFmtEncodeFunc encode; 114 MixVideoFmtEncFlushFunc flush; 115 MixVideoFmtEncEndOfStreamFunc eos; 116 MixVideoFmtEncDeinitializeFunc deinitialize; 117 MixVideoFmtEncGetMaxEncodedBufSizeFunc getmaxencodedbufsize; 118 }; 119 120 /** 121 * mix_videoformatenc_get_type: 122 * @returns: type 123 * 124 * Get the type of object. 125 */ 126 GType mix_videoformatenc_get_type(void); 127 128 /** 129 * mix_videoformatenc_new: 130 * @returns: A newly allocated instance of #MixVideoFormatEnc 131 * 132 * Use this method to create new instance of #MixVideoFormatEnc 133 */ 134 MixVideoFormatEnc *mix_videoformatenc_new(void); 135 136 /** 137 * mix_videoformatenc_ref: 138 * @mix: object to add reference 139 * @returns: the MixVideoFormatEnc instance where reference count has been increased. 140 * 141 * Add reference count. 142 */ 143 MixVideoFormatEnc *mix_videoformatenc_ref(MixVideoFormatEnc * mix); 144 145 /** 146 * mix_videoformatenc_unref: 147 * @obj: object to unref. 148 * 149 * Decrement reference count of the object. 150 */ 151 #define mix_videoformatenc_unref(obj) g_object_unref (G_OBJECT(obj)) 152 153 /* Class Methods */ 154 155 /* TODO: change method parameter list */ 156 MIX_RESULT mix_videofmtenc_getcaps(MixVideoFormatEnc *mix, GString *msg); 157 158 MIX_RESULT mix_videofmtenc_initialize(MixVideoFormatEnc *mix, 159 MixVideoConfigParamsEnc * enc_config_params, 160 MixFrameManager * frame_mgr, 161 MixBufferPool * input_buf_pool, 162 MixSurfacePool ** surface_pool, 163 VADisplay va_display); 164 165 MIX_RESULT mix_videofmtenc_encode(MixVideoFormatEnc *mix, MixBuffer * bufin[], 166 gint bufincnt, MixIOVec * iovout[], gint iovoutcnt, 167 MixVideoEncodeParams * encode_params); 168 169 MIX_RESULT mix_videofmtenc_flush(MixVideoFormatEnc *mix); 170 171 MIX_RESULT mix_videofmtenc_eos(MixVideoFormatEnc *mix); 172 173 MIX_RESULT mix_videofmtenc_deinitialize(MixVideoFormatEnc *mix); 174 175 MIX_RESULT mix_videofmtenc_get_max_coded_buffer_size(MixVideoFormatEnc *mix, guint *max_size); 176 177 178 #endif /* __MIX_VIDEOFORMATENC_H__ */ 179