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 Intels 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 /** 10 * SECTION:mixvideoconfigparamsenc_mpeg4 11 * @short_description: VideoConfig parameters 12 * 13 * A data object which stores videoconfig specific parameters. 14 */ 15 16 #include "mixvideolog.h" 17 #include "mixvideoconfigparamsenc_mpeg4.h" 18 19 #define MDEBUG 20 21 22 static GType _mix_videoconfigparamsenc_mpeg4_type = 0; 23 static MixVideoConfigParamsEncClass *parent_class = NULL; 24 25 #define _do_init { _mix_videoconfigparamsenc_mpeg4_type = g_define_type_id; } 26 27 gboolean mix_videoconfigparamsenc_mpeg4_copy (MixParams * target, 28 const MixParams * src); 29 MixParams *mix_videoconfigparamsenc_mpeg4_dup (const MixParams * obj); 30 gboolean mix_videoconfigparamsencenc_mpeg4_equal (MixParams * first, 31 MixParams * second); 32 static void mix_videoconfigparamsenc_mpeg4_finalize (MixParams * obj); 33 34 G_DEFINE_TYPE_WITH_CODE (MixVideoConfigParamsEncMPEG4, /* The name of the new type, in Camel case */ 35 mix_videoconfigparamsenc_mpeg4, /* The name of the new type in lowercase */ 36 MIX_TYPE_VIDEOCONFIGPARAMSENC, /* The GType of the parent type */ 37 _do_init); 38 39 void 40 _mix_videoconfigparamsenc_mpeg4_initialize (void) 41 { 42 /* the MixParams types need to be class_ref'd once before it can be 43 * done from multiple threads; 44 * see http://bugzilla.gnome.org/show_bug.cgi?id=304551 */ 45 g_type_class_ref (mix_videoconfigparamsenc_mpeg4_get_type ()); 46 } 47 48 static void 49 mix_videoconfigparamsenc_mpeg4_init (MixVideoConfigParamsEncMPEG4 * self) 50 { 51 /* initialize properties here */ 52 /* TODO: initialize properties */ 53 54 self->fixed_vop_time_increment = 3; 55 self->profile_and_level_indication = 3; 56 self->disable_deblocking_filter_idc = 0; 57 58 self->reserved1 = NULL; 59 self->reserved2 = NULL; 60 self->reserved3 = NULL; 61 self->reserved4 = NULL; 62 } 63 64 static void 65 mix_videoconfigparamsenc_mpeg4_class_init (MixVideoConfigParamsEncMPEG4Class * klass) 66 { 67 MixVideoConfigParamsEncClass *this_parent_class = 68 MIX_VIDEOCONFIGPARAMSENC_CLASS (klass); 69 MixParamsClass *this_root_class = MIX_PARAMS_CLASS (this_parent_class); 70 71 /* setup static parent class */ 72 parent_class = 73 (MixVideoConfigParamsEncClass *) g_type_class_peek_parent (klass); 74 75 this_root_class->finalize = mix_videoconfigparamsenc_mpeg4_finalize; 76 this_root_class->copy = 77 (MixParamsCopyFunction) mix_videoconfigparamsenc_mpeg4_copy; 78 this_root_class->dup = 79 (MixParamsDupFunction) mix_videoconfigparamsenc_mpeg4_dup; 80 this_root_class->equal = 81 (MixParamsEqualFunction) mix_videoconfigparamsencenc_mpeg4_equal; 82 } 83 84 MixVideoConfigParamsEncMPEG4 * 85 mix_videoconfigparamsenc_mpeg4_new (void) 86 { 87 MixVideoConfigParamsEncMPEG4 *ret = (MixVideoConfigParamsEncMPEG4 *) 88 g_type_create_instance (MIX_TYPE_VIDEOCONFIGPARAMSENC_MPEG4); 89 90 return ret; 91 } 92 93 void 94 mix_videoconfigparamsenc_mpeg4_finalize (MixParams * obj) 95 { 96 /* MixVideoConfigParamsEncMPEG4 *this_obj = MIX_VIDEOCONFIGPARAMSENC_MPEG4 (obj); */ 97 MixParamsClass *root_class = MIX_PARAMS_CLASS (parent_class); 98 99 /* TODO: cleanup resources allocated */ 100 101 /* Chain up parent */ 102 103 if (root_class->finalize) 104 { 105 root_class->finalize (obj); 106 } 107 } 108 109 MixVideoConfigParamsEncMPEG4 110 * mix_videoconfigparamsenc_mpeg4_ref (MixVideoConfigParamsEncMPEG4 * mix) 111 { 112 return (MixVideoConfigParamsEncMPEG4 *) mix_params_ref (MIX_PARAMS (mix)); 113 } 114 115 /** 116 * mix_videoconfigparamsenc_mpeg4_dup: 117 * @obj: a #MixVideoConfigParams object 118 * @returns: a newly allocated duplicate of the object. 119 * 120 * Copy duplicate of the object. 121 */ 122 MixParams * 123 mix_videoconfigparamsenc_mpeg4_dup (const MixParams * obj) 124 { 125 MixParams *ret = NULL; 126 127 if (MIX_IS_VIDEOCONFIGPARAMSENC_MPEG4 (obj)) 128 { 129 MixVideoConfigParamsEncMPEG4 *duplicate = mix_videoconfigparamsenc_mpeg4_new (); 130 if (mix_videoconfigparamsenc_mpeg4_copy 131 (MIX_PARAMS (duplicate), MIX_PARAMS (obj))) 132 { 133 ret = MIX_PARAMS (duplicate); 134 } 135 else 136 { 137 mix_videoconfigparamsenc_mpeg4_unref (duplicate); 138 } 139 } 140 return ret; 141 } 142 143 /** 144 * mix_videoconfigparamsenc_mpeg4_copy: 145 * @target: copy to target 146 * @src: copy from src 147 * @returns: boolean indicates if copy is successful. 148 * 149 * Copy instance data from @src to @target. 150 */ 151 gboolean 152 mix_videoconfigparamsenc_mpeg4_copy (MixParams * target, const MixParams * src) 153 { 154 MixVideoConfigParamsEncMPEG4 *this_target, *this_src; 155 MixParamsClass *root_class; 156 157 LOG_V( "Begin\n"); 158 159 if (MIX_IS_VIDEOCONFIGPARAMSENC_MPEG4 (target) 160 && MIX_IS_VIDEOCONFIGPARAMSENC_MPEG4 (src)) 161 { 162 // Cast the base object to this child object 163 this_target = MIX_VIDEOCONFIGPARAMSENC_MPEG4 (target); 164 this_src = MIX_VIDEOCONFIGPARAMSENC_MPEG4 (src); 165 166 //add properties 167 this_target->profile_and_level_indication= this_src->profile_and_level_indication; 168 this_target->fixed_vop_time_increment= this_src->fixed_vop_time_increment; 169 this_target->disable_deblocking_filter_idc = this_src->disable_deblocking_filter_idc; 170 171 // Now chainup base class 172 root_class = MIX_PARAMS_CLASS (parent_class); 173 174 if (root_class->copy) 175 { 176 return root_class->copy (MIX_PARAMS_CAST (target), 177 MIX_PARAMS_CAST (src)); 178 } 179 else 180 { 181 return TRUE; 182 } 183 } 184 return FALSE; 185 } 186 187 /** 188 * mix_videoconfigparamsenc_mpeg4: 189 * @first: first object to compare 190 * @second: seond object to compare 191 * @returns: boolean indicates if instance are equal. 192 * 193 * Copy instance data from @src to @target. 194 */ 195 gboolean 196 mix_videoconfigparamsencenc_mpeg4_equal (MixParams * first, MixParams * second) 197 { 198 gboolean ret = FALSE; 199 MixVideoConfigParamsEncMPEG4 *this_first, *this_second; 200 201 if (MIX_IS_VIDEOCONFIGPARAMSENC_MPEG4 (first) 202 && MIX_IS_VIDEOCONFIGPARAMSENC_MPEG4 (second)) 203 { 204 // Cast the base object to this child object 205 206 this_first = MIX_VIDEOCONFIGPARAMSENC_MPEG4 (first); 207 this_second = MIX_VIDEOCONFIGPARAMSENC_MPEG4 (second); 208 209 if (this_first->profile_and_level_indication!= this_second->profile_and_level_indication) { 210 goto not_equal; 211 } 212 213 if (this_first->fixed_vop_time_increment!= this_second->fixed_vop_time_increment) { 214 goto not_equal; 215 } 216 217 if (this_first->disable_deblocking_filter_idc != this_second->disable_deblocking_filter_idc) { 218 goto not_equal; 219 } 220 221 222 ret = TRUE; 223 224 not_equal: 225 226 if (ret != TRUE) { 227 return ret; 228 } 229 230 /* TODO: add comparison for properties */ 231 { 232 // members within this scope equal. chaining up. 233 MixParamsClass *klass = MIX_PARAMS_CLASS (parent_class); 234 if (klass->equal) 235 { 236 ret = klass->equal (first, second); 237 } 238 else 239 { 240 ret = TRUE; 241 } 242 } 243 } 244 245 return ret; 246 } 247 248 /* TODO: Add getters and setters for properties if any */ 249 250 #define MIX_VIDEOCONFIGPARAMSENC_MPEG4_SETTER_CHECK_INPUT(obj) \ 251 if(!obj) return MIX_RESULT_NULL_PTR; \ 252 if(!MIX_IS_VIDEOCONFIGPARAMSENC_MPEG4(obj)) return MIX_RESULT_FAIL; \ 253 254 #define MIX_VIDEOCONFIGPARAMSENC_MPEG4_GETTER_CHECK_INPUT(obj, prop) \ 255 if(!obj || !prop) return MIX_RESULT_NULL_PTR; \ 256 if(!MIX_IS_VIDEOCONFIGPARAMSENC_MPEG4(obj)) return MIX_RESULT_FAIL; \ 257 258 259 MIX_RESULT mix_videoconfigparamsenc_mpeg4_set_profile_level (MixVideoConfigParamsEncMPEG4 * obj, 260 guchar profile_and_level_indication) { 261 MIX_VIDEOCONFIGPARAMSENC_MPEG4_SETTER_CHECK_INPUT (obj); 262 obj->profile_and_level_indication = profile_and_level_indication; 263 return MIX_RESULT_SUCCESS; 264 } 265 266 MIX_RESULT mix_videoconfigparamsenc_mpeg4_get_profile_level (MixVideoConfigParamsEncMPEG4 * obj, 267 guchar * profile_and_level_indication) { 268 MIX_VIDEOCONFIGPARAMSENC_MPEG4_GETTER_CHECK_INPUT (obj, profile_and_level_indication); 269 *profile_and_level_indication = obj->profile_and_level_indication; 270 return MIX_RESULT_SUCCESS; 271 } 272 273 MIX_RESULT mix_videoconfigparamsenc_mpeg4_set_fixed_vti (MixVideoConfigParamsEncMPEG4 * obj, 274 guint fixed_vop_time_increment) { 275 MIX_VIDEOCONFIGPARAMSENC_MPEG4_SETTER_CHECK_INPUT (obj); 276 obj->fixed_vop_time_increment = fixed_vop_time_increment; 277 return MIX_RESULT_SUCCESS; 278 } 279 280 MIX_RESULT mix_videoconfigparamsenc_mpeg4_get_fixed_vti (MixVideoConfigParamsEncMPEG4 * obj, 281 guint * fixed_vop_time_increment) { 282 MIX_VIDEOCONFIGPARAMSENC_MPEG4_GETTER_CHECK_INPUT (obj, fixed_vop_time_increment); 283 *fixed_vop_time_increment = obj->fixed_vop_time_increment; 284 return MIX_RESULT_SUCCESS; 285 } 286 287 MIX_RESULT mix_videoconfigparamsenc_mpeg4_set_dlk (MixVideoConfigParamsEncMPEG4 * obj, 288 guint disable_deblocking_filter_idc) { 289 MIX_VIDEOCONFIGPARAMSENC_MPEG4_SETTER_CHECK_INPUT (obj); 290 obj->disable_deblocking_filter_idc = disable_deblocking_filter_idc; 291 return MIX_RESULT_SUCCESS; 292 } 293 294 MIX_RESULT mix_videoconfigparamsenc_mpeg4_get_dlk (MixVideoConfigParamsEncMPEG4 * obj, 295 guint * disable_deblocking_filter_idc) { 296 MIX_VIDEOCONFIGPARAMSENC_MPEG4_GETTER_CHECK_INPUT (obj, disable_deblocking_filter_idc); 297 *disable_deblocking_filter_idc = obj->disable_deblocking_filter_idc; 298 return MIX_RESULT_SUCCESS; 299 } 300 301