[x265] param: prevent race conditions in initialising global tables (refs #247)

Deepthi Nandakumar deepthi at multicorewareinc.com
Fri Mar 18 11:13:07 CET 2016


# HG changeset patch
# User Deepthi Nandakumar <deepthi at multicorewareinc.com>
# Date 1458293588 -19800
#      Fri Mar 18 15:03:08 2016 +0530
# Node ID f60818c73f3b2c8c42d987c6d25d9c73ef6bc089
# Parent  63748dea60675d5a029ca0b1b8a92de2aaad94b0
param: prevent race conditions in initialising global tables (refs #247)

Reset param if different encoder instances have different CU sizes.

diff -r 63748dea6067 -r f60818c73f3b source/common/param.cpp
--- a/source/common/param.cpp Thu Mar 17 13:01:37 2016 +0530
+++ b/source/common/param.cpp Fri Mar 18 15:03:08 2016 +0530
@@ -1225,18 +1225,21 @@
     uint32_t maxLog2CUSize = (uint32_t)g_log2Size[param->maxCUSize];
     uint32_t minLog2CUSize = (uint32_t)g_log2Size[param->minCUSize];

-    if (ATOMIC_INC(&g_ctuSizeConfigured) > 1)
+    Lock gLock;
+    ScopedLock sLock(gLock);
+
+    if (++g_ctuSizeConfigured > 1)
     {
         if (g_maxCUSize != param->maxCUSize)
         {
-            x265_log(param, X265_LOG_ERROR, "maxCUSize must be the same
for all encoders in a single process");
-            return -1;
+            x265_log(param, X265_LOG_WARNING, "maxCUSize must be the same
for all encoders in a single process");
         }
         if (g_maxCUDepth != maxLog2CUSize - minLog2CUSize)
         {
-            x265_log(param, X265_LOG_ERROR, "maxCUDepth must be the same
for all encoders in a single process");
-            return -1;
+            x265_log(param, X265_LOG_WARNING, "maxCUDepth must be the same
for all encoders in a single process");
         }
+        param->maxCUSize = g_maxCUSize;
+        return x265_check_params(param); /* Check again, since param may
have changed */
     }
     else
     {


-- 
Deepthi Nandakumar
Engineering Manager, x265
Multicoreware, Inc
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/x265-devel/attachments/20160318/bb374043/attachment.html>


More information about the x265-devel mailing list