WinGui: Fix another instance of the Caliburn vs Json.net sillyness where objects...
[HandBrake.git] / libhb / qsv_common.h
blobb1adc5c5ae1bec804dfd9c81d79f4620533d3c45
1 /* qsv_common.h
3 * Copyright (c) 2003-2015 HandBrake Team
4 * This file is part of the HandBrake source code.
5 * Homepage: <http://handbrake.fr/>.
6 * It may be used under the terms of the GNU General Public License v2.
7 * For full terms see the file COPYING file or visit http://www.gnu.org/licenses/gpl-2.0.html
8 */
10 #ifndef HB_QSV_COMMON_H
11 #define HB_QSV_COMMON_H
13 #include "msdk/mfxvideo.h"
14 #include "msdk/mfxplugin.h"
15 #include "libavcodec/avcodec.h"
17 /* Minimum Intel Media SDK version (currently 1.3, for Sandy Bridge support) */
18 #define HB_QSV_MINVERSION_MAJOR AV_QSV_MSDK_VERSION_MAJOR
19 #define HB_QSV_MINVERSION_MINOR AV_QSV_MSDK_VERSION_MINOR
22 * Get & store all available Intel Quick Sync information:
24 * - general availability
25 * - available implementations (hardware-accelerated, software fallback, etc.)
26 * - available codecs, filters, etc. for direct access (convenience)
27 * - supported API version
28 * - supported resolutions
30 typedef struct hb_qsv_info_s
32 // each info struct only corresponds to one CodecId and implementation combo
33 const mfxU32 codec_id;
34 const mfxIMPL implementation;
36 // whether the encoder is available for this implementation
37 int available;
39 // version-specific or hardware-specific capabilities
40 uint64_t capabilities;
41 // support for API 1.6 or later
42 #define HB_QSV_CAP_MSDK_API_1_6 (1LL << 0)
43 // H.264, H.265: B-frames can be used as references
44 #define HB_QSV_CAP_B_REF_PYRAMID (1LL << 1)
45 // mfxExtVideoSignalInfo
46 #define HB_QSV_CAP_VUI_VSINFO (1LL << 3)
47 // optional rate control methods
48 #define HB_QSV_CAP_RATECONTROL_LA (1LL << 10)
49 #define HB_QSV_CAP_RATECONTROL_LAi (1LL << 11)
50 #define HB_QSV_CAP_RATECONTROL_ICQ (1LL << 12)
51 // mfxExtCodingOption
52 #define HB_QSV_CAP_OPTION1 (1LL << 20)
53 // mfxExtCodingOption2
54 #define HB_QSV_CAP_OPTION2 (1LL << 30)
55 #define HB_QSV_CAP_OPTION2_MBBRC (1LL << 31)
56 #define HB_QSV_CAP_OPTION2_EXTBRC (1LL << 32)
57 #define HB_QSV_CAP_OPTION2_TRELLIS (1LL << 33)
58 #define HB_QSV_CAP_OPTION2_BREFTYPE (1LL << 34)
59 #define HB_QSV_CAP_OPTION2_IB_ADAPT (1LL << 35)
60 #define HB_QSV_CAP_OPTION2_LA_DOWNS (1LL << 36)
61 #define HB_QSV_CAP_OPTION2_NMPSLICE (1LL << 37)
63 // TODO: add maximum encode resolution, etc.
64 } hb_qsv_info_t;
66 /* Intel Quick Sync Video utilities */
67 int hb_qsv_available();
68 int hb_qsv_video_encoder_is_enabled(int encoder);
69 int hb_qsv_audio_encoder_is_enabled(int encoder);
70 int hb_qsv_info_init();
71 void hb_qsv_info_print();
72 hb_qsv_info_t* hb_qsv_info_get(int encoder);
74 /* Automatically load and unload any required MFX plug-ins */
75 hb_list_t* hb_qsv_load_plugins (hb_qsv_info_t *info, mfxSession session, mfxVersion version);
76 void hb_qsv_unload_plugins(hb_list_t **_l, mfxSession session, mfxVersion version);
78 /* Intel Quick Sync Video DECODE utilities */
79 const char* hb_qsv_decode_get_codec_name(enum AVCodecID codec_id);
80 int hb_qsv_decode_is_enabled(hb_job_t *job);
83 * mfxCoreInterface::CopyFrame had a bug preventing us from using it, but
84 * it was fixed in newer drivers - we can use this to determine usability
86 int hb_qsv_copyframe_is_slow(int encoder);
88 /* Media SDK parameters handling */
89 enum
91 HB_QSV_PARAM_OK,
92 HB_QSV_PARAM_ERROR,
93 HB_QSV_PARAM_BAD_NAME,
94 HB_QSV_PARAM_BAD_VALUE,
95 HB_QSV_PARAM_UNSUPPORTED,
98 typedef struct
101 * Supported mfxExtBuffer.BufferId values:
103 * MFX_EXTBUFF_AVC_REFLIST_CTRL
104 * MFX_EXTBUFF_AVC_TEMPORAL_LAYERS
105 * MFX_EXTBUFF_CODING_OPTION
106 * MFX_EXTBUFF_CODING_OPTION_SPSPPS
107 * MFX_EXTBUFF_CODING_OPTION2
108 * MFX_EXTBUFF_ENCODER_CAPABILITY
109 * MFX_EXTBUFF_ENCODER_RESET_OPTION
110 * MFX_EXTBUFF_OPAQUE_SURFACE_ALLOCATION
111 * MFX_EXTBUFF_PICTURE_TIMING_SEI
112 * MFX_EXTBUFF_VIDEO_SIGNAL_INFO
114 * This should cover all encode-compatible extended
115 * buffers that can be attached to an mfxVideoParam.
117 #define HB_QSV_ENC_NUM_EXT_PARAM_MAX 10
118 mfxExtBuffer* ExtParamArray[HB_QSV_ENC_NUM_EXT_PARAM_MAX];
119 mfxExtCodingOption codingOption;
120 mfxExtCodingOption2 codingOption2;
121 mfxExtVideoSignalInfo videoSignalInfo;
122 struct
124 int b_pyramid;
125 int gop_pic_size;
126 int gop_ref_dist;
127 int int_ref_cycle_size;
128 } gop;
129 struct
131 int icq;
132 int lookahead;
133 int cqp_offsets[3];
134 int vbv_max_bitrate;
135 int vbv_buffer_size;
136 float vbv_buffer_init;
137 } rc;
139 // assigned via hb_qsv_param_default, may be shared with another structure
140 mfxVideoParam *videoParam;
141 } hb_qsv_param_t;
143 static const char* const hb_qsv_preset_names1[] = { "speed", "balanced", NULL, };
144 static const char* const hb_qsv_preset_names2[] = { "speed", "balanced", "quality", NULL, };
145 const char* const* hb_qsv_preset_get_names();
146 const char* const* hb_qsv_profile_get_names(int encoder);
147 const char* const* hb_qsv_level_get_names(int encoder);
149 const char* hb_qsv_video_quality_get_name(uint32_t codec);
150 void hb_qsv_video_quality_get_limits(uint32_t codec, float *low, float *high, float *granularity, int *direction);
152 #define HB_QSV_CLIP3(min, max, val) ((val < min) ? min : (val > max) ? max : val)
153 int hb_qsv_codingoption_xlat (int val);
154 const char* hb_qsv_codingoption_get_name(int val);
156 int hb_qsv_trellisvalue_xlat(int val);
157 int hb_qsv_atoindex(const char* const *arr, const char *str, int *err);
158 int hb_qsv_atobool (const char *str, int *err);
159 int hb_qsv_atoi (const char *str, int *err);
160 float hb_qsv_atof (const char *str, int *err);
162 int hb_qsv_param_default_preset(hb_qsv_param_t *param, mfxVideoParam *videoParam, hb_qsv_info_t *info, const char *preset);
163 int hb_qsv_param_default (hb_qsv_param_t *param, mfxVideoParam *videoParam, hb_qsv_info_t *info);
164 int hb_qsv_param_parse (hb_qsv_param_t *param, hb_qsv_info_t *info, const char *key, const char *value);
165 int hb_qsv_profile_parse (hb_qsv_param_t *param, hb_qsv_info_t *info, const char *profile_key);
166 int hb_qsv_level_parse (hb_qsv_param_t *param, hb_qsv_info_t *info, const char *level_key);
168 typedef struct
170 const char *name;
171 const char *key;
172 const int value;
174 hb_triplet_t;
176 hb_triplet_t* hb_triplet4value(hb_triplet_t *triplets, const int value);
177 hb_triplet_t* hb_triplet4name (hb_triplet_t *triplets, const char *name);
178 hb_triplet_t* hb_triplet4key (hb_triplet_t *triplets, const char *key);
180 const char* hb_qsv_codec_name (uint32_t codec_id);
181 const char* hb_qsv_profile_name (uint32_t codec_id, uint16_t profile_id);
182 const char* hb_qsv_level_name (uint32_t codec_id, uint16_t level_id);
183 const char* hb_qsv_frametype_name(uint16_t qsv_frametype);
184 uint8_t hb_qsv_frametype_xlat(uint16_t qsv_frametype, uint16_t *out_flags);
186 int hb_qsv_impl_set_preferred(const char *name);
187 const char* hb_qsv_impl_get_name(int impl);
189 void hb_qsv_force_workarounds(); // for developers only
191 #endif