diff --git a/PyNvCodec/TC/inc/NvDecoder.h b/PyNvCodec/TC/inc/NvDecoder.h index e50dd511..2f0a74be 100644 --- a/PyNvCodec/TC/inc/NvDecoder.h +++ b/PyNvCodec/TC/inc/NvDecoder.h @@ -122,4 +122,5 @@ class DllExport NvDecoder { int ReconfigureDecoder(CUVIDEOFORMAT *pVideoFormat); struct NvDecoderImpl *p_impl; + bool setEndOfPicture = false; }; diff --git a/PyNvCodec/TC/src/NvDecoder.cpp b/PyNvCodec/TC/src/NvDecoder.cpp index f8b18763..f01072d6 100644 --- a/PyNvCodec/TC/src/NvDecoder.cpp +++ b/PyNvCodec/TC/src/NvDecoder.cpp @@ -101,6 +101,11 @@ static int GetChromaPlaneCount(cudaVideoChromaFormat eChromaFormat) unsigned long GetNumDecodeSurfaces(cudaVideoCodec eCodec, unsigned int nWidth, unsigned int nHeight) { + const char *num_decode_surfaces_str = getenv("NV_NUM_DECODE_SURFACES"); + if (num_decode_surfaces_str) { + return atoi(num_decode_surfaces_str); + } + if (eCodec == cudaVideoCodec_VP9) { return 12; } @@ -614,6 +619,10 @@ NvDecoder::NvDecoder(CUstream cuStream, CUcontext cuContext, cudaVideoCodec eCodec, bool bLowLatency, int maxWidth, int maxHeight) { + int lowLatency = getenv("NV_LOW_LATENCY") ? atoi(getenv("NV_LOW_LATENCY")) : 0; + if (lowLatency&1) setEndOfPicture = true; + if (lowLatency&2) bLowLatency = true; + p_impl = new NvDecoderImpl(); p_impl->m_cuvidStream = cuStream; p_impl->m_cuContext = cuContext; @@ -716,6 +725,7 @@ bool NvDecoder::DecodeLockSurface(Buffer const* encFrame, encFrame ? encFrame->GetDataAs() : nullptr; packet.payload_size = encFrame ? encFrame->GetRawMemSize() : 0U; packet.flags = CUVID_PKT_TIMESTAMP; + if (setEndOfPicture) packet.flags |= CUVID_PKT_ENDOFPICTURE; packet.timestamp = pdata.pts; if (!decCtx.no_eos && (nullptr == packet.payload || 0 == packet.payload_size)) {