Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion.

Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules.

 

Go Back   Doom9's Forum > Video Encoding > MPEG-4 AVC / H.264

Reply
 
Thread Tools Search this Thread Display Modes
Old 7th May 2015, 10:17   #1  |  Link
l35633
Registered User
 
Join Date: Oct 2014
Posts: 43
How to use GPU decoding 264 stream, any open source code?

hello,every dear friend!

I want to use GPU to decode 264 stream encoded by x264 library, I wonder if there is any open source code for GPU decoding 264 stream?

Any idea?

Thank you very much!
Best regards
l35633 is offline   Reply With Quote
Old 7th May 2015, 18:51   #2  |  Link
captainadamo
Guest
 
Posts: n/a
LAVFilters.
  Reply With Quote
Old 7th May 2015, 19:31   #3  |  Link
LoRd_MuldeR
Software Developer
 
LoRd_MuldeR's Avatar
 
Join Date: Jun 2005
Location: Last House on Slunk Street
Posts: 13,251
The so-called "GPU decoding" almost always does not actually run on the GPU, but uses a dedicated hardware H.264 decoder (i.e. a separate piece of silicon) that just happens to be integrated with the GPU. This has the important consequence that you do not need to write your own GPU shader/kernel code for H.264 decoding (e.g. via CUDA or OpenCL), since the "programmable" part of the GPU is not even used. Instead, you just use the "hardwired" H.264 decoding routines that already are burnt into the silicon. And you can use the hardware H.264 decoder via standard programming interfaces, such as DXVA, CUVID or VDPAU. So it's the DXVA, CUVID or VDPAU SDK that you need to look into for code samples, I suppose...
__________________
Go to https://standforukraine.com/ to find legitimate Ukrainian Charities 🇺🇦✊

Last edited by LoRd_MuldeR; 7th May 2015 at 21:19.
LoRd_MuldeR is offline   Reply With Quote
Old 24th May 2015, 10:46   #4  |  Link
l35633
Registered User
 
Join Date: Oct 2014
Posts: 43
Quote:
Originally Posted by LoRd_MuldeR View Post
The so-called "GPU decoding" almost always does not actually run on the GPU, but uses a dedicated hardware H.264 decoder (i.e. a separate piece of silicon) that just happens to be integrated with the GPU. This has the important consequence that you do not need to write your own GPU shader/kernel code for H.264 decoding (e.g. via CUDA or OpenCL), since the "programmable" part of the GPU is not even used. Instead, you just use the "hardwired" H.264 decoding routines that already are burnt into the silicon. And you can use the hardware H.264 decoder via standard programming interfaces, such as DXVA, CUVID or VDPAU. So it's the DXVA, CUVID or VDPAU SDK that you need to look into for code samples, I suppose...
Thank you very much!
Now I wonder if I can decode 8bit/10bit 264 encoded data by "NVIDIA VIDEO CODEC SDK" as shown below link, would you please give me some great advices? Thank you very much!
https://developer.nvidia.com/nvidia-video-codec-sdk

l35633 is offline   Reply With Quote
Old 24th May 2015, 11:37   #5  |  Link
nevcairiel
Registered Developer
 
Join Date: Mar 2010
Location: Hamburg/Germany
Posts: 10,368
Quote:
Originally Posted by l35633 View Post
Thank you very much!
Now I wonder if I can decode 8bit/10bit 264 encoded data by "NVIDIA VIDEO CODEC SDK" as shown below link, would you please give me some great advices? Thank you very much!
https://developer.nvidia.com/nvidia-video-codec-sdk

You cannot, that SDK is for encoding video.
Decoding is done through NVCUVID, which is part of the CUDA Toolkit
__________________
LAV Filters - open source ffmpeg based media splitter and decoders
nevcairiel is offline   Reply With Quote
Old 26th May 2015, 08:20   #6  |  Link
l35633
Registered User
 
Join Date: Oct 2014
Posts: 43
Quote:
Originally Posted by nevcairiel View Post
You cannot, that SDK is for encoding video.
Decoding is done through NVCUVID, which is part of the CUDA Toolkit
Did you mean that if I use NVCUVID as you referred, I can decode 264 8bit/10bit data directly by API from GPU?

