]> git.sesse.net Git - casparcg/blobdiff - modules/ffmpeg/producer/tbb_avcodec.cpp
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
[casparcg] / modules / ffmpeg / producer / tbb_avcodec.cpp
index 40babe0834dff73f15670916dc7985d7b00b7bf5..09ad9d573d7990936cbd57c05fba4f08571a1d17 100644 (file)
@@ -1,3 +1,24 @@
+/*\r
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
+*\r
+* This file is part of CasparCG (www.casparcg.com).\r
+*\r
+* CasparCG is free software: you can redistribute it and/or modify\r
+* it under the terms of the GNU General Public License as published by\r
+* the Free Software Foundation, either version 3 of the License, or\r
+* (at your option) any later version.\r
+*\r
+* CasparCG is distributed in the hope that it will be useful,\r
+* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+* GNU General Public License for more details.\r
+*\r
+* You should have received a copy of the GNU General Public License\r
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
+*\r
+* Author: Robert Nagy, ronag89@gmail.com\r
+*/\r
+\r
 #include "../stdafx.h"\r
 \r
 #include "tbb_avcodec.h"\r
@@ -29,15 +50,12 @@ namespace caspar {
                \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
+       tbb::parallel_for(0, count, 1, [&](int i)\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
-       });\r
+        int r = func(s, (char*)arg + i*size);\r
+        if(ret) \r
+                       ret[i] = r;\r
+    });\r
 \r
        return 0;\r
 }\r
@@ -47,7 +65,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
+       CASPAR_VERIFY(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
@@ -90,13 +108,13 @@ void thread_free(AVCodecContext* s)
 \r
 int tbb_avcodec_open(AVCodecContext* avctx, AVCodec* codec)\r
 {\r
-       CodecID supported_codecs[] = {CODEC_ID_MPEG2VIDEO, CODEC_ID_PRORES};\r
+       CodecID supported_codecs[] = {CODEC_ID_MPEG2VIDEO, CODEC_ID_PRORES, CODEC_ID_FFV1};\r
 \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(std::find(std::begin(supported_codecs), std::end(supported_codecs), codec->id) != std::end(supported_codecs) && \r
          (codec->capabilities & CODEC_CAP_SLICE_THREADS) && \r
-         (avctx->thread_type & FF_THREAD_SLICE))\r
+         (avctx->thread_type & FF_THREAD_SLICE)) \r
        {\r
                thread_init(avctx);\r
        }       \r