From 61390de8561af5ff7f673bcbdc8373dd606a725b Mon Sep 17 00:00:00 2001 From: wang-bin Date: Tue, 25 Mar 2014 18:28:38 +0800 Subject: [PATCH] cuda: release old parser before create --- src/VideoDecoderCUDA.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/VideoDecoderCUDA.cpp b/src/VideoDecoderCUDA.cpp index 62cb38724..b2b63b38d 100644 --- a/src/VideoDecoderCUDA.cpp +++ b/src/VideoDecoderCUDA.cpp @@ -30,6 +30,8 @@ /* * TODO: update helper_cuda with 5.5 * avc1, ccv1 => h264 + sps, pps, nal. use filter or lavcudiv + * http://blog.csdn.net/gavinr/article/details/7183499 + * https://www.ffmpeg.org/ffmpeg-bitstream-filters.html * flush api * CUDA_ERROR_INVALID_VALUE "cuvidDecodePicture(p->dec, cuvidpic)" */ @@ -155,7 +157,14 @@ class VideoDecoderCUDAPrivate : public VideoDecoderPrivate return true; } bool releaseCuda() { - cuvidDestroyDecoder(dec); + if (dec) { + cuvidDestroyDecoder(dec); + dec = 0; + } + if (parser) { + cuvidDestroyVideoParser(parser); + parser = 0; + } if (stream) { cuStreamDestroy(stream); stream = 0; @@ -218,6 +227,10 @@ class VideoDecoderCUDAPrivate : public VideoDecoderPrivate available = false; return false; } + if (parser) { + cuvidDestroyVideoParser(parser); + parser = 0; + } //lavfilter check level C CUVIDPARSERPARAMS parser_params; memset(&parser_params, 0, sizeof(CUVIDPARSERPARAMS));