It reads "Starting SDK 12.1, NVENCODE API supports reconstructed frame output for H.264, HEVC and AV1 encode for Turing and later GPUs. "
I am now use OpenGL library for rendering and texture management.
Does reconstructed frame output still work on OpenGL ?
GLuint nv12Texture;
glGenTextures(1, &nv12Texture);
glBindTexture(GL_TEXTURE_2D, nv12Texture);
// Set parameters to avoid filtering artifacts
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
// Allocate memory for NV12 data (Y + interleaved UV)
// Height = original_height * 1.5 (e.g., 1080 → 1620 for Y + UV planes)
glPixelStorei(GL_UNPACK_ALIGNMENT, 1); // Disable padding
glTexImage2D(
GL_TEXTURE_2D,
0,
GL_R8, // Single-channel (Y and UV stored sequentially)
frameSize.w,
frameSize.h * 3 / 2, // Total height = 1.5x original
0,
GL_RED,
GL_UNSIGNED_BYTE,
nullptr);
NV_ENC_REGISTER_RESOURCE registerParams = {0};
registerParams.version = NV_ENC_REGISTER_RESOURCE_VER;
registerParams.resourceType = NV_ENC_INPUT_RESOURCE_TYPE_OPENGL_TEX;
registerParams.width = frameSize.w;
registerParams.height = frameSize.h; // Original height (not 1.5x)
registerParams.pitch = frameSize.w; // Assume no padding
registerParams.bufferFormat = NV_ENC_BUFFER_FORMAT_NV12;
registerParams.bufferUsage = NV_ENC_OUTPUT_RECON;
NV_ENC_INPUT_RESOURCE_OPENGL_TEX texParams = {0};
texParams.texture = nv12Texture;
texParams.target = GL_TEXTURE_2D;
registerParams.resourceToRegister = &texParams;
status = pEncFn.nvEncRegisterResource(encoder, ®isterParams);
if (status != NV_ENC_SUCCESS)
{
std::cerr << "Failed to register NV12 texture!" << std::endl;
}
when I set encParams.outputReconBuffer = recon_mapParams.mappedResource;
I can not run nvEncEncodePicture ,but If I delete " encParams.outputReconBuffer = recon_mapParams.mappedResource;" nvEncEncodePicture is OK ?
by the way, can you tell me how I can get PSNR better, when I use nvEncEncodePicture ?