shithub: libvpx

Download patch

ref: feda5d244cd5baf93575f7027b5a5c8b2ac09c2f
parent: b21e361f8d692f70d5398b068b86b6fdab2c5759
parent: 587a0b3ef9b191d294d2447a7a918d43bd082db4
author: Alex Converse <aconverse@google.com>
date: Thu Mar 5 09:43:42 EST 2015

Merge changes I219c287b,I6adee670

* changes:
  Call encoder control before running ethread test.
  Don't copy thread data for the main thread.

--- a/test/vp9_ethread_test.cc
+++ b/test/vp9_ethread_test.cc
@@ -24,6 +24,7 @@
  protected:
   VP9EncoderThreadTest()
       : EncoderTest(GET_PARAM(0)),
+        encoder_initialized_(false),
         tiles_(2),
         encoding_mode_(GET_PARAM(1)),
         set_cpu_used_(GET_PARAM(2)) {
@@ -57,9 +58,13 @@
     cfg_.rc_min_quantizer = 0;
   }
 
+  virtual void BeginPassHook(unsigned int /*pass*/) {
+    encoder_initialized_ = false;
+  }
+
   virtual void PreEncodeFrameHook(::libvpx_test::VideoSource *video,
                                   ::libvpx_test::Encoder *encoder) {
-    if (video->frame() == 0) {
+    if (!encoder_initialized_) {
       // Encode 4 column tiles.
       encoder->Control(VP9E_SET_TILE_COLUMNS, tiles_);
       encoder->Control(VP8E_SET_CPUUSED, set_cpu_used_);
@@ -71,6 +76,7 @@
       } else {
         encoder->Control(VP8E_SET_ENABLEAUTOALTREF, 0);
       }
+      encoder_initialized_ = true;
     }
   }
 
@@ -90,6 +96,7 @@
     }
   }
 
+  bool encoder_initialized_;
   int tiles_;
   ::libvpx_test::TestMode encoding_mode_;
   int set_cpu_used_;
--- a/vp9/encoder/vp9_ethread.c
+++ b/vp9/encoder/vp9_ethread.c
@@ -119,10 +119,14 @@
     thread_data = (EncWorkerData*)worker->data1;
 
     // Before encoding a frame, copy the thread data from cpi.
-    thread_data->td->mb = cpi->td.mb;
-    thread_data->td->rd_counts = cpi->td.rd_counts;
-    vpx_memcpy(thread_data->td->counts, &cpi->common.counts,
-               sizeof(cpi->common.counts));
+    if (thread_data->td != &cpi->td) {
+      thread_data->td->mb = cpi->td.mb;
+      thread_data->td->rd_counts = cpi->td.rd_counts;
+    }
+    if (thread_data->td->counts != &cpi->common.counts) {
+      vpx_memcpy(thread_data->td->counts, &cpi->common.counts,
+                 sizeof(cpi->common.counts));
+    }
 
     // Handle use_nonrd_pick_mode case.
     if (cpi->sf.use_nonrd_pick_mode) {