MCPcopy Create free account
hub / github.com/OpenShot/libopenshot / get_hw_dec_format

Function get_hw_dec_format

src/FFmpegReader.cpp:164–239  ·  view source on GitHub ↗

Get hardware pix format

Source from the content-addressed store, hash-verified

162
163// Get hardware pix format
164static enum AVPixelFormat get_hw_dec_format(AVCodecContext *ctx, const enum AVPixelFormat *pix_fmts)
165{
166 const enum AVPixelFormat *p;
167
168 // Prefer only the format matching the selected hardware decoder
169 int selected = openshot::Settings::Instance()->HARDWARE_DECODER;
170
171 for (p = pix_fmts; *p != AV_PIX_FMT_NONE; p++) {
172 switch (*p) {
173#if defined(__linux__)
174 // Linux pix formats
175 case AV_PIX_FMT_VAAPI:
176 if (selected == 1) {
177 hw_de_av_pix_fmt_global = AV_PIX_FMT_VAAPI;
178 hw_de_av_device_type_global = AV_HWDEVICE_TYPE_VAAPI;
179 return *p;
180 }
181 break;
182 case AV_PIX_FMT_VDPAU:
183 if (selected == 6) {
184 hw_de_av_pix_fmt_global = AV_PIX_FMT_VDPAU;
185 hw_de_av_device_type_global = AV_HWDEVICE_TYPE_VDPAU;
186 return *p;
187 }
188 break;
189#endif
190#if defined(_WIN32)
191 // Windows pix formats
192 case AV_PIX_FMT_DXVA2_VLD:
193 if (selected == 3) {
194 hw_de_av_pix_fmt_global = AV_PIX_FMT_DXVA2_VLD;
195 hw_de_av_device_type_global = AV_HWDEVICE_TYPE_DXVA2;
196 return *p;
197 }
198 break;
199 case AV_PIX_FMT_D3D11:
200 if (selected == 4) {
201 hw_de_av_pix_fmt_global = AV_PIX_FMT_D3D11;
202 hw_de_av_device_type_global = AV_HWDEVICE_TYPE_D3D11VA;
203 return *p;
204 }
205 break;
206#endif
207#if defined(__APPLE__)
208 // Apple pix formats
209 case AV_PIX_FMT_VIDEOTOOLBOX:
210 if (selected == 5) {
211 hw_de_av_pix_fmt_global = AV_PIX_FMT_VIDEOTOOLBOX;
212 hw_de_av_device_type_global = AV_HWDEVICE_TYPE_VIDEOTOOLBOX;
213 return *p;
214 }
215 break;
216#endif
217 // Cross-platform pix formats
218 case AV_PIX_FMT_CUDA:
219 if (selected == 2) {
220 hw_de_av_pix_fmt_global = AV_PIX_FMT_CUDA;
221 hw_de_av_device_type_global = AV_HWDEVICE_TYPE_CUDA;

Callers

nothing calls this directly

Calls 1

AppendDebugMethodMethod · 0.80

Tested by

no test coverage detected