Skip to content
This repository was archived by the owner on Jun 10, 2024. It is now read-only.

Commit f7e3ffc

Browse files
authored
issue #375: fix decoder reconfig counter (#376)
1 parent ce30c54 commit f7e3ffc

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

PyNvCodec/TC/src/NvDecoder.cpp

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -144,14 +144,14 @@ struct Dim {
144144
};
145145

146146
struct NvDecoderImpl {
147-
bool m_bReconfigExternal = false, m_bReconfigExtPPChange = false,
148-
eos_set = false, decoder_recon = false;
147+
bool m_bReconfigExternal = false, m_bReconfigExtPPChange = false, eos_set = false;
148+
149149

150150
unsigned int m_nWidth = 0U, m_nLumaHeight = 0U, m_nChromaHeight = 0U,
151151
m_nNumChromaPlanes = 0U, m_nMaxWidth = 0U, m_nMaxHeight = 0U;
152152

153153
int m_nSurfaceHeight = 0, m_nSurfaceWidth = 0, m_nBitDepthMinus8 = 0,
154-
m_nFrameAlloc = 0, m_nBPP = 1, m_nDecodedFrame = 0, m_nDecodePicCnt = 0,
154+
m_nFrameAlloc = 0, m_nBPP = 1, m_nDecodePicCnt = 0,
155155
m_nPicNumInDecodeOrder[32] = {0};
156156

157157
Rect m_displayRect = {}, m_cropRect = {};
@@ -181,6 +181,8 @@ struct NvDecoderImpl {
181181

182182
atomic<int> decode_error;
183183
atomic<int> parser_error;
184+
atomic<int> decoder_recon;
185+
atomic<int> m_nDecodedFrame;
184186
atomic<unsigned int> bit_stream_len;
185187
};
186188

@@ -195,7 +197,7 @@ cudaVideoCodec NvDecoder::GetCodec() const { return p_impl->m_eCodec; }
195197
int NvDecoder::HandleVideoSequence(CUVIDEOFORMAT* pVideoFormat) noexcept
196198
{
197199
try {
198-
p_impl->decoder_recon = true;
200+
p_impl->decoder_recon++;
199201
CudaCtxPush ctxPush(p_impl->m_cuContext);
200202
CudaStrSync strSync(p_impl->m_cuvidStream);
201203

@@ -775,8 +777,8 @@ bool NvDecoder::DecodeLockSurface(Buffer const* encFrame,
775777
/* In case decoder was reconfigured by cuvidParseVideoData() call made above,
776778
* some previously decoded frames could have been pushed to decoded frames
777779
* queue. Need to clean them up; */
778-
if (p_impl->decoder_recon) {
779-
p_impl->decoder_recon = false;
780+
if (p_impl->decoder_recon > 1) {
781+
p_impl->decoder_recon--;
780782
while (!p_impl->m_DecFramesCtxQueue.empty()) {
781783
p_impl->m_DecFramesCtxQueue.pop();
782784
}

0 commit comments

Comments
 (0)