Thank you very much!
l35633 is offline   Reply With Quote
Old 26th May 2015, 08:50   #7  |  Link
nevcairiel
Registered Developer
 
Join Date: Mar 2010
Location: Hamburg/Germany
Posts: 10,368
Only 8-bit, 10-bit decoding for H264 is not supported by hardware.
__________________
LAV Filters - open source ffmpeg based media splitter and decoders
nevcairiel is offline   Reply With Quote
Old 27th May 2015, 07:48   #8  |  Link
l35633
Registered User
 
Join Date: Oct 2014
Posts: 43
Quote:
Originally Posted by nevcairiel View Post
Only 8-bit, 10-bit decoding for H264 is not supported by hardware.
Thank you very much!

Another question is which one is better between LAV Filters and NVCUVID through CUDA Toolkit.
Would you please give more advices?
Thank you very much!
l35633 is offline   Reply With Quote
Old 27th May 2015, 22:27   #9  |  Link
Asmodian
Registered User
 
Join Date: Feb 2002
Location: San Jose, California
Posts: 4,429
LAV Filters is a finished implementation of NVCUVID through CUDA Toolkit, it is well tested so if all you need is a direct show filter to implement CUVID, LAV is already available.

LAV also has DXVA2 support, so it works on AMD or Intel GPUs as well. It also has software decoding to fall back to if the format is not compatible with hardware decoding.

Better depends on what you want it to do and how you are implementing it. If you want CUVID decoding integrated into your own application and don't care about DXVA2 or software decoding using the CUDA Toolkit will give you more control but would be more work.
__________________
madVR options explained
Asmodian is offline   Reply With Quote
Old 27th May 2015, 22:44   #10  |  Link
stax76
Registered User
 
stax76's Avatar
 
Join Date: Jun 2002
Location: On thin ice
Posts: 6,846
Maybe he wants to build a AviSynth or VapourSynth plugin.
stax76 is offline   Reply With Quote
Old 28th May 2015, 08:06   #11  |  Link
l35633
Registered User
 
Join Date: Oct 2014
Posts: 43
Quote:
Originally Posted by Asmodian View Post
LAV Filters is a finished implementation of NVCUVID through CUDA Toolkit, it is well tested so if all you need is a direct show filter to implement CUVID, LAV is already available.

LAV also has DXVA2 support, so it works on AMD or Intel GPUs as well. It also has software decoding to fall back to if the format is not compatible with hardware decoding.

Better depends on what you want it to do and how you are implementing it. If you want CUVID decoding integrated into your own application and don't care about DXVA2 or software decoding using the CUDA Toolkit will give you more control but would be more work.
Thank you very much! What I only wan to do is to decode the 264 stream with GPU in my own programm, so as what you said, CUDA Toolkit is a better option?
Thank you!
l35633 is offline   Reply With Quote
Old 28th May 2015, 12:26   #12  |  Link
Asmodian
Registered User
 
Join Date: Feb 2002
Location: San Jose, California
Posts: 4,429
Quote:
Originally Posted by l35633 View Post
Thank you very much! What I only wan to do is to decode the 264 stream with GPU in my own programm, so as what you said, CUDA Toolkit is a better option?
Thank you!
Yes, but remember CUDA is Nvidia only.
__________________
madVR options explained
Asmodian is offline   Reply With Quote
Old 2nd June 2015, 11:19   #13  |  Link
l35633
Registered User
 
Join Date: Oct 2014
Posts: 43
hi, now I want to use the GTX980 to decode 264, then there is a decoding sample named cudaDecodeGL in CUDA samples, there is no error when making.
When I ran cudaDecodeGL, the error showed below, why is it, would you please give me some advices? Thank you very much!

