Skip to content

Commit 3bd2ae5

Browse files
committed
Integrating VDPAU decoding into libopenshot
1 parent eea67ad commit 3bd2ae5

File tree

3 files changed

+31
-0
lines changed

3 files changed

+31
-0
lines changed

doc/HW-ACCEL.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,3 +96,9 @@ copied to GPU memory for encoding. That is necessary because the modifications
9696
are done by the CPU. Using the GPU for that too will make it possible to do
9797
away with these two copies. A possible solution would be to use Vulkan compute
9898
which would be available on Linux and Windows natively and on MacOS via MoltenVK.
99+
100+
## Credit
101+
102+
A big thanks to Peter M (https://github.com/eisneinechse) for all his work
103+
on integrating hardware accelleration into libopenshot! The community thanks
104+
you for this major contribution!

src/FFmpegReader.cpp

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,23 @@ static enum AVPixelFormat get_hw_dec_format_cu(AVCodecContext *ctx, const enum A
186186
ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::get_hw_dec_format_cu (Unable to decode this file using hardware decode.)", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1);
187187
return AV_PIX_FMT_NONE;
188188
}
189+
190+
static enum AVPixelFormat get_hw_dec_format_vd(AVCodecContext *ctx, const enum AVPixelFormat *pix_fmts)
191+
{
192+
const enum AVPixelFormat *p;
193+
194+
for (p = pix_fmts; *p != AV_PIX_FMT_NONE; p++) {
195+
switch (*p) {
196+
case AV_PIX_FMT_VDPAU:
197+
hw_de_av_pix_fmt_global = AV_PIX_FMT_VDPAU;
198+
hw_de_av_device_type_global = AV_HWDEVICE_TYPE_VDPAU;
199+
return *p;
200+
break;
201+
}
202+
}
203+
ZmqLogger::Instance()->AppendDebugMethod("FFmpegReader::get_hw_dec_format_vd (Unable to decode this file using hardware decode.)", "", -1, "", -1, "", -1, "", -1, "", -1, "", -1);
204+
return AV_PIX_FMT_NONE;
205+
}
189206
#endif
190207

191208
#if defined(_WIN32)
@@ -377,6 +394,10 @@ void FFmpegReader::Open() {
377394
hw_de_av_device_type = AV_HWDEVICE_TYPE_CUDA;
378395
pCodecCtx->get_format = get_hw_dec_format_cu;
379396
break;
397+
case 6:
398+
hw_de_av_device_type = AV_HWDEVICE_TYPE_VDPAU;
399+
pCodecCtx->get_format = get_hw_dec_format_vd;
400+
break;
380401
default:
381402
hw_de_av_device_type = AV_HWDEVICE_TYPE_VAAPI;
382403
pCodecCtx->get_format = get_hw_dec_format_va;

src/examples/Example.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,10 @@ using namespace openshot;
3636

3737
int main(int argc, char* argv[]) {
3838

39+
Settings *s = Settings::Instance();
40+
s->HARDWARE_DECODER = 2; // 1 VA-API, 2 NVDEC
41+
s->HW_DE_DEVICE_SET = 1;
42+
3943
FFmpegReader r9("/home/jonathan/Videos/sintel_trailer-720p.mp4");
4044
r9.Open();
4145
r9.DisplayInfo();

0 commit comments

Comments
 (0)