shithub: libvpx

Download patch

ref: a53da566290db46ed32e465aa3d8b4b70b299886
parent: 3bc58f13cc4ae0881ce483a8dcd7789a2d6f325d
author: angiebird <[email protected]>
date: Mon May 18 15:33:05 EDT 2020

Refactor decode_api_test and realtime_test

Replace NULL by nullptr.
Use override specifier over virtual specifier.

Change-Id: Iac2c97f997abd6ed9a5cd3991e052e79996f40f4

--- a/test/decode_api_test.cc
+++ b/test/decode_api_test.cc
@@ -31,28 +31,33 @@
   uint8_t buf[1] = { 0 };
   vpx_codec_ctx_t dec;
 
-  EXPECT_EQ(VPX_CODEC_INVALID_PARAM, vpx_codec_dec_init(NULL, NULL, NULL, 0));
-  EXPECT_EQ(VPX_CODEC_INVALID_PARAM, vpx_codec_dec_init(&dec, NULL, NULL, 0));
-  EXPECT_EQ(VPX_CODEC_INVALID_PARAM, vpx_codec_decode(NULL, NULL, 0, NULL, 0));
-  EXPECT_EQ(VPX_CODEC_INVALID_PARAM, vpx_codec_decode(NULL, buf, 0, NULL, 0));
-  EXPECT_EQ(VPX_CODEC_INVALID_PARAM,
-            vpx_codec_decode(NULL, buf, NELEMENTS(buf), NULL, 0));
-  EXPECT_EQ(VPX_CODEC_INVALID_PARAM,
-            vpx_codec_decode(NULL, NULL, NELEMENTS(buf), NULL, 0));
-  EXPECT_EQ(VPX_CODEC_INVALID_PARAM, vpx_codec_destroy(NULL));
-  EXPECT_TRUE(vpx_codec_error(NULL) != NULL);
-  EXPECT_TRUE(vpx_codec_error_detail(NULL) == NULL);
+  EXPECT_EQ(vpx_codec_dec_init(nullptr, nullptr, nullptr, 0),
+            VPX_CODEC_INVALID_PARAM);
+  EXPECT_EQ(vpx_codec_dec_init(&dec, nullptr, nullptr, 0),
+            VPX_CODEC_INVALID_PARAM);
+  EXPECT_EQ(vpx_codec_decode(nullptr, nullptr, 0, nullptr, 0),
+            VPX_CODEC_INVALID_PARAM);
+  EXPECT_EQ(vpx_codec_decode(nullptr, buf, 0, nullptr, 0),
+            VPX_CODEC_INVALID_PARAM);
+  EXPECT_EQ(vpx_codec_decode(nullptr, buf, NELEMENTS(buf), nullptr, 0),
+            VPX_CODEC_INVALID_PARAM);
+  EXPECT_EQ(vpx_codec_decode(nullptr, nullptr, NELEMENTS(buf), nullptr, 0),
+            VPX_CODEC_INVALID_PARAM);
+  EXPECT_EQ(vpx_codec_destroy(nullptr), VPX_CODEC_INVALID_PARAM);
+  EXPECT_NE(vpx_codec_error(nullptr), nullptr);
+  EXPECT_EQ(vpx_codec_error_detail(nullptr), nullptr);
 
   for (int i = 0; i < NELEMENTS(kCodecs); ++i) {
     EXPECT_EQ(VPX_CODEC_INVALID_PARAM,
-              vpx_codec_dec_init(NULL, kCodecs[i], NULL, 0));
+              vpx_codec_dec_init(nullptr, kCodecs[i], nullptr, 0));
 
