Skip to content

Commit

Permalink
style(*): convert all uses of NULL to nullptr
Browse files Browse the repository at this point in the history
Signed-off-by: k4yt3x <i@k4yt3x.com>
  • Loading branch information
k4yt3x committed Jan 4, 2025
1 parent f38452f commit 953147e
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/fsutils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ static std::filesystem::path get_executable_directory() {
std::vector<wchar_t> filepath(MAX_PATH);

// Get the executable path, expanding the buffer if necessary
DWORD size = GetModuleFileNameW(NULL, filepath.data(), static_cast<DWORD>(filepath.size()));
DWORD size = GetModuleFileNameW(nullptr, filepath.data(), static_cast<DWORD>(filepath.size()));
if (size == 0) {
logger()->error("Error getting executable path: {}", GetLastError());
return std::filesystem::path();
Expand All @@ -29,7 +29,7 @@ static std::filesystem::path get_executable_directory() {
// Resize the buffer if necessary
while (size >= filepath.size()) {
filepath.resize(filepath.size() * 2);
size = GetModuleFileNameW(NULL, filepath.data(), static_cast<DWORD>(filepath.size()));
size = GetModuleFileNameW(nullptr, filepath.data(), static_cast<DWORD>(filepath.size()));
if (size == 0) {
logger()->error("Error getting executable path: {}", GetLastError());
return std::filesystem::path();
Expand Down
20 changes: 12 additions & 8 deletions src/libplacebo.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "libplacebo.h"

#include <stdio.h>
#include <stdlib.h>
#include <string>

Expand Down Expand Up @@ -31,7 +30,11 @@ int init_libplacebo(
// Create the Vulkan hardware device context
AVBufferRef* vk_hw_device_ctx = nullptr;
ret = av_hwdevice_ctx_create(
&vk_hw_device_ctx, AV_HWDEVICE_TYPE_VULKAN, std::to_string(vk_device_index).c_str(), NULL, 0
&vk_hw_device_ctx,
AV_HWDEVICE_TYPE_VULKAN,
std::to_string(vk_device_index).c_str(),
nullptr,
0
);
if (ret < 0) {
logger()->error("Failed to create Vulkan hardware device context for libplacebo.");
Expand Down Expand Up @@ -68,21 +71,22 @@ int init_libplacebo(
AVClass* priv_class_copy_ptr = &priv_class_copy;

// Check if the colorspace option is supported
if (av_opt_find(&priv_class_copy_ptr, "colorspace", NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)) {
if (av_opt_find(&priv_class_copy_ptr, "colorspace", nullptr, 0, AV_OPT_SEARCH_FAKE_OBJ)) {
args += ":colorspace=" + std::to_string(dec_ctx->colorspace);
} else {
logger()->warn("Option 'colorspace' is not supported by the buffer filter.");
}

// Check if the range option is supported
if (av_opt_find(&priv_class_copy_ptr, "range", NULL, 0, AV_OPT_SEARCH_FAKE_OBJ)) {
if (av_opt_find(&priv_class_copy_ptr, "range", nullptr, 0, AV_OPT_SEARCH_FAKE_OBJ)) {
args += ":range=" + std::to_string(dec_ctx->color_range);
} else {
logger()->warn("Option 'range' is not supported by the buffer filter.");
}

logger()->debug("Buffer source args: {}", args);
ret = avfilter_graph_create_filter(buffersrc_ctx, buffersrc, "in", args.c_str(), NULL, graph);
ret =
avfilter_graph_create_filter(buffersrc_ctx, buffersrc, "in", args.c_str(), nullptr, graph);
if (ret < 0) {
logger()->error("Cannot create buffer source.");
avfilter_graph_free(&graph);
Expand Down Expand Up @@ -114,7 +118,7 @@ int init_libplacebo(

AVFilterContext* libplacebo_ctx;
ret = avfilter_graph_create_filter(
&libplacebo_ctx, libplacebo_filter, "libplacebo", filter_args.c_str(), NULL, graph
&libplacebo_ctx, libplacebo_filter, "libplacebo", filter_args.c_str(), nullptr, graph
);
if (ret < 0) {
logger()->error("Cannot create libplacebo filter.");
Expand All @@ -140,7 +144,7 @@ int init_libplacebo(

// Create buffer sink
const AVFilter* buffersink = avfilter_get_by_name("buffersink");
ret = avfilter_graph_create_filter(buffersink_ctx, buffersink, "out", NULL, NULL, graph);
ret = avfilter_graph_create_filter(buffersink_ctx, buffersink, "out", nullptr, nullptr, graph);
if (ret < 0) {
logger()->error("Cannot create buffer sink.");
avfilter_graph_free(&graph);
Expand All @@ -156,7 +160,7 @@ int init_libplacebo(
}

// Configure the filter graph
ret = avfilter_graph_config(graph, NULL);
ret = avfilter_graph_config(graph, nullptr);
if (ret < 0) {
logger()->error("Error configuring the filter graph.");
avfilter_graph_free(&graph);
Expand Down
2 changes: 1 addition & 1 deletion src/libvideo2x.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ int VideoProcessor::process(
// Initialize hardware device context
if (hw_device_type_ != AV_HWDEVICE_TYPE_NONE) {
AVBufferRef* tmp_hw_ctx = nullptr;
ret = av_hwdevice_ctx_create(&tmp_hw_ctx, hw_device_type_, NULL, NULL, 0);
ret = av_hwdevice_ctx_create(&tmp_hw_ctx, hw_device_type_, nullptr, nullptr, 0);
if (ret < 0) {
return handle_error(ret, "Error initializing hardware device context");
}
Expand Down

0 comments on commit 953147e

Please sign in to comment.