1 /* GStreamer Intel MSDK plugin
2  * Copyright (c) 2018, Intel corporation
3  * All rights reserved.
4  *
5  * Author:Sreerenj Balachandran <sreerenj.balachandran@intel.com>
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions are met:
9  *
10  * 1. Redistributions of source code must retain the above copyright notice,
11  *    this list of conditions and the following disclaimer.
12  *
13  * 2. Redistributions in binary form must reproduce the above copyright notice,
14  *    this list of conditions and the following disclaimer in the documentation
15  *    and/or other materials provided with the distribution.
16  *
17  * 3. Neither the name of the copyright holder nor the names of its contributors
18  *    may be used to endorse or promote products derived from this software
19  *    without specific prior written permission.
20  *
21  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
22  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
23  * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
24  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR
25  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
26  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
27  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
28  * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
29  * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
30  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
31  * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32  */
33 
34 #include "msdk-enums.h"
35 
36 /*========= MSDK Decoder Enums =========================*/
37 GType
gst_msdkdec_output_order_get_type(void)38 gst_msdkdec_output_order_get_type (void)
39 {
40   static GType type = 0;
41 
42   static const GEnumValue values[] = {
43     {GST_MSDKDEC_OUTPUT_ORDER_DISPLAY, "Output frames in Display order",
44         "display"},
45     {GST_MSDKDEC_OUTPUT_ORDER_DECODE, "Output frames in Decoded order",
46         "decoded"},
47     {0, NULL, NULL}
48   };
49 
50   if (!type) {
51     type = g_enum_register_static ("GstMsdkDecOutputOrder", values);
52   }
53   return type;
54 }
55 
56 /*========= MSDK Encoder Enums =========================*/
57 GType
gst_msdkenc_rate_control_get_type(void)58 gst_msdkenc_rate_control_get_type (void)
59 {
60   static GType type = 0;
61 
62   static const GEnumValue values[] = {
63     {MFX_RATECONTROL_CBR, "Constant Bitrate", "cbr"},
64     {MFX_RATECONTROL_VBR, "Variable Bitrate", "vbr"},
65     {MFX_RATECONTROL_CQP, "Constant Quantizer", "cqp"},
66     {MFX_RATECONTROL_AVBR, "Average Bitrate", "avbr"},
67     {MFX_RATECONTROL_LA, "VBR with look ahead (Non HRD compliant)", "la_vbr"},
68     {MFX_RATECONTROL_ICQ, "Intelligent CQP", "icq"},
69     {MFX_RATECONTROL_VCM, "Video Conferencing Mode (Non HRD compliant)", "vcm"},
70     {MFX_RATECONTROL_LA_ICQ, "Intelligent CQP with LA (Non HRD compliant)",
71         "la_icq"},
72 #if 0
73     /* intended for one to N transcode scenario */
74     {MFX_RATECONTROL_LA_EXT, "Extended LA", "la_ext"},
75 #endif
76     {MFX_RATECONTROL_LA_HRD, "HRD compliant LA", "la_hrd"},
77     {MFX_RATECONTROL_QVBR, "VBR with CQP", "qvbr"},
78     {0, NULL, NULL}
79   };
80 
81   if (!type) {
82     type = g_enum_register_static ("GstMsdkEncRateControl", values);
83   }
84   return type;
85 }
86 
87 GType
gst_msdkenc_trellis_quantization_get_type(void)88 gst_msdkenc_trellis_quantization_get_type (void)
89 {
90   static GType type = 0;
91 
92   static const GFlagsValue values[] = {
93     {_MFX_TRELLIS_NONE, "Disable for all frames", "None"},
94     {MFX_TRELLIS_I, "Enable for I frames", "i"},
95     {MFX_TRELLIS_P, "Enable for P frames", "p"},
96     {MFX_TRELLIS_B, "Enable for B frames", "b"},
97     {0, NULL, NULL}
98   };
99 
100   if (!type) {
101     type = g_flags_register_static ("GstMsdkEncTrellisQuantization", values);
102   }
103   return type;
104 }
105 
106 GType
gst_msdkenc_rc_lookahead_ds_get_type(void)107 gst_msdkenc_rc_lookahead_ds_get_type (void)
108 {
109   static GType type = 0;
110 
111   static const GEnumValue values[] = {
112     {MFX_LOOKAHEAD_DS_UNKNOWN, "SDK desides what to do", "default"},
113     {MFX_LOOKAHEAD_DS_OFF, "No downsampling", "off"},
114     {MFX_LOOKAHEAD_DS_2x, "Down sample 2-times before estimation", "2x"},
115     {MFX_LOOKAHEAD_DS_4x, "Down sample 4-times before estimation", "4x"},
116     {0, NULL, NULL}
117   };
118 
119   if (!type) {
120     type = g_enum_register_static ("GstMsdkEncRCLookAheadDownsampling", values);
121   }
122   return type;
123 }
124 
125 GType
gst_msdkenc_mbbrc_get_type(void)126 gst_msdkenc_mbbrc_get_type (void)
127 {
128   static GType type = 0;
129 
130   static const GEnumValue values[] = {
131     {MFX_CODINGOPTION_UNKNOWN, "SDK desides what to do", "auto"},
132     {MFX_CODINGOPTION_OFF, "Disable Macroblock level bit rate control", "off"},
133     {MFX_CODINGOPTION_ON, "Enable Macroblock level bit rate control ", "on"},
134     {0, NULL, NULL}
135   };
136 
137   if (!type) {
138     type = g_enum_register_static ("GstMsdkEncMbBitrateControl", values);
139   }
140   return type;
141 }
142 
143 GType
gst_msdkenc_adaptive_i_get_type(void)144 gst_msdkenc_adaptive_i_get_type (void)
145 {
146   static GType type = 0;
147 
148   static const GEnumValue values[] = {
149     {MFX_CODINGOPTION_UNKNOWN, "SDK desides what to do", "auto"},
150     {MFX_CODINGOPTION_OFF, "Disable Adaptive I frame insertion ", "off"},
151     {MFX_CODINGOPTION_ON, "Enable Aaptive I frame insertion ", "on"},
152     {0, NULL, NULL}
153   };
154 
155   if (!type) {
156     type = g_enum_register_static ("GstMsdkEncAdaptiveI", values);
157   }
158   return type;
159 }
160 
161 GType
gst_msdkenc_adaptive_b_get_type(void)162 gst_msdkenc_adaptive_b_get_type (void)
163 {
164   static GType type = 0;
165 
166   static const GEnumValue values[] = {
167     {MFX_CODINGOPTION_UNKNOWN, "SDK desides what to do", "auto"},
168     {MFX_CODINGOPTION_OFF, "Disable Adaptive B-Frame insertion ", "off"},
169     {MFX_CODINGOPTION_ON, "Enable Aaptive B-Frame insertion ", "on"},
170     {0, NULL, NULL}
171   };
172 
173   if (!type) {
174     type = g_enum_register_static ("GstMsdkEncAdaptiveB", values);
175   }
176   return type;
177 }
178 
179 /*========= MSDK VPP Enums =========================*/
180 
181 GType
gst_msdkvpp_rotation_get_type(void)182 gst_msdkvpp_rotation_get_type (void)
183 {
184   static GType type = 0;
185 
186   static const GEnumValue values[] = {
187     {MFX_ANGLE_0, "Unrotated mode", "0"},
188     {MFX_ANGLE_90, "Rotated by 90°", "90"},
189     {MFX_ANGLE_180, "Rotated by 180°", "180"},
190     {MFX_ANGLE_270, "Rotated by 270°", "270"},
191     {0, NULL, NULL}
192   };
193 
194   if (!type) {
195     type = g_enum_register_static ("GstMsdkVPPRotation", values);
196   }
197   return type;
198 }
199 
200 GType
gst_msdkvpp_deinterlace_mode_get_type(void)201 gst_msdkvpp_deinterlace_mode_get_type (void)
202 {
203   static GType type = 0;
204 
205   static const GEnumValue values[] = {
206     {GST_MSDKVPP_DEINTERLACE_MODE_AUTO,
207         "Auto detection", "auto"},
208     {GST_MSDKVPP_DEINTERLACE_MODE_INTERLACED,
209         "Force deinterlacing", "interlaced"},
210     {GST_MSDKVPP_DEINTERLACE_MODE_DISABLED,
211         "Never deinterlace", "disabled"},
212     {0, NULL, NULL},
213   };
214 
215   if (!type) {
216     type = g_enum_register_static ("GstMsdkVPPDeinterlaceMode", values);
217   }
218   return type;
219 }
220 
221 GType
gst_msdkvpp_deinterlace_method_get_type(void)222 gst_msdkvpp_deinterlace_method_get_type (void)
223 {
224   static GType type = 0;
225 
226   static const GEnumValue values[] = {
227     {_MFX_DEINTERLACE_METHOD_NONE,
228         "Disable deinterlacing", "none"},
229     {MFX_DEINTERLACING_BOB, "Bob deinterlacing", "bob"},
230     {MFX_DEINTERLACING_ADVANCED, "Advanced deinterlacing (Motion adaptive)",
231         "advanced"},
232 #if 0
233     {MFX_DEINTERLACING_AUTO_DOUBLE,
234           "Auto mode with deinterlacing double framerate output",
235         "auto-double"},
236     {MFX_DEINTERLACING_AUTO_SINGLE,
237           "Auto mode with deinterlacing single framerate output",
238         "auto-single"},
239     {MFX_DEINTERLACING_FULL_FR_OUT,
240         "Deinterlace only mode with full framerate output", "full-fr"},
241     {MFX_DEINTERLACING_HALF_FR_OUT,
242         "Deinterlace only Mode with half framerate output", "half-fr"},
243     {MFX_DEINTERLACING_24FPS_OUT, "24 fps fixed output mode", "24-fps"},
244     {MFX_DEINTERLACING_FIXED_TELECINE_PATTERN,
245         "Fixed telecine pattern removal mode", "fixed-telecine-removal"},
246     {MFX_DEINTERLACING_30FPS_OUT, "30 fps fixed output mode", "30-fps"},
247     {MFX_DEINTERLACING_DETECT_INTERLACE, "Only interlace detection",
248         "only-detect"},
249 #endif
250     {MFX_DEINTERLACING_ADVANCED_NOREF,
251           "Advanced deinterlacing mode without using of reference frames",
252         "advanced-no-ref"},
253     {MFX_DEINTERLACING_ADVANCED_SCD,
254           "Advanced deinterlacing mode with scene change detection",
255         "advanced-scd"},
256     {MFX_DEINTERLACING_FIELD_WEAVING, "Field weaving", "field-weave"},
257     {0, NULL, NULL},
258   };
259 
260   if (!type) {
261     type = g_enum_register_static ("GstMsdkVPPDeinterlaceMethod", values);
262   }
263   return type;
264 }
265 
266 GType
gst_msdkvpp_mirroring_get_type(void)267 gst_msdkvpp_mirroring_get_type (void)
268 {
269   static GType type = 0;
270 
271   static const GEnumValue values[] = {
272     {MFX_MIRRORING_DISABLED, "Disable mirroring", "disable"},
273     {MFX_MIRRORING_HORIZONTAL, "Horizontal Mirroring", "horizontal"},
274     {MFX_MIRRORING_VERTICAL, "Vertical Mirroring", "vertical"},
275     {0, NULL, NULL}
276   };
277 
278   if (!type) {
279     type = g_enum_register_static ("GstMsdkVPPMirroring", values);
280   }
281   return type;
282 }
283 
284 GType
gst_msdkvpp_scaling_mode_get_type(void)285 gst_msdkvpp_scaling_mode_get_type (void)
286 {
287   static GType type = 0;
288 
289   static const GEnumValue values[] = {
290     {MFX_SCALING_MODE_DEFAULT, "Default Scaling", "disable"},
291     {MFX_SCALING_MODE_LOWPOWER, "Lowpower Scaling", "lowpower"},
292     {MFX_SCALING_MODE_QUALITY, "High Quality Scaling", "quality"},
293     {0, NULL, NULL}
294   };
295 
296   if (!type) {
297     type = g_enum_register_static ("GstMsdkVPPScalingMode", values);
298   }
299   return type;
300 }
301 
302 GType
gst_msdkvpp_frc_algorithm_get_type(void)303 gst_msdkvpp_frc_algorithm_get_type (void)
304 {
305   static GType type = 0;
306 
307   static const GEnumValue values[] = {
308     {_MFX_FRC_ALGORITHM_NONE, "No FrameRate Control algorithm", "none"},
309     {MFX_FRCALGM_PRESERVE_TIMESTAMP,
310         "Frame dropping/repetition, Preserve timestamp", "preserve-ts"},
311     {MFX_FRCALGM_DISTRIBUTED_TIMESTAMP,
312         "Frame dropping/repetition, Distribute timestamp", "distribute-ts"},
313     {MFX_FRCALGM_FRAME_INTERPOLATION, "Frame interpolation", "interpolate"},
314     {MFX_FRCALGM_FRAME_INTERPOLATION | MFX_FRCALGM_PRESERVE_TIMESTAMP,
315         "Frame interpolation, Preserve timestamp", "interpolate-preserve-ts"},
316     {MFX_FRCALGM_FRAME_INTERPOLATION | MFX_FRCALGM_DISTRIBUTED_TIMESTAMP,
317           "Frame interpolation, Distribute timestamp",
318         "interpolate-distribute-ts"},
319     {0, NULL, NULL}
320   };
321 
322   if (!type) {
323     type = g_enum_register_static ("GstMsdkVPPFrcAlgorithm", values);
324   }
325   return type;
326 }
327