-    EXPECT_EQ(VPX_CODEC_OK, vpx_codec_dec_init(&dec, kCodecs[i], NULL, 0));
+    EXPECT_EQ(VPX_CODEC_OK, vpx_codec_dec_init(&dec, kCodecs[i], nullptr, 0));
     EXPECT_EQ(VPX_CODEC_UNSUP_BITSTREAM,
-              vpx_codec_decode(&dec, buf, NELEMENTS(buf), NULL, 0));
+              vpx_codec_decode(&dec, buf, NELEMENTS(buf), nullptr, 0));
     EXPECT_EQ(VPX_CODEC_INVALID_PARAM,
-              vpx_codec_decode(&dec, NULL, NELEMENTS(buf), NULL, 0));
-    EXPECT_EQ(VPX_CODEC_INVALID_PARAM, vpx_codec_decode(&dec, buf, 0, NULL, 0));
+              vpx_codec_decode(&dec, nullptr, NELEMENTS(buf), nullptr, 0));
+    EXPECT_EQ(VPX_CODEC_INVALID_PARAM,
+              vpx_codec_decode(&dec, buf, 0, nullptr, 0));
 
     EXPECT_EQ(VPX_CODEC_OK, vpx_codec_destroy(&dec));
   }
@@ -63,11 +68,12 @@
   vpx_codec_ctx_t dec;
 
 #if CONFIG_ERROR_CONCEALMENT
-  EXPECT_EQ(VPX_CODEC_OK, vpx_codec_dec_init(&dec, &vpx_codec_vp8_dx_algo, NULL,
-                                             VPX_CODEC_USE_ERROR_CONCEALMENT));
+  EXPECT_EQ(VPX_CODEC_OK,
+            vpx_codec_dec_init(&dec, &vpx_codec_vp8_dx_algo, nullptr,
+                               VPX_CODEC_USE_ERROR_CONCEALMENT));
 #else
   EXPECT_EQ(VPX_CODEC_INCAPABLE,
-            vpx_codec_dec_init(&dec, &vpx_codec_vp8_dx_algo, NULL,
+            vpx_codec_dec_init(&dec, &vpx_codec_vp8_dx_algo, nullptr,
                                VPX_CODEC_USE_ERROR_CONCEALMENT));
 #endif  // CONFIG_ERROR_CONCEALMENT
 }
@@ -91,7 +97,7 @@
       default: EXPECT_EQ(VPX_CODEC_OK, res) << kControls[i]; break;
     }
     EXPECT_EQ(VPX_CODEC_INVALID_PARAM,
-              vpx_codec_control_(dec, kControls[i], NULL));
+              vpx_codec_control_(dec, kControls[i], nullptr));
   }
 
   vp9_ref_frame_t ref;
@@ -98,18 +104,18 @@
   ref.idx = 0;
   EXPECT_EQ(VPX_CODEC_ERROR, vpx_codec_control(dec, VP9_GET_REFERENCE, &ref));
   EXPECT_EQ(VPX_CODEC_INVALID_PARAM,
-            vpx_codec_control(dec, VP9_GET_REFERENCE, NULL));
+            vpx_codec_control(dec, VP9_GET_REFERENCE, nullptr));
 
   vpx_ref_frame_t ref_copy;
   const int width = 352;
   const int height = 288;
-  ASSERT_TRUE(
-      vpx_img_alloc(&ref_copy.img, VPX_IMG_FMT_I420, width, height, 1) != NULL);
+  EXPECT_NE(vpx_img_alloc(&ref_copy.img, VPX_IMG_FMT_I420, width, height, 1),
+            nullptr);
   ref_copy.frame_type = VP8_LAST_FRAME;
   EXPECT_EQ(VPX_CODEC_ERROR,
             vpx_codec_control(dec, VP8_COPY_REFERENCE, &ref_copy));
   EXPECT_EQ(VPX_CODEC_INVALID_PARAM,
-            vpx_codec_control(dec, VP8_COPY_REFERENCE, NULL));
+            vpx_codec_control(dec, VP8_COPY_REFERENCE, nullptr));
   vpx_img_free(&ref_copy.img);
 }
 
@@ -123,17 +129,17 @@
   ASSERT_TRUE(!HasFailure());
 
   vpx_codec_ctx_t dec;
