shithub: libvpx

Download patch

ref: 65d73881f752d83e873c966be7e9d44bc7749577
parent: 1fc3cc8e97c5fbd456abc741ad909f83b4c4fb7c
author: Jim Bankoski <jimbankoski@google.com>
date: Fri Oct 26 15:49:44 EDT 2012

Minor tweaks to video source frameworks

Fix the video source to close if file is open already and add a limit.

Change-Id: I36ada4c609d027b6eaa9b447fe9ad4115532edc1

--- a/test/i420_video_source.h
+++ b/test/i420_video_source.h
@@ -25,6 +25,7 @@
                   int rate_numerator, int rate_denominator,
                   unsigned int start, int limit)
       : file_name_(file_name),
+        input_file_(NULL),
         img_(NULL),
         start_(start),
         limit_(limit),
@@ -45,10 +46,11 @@
   }
 
   virtual void Begin() {
+    if (input_file_)
+      fclose(input_file_);
     input_file_ = OpenTestDataFile(file_name_);
     ASSERT_TRUE(input_file_) << "Input file open failed. Filename: "
         << file_name_;
-
     if (start_) {
       fseek(input_file_, raw_sz_ * start_, SEEK_SET);
     }
@@ -75,6 +77,8 @@
   }
 
   virtual unsigned int frame() const { return frame_; }
+
+  virtual unsigned int limit() const { return limit_; }
 
   void SetSize(unsigned int width, unsigned int height) {
     if (width != width_ || height != height_) {
--- a/test/video_source.h
+++ b/test/video_source.h
@@ -57,6 +57,9 @@
 
   // Get the current frame counter, starting at 0.
   virtual unsigned int frame() const = 0;
+
+  // Get the current file limit.
+  virtual unsigned int limit() const = 0;
 };
 
 
@@ -93,6 +96,8 @@
   }
 
   virtual unsigned int frame() const { return frame_; }
+
+  virtual unsigned int limit() const { return limit_; }
 
   void SetSize(unsigned int width, unsigned int height) {
     if (width != width_ || height != height_) {
--