Blame SOURCES/0001-vp8-fix-threading-issues.patch

d88f57
From c1524f293784d9957c2339fc462fcea5c9619bee Mon Sep 17 00:00:00 2001
d88f57
From: Jim Bankoski <jimbankoski@google.com>
d88f57
Date: Tue, 7 Jan 2020 11:38:36 +0100
d88f57
Subject: [PATCH] vp8:fix threading issues
d88f57
d88f57
1 - stops de allocating before threads are closed.
d88f57
2 - limits threads to mb_rows when mb_rows < partitions
d88f57
d88f57
BUG=webm:851
d88f57
---
d88f57
 vp8/decoder/decodframe.c |   2 +
d88f57
 vp8/decoder/onyxd_if.c   |   2 -
d88f57
 vp8/decoder/threading.c  | 107 +++++++++++++++++++--------------------
d88f57
 3 files changed, 55 insertions(+), 56 deletions(-)
d88f57
d88f57
diff --git a/vp8/decoder/decodframe.c b/vp8/decoder/decodframe.c
d88f57
index 16da78a2c..ee14c3b04 100644
d88f57
--- a/vp8/decoder/decodframe.c
d88f57
+++ b/vp8/decoder/decodframe.c
d88f57
@@ -904,6 +904,8 @@ static void setup_token_decoder(VP8D_COMP *pbi,
d88f57
     /* Clamp number of decoder threads */
d88f57
     if (pbi->decoding_thread_count > num_token_partitions - 1)
d88f57
         pbi->decoding_thread_count = num_token_partitions - 1;
d88f57
+    if (pbi->decoding_thread_count > pbi->common.mb_rows - 1)
d88f57
+        pbi->decoding_thread_count = pbi->common.mb_rows - 1;
d88f57
 #endif
d88f57
 }
d88f57
 
d88f57
diff --git a/vp8/decoder/onyxd_if.c b/vp8/decoder/onyxd_if.c
d88f57
index 2d9e343bc..57fa39bc7 100644
d88f57
--- a/vp8/decoder/onyxd_if.c
d88f57
+++ b/vp8/decoder/onyxd_if.c
d88f57
@@ -509,8 +509,6 @@ int vp8_remove_decoder_instances(struct frame_buffers *fb)
d88f57
         if (!pbi)
d88f57
             return VPX_CODEC_ERROR;
d88f57
 #if CONFIG_MULTITHREAD
d88f57
-        if (pbi->b_multithreaded_rd)
d88f57
-            vp8mt_de_alloc_temp_buffers(pbi, pbi->common.mb_rows);
d88f57
         vp8_decoder_remove_threads(pbi);
d88f57
 #endif
d88f57
 