-  EXPECT_EQ(VPX_CODEC_OK, vpx_codec_dec_init(&dec, codec, NULL, 0));
+  EXPECT_EQ(VPX_CODEC_OK, vpx_codec_dec_init(&dec, codec, nullptr, 0));
   const uint32_t frame_size = static_cast<uint32_t>(video.frame_size());
 #if CONFIG_VP9_HIGHBITDEPTH
   EXPECT_EQ(VPX_CODEC_MEM_ERROR,
-            vpx_codec_decode(&dec, video.cxdata(), frame_size, NULL, 0));
+            vpx_codec_decode(&dec, video.cxdata(), frame_size, nullptr, 0));
 #else
   EXPECT_EQ(VPX_CODEC_UNSUP_BITSTREAM,
-            vpx_codec_decode(&dec, video.cxdata(), frame_size, NULL, 0));
+            vpx_codec_decode(&dec, video.cxdata(), frame_size, nullptr, 0));
 #endif
-  vpx_codec_iter_t iter = NULL;
-  EXPECT_EQ(NULL, vpx_codec_get_frame(&dec, &iter));
+  vpx_codec_iter_t iter = nullptr;
+  EXPECT_EQ(nullptr, vpx_codec_get_frame(&dec, &iter));
 
   TestVp9Controls(&dec);
   EXPECT_EQ(VPX_CODEC_OK, vpx_codec_destroy(&dec));
@@ -146,12 +152,12 @@
   // to decoder_peek_si_internal on frames of size < 8.
   if (data_sz >= 8) {
     vpx_codec_ctx_t dec;
-    EXPECT_EQ(VPX_CODEC_OK, vpx_codec_dec_init(&dec, codec, NULL, 0));
+    EXPECT_EQ(VPX_CODEC_OK, vpx_codec_dec_init(&dec, codec, nullptr, 0));
     EXPECT_EQ((data_sz < peek_size) ? VPX_CODEC_UNSUP_BITSTREAM
                                     : VPX_CODEC_CORRUPT_FRAME,
-              vpx_codec_decode(&dec, data, data_sz, NULL, 0));
-    vpx_codec_iter_t iter = NULL;
-    EXPECT_EQ(NULL, vpx_codec_get_frame(&dec, &iter));
+              vpx_codec_decode(&dec, data, data_sz, nullptr, 0));
+    vpx_codec_iter_t iter = nullptr;
+    EXPECT_EQ(nullptr, vpx_codec_get_frame(&dec, &iter));
     EXPECT_EQ(VPX_CODEC_OK, vpx_codec_destroy(&dec));
   }
 
--- a/test/realtime_test.cc
+++ b/test/realtime_test.cc
@@ -24,15 +24,15 @@
       public ::libvpx_test::CodecTestWithParam<libvpx_test::TestMode> {
  protected:
   RealtimeTest() : EncoderTest(GET_PARAM(0)), frame_packets_(0) {}
-  virtual ~RealtimeTest() {}
+  ~RealtimeTest() override {}
 
-  virtual void SetUp() {
+  void SetUp() override {
     InitializeConfig();
     cfg_.g_lag_in_frames = 0;
     SetMode(::libvpx_test::kRealTime);
   }
 
-  virtual void BeginPassHook(unsigned int /*pass*/) {
+  void BeginPassHook(unsigned int /*pass*/) override {
     // TODO(tomfinegan): We're changing the pass value here to make sure
     // we get frames when real time mode is combined with |g_pass| set to
     // VPX_RC_FIRST_PASS. This is necessary because EncoderTest::RunLoop() sets
@@ -41,14 +41,14 @@
     cfg_.g_pass = VPX_RC_FIRST_PASS;
   }
 
-  virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
-                                  ::libvpx_test::Encoder *encoder) {
+  void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
+                          ::libvpx_test::Encoder *encoder) override {
     if (video->frame() == 0) {
       encoder->Control(VP8E_SET_CPUUSED, 8);
     }
   }
 
-  virtual void FramePktHook(const vpx_codec_cx_pkt_t * /*pkt*/) {
+  void FramePktHook(const vpx_codec_cx_pkt_t * /*pkt*/) override {
     frame_packets_++;
   }