ldl
ldl

Reputation: 156

How to get NV12 file in the Nvidia CUDA 5.0 SDK's project cudaDecodeGL?

Lately, I've been reading the cudaDecodeGL project of Nvidia cuda5.0 SDK.This project convert a MPEG2 file to NV12 file, then the NV12 file is converted to ARGB file in the kernel function, finally this ARGB file will be rendered and displayed in the OpenGL window. Actually, the middle-produced NV12 file is not output, while I want to get the NV12 file. I would be so appreciated if someone could tell me what to do.

Upvotes: 0

Views: 435

Answers (1)

Robert Crovella
Robert Crovella

Reputation: 151849

Referring to the whitepaper:

Post processing on a frame is done by mapping the frame through cudaPostProcessFrame(). This returns a pointer to a NV12 decoded frame.

This function is contained (and used) in the source file videoDecodeGL.cpp which is contained in the sample project.

There is only one actual use (function call) for this function. It is called out of the copyDecodedFrameToTexture function. The decoded frame in this function is what you want. If you look through this function prior to the call to cudaPostProcessFrame you'll see the following code:

        // If streams are enabled, we can perform the readback to the host while the kernel is executing
        if (g_bReadback && g_ReadbackSID)
        {
            CUresult result = cuMemcpyDtoHAsync(g_bFrameData[active_field], pDecodedFrame[active_field], (nDecodedPitch * nHeight * 3 / 2), g_ReadbackSID);

This shows how/where/when to grab the decoded frame back to the host if you want to. At that point you will have to queue up the frames and save to a file if that is what you want to do.

Upvotes: 2

Related Questions