d88f57
diff --git a/vp8/decoder/threading.c b/vp8/decoder/threading.c
d88f57
index fe290cffe..9001d275f 100644
d88f57
--- a/vp8/decoder/threading.c
d88f57
+++ b/vp8/decoder/threading.c
d88f57
@@ -696,78 +696,75 @@ void vp8mt_de_alloc_temp_buffers(VP8D_COMP *pbi, int mb_rows)
d88f57
 {
d88f57
     int i;
d88f57
 
d88f57
-    if (pbi->b_multithreaded_rd)
d88f57
-    {
d88f57
-            vpx_free(pbi->mt_current_mb_col);
d88f57
-            pbi->mt_current_mb_col = NULL ;
d88f57
+    vpx_free(pbi->mt_current_mb_col);
d88f57
+    pbi->mt_current_mb_col = NULL ;
d88f57
 
d88f57
-        /* Free above_row buffers. */
d88f57
-        if (pbi->mt_yabove_row)
d88f57
+    /* Free above_row buffers. */
d88f57
+    if (pbi->mt_yabove_row)
d88f57
+    {
d88f57
+        for (i=0; i< mb_rows; i++)
d88f57
         {
d88f57
-            for (i=0; i< mb_rows; i++)
d88f57
-            {
d88f57
-                    vpx_free(pbi->mt_yabove_row[i]);
d88f57
-                    pbi->mt_yabove_row[i] = NULL ;
d88f57
-            }
d88f57
-            vpx_free(pbi->mt_yabove_row);
d88f57
-            pbi->mt_yabove_row = NULL ;
d88f57
+                vpx_free(pbi->mt_yabove_row[i]);
d88f57
+                pbi->mt_yabove_row[i] = NULL ;
d88f57
         }
d88f57
+        vpx_free(pbi->mt_yabove_row);
d88f57
+        pbi->mt_yabove_row = NULL ;
d88f57
+    }
d88f57
 
d88f57
-        if (pbi->mt_uabove_row)
d88f57
+    if (pbi->mt_uabove_row)
d88f57
+    {
d88f57
+        for (i=0; i< mb_rows; i++)
d88f57
         {
d88f57
-            for (i=0; i< mb_rows; i++)
d88f57
-            {
d88f57
-                    vpx_free(pbi->mt_uabove_row[i]);
d88f57
-                    pbi->mt_uabove_row[i] = NULL ;
d88f57
-            }
d88f57
-            vpx_free(pbi->mt_uabove_row);
d88f57
-            pbi->mt_uabove_row = NULL ;
d88f57
+                vpx_free(pbi->mt_uabove_row[i]);
d88f57
+                pbi->mt_uabove_row[i] = NULL ;
d88f57
         }
d88f57
+        vpx_free(pbi->mt_uabove_row);
d88f57
+        pbi->mt_uabove_row = NULL ;
d88f57
+    }
d88f57
 
d88f57
-        if (pbi->mt_vabove_row)
d88f57
+    if (pbi->mt_vabove_row)
d88f57
+    {
d88f57
+        for (i=0; i< mb_rows; i++)
d88f57
         {
d88f57
-            for (i=0; i< mb_rows; i++)
d88f57
-            {
d88f57
-                    vpx_free(pbi->mt_vabove_row[i]);
d88f57
-                    pbi->mt_vabove_row[i] = NULL ;
d88f57
-            }
d88f57
-            vpx_free(pbi->mt_vabove_row);
d88f57
-            pbi->mt_vabove_row = NULL ;
d88f57
+                vpx_free(pbi->mt_vabove_row[i]);
d88f57
+                pbi->mt_vabove_row[i] = NULL ;
d88f57
         }
d88f57
+        vpx_free(pbi->mt_vabove_row);
d88f57
+        pbi->mt_vabove_row = NULL ;
d88f57
+    }
d88f57
 
d88f57
-        /* Free left_col buffers. */
d88f57
-        if (pbi->mt_yleft_col)
d88f57
+    /* Free left_col buffers. */
d88f57
+    if (pbi->mt_yleft_col)
d88f57
+    {
d88f57
+        for (i=0; i< mb_rows; i++)
d88f57
         {
d88f57
-            for (i=0; i< mb_rows; i++)
d88f57
-            {
d88f57
-                    vpx_free(pbi->mt_yleft_col[i]);
d88f57
-                    pbi->mt_yleft_col[i] = NULL ;
d88f57
-            }
d88f57
-            vpx_free(pbi->mt_yleft_col);
d88f57
-            pbi->mt_yleft_col = NULL ;
d88f57
+                vpx_free(pbi->mt_yleft_col[i]);
d88f57
+                pbi->mt_yleft_col[i] = NULL ;
d88f57
         }
d88f57
+        vpx_free(pbi->mt_yleft_col);
d88f57
+        pbi->mt_yleft_col = NULL ;
d88f57
+    }
d88f57
 
d88f57
-        if (pbi->mt_uleft_col)
d88f57
+    if (pbi->mt_uleft_col)
d88f57
+    {
d88f57
+        for (i=0; i< mb_rows; i++)
d88f57
         {
d88f57
-            for (i=0; i< mb_rows; i++)
d88f57
-            {
d88f57
-                    vpx_free(pbi->mt_uleft_col[i]);
d88f57
-                    pbi->mt_uleft_col[i] = NULL ;
d88f57
-            }
d88f57
-            vpx_free(pbi->mt_uleft_col);
d88f57
-            pbi->mt_uleft_col = NULL ;
d88f57
+                vpx_free(pbi->mt_uleft_col[i]);
d88f57
+                pbi->mt_uleft_col[i] = NULL ;
d88f57
         }
d88f57
+        vpx_free(pbi->mt_uleft_col);
d88f57
+        pbi->mt_uleft_col = NULL ;
d88f57
+    }
d88f57
 
d88f57
-        if (pbi->mt_vleft_col)
d88f57
+    if (pbi->mt_vleft_col)
d88f57
+    {
d88f57
+        for (i=0; i< mb_rows; i++)
d88f57
         {
d88f57
-            for (i=0; i< mb_rows; i++)
d88f57
-            {
d88f57
-                    vpx_free(pbi->mt_vleft_col[i]);
d88f57
-                    pbi->mt_vleft_col[i] = NULL ;
d88f57
-            }
d88f57
-            vpx_free(pbi->mt_vleft_col);
d88f57
-            pbi->mt_vleft_col = NULL ;
d88f57
+                vpx_free(pbi->mt_vleft_col[i]);
d88f57
+                pbi->mt_vleft_col[i] = NULL ;
d88f57
         }
d88f57
+        vpx_free(pbi->mt_vleft_col);
d88f57
+        pbi->mt_vleft_col = NULL ;
d88f57
     }
d88f57
 }
d88f57
 
d88f57
@@ -859,6 +856,8 @@ void vp8_decoder_remove_threads(VP8D_COMP *pbi)
d88f57
 
d88f57
             vpx_free(pbi->de_thread_data);
d88f57
             pbi->de_thread_data = NULL;
d88f57
+
d88f57
+            vp8mt_de_alloc_temp_buffers(pbi, pbi->common.mb_rows);
d88f57
     }
d88f57
 }
d88f57
 
d88f57
-- 
d88f57
2.24.1
d88f57