-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathR3DCxxAbi.cpp
64 lines (60 loc) · 1.67 KB
/
R3DCxxAbi.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
/*
* Copyright (c) 2023 WangBin <wbsecg1 at gmail.com>
* r3d plugin for libmdk
*/
#include "R3DCxxAbi.h"
#include "string.h"
#include <iostream>
using namespace std;
char* MetadataItemKey(const R3DSDK::Clip* clip, size_t index)
{
return
#if defined(_MSC_VER)
_strdup
#else
strdup
#endif
(clip->MetadataItemKey(index).data());
}
char* MetadataItemAsString(const R3DSDK::Clip* clip, size_t index)
{
return
#if defined(_MSC_VER)
_strdup
#else
strdup
#endif
(clip->MetadataItemAsString(index).data());
}
R3DSDK::R3DStatus SetupCudaCLDevices(R3DSDK::R3DDecoderOptions* opts, int type)
{
auto status = R3DSDK::R3DStatus_NoGPUDeviceSpecified;
// prefer opencl. cuda seems very slow
if (type & OPTION_RED_OPENCL) {
clog << "R3DDecoder try to use OpenCL" << endl;
vector<R3DSDK::OpenCLDeviceInfo> devs;
status = opts->GetOpenCLDeviceList(devs);
if (status == R3DSDK::R3DStatus_Ok) {
if (devs.empty())
status = R3DSDK::R3DStatus_NoGPUDeviceSpecified;
for (const auto& i : devs) {
status = opts->useDevice(i);
}
}
}
if (status == R3DSDK::R3DStatus_Ok)
return status;
if (type & OPTION_RED_CUDA) {
clog << "R3DDecoder try to use CUDA" << endl;
vector<R3DSDK::CudaDeviceInfo> devs;
status = opts->GetCudaDeviceList(devs);
if (status == R3DSDK::R3DStatus_Ok) {
if (devs.empty())
status = R3DSDK::R3DStatus_NoGPUDeviceSpecified;
for (const auto& i : devs) {
status = opts->useDevice(i);
}
}
}
return status;
}