shithub: libvpx

Download patch

ref: 4916a87bfc58b96882db3a9e978e604384821d92
parent: 941fe20336d051a5b79623c110c7eb86b81467d1
parent: 475e9d26e0e612cf2fd2fe650f67add316a53718
author: James Zern <jzern@google.com>
date: Tue Aug 9 20:05:54 EDT 2016

Merge changes I1d3edbdb,I8b49fd05

* changes:
  tests: use scoped_ptr for local video source vars
  y4m_test: init members in the constructor

--- a/test/external_frame_buffer_test.cc
+++ b/test/external_frame_buffer_test.cc
@@ -350,7 +350,6 @@
 // Otherwise, the test failed.
 TEST_P(ExternalFrameBufferMD5Test, ExtFBMD5Match) {
   const std::string filename = GET_PARAM(kVideoNameParam);
-  libvpx_test::CompressedVideoSource *video = NULL;
 
   // Number of buffers equals #VP9_MAXIMUM_REF_BUFFERS +
   // #VPX_MAXIMUM_WORK_BUFFERS + four jitter buffers.
@@ -365,11 +364,12 @@
 #endif
 
   // Open compressed video file.
+  testing::internal::scoped_ptr<libvpx_test::CompressedVideoSource> video;
   if (filename.substr(filename.length() - 3, 3) == "ivf") {
-    video = new libvpx_test::IVFVideoSource(filename);
+    video.reset(new libvpx_test::IVFVideoSource(filename));
   } else {
 #if CONFIG_WEBM_IO
-    video = new libvpx_test::WebMVideoSource(filename);
+    video.reset(new libvpx_test::WebMVideoSource(filename));
 #else
     fprintf(stderr, "WebM IO is disabled, skipping test vector %s\n",
             filename.c_str());
@@ -376,7 +376,7 @@
     return;
 #endif
   }
-  ASSERT_TRUE(video != NULL);
+  ASSERT_TRUE(video.get() != NULL);
   video->Init();
 
   // Construct md5 file name.
@@ -384,8 +384,7 @@
   OpenMD5File(md5_filename);
 
   // Decode frame, and check the md5 matching.
-  ASSERT_NO_FATAL_FAILURE(RunLoop(video));
-  delete video;
+  ASSERT_NO_FATAL_FAILURE(RunLoop(video.get()));
 }
 
 #if CONFIG_WEBM_IO
--- a/test/invalid_file_test.cc
+++ b/test/invalid_file_test.cc
@@ -84,17 +84,17 @@
 
   void RunTest() {
     const DecodeParam input = GET_PARAM(1);
-    libvpx_test::CompressedVideoSource *video = NULL;
     vpx_codec_dec_cfg_t cfg = vpx_codec_dec_cfg_t();
     cfg.threads = input.threads;
     const std::string filename = input.filename;
 
     // Open compressed video file.
+    testing::internal::scoped_ptr<libvpx_test::CompressedVideoSource> video;
     if (filename.substr(filename.length() - 3, 3) == "ivf") {
-      video = new libvpx_test::IVFVideoSource(filename);
+      video.reset(new libvpx_test::IVFVideoSource(filename));
     } else if (filename.substr(filename.length() - 4, 4) == "webm") {
 #if CONFIG_WEBM_IO
-      video = new libvpx_test::WebMVideoSource(filename);
+      video.reset(new libvpx_test::WebMVideoSource(filename));
 #else
       fprintf(stderr, "WebM IO is disabled, skipping test vector %s\n",
               filename.c_str());
@@ -101,6 +101,7 @@
       return;
 #endif
     }
+    ASSERT_TRUE(video.get() != NULL);
     video->Init();
 
     // Construct result file name. The file holds a list of expected integer
@@ -110,8 +111,7 @@
     OpenResFile(res_filename);
 
     // Decode frame, and check the md5 matching.
-    ASSERT_NO_FATAL_FAILURE(RunLoop(video, cfg));
-    delete video;
+    ASSERT_NO_FATAL_FAILURE(RunLoop(video.get(), cfg));
   }
 
  private:
--- a/test/test_vector_test.cc
+++ b/test/test_vector_test.cc
@@ -94,7 +94,6 @@
   const std::string filename = std::tr1::get<kFileName>(input);
   const int threads = std::tr1::get<kThreads>(input);
   const int mode = std::tr1::get<kDecodeMode>(input);
-  libvpx_test::CompressedVideoSource *video = NULL;
   vpx_codec_flags_t flags = 0;
   vpx_codec_dec_cfg_t cfg = vpx_codec_dec_cfg_t();
   char str[256];
