Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
vision
Commits
d868be90
Unverified
Commit
d868be90
authored
Mar 20, 2024
by
Nicolas Hug
Committed by
GitHub
Mar 20, 2024
Browse files
[FBcode->GH] [codemod] Use `nullptr` intead of NULL (#8335)
Co-authored-by:
Richard Barnes
<
rbarnes@meta.com
>
parent
18a1d411
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
17 additions
and
17 deletions
+17
-17
torchvision/csrc/io/decoder/gpu/decoder.cpp
torchvision/csrc/io/decoder/gpu/decoder.cpp
+6
-6
torchvision/csrc/io/image/cpu/encode_png.cpp
torchvision/csrc/io/image/cpu/encode_png.cpp
+7
-7
torchvision/csrc/io/image/cpu/read_write_file.cpp
torchvision/csrc/io/image/cpu/read_write_file.cpp
+1
-1
torchvision/csrc/io/image/image.cpp
torchvision/csrc/io/image/image.cpp
+1
-1
torchvision/csrc/io/video_reader/video_reader.cpp
torchvision/csrc/io/video_reader/video_reader.cpp
+1
-1
torchvision/csrc/vision.cpp
torchvision/csrc/vision.cpp
+1
-1
No files found.
torchvision/csrc/io/decoder/gpu/decoder.cpp
View file @
d868be90
...
...
@@ -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
;
}
...
...
torchvision/csrc/io/image/cpu/encode_png.cpp
View file @
d868be90
...
...
@@ -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
;
...
...
torchvision/csrc/io/image/cpu/read_write_file.cpp
View file @
d868be90
...
...
@@ -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
<
int
>
(
str
.
size
()),
NULL
,
0
);
CP_UTF8
,
0
,
str
.
c_str
(),
static_cast
<
int
>
(
str
.
size
()),
nullptr
,
0
);
TORCH_CHECK
(
size_needed
>
0
,
"Error converting the content to Unicode"
);
std
::
wstring
wstrTo
(
size_needed
,
0
);
MultiByteToWideChar
(
...
...
torchvision/csrc/io/image/image.cpp
View file @
d868be90
...
...
@@ -11,7 +11,7 @@
#ifdef _WIN32
PyMODINIT_FUNC
PyInit_image
(
void
)
{
// No need to do anything.
return
NULL
;
return
nullptr
;
}
#endif
#endif // USE_PYTHON
...
...
torchvision/csrc/io/video_reader/video_reader.cpp
View file @
d868be90
...
...
@@ -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
...
...
torchvision/csrc/vision.cpp
View file @
d868be90
...
...
@@ -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)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment