]> granicus.if.org Git - libvpx/commitdiff
Minor tweaks to video source frameworks
authorJim Bankoski <jimbankoski@google.com>
Sat, 27 Oct 2012 02:49:44 +0000 (19:49 -0700)
committerJim Bankoski <jimbankoski@google.com>
Sat, 27 Oct 2012 02:49:44 +0000 (19:49 -0700)
Fix the video source to close if file is open already and add a limit.

Change-Id: I36ada4c609d027b6eaa9b447fe9ad4115532edc1

test/i420_video_source.h
test/video_source.h

index 0fe9ca6929ad3b8f77d1dfaec4cd5ac981a43f3b..219bd3393c864567b3ce58fbbd55cec45edfdc3f 100644 (file)
@@ -25,6 +25,7 @@ class I420VideoSource : public VideoSource {
                   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 @@ class I420VideoSource : public VideoSource {
   }
 
   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);
     }
@@ -76,6 +78,8 @@ class I420VideoSource : public VideoSource {
 
   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_) {
       vpx_img_free(img_);
index ced0caed1a960570e657450f01599ab87ad0bc19..9772657d6861e8dbb437c4d499c97fafcef7cc33 100644 (file)
@@ -57,6 +57,9 @@ class VideoSource {
 
   // 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;
 };
 
 
@@ -94,6 +97,8 @@ class DummyVideoSource : public VideoSource {
 
   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_) {
       vpx_img_free(img_);