diff options
author | James Zern <jzern@google.com> | 2022-05-27 19:36:47 -0700 |
---|---|---|
committer | James Zern <jzern@google.com> | 2022-05-27 21:57:11 -0700 |
commit | c304ec38d05040b74de4aacada62c4a336714341 (patch) | |
tree | d636c5e35e3c8743a439846758148102865bd43a | |
parent | 9f1329f8ac88ea5d7c6ae5d6a57221c36cf85ac8 (diff) | |
download | libvpx-c304ec38d05040b74de4aacada62c4a336714341.tar libvpx-c304ec38d05040b74de4aacada62c4a336714341.tar.gz libvpx-c304ec38d05040b74de4aacada62c4a336714341.tar.bz2 libvpx-c304ec38d05040b74de4aacada62c4a336714341.zip |
test/*: normalize use of nullptr
this is preferred over NULL in C++11
Change-Id: Ic48ddcc6dfb8975a57f6713549ad04d93db21415
-rw-r--r-- | test/buffer.h | 14 | ||||
-rw-r--r-- | test/codec_factory.h | 16 | ||||
-rw-r--r-- | test/decode_test_driver.h | 2 | ||||
-rw-r--r-- | test/encode_test_driver.h | 2 | ||||
-rw-r--r-- | test/ivf_video_source.h | 14 | ||||
-rw-r--r-- | test/register_state_check.h | 2 | ||||
-rw-r--r-- | test/video_source.h | 22 | ||||
-rw-r--r-- | test/webm_video_source.h | 14 | ||||
-rw-r--r-- | test/y4m_test.cc | 4 | ||||
-rw-r--r-- | test/y4m_video_source.h | 16 | ||||
-rw-r--r-- | test/yuv_video_source.h | 16 |
11 files changed, 64 insertions, 58 deletions
diff --git a/test/buffer.h b/test/buffer.h index b003d2f0d..023939ced 100644 --- a/test/buffer.h +++ b/test/buffer.h @@ -31,7 +31,7 @@ class Buffer { : width_(width), height_(height), top_padding_(top_padding), left_padding_(left_padding), right_padding_(right_padding), bottom_padding_(bottom_padding), alignment_(0), padding_value_(0), - stride_(0), raw_size_(0), num_elements_(0), raw_buffer_(NULL) {} + stride_(0), raw_size_(0), num_elements_(0), raw_buffer_(nullptr) {} Buffer(int width, int height, int top_padding, int left_padding, int right_padding, int bottom_padding, unsigned int alignment) @@ -39,19 +39,19 @@ class Buffer { left_padding_(left_padding), right_padding_(right_padding), bottom_padding_(bottom_padding), alignment_(alignment), padding_value_(0), stride_(0), raw_size_(0), num_elements_(0), - raw_buffer_(NULL) {} + raw_buffer_(nullptr) {} Buffer(int width, int height, int padding) : width_(width), height_(height), top_padding_(padding), left_padding_(padding), right_padding_(padding), bottom_padding_(padding), alignment_(0), padding_value_(0), stride_(0), - raw_size_(0), num_elements_(0), raw_buffer_(NULL) {} + raw_size_(0), num_elements_(0), raw_buffer_(nullptr) {} Buffer(int width, int height, int padding, unsigned int alignment) : width_(width), height_(height), top_padding_(padding), left_padding_(padding), right_padding_(padding), bottom_padding_(padding), alignment_(alignment), padding_value_(0), - stride_(0), raw_size_(0), num_elements_(0), raw_buffer_(NULL) {} + stride_(0), raw_size_(0), num_elements_(0), raw_buffer_(nullptr) {} ~Buffer() { if (alignment_) { @@ -103,7 +103,7 @@ class Buffer { bool CheckValues(const Buffer<T> &a) const; bool Init() { - if (raw_buffer_ != NULL) return false; + if (raw_buffer_ != nullptr) return false; EXPECT_GT(width_, 0); EXPECT_GT(height_, 0); EXPECT_GE(top_padding_, 0); @@ -126,7 +126,7 @@ class Buffer { } else { raw_buffer_ = new (std::nothrow) T[num_elements_]; } - EXPECT_TRUE(raw_buffer_ != NULL); + EXPECT_NE(raw_buffer_, nullptr); SetPadding(std::numeric_limits<T>::max()); return !::testing::Test::HasFailure(); } @@ -150,7 +150,7 @@ class Buffer { template <typename T> T *Buffer<T>::TopLeftPixel() const { - if (!raw_buffer_) return NULL; + if (!raw_buffer_) return nullptr; return raw_buffer_ + (top_padding_ * stride_) + left_padding_; } diff --git a/test/codec_factory.h b/test/codec_factory.h index 77ce49de9..96092610c 100644 --- a/test/codec_factory.h +++ b/test/codec_factory.h @@ -88,7 +88,7 @@ class VP8Decoder : public Decoder { #if CONFIG_VP8_DECODER return &vpx_codec_vp8_dx_algo; #else - return NULL; + return nullptr; #endif } }; @@ -104,7 +104,7 @@ class VP8Encoder : public Encoder { #if CONFIG_VP8_ENCODER return &vpx_codec_vp8_cx_algo; #else - return NULL; + return nullptr; #endif } }; @@ -124,7 +124,7 @@ class VP8CodecFactory : public CodecFactory { #else (void)cfg; (void)flags; - return NULL; + return nullptr; #endif } @@ -139,7 +139,7 @@ class VP8CodecFactory : public CodecFactory { (void)deadline; (void)init_flags; (void)stats; - return NULL; + return nullptr; #endif } @@ -184,7 +184,7 @@ class VP9Decoder : public Decoder { #if CONFIG_VP9_DECODER return &vpx_codec_vp9_dx_algo; #else - return NULL; + return nullptr; #endif } }; @@ -200,7 +200,7 @@ class VP9Encoder : public Encoder { #if CONFIG_VP9_ENCODER return &vpx_codec_vp9_cx_algo; #else - return NULL; + return nullptr; #endif } }; @@ -220,7 +220,7 @@ class VP9CodecFactory : public CodecFactory { #else (void)cfg; (void)flags; - return NULL; + return nullptr; #endif } @@ -235,7 +235,7 @@ class VP9CodecFactory : public CodecFactory { (void)deadline; (void)init_flags; (void)stats; - return NULL; + return nullptr; #endif } diff --git a/test/decode_test_driver.h b/test/decode_test_driver.h index 04876cdd7..f446ab466 100644 --- a/test/decode_test_driver.h +++ b/test/decode_test_driver.h @@ -24,7 +24,7 @@ class CompressedVideoSource; class DxDataIterator { public: explicit DxDataIterator(vpx_codec_ctx_t *decoder) - : decoder_(decoder), iter_(NULL) {} + : decoder_(decoder), iter_(nullptr) {} const vpx_image_t *Next() { return vpx_codec_get_frame(decoder_, &iter_); } diff --git a/test/encode_test_driver.h b/test/encode_test_driver.h index 38c61952e..7085945f6 100644 --- a/test/encode_test_driver.h +++ b/test/encode_test_driver.h @@ -49,7 +49,7 @@ enum TestMode { class CxDataIterator { public: explicit CxDataIterator(vpx_codec_ctx_t *encoder) - : encoder_(encoder), iter_(NULL) {} + : encoder_(encoder), iter_(nullptr) {} const vpx_codec_cx_pkt_t *Next() { return vpx_codec_get_cx_data(encoder_, &iter_); diff --git a/test/ivf_video_source.h b/test/ivf_video_source.h index 22c05ecde..a8ac4f154 100644 --- a/test/ivf_video_source.h +++ b/test/ivf_video_source.h @@ -29,8 +29,9 @@ static unsigned int MemGetLe32(const uint8_t *mem) { class IVFVideoSource : public CompressedVideoSource { public: explicit IVFVideoSource(const std::string &file_name) - : file_name_(file_name), input_file_(NULL), compressed_frame_buf_(NULL), - frame_sz_(0), frame_(0), end_of_file_(false) {} + : file_name_(file_name), input_file_(nullptr), + compressed_frame_buf_(nullptr), frame_sz_(0), frame_(0), + end_of_file_(false) {} virtual ~IVFVideoSource() { delete[] compressed_frame_buf_; @@ -41,13 +42,12 @@ class IVFVideoSource : public CompressedVideoSource { virtual void Init() { // Allocate a buffer for read in the compressed video frame. compressed_frame_buf_ = new uint8_t[libvpx_test::kCodeBufferSize]; - ASSERT_TRUE(compressed_frame_buf_ != NULL) - << "Allocate frame buffer failed"; + ASSERT_NE(compressed_frame_buf_, nullptr) << "Allocate frame buffer failed"; } virtual void Begin() { input_file_ = OpenTestDataFile(file_name_); - ASSERT_TRUE(input_file_ != NULL) + ASSERT_NE(input_file_, nullptr) << "Input file open failed. Filename: " << file_name_; // Read file header @@ -68,7 +68,7 @@ class IVFVideoSource : public CompressedVideoSource { } void FillFrame() { - ASSERT_TRUE(input_file_ != NULL); + ASSERT_NE(input_file_, nullptr); uint8_t frame_hdr[kIvfFrameHdrSize]; // Check frame header and read a frame from input_file. if (fread(frame_hdr, 1, kIvfFrameHdrSize, input_file_) != @@ -87,7 +87,7 @@ class IVFVideoSource : public CompressedVideoSource { } virtual const uint8_t *cxdata() const { - return end_of_file_ ? NULL : compressed_frame_buf_; + return end_of_file_ ? nullptr : compressed_frame_buf_; } virtual size_t frame_size() const { return frame_sz_; } virtual unsigned int frame_number() const { return frame_; } diff --git a/test/register_state_check.h b/test/register_state_check.h index 1746240c6..0b837dd04 100644 --- a/test/register_state_check.h +++ b/test/register_state_check.h @@ -56,7 +56,7 @@ class RegisterStateCheck { private: static bool StoreRegisters(CONTEXT *const context) { const HANDLE this_thread = GetCurrentThread(); - EXPECT_TRUE(this_thread != NULL); + EXPECT_NE(this_thread, nullptr); context->ContextFlags = CONTEXT_FLOATING_POINT; const bool context_saved = GetThreadContext(this_thread, context) == TRUE; EXPECT_TRUE(context_saved) << "GetLastError: " << GetLastError(); diff --git a/test/video_source.h b/test/video_source.h index 349e3de37..a10ff6fb0 100644 --- a/test/video_source.h +++ b/test/video_source.h @@ -42,7 +42,7 @@ namespace libvpx_test { // A simple function to encapsulate cross platform retrieval of test data path static std::string GetDataPath() { const char *const data_path = getenv("LIBVPX_TEST_DATA_PATH"); - if (data_path == NULL) { + if (data_path == nullptr) { #ifdef LIBVPX_TEST_DATA_PATH // In some environments, we cannot set environment variables // Instead, we set the data path by using a preprocessor symbol @@ -76,10 +76,10 @@ static FILE *GetTempOutFile(std::string *file_name) { return fopen(fname, "wb+"); } } - return NULL; + return nullptr; #else std::string temp_dir = testing::TempDir(); - if (temp_dir.empty()) return NULL; + if (temp_dir.empty()) return nullptr; // Versions of testing::TempDir() prior to release-1.11.0-214-g5e6a5336 may // use the value of an environment variable without checking for a trailing // path delimiter. @@ -87,12 +87,12 @@ static FILE *GetTempOutFile(std::string *file_name) { const char name_template[] = "libvpxtest.XXXXXX"; std::unique_ptr<char[]> temp_file_name( new char[temp_dir.size() + sizeof(name_template)]); - if (temp_file_name == nullptr) return NULL; + if (temp_file_name == nullptr) return nullptr; memcpy(temp_file_name.get(), temp_dir.data(), temp_dir.size()); memcpy(temp_file_name.get() + temp_dir.size(), name_template, sizeof(name_template)); const int fd = mkstemp(temp_file_name.get()); - if (fd == -1) return NULL; + if (fd == -1) return nullptr; *file_name = temp_file_name.get(); return fdopen(fd, "wb+"); #endif @@ -114,7 +114,7 @@ class TempOutFile { void CloseFile() { if (file_) { fclose(file_); - file_ = NULL; + file_ = nullptr; } } FILE *file_; @@ -133,7 +133,7 @@ class VideoSource { // Advance the cursor to the next frame virtual void Next() = 0; - // Get the current video frame, or NULL on End-Of-Stream. + // Get the current video frame, or nullptr on End-Of-Stream. virtual vpx_image_t *img() const = 0; // Get the presentation timestamp of the current frame. @@ -155,7 +155,7 @@ class VideoSource { class DummyVideoSource : public VideoSource { public: DummyVideoSource() - : img_(NULL), limit_(100), width_(80), height_(64), + : img_(nullptr), limit_(100), width_(80), height_(64), format_(VPX_IMG_FMT_I420) { ReallocImage(); } @@ -172,7 +172,9 @@ class DummyVideoSource : public VideoSource { FillFrame(); } - virtual vpx_image_t *img() const { return (frame_ < limit_) ? img_ : NULL; } + virtual vpx_image_t *img() const { + return (frame_ < limit_) ? img_ : nullptr; + } // Models a stream where Timebase = 1/FPS, so pts == frame. virtual vpx_codec_pts_t pts() const { return frame_; } @@ -212,7 +214,7 @@ class DummyVideoSource : public VideoSource { void ReallocImage() { vpx_img_free(img_); - img_ = vpx_img_alloc(NULL, format_, width_, height_, 32); + img_ = vpx_img_alloc(nullptr, format_, width_, height_, 32); ASSERT_NE(img_, nullptr); raw_sz_ = ((img_->w + 31) & ~31u) * img_->h * img_->bps / 8; } diff --git a/test/webm_video_source.h b/test/webm_video_source.h index 6f55f7db7..d24592629 100644 --- a/test/webm_video_source.h +++ b/test/webm_video_source.h @@ -26,11 +26,11 @@ class WebMVideoSource : public CompressedVideoSource { public: explicit WebMVideoSource(const std::string &file_name) : file_name_(file_name), vpx_ctx_(new VpxInputContext()), - webm_ctx_(new WebmInputContext()), buf_(NULL), buf_sz_(0), frame_(0), + webm_ctx_(new WebmInputContext()), buf_(nullptr), buf_sz_(0), frame_(0), end_of_file_(false) {} virtual ~WebMVideoSource() { - if (vpx_ctx_->file != NULL) fclose(vpx_ctx_->file); + if (vpx_ctx_->file != nullptr) fclose(vpx_ctx_->file); webm_free(webm_ctx_); delete vpx_ctx_; delete webm_ctx_; @@ -40,7 +40,7 @@ class WebMVideoSource : public CompressedVideoSource { virtual void Begin() { vpx_ctx_->file = OpenTestDataFile(file_name_); - ASSERT_TRUE(vpx_ctx_->file != NULL) + ASSERT_NE(vpx_ctx_->file, nullptr) << "Input file open failed. Filename: " << file_name_; ASSERT_EQ(file_is_webm(webm_ctx_, vpx_ctx_), 1) << "file is not WebM"; @@ -54,7 +54,7 @@ class WebMVideoSource : public CompressedVideoSource { } void FillFrame() { - ASSERT_TRUE(vpx_ctx_->file != NULL); + ASSERT_NE(vpx_ctx_->file, nullptr); const int status = webm_read_frame(webm_ctx_, &buf_, &buf_sz_); ASSERT_GE(status, 0) << "webm_read_frame failed"; if (status == 1) { @@ -63,7 +63,7 @@ class WebMVideoSource : public CompressedVideoSource { } void SeekToNextKeyFrame() { - ASSERT_TRUE(vpx_ctx_->file != NULL); + ASSERT_NE(vpx_ctx_->file, nullptr); do { const int status = webm_read_frame(webm_ctx_, &buf_, &buf_sz_); ASSERT_GE(status, 0) << "webm_read_frame failed"; @@ -74,7 +74,9 @@ class WebMVideoSource : public CompressedVideoSource { } while (!webm_ctx_->is_key_frame && !end_of_file_); } - virtual const uint8_t *cxdata() const { return end_of_file_ ? NULL : buf_; } + virtual const uint8_t *cxdata() const { + return end_of_file_ ? nullptr : buf_; + } virtual size_t frame_size() const { return buf_sz_; } virtual unsigned int frame_number() const { return frame_; } diff --git a/test/y4m_test.cc b/test/y4m_test.cc index 89c6552c5..32f2cd51d 100644 --- a/test/y4m_test.cc +++ b/test/y4m_test.cc @@ -202,7 +202,7 @@ TEST(Y4MHeaderTest, RegularHeader) { EXPECT_EQ(0, fseek(f.file(), 0, 0)); y4m_input y4m; - EXPECT_EQ(y4m_input_open(&y4m, f.file(), /*skip_buffer=*/NULL, + EXPECT_EQ(y4m_input_open(&y4m, f.file(), /*skip_buffer=*/nullptr, /*num_skip=*/0, /*only_420=*/0), 0); EXPECT_EQ(y4m.pic_w, 4); @@ -229,7 +229,7 @@ TEST(Y4MHeaderTest, LongHeader) { EXPECT_EQ(fseek(f.file(), 0, 0), 0); y4m_input y4m; - EXPECT_EQ(y4m_input_open(&y4m, f.file(), /*skip_buffer=*/NULL, + EXPECT_EQ(y4m_input_open(&y4m, f.file(), /*skip_buffer=*/nullptr, /*num_skip=*/0, /*only_420=*/0), 0); EXPECT_EQ(y4m.pic_w, 4); diff --git a/test/y4m_video_source.h b/test/y4m_video_source.h index 89aa2a44f..71fbf3193 100644 --- a/test/y4m_video_source.h +++ b/test/y4m_video_source.h @@ -23,7 +23,7 @@ namespace libvpx_test { class Y4mVideoSource : public VideoSource { public: Y4mVideoSource(const std::string &file_name, unsigned int start, int limit) - : file_name_(file_name), input_file_(NULL), img_(new vpx_image_t()), + : file_name_(file_name), input_file_(nullptr), img_(new vpx_image_t()), start_(start), limit_(limit), frame_(0), framerate_numerator_(0), framerate_denominator_(0), y4m_() {} @@ -35,13 +35,13 @@ class Y4mVideoSource : public VideoSource { virtual void OpenSource() { CloseSource(); input_file_ = OpenTestDataFile(file_name_); - ASSERT_TRUE(input_file_ != NULL) + ASSERT_NE(input_file_, nullptr) << "Input file open failed. Filename: " << file_name_; } virtual void ReadSourceToStart() { - ASSERT_TRUE(input_file_ != NULL); - ASSERT_FALSE(y4m_input_open(&y4m_, input_file_, NULL, 0, 0)); + ASSERT_NE(input_file_, nullptr); + ASSERT_FALSE(y4m_input_open(&y4m_, input_file_, nullptr, 0, 0)); framerate_numerator_ = y4m_.fps_n; framerate_denominator_ = y4m_.fps_d; frame_ = 0; @@ -62,7 +62,7 @@ class Y4mVideoSource : public VideoSource { } virtual vpx_image_t *img() const { - return (frame_ < limit_) ? img_.get() : NULL; + return (frame_ < limit_) ? img_.get() : nullptr; } // Models a stream where Timebase = 1/FPS, so pts == frame. @@ -80,7 +80,7 @@ class Y4mVideoSource : public VideoSource { virtual unsigned int limit() const { return limit_; } virtual void FillFrame() { - ASSERT_TRUE(input_file_ != NULL); + ASSERT_NE(input_file_, nullptr); // Read a frame from input_file. y4m_input_fetch_frame(&y4m_, input_file_, img_.get()); } @@ -101,9 +101,9 @@ class Y4mVideoSource : public VideoSource { void CloseSource() { y4m_input_close(&y4m_); y4m_ = y4m_input(); - if (input_file_ != NULL) { + if (input_file_ != nullptr) { fclose(input_file_); - input_file_ = NULL; + input_file_ = nullptr; } } diff --git a/test/yuv_video_source.h b/test/yuv_video_source.h index 383ab8f1b..51948c0ef 100644 --- a/test/yuv_video_source.h +++ b/test/yuv_video_source.h @@ -27,8 +27,8 @@ class YUVVideoSource : public VideoSource { YUVVideoSource(const std::string &file_name, vpx_img_fmt format, unsigned int width, unsigned int height, int rate_numerator, int rate_denominator, unsigned int start, int limit) - : file_name_(file_name), input_file_(NULL), img_(NULL), start_(start), - limit_(limit), frame_(0), width_(0), height_(0), + : file_name_(file_name), input_file_(nullptr), img_(nullptr), + start_(start), limit_(limit), frame_(0), width_(0), height_(0), format_(VPX_IMG_FMT_NONE), framerate_numerator_(rate_numerator), framerate_denominator_(rate_denominator) { // This initializes format_, raw_size_, width_, height_ and allocates img. @@ -43,7 +43,7 @@ class YUVVideoSource : public VideoSource { virtual void Begin() { if (input_file_) fclose(input_file_); input_file_ = OpenTestDataFile(file_name_); - ASSERT_TRUE(input_file_ != NULL) + ASSERT_NE(input_file_, nullptr) << "Input file open failed. Filename: " << file_name_; if (start_) { fseek(input_file_, static_cast<unsigned>(raw_size_) * start_, SEEK_SET); @@ -58,7 +58,9 @@ class YUVVideoSource : public VideoSource { FillFrame(); } - virtual vpx_image_t *img() const { return (frame_ < limit_) ? img_ : NULL; } + virtual vpx_image_t *img() const { + return (frame_ < limit_) ? img_ : nullptr; + } // Models a stream where Timebase = 1/FPS, so pts == frame. virtual vpx_codec_pts_t pts() const { return frame_; } @@ -78,8 +80,8 @@ class YUVVideoSource : public VideoSource { vpx_img_fmt format) { if (width != width_ || height != height_ || format != format_) { vpx_img_free(img_); - img_ = vpx_img_alloc(NULL, format, width, height, 1); - ASSERT_TRUE(img_ != NULL); + img_ = vpx_img_alloc(nullptr, format, width, height, 1); + ASSERT_NE(img_, nullptr); width_ = width; height_ = height; format_ = format; @@ -99,7 +101,7 @@ class YUVVideoSource : public VideoSource { } virtual void FillFrame() { - ASSERT_TRUE(input_file_ != NULL); + ASSERT_NE(input_file_, nullptr); // Read a frame from input_file. if (fread(img_->img_data, raw_size_, 1, input_file_) == 0) { limit_ = frame_; |