diff --git a/torchvision/csrc/io/decoder/gpu/decoder.cpp b/torchvision/csrc/io/decoder/gpu/decoder.cpp index 0e451298825..22cce7f87ab 100644 --- a/torchvision/csrc/io/decoder/gpu/decoder.cpp +++ b/torchvision/csrc/io/decoder/gpu/decoder.cpp @@ -59,7 +59,7 @@ void Decoder::release() { if (decoder) { cuvidDestroyDecoder(decoder); } - cuCtxPopCurrent(NULL); + cuCtxPopCurrent(nullptr); } /* Trigger video decoding. @@ -100,7 +100,7 @@ int Decoder::handle_picture_decode(CUVIDPICPARAMS* pic_params) { check_for_cuda_errors(cuCtxPushCurrent(cu_context), __LINE__, __FILE__); check_for_cuda_errors( cuvidDecodePicture(decoder, pic_params), __LINE__, __FILE__); - check_for_cuda_errors(cuCtxPopCurrent(NULL), __LINE__, __FILE__); + check_for_cuda_errors(cuCtxPopCurrent(nullptr), __LINE__, __FILE__); return 1; } @@ -159,7 +159,7 @@ int Decoder::handle_picture_display(CUVIDPARSERDISPINFO* disp_info) { check_for_cuda_errors(cuStreamSynchronize(cuvidStream), __LINE__, __FILE__); decoded_frames.push(decoded_frame); - check_for_cuda_errors(cuCtxPopCurrent(NULL), __LINE__, __FILE__); + check_for_cuda_errors(cuCtxPopCurrent(nullptr), __LINE__, __FILE__); check_for_cuda_errors( cuvidUnmapVideoFrame(decoder, source_frame), __LINE__, __FILE__); @@ -177,7 +177,7 @@ void Decoder::query_hardware(CUVIDEOFORMAT* video_format) { check_for_cuda_errors(cuCtxPushCurrent(cu_context), __LINE__, __FILE__); check_for_cuda_errors(cuvidGetDecoderCaps(&decode_caps), __LINE__, __FILE__); - check_for_cuda_errors(cuCtxPopCurrent(NULL), __LINE__, __FILE__); + check_for_cuda_errors(cuCtxPopCurrent(nullptr), __LINE__, __FILE__); if (!decode_caps.bIsSupported) { TORCH_CHECK(false, "Codec not supported on this GPU"); @@ -319,7 +319,7 @@ int Decoder::handle_video_sequence(CUVIDEOFORMAT* video_format) { cuvidCreateDecoder(&decoder, &video_decode_create_info), __LINE__, __FILE__); - check_for_cuda_errors(cuCtxPopCurrent(NULL), __LINE__, __FILE__); + check_for_cuda_errors(cuCtxPopCurrent(nullptr), __LINE__, __FILE__); return decode_surface; } @@ -389,7 +389,7 @@ int Decoder::reconfigure_decoder(CUVIDEOFORMAT* video_format) { check_for_cuda_errors(cuCtxPushCurrent(cu_context), __LINE__, __FILE__); check_for_cuda_errors( cuvidReconfigureDecoder(decoder, &reconfig_params), __LINE__, __FILE__); - check_for_cuda_errors(cuCtxPopCurrent(NULL), __LINE__, __FILE__); + check_for_cuda_errors(cuCtxPopCurrent(nullptr), __LINE__, __FILE__); return decode_surface; } diff --git a/torchvision/csrc/io/image/cpu/encode_png.cpp b/torchvision/csrc/io/image/cpu/encode_png.cpp index a9b7d76ff61..5596d3a6789 100644 --- a/torchvision/csrc/io/image/cpu/encode_png.cpp +++ b/torchvision/csrc/io/image/cpu/encode_png.cpp @@ -71,7 +71,7 @@ torch::Tensor encode_png(const torch::Tensor& data, int64_t compression_level) { // Define output buffer struct torch_mem_encode buf_info; - buf_info.buffer = NULL; + buf_info.buffer = nullptr; buf_info.size = 0; /* Establish the setjmp return context for my_error_exit to use. */ @@ -79,15 +79,15 @@ torch::Tensor encode_png(const torch::Tensor& data, int64_t compression_level) { /* If we get here, the PNG code has signaled an error. * We need to clean up the PNG object and the buffer. */ - if (info_ptr != NULL) { + if (info_ptr != nullptr) { png_destroy_info_struct(png_write, &info_ptr); } - if (png_write != NULL) { - png_destroy_write_struct(&png_write, NULL); + if (png_write != nullptr) { + png_destroy_write_struct(&png_write, nullptr); } - if (buf_info.buffer != NULL) { + if (buf_info.buffer != nullptr) { free(buf_info.buffer); } @@ -121,12 +121,12 @@ torch::Tensor encode_png(const torch::Tensor& data, int64_t compression_level) { // Initialize PNG structures png_write = png_create_write_struct( - PNG_LIBPNG_VER_STRING, &err_ptr, torch_png_error, NULL); + PNG_LIBPNG_VER_STRING, &err_ptr, torch_png_error, nullptr); info_ptr = png_create_info_struct(png_write); // Define custom buffer output - png_set_write_fn(png_write, &buf_info, torch_png_write_data, NULL); + png_set_write_fn(png_write, &buf_info, torch_png_write_data, nullptr); // Set output image information auto color_type = channels == 1 ? PNG_COLOR_TYPE_GRAY : PNG_COLOR_TYPE_RGB; diff --git a/torchvision/csrc/io/image/cpu/read_write_file.cpp b/torchvision/csrc/io/image/cpu/read_write_file.cpp index def74c6721a..06de72a5053 100644 --- a/torchvision/csrc/io/image/cpu/read_write_file.cpp +++ b/torchvision/csrc/io/image/cpu/read_write_file.cpp @@ -17,7 +17,7 @@ std::wstring utf8_decode(const std::string& str) { return std::wstring(); } int size_needed = MultiByteToWideChar( - CP_UTF8, 0, str.c_str(), static_cast(str.size()), NULL, 0); + CP_UTF8, 0, str.c_str(), static_cast(str.size()), nullptr, 0); TORCH_CHECK(size_needed > 0, "Error converting the content to Unicode"); std::wstring wstrTo(size_needed, 0); MultiByteToWideChar( diff --git a/torchvision/csrc/io/image/image.cpp b/torchvision/csrc/io/image/image.cpp index 53d588e4746..fb5ee874acb 100644 --- a/torchvision/csrc/io/image/image.cpp +++ b/torchvision/csrc/io/image/image.cpp @@ -11,7 +11,7 @@ #ifdef _WIN32 PyMODINIT_FUNC PyInit_image(void) { // No need to do anything. - return NULL; + return nullptr; } #endif #endif // USE_PYTHON diff --git a/torchvision/csrc/io/video/video.cpp b/torchvision/csrc/io/video/video.cpp index cdba43c68ee..17ecce2b99e 100644 --- a/torchvision/csrc/io/video/video.cpp +++ b/torchvision/csrc/io/video/video.cpp @@ -2,6 +2,8 @@ #include +using namespace ffmpeg; + namespace vision { namespace video { diff --git a/torchvision/csrc/io/video/video.h b/torchvision/csrc/io/video/video.h index 7e57fcf6ed1..abda3a39c6d 100644 --- a/torchvision/csrc/io/video/video.h +++ b/torchvision/csrc/io/video/video.h @@ -64,12 +64,12 @@ struct Video : torch::CustomClassHolder { std::map> streamTimeBase; // not used - DecoderInCallback callback = nullptr; - std::vector metadata; + ffmpeg::DecoderInCallback callback = nullptr; + std::vector metadata; protected: - SyncDecoder decoder; - DecoderParameters params; + ffmpeg::SyncDecoder decoder; + ffmpeg::DecoderParameters params; }; // struct Video diff --git a/torchvision/csrc/io/video_reader/video_reader.cpp b/torchvision/csrc/io/video_reader/video_reader.cpp index 39b9cacc224..78b0a64d1cb 100644 --- a/torchvision/csrc/io/video_reader/video_reader.cpp +++ b/torchvision/csrc/io/video_reader/video_reader.cpp @@ -13,7 +13,7 @@ #ifdef _WIN32 PyMODINIT_FUNC PyInit_video_reader(void) { // No need to do anything. - return NULL; + return nullptr; } #endif #endif // USE_PYTHONs diff --git a/torchvision/csrc/vision.cpp b/torchvision/csrc/vision.cpp index 161b8ecfa2f..b7040cdf4de 100644 --- a/torchvision/csrc/vision.cpp +++ b/torchvision/csrc/vision.cpp @@ -21,7 +21,7 @@ #ifdef USE_PYTHON PyMODINIT_FUNC PyInit__C(void) { // No need to do anything. - return NULL; + return nullptr; } #endif // USE_PYTHON #endif // !defined(MOBILE) && defined(_WIN32)