Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 16 additions & 9 deletions src/video/nvcodec/cuda_decoder_impl.cc
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,23 @@ CUVideoDecoderImpl& CUVideoDecoderImpl::operator=(CUVideoDecoderImpl&& other) {
}

int CUVideoDecoderImpl::Initialize(CUVIDEOFORMAT* format) {
if (initialized_) {
if ((format->codec != decoder_info_.CodecType) ||
(format->coded_width != decoder_info_.ulWidth) ||
(format->coded_height != decoder_info_.ulHeight) ||
(format->chroma_format != decoder_info_.ChromaFormat)) {
std::cerr << "Encountered a dynamic video format change.\n";
return 0;
if (initialized_)
{
if ((format->codec == decoder_info_.CodecType) &&
(format->coded_width == decoder_info_.ulWidth) &&
(format->coded_height == decoder_info_.ulHeight) &&
(format->chroma_format == decoder_info_.ChromaFormat))
{
return 1;
}
else //When the video format changes, reinitialize the decoder and continue to decode
{
CHECK_CUDA_CALL(cuvidDestroyDecoder(decoder_));
std::cerr << "Encountered a dynamic video format change.\n";
std::cerr << "Reinitialize the decoder\n";
}
}
return 1;
}



// DLOG(INFO) << "Hardware Decoder Input Information" << std::endl
Expand Down