@@ -119,11 +118,12 @@
   SCOPED_TRACE(str);
 
   // Open compressed video file.
+  testing::internal::scoped_ptr<libvpx_test::CompressedVideoSource> video;
   if (filename.substr(filename.length() - 3, 3) == "ivf") {
-    video = new libvpx_test::IVFVideoSource(filename);
+    video.reset(new libvpx_test::IVFVideoSource(filename));
   } else if (filename.substr(filename.length() - 4, 4) == "webm") {
 #if CONFIG_WEBM_IO
-    video = new libvpx_test::WebMVideoSource(filename);
+    video.reset(new libvpx_test::WebMVideoSource(filename));
 #else
     fprintf(stderr, "WebM IO is disabled, skipping test vector %s\n",
             filename.c_str());
@@ -130,6 +130,7 @@
     return;
 #endif
   }
+  ASSERT_TRUE(video.get() != NULL);
   video->Init();
 
   // Construct md5 file name.
@@ -141,8 +142,7 @@
   set_flags(flags);
 
   // Decode frame, and check the md5 matching.
-  ASSERT_NO_FATAL_FAILURE(RunLoop(video, cfg));
-  delete video;
+  ASSERT_NO_FATAL_FAILURE(RunLoop(video.get(), cfg));
 }
 
 // Test VP8 decode in serial mode with single thread.
--- a/test/vp9_encoder_parms_get_to_decoder.cc
+++ b/test/vp9_encoder_parms_get_to_decoder.cc
@@ -140,12 +140,11 @@
 TEST_P(VpxEncoderParmsGetToDecoder, BitstreamParms) {
   init_flags_ = VPX_CODEC_USE_PSNR;
 
-  libvpx_test::VideoSource *const video =
-      new libvpx_test::Y4mVideoSource(test_video_.name, 0, test_video_.frames);
-  ASSERT_TRUE(video != NULL);
+  testing::internal::scoped_ptr<libvpx_test::VideoSource> video(
+      new libvpx_test::Y4mVideoSource(test_video_.name, 0, test_video_.frames));
+  ASSERT_TRUE(video.get() != NULL);
 
-  ASSERT_NO_FATAL_FAILURE(RunLoop(video));
-  delete video;
+  ASSERT_NO_FATAL_FAILURE(RunLoop(video.get()));
 }
 
 VP9_INSTANTIATE_TEST_CASE(VpxEncoderParmsGetToDecoder,
--- a/test/vp9_end_to_end_test.cc
+++ b/test/vp9_end_to_end_test.cc
@@ -154,20 +154,20 @@
   init_flags_ = VPX_CODEC_USE_PSNR;
   if (cfg_.g_bit_depth > 8) init_flags_ |= VPX_CODEC_USE_HIGHBITDEPTH;
 
-  libvpx_test::VideoSource *video;
+  testing::internal::scoped_ptr<libvpx_test::VideoSource> video;
   if (is_extension_y4m(test_video_param_.filename)) {
-    video =
-        new libvpx_test::Y4mVideoSource(test_video_param_.filename, 0, kFrames);
+    video.reset(new libvpx_test::Y4mVideoSource(test_video_param_.filename, 0,
+                                                kFrames));
   } else {
-    video = new libvpx_test::YUVVideoSource(test_video_param_.filename,
-                                            test_video_param_.fmt, kWidth,
-                                            kHeight, kFramerate, 1, 0, kFrames);
+    video.reset(new libvpx_test::YUVVideoSource(
+        test_video_param_.filename, test_video_param_.fmt, kWidth, kHeight,
+        kFramerate, 1, 0, kFrames));
   }
+  ASSERT_TRUE(video.get() != NULL);
 
-  ASSERT_NO_FATAL_FAILURE(RunLoop(video));
+  ASSERT_NO_FATAL_FAILURE(RunLoop(video.get()));
   const double psnr = GetAveragePsnr();
   EXPECT_GT(psnr, GetPsnrThreshold());
-  delete (video);
 }
 
 VP9_INSTANTIATE_TEST_CASE(EndToEndTestLarge,
--- a/test/y4m_test.cc
+++ b/test/y4m_test.cc
@@ -138,7 +138,7 @@
 
 class Y4mVideoWriteTest : public Y4mVideoSourceTest {
  protected:
-  Y4mVideoWriteTest() {}
+  Y4mVideoWriteTest() : tmpfile_(NULL) {}
 
   virtual ~Y4mVideoWriteTest() {
     delete tmpfile_;