shithub: libvpx

Download patch

ref: b6a5f6f740d476f15c083fce022c06eff14731a4
parent: ce634bbf4d4e995067f47494f57056727751df15
author: Marco <marpan@google.com>
date: Thu Aug 25 04:53:24 EDT 2016

vp8: Move loopfilter synchronization to end of encode_frame call.

Allow loopfilter to continue until encode_frame is completed.

Change-Id: I7bbccc3d409e263aab6a6ff24588d8b2a964a96e

--- a/vp8/encoder/ethreading.c
+++ b/vp8/encoder/ethreading.c
@@ -492,6 +492,7 @@
 
   cpi->b_multi_threaded = 0;
   cpi->encoding_thread_count = 0;
+  cpi->b_lpf_running = 0;
 
   if (cm->processor_core_count > 1 && cpi->oxcf.multi_threaded > 1) {
     int ithread;
--- a/vp8/encoder/onyx_if.c
+++ b/vp8/encoder/onyx_if.c
@@ -4364,6 +4364,7 @@
   if (cpi->b_multi_threaded) {
     /* start loopfilter in separate thread */
     sem_post(&cpi->h_event_start_lpf);
+    cpi->b_lpf_running = 1;
   } else
 #endif
   {
@@ -4392,13 +4393,6 @@
   /* build the bitstream */
   vp8_pack_bitstream(cpi, dest, dest_end, size);
 
-#if CONFIG_MULTITHREAD
-  /* wait for the lpf thread done */
-  if (cpi->b_multi_threaded) {
-    sem_wait(&cpi->h_event_end_lpf);
-  }
-#endif
-
   /* Move storing frame_type out of the above loop since it is also
    * needed in motion search besides loopfilter */
   cm->last_frame_type = cm->frame_type;
@@ -5234,6 +5228,14 @@
 #endif
 
   cpi->common.error.setjmp = 0;
+
+#if CONFIG_MULTITHREAD
+  /* wait for the lpf thread done */
+  if (cpi->b_multi_threaded && cpi->b_lpf_running) {
+    sem_wait(&cpi->h_event_end_lpf);
+    cpi->b_lpf_running = 0;
+  }
+#endif
 
   return 0;
 }
--- a/vp8/encoder/onyx_int.h
+++ b/vp8/encoder/onyx_int.h
@@ -509,6 +509,7 @@
   int mt_sync_range;
   int b_multi_threaded;
   int encoding_thread_count;
+  int b_lpf_running;
 
   pthread_t *h_encoding_thread;
   pthread_t h_filter_thread;