]> git.sesse.net Git - casparcg/blobdiff - modules/ffmpeg/tbb_avcodec.cpp
2.0.1: ffmpeg: Replaced TBB implementation with better Concurrency Runtime based...
[casparcg] / modules / ffmpeg / tbb_avcodec.cpp
index 71d623d607ba57ab93beed1427289070178f0dfc..1f0eb7b2a9af95db54523b6b7f695a49f5e8953d 100644 (file)
@@ -8,7 +8,8 @@
 #include <common/env.h>\r
 #include <common/utility/assert.h>\r
 \r
-#include <tbb/task.h>\r
+#include <ppl.h>\r
+\r
 #include <tbb/atomic.h>\r
 #include <tbb/parallel_for.h>\r
 #include <tbb/tbb_thread.h>\r
@@ -31,14 +32,11 @@ namespace caspar { namespace ffmpeg {
                \r
 int thread_execute(AVCodecContext* s, int (*func)(AVCodecContext *c2, void *arg2), void* arg, int* ret, int count, int size)\r
 {\r
-       tbb::parallel_for(tbb::blocked_range<size_t>(0, count), [&](const tbb::blocked_range<size_t>& r)\r
+       Concurrency::parallel_for(0, count, [&](size_t n)\r
        {\r
-               for(size_t n = r.begin(); n != r.end(); ++n)            \r
-               {\r
-                       int r = func(s, reinterpret_cast<uint8_t*>(arg) + n*size);\r
-                       if(ret)\r
-                               ret[n] = r;\r
-               }\r
+               int r = func(s, reinterpret_cast<uint8_t*>(arg) + n*size);\r
+               if(ret)\r
+                       ret[n] = r;\r
        });\r
 \r
        return 0;\r
@@ -51,15 +49,12 @@ int thread_execute2(AVCodecContext* s, int (*func)(AVCodecContext* c2, void* arg
 \r
        CASPAR_ASSERT(tbb::tbb_thread::hardware_concurrency() < 16);\r
        // Note: this will probably only work when tbb::task_scheduler_init::num_threads() < 16.\r
-    tbb::parallel_for(tbb::blocked_range<int>(0, count, 2), [&](const tbb::blocked_range<int> &r)    \r
+    Concurrency::parallel_for(0, count, 2, [&](int jobnr)    \r
     {   \r
         int threadnr = counter++;   \r
-        for(int jobnr = r.begin(); jobnr != r.end(); ++jobnr)\r
-        {   \r
-            int r = func(s, arg, jobnr, threadnr);   \r
-            if (ret)   \r
-                ret[jobnr] = r;   \r
-        }\r
+        int r = func(s, arg, jobnr, threadnr);   \r
+        if (ret)   \r
+            ret[jobnr] = r;  \r
         --counter;\r
     });   \r
 \r