]> git.sesse.net Git - casparcg/blobdiff - modules/ffmpeg/tbb_avcodec.cpp
2.0. Updated namespaces.
[casparcg] / modules / ffmpeg / tbb_avcodec.cpp
index f88bac0c4003268699466d4100bfa22ae125d4f6..71d623d607ba57ab93beed1427289070178f0dfc 100644 (file)
@@ -6,21 +6,28 @@
 \r
 #include <common/log/log.h>\r
 #include <common/env.h>\r
+#include <common/utility/assert.h>\r
 \r
 #include <tbb/task.h>\r
 #include <tbb/atomic.h>\r
+#include <tbb/parallel_for.h>\r
+#include <tbb/tbb_thread.h>\r
 \r
-#include <regex>\r
-#include <boost/algorithm/string.hpp>\r
-\r
+#if defined(_MSC_VER)\r
+#pragma warning (push)\r
+#pragma warning (disable : 4244)\r
+#endif\r
 extern "C" \r
 {\r
        #define __STDC_CONSTANT_MACROS\r
        #define __STDC_LIMIT_MACROS\r
        #include <libavformat/avformat.h>\r
 }\r
+#if defined(_MSC_VER)\r
+#pragma warning (pop)\r
+#endif\r
 \r
-namespace caspar {\r
+namespace caspar { namespace ffmpeg {\r
                \r
 int thread_execute(AVCodecContext* s, int (*func)(AVCodecContext *c2, void *arg2), void* arg, int* ret, int count, int size)\r
 {\r
@@ -42,6 +49,7 @@ int thread_execute2(AVCodecContext* s, int (*func)(AVCodecContext* c2, void* arg
        tbb::atomic<int> counter;   \r
     counter = 0;   \r
 \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
     {   \r
@@ -86,7 +94,7 @@ int tbb_avcodec_open(AVCodecContext* avctx, AVCodec* codec)
 {\r
        avctx->thread_count = 1;\r
        // Some codecs don't like to have multiple multithreaded decoding instances. Only enable for those we know work.\r
-       if(codec->id == CODEC_ID_MPEG2VIDEO && \r
+       if((codec->id == CODEC_ID_MPEG2VIDEO) && \r
          (codec->capabilities & CODEC_CAP_SLICE_THREADS) && \r
          (avctx->thread_type & FF_THREAD_SLICE))\r
        {\r
@@ -103,4 +111,4 @@ int tbb_avcodec_close(AVCodecContext* avctx)
        return avcodec_close(avctx); \r
 }\r
 \r
-}
\ No newline at end of file
+}}
\ No newline at end of file