> Device 0: < GeForce GTX 980 >, Compute SM 5.2 detected
>> initGL() creating window [1280 x 720]
MapSMtoCores for SM 5.2 is undefined. Default to use 128 Cores/SM
> Using CUDA/GL Device [0]: GeForce GTX 980
> Using GPU Device: GeForce GTX 980 has SM 5.2 compute capability
Total amount of global memory: 4095.3125 MB
>> modInitCTX<NV12ToARGB_drvapi64.ptx > initialized OK
>> modGetCudaFunction< CUDA file: NV12ToARGB_drvapi64.ptx >
CUDA Kernel Function (0x027f5940) = < NV12ToARGB_drvapi >
>> modGetCudaFunction< CUDA file: NV12ToARGB_drvapi64.ptx >
CUDA Kernel Function (0x027f3050) = < Passthru_drvapi >
cuvidCtxLockCreate failed: 100
cudaDecodeGL: videoDecodeGL.cpp:1039: void initCudaVideo(): Assertion `0' failed.
Aborted (core dumped)


// and the function source code is below
void
initCudaVideo()
{
// bind the context lock to the CUDA context
CUresult result = cuvidCtxLockCreate(&g_CtxLock, g_oContext);

if (result != CUDA_SUCCESS)
{
printf("cuvidCtxLockCreate failed: %d\n", result);
assert(0);
}

size_t totalGlobalMem;
size_t freeMem;

cuMemGetInfo(&freeMem,&totalGlobalMem);
printf(" Free memory: %4.4f MB\n", (float)freeMem/(1024*1024));

std::auto_ptr<VideoDecoder> apVideoDecoder(new VideoDecoder(g_pVideoSource->format(), g_oContext, g_eVideoCreateFlags, g_CtxLock));
std::auto_ptr<VideoParser> apVideoParser(new VideoParser(apVideoDecoder.get(), g_pFrameQueue, &g_oContext));
g_pVideoSource->setParser(*apVideoParser.get());

g_pVideoParser = apVideoParser.release();
g_pVideoDecoder = apVideoDecoder.release();

// Create a Stream ID for handling Readback
if (g_bReadback)
{
checkCudaErrors(cuStreamCreate(&g_ReadbackSID, 0));
checkCudaErrors(cuStreamCreate(&g_KernelSID, 0));
printf(">> initCudaVideo()\n");
printf(" CUDA Streams (%s) <g_ReadbackSID = %p>\n", ((g_ReadbackSID == 0) ? "Disabled" : "Enabled"), g_ReadbackSID);
printf(" CUDA Streams (%s) <g_KernelSID = %p>\n", ((g_KernelSID == 0) ? "Disabled" : "Enabled"), g_KernelSID);
}
}
l35633 is offline   Reply With Quote
Old 2nd June 2015, 14:05   #14  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,666
The error is telling you that no CUDA device is detected. Give your platform details, driver version, and CUDA toolkit version.

Is your main display running off the card? Are you using remote access to the machine?
videoh is offline   Reply With Quote
Old 3rd June 2015, 10:10   #15  |  Link
l35633
Registered User
 
Join Date: Oct 2014
Posts: 43
Quote:
Originally Posted by videoh View Post
The error is telling you that no CUDA device is detected. Give your platform details, driver version, and CUDA toolkit version.

Is your main display running off the card? Are you using remote access to the machine?
The version info is below:
Ubuntu 14.04.2 LTS

CUDA 6.5
nvcc: NVIDIA (R) Cuda compiler driver
Copyright (c) 2005-2011 NVIDIA Corporation
Built on Thu_Jan_12_14:41:45_PST_2012
Cuda compilation tools, release 4.1, V0.2.1221

NVIDIA Driver Version:346.35

And I am running in the local machine not remote way.
Maybe CUDA version is too old for GeForce GTX 980 ?
Need your advices again!
Thank you very much!
l35633 is offline   Reply With Quote
Old 3rd June 2015, 15:12   #16  |  Link
videoh
Useful n00b
 
Join Date: Jul 2014
Posts: 1,666
Toolkit 6.5 should be fine.

I don't do linux so can't help you directly, but I found this following link where a guy has the same problem and gets a working solution.

https://devtalk.nvidia.com/default/t...pu-undetected/

Surely worth a try.
videoh is offline   Reply With Quote
Old 4th June 2015, 10:11   #17  |  Link
l35633
Registered User
 
Join Date: Oct 2014
Posts: 43
Quote:
Originally Posted by videoh View Post
Toolkit 6.5 should be fine.

I don't do linux so can't help you directly, but I found this following link where a guy has the same problem and gets a working solution.

https://devtalk.nvidia.com/default/t...pu-undetected/

Surely worth a try.
Thank you very much! It worked after I installed the newest CUDA_toolkit 7.0 version.
l35633 is offline   Reply With Quote
Reply

Tags
264, decoding, gpu

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +1. The time now is 01:46.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.