]> git.sesse.net Git - casparcg/commitdiff
2.0.0.2: tbb_avcodec: Some refactoring.
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Thu, 19 May 2011 14:13:13 +0000 (14:13 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Thu, 19 May 2011 14:13:13 +0000 (14:13 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@786 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

modules/ffmpeg/tbb_avcodec.cpp

index 8c73e67139417e62f6c907fc103e759d7e64a68e..b1d68757c8dd849f592ef0d941319177215429e9 100644 (file)
@@ -17,12 +17,9 @@ extern "C"
 }\r
 \r
 namespace caspar {\r
-\r
-struct thread_context{};\r
-\r
-int task_execute(AVCodecContext* s, const std::function<int(void* arg, int arg_size, int jobnr, int threadnr)>& func, void* arg, int* ret, int count, int size)\r
+       \r
+int task_execute(AVCodecContext* s, std::function<int(void* arg, int arg_size, int jobnr, int threadnr)>&& func, void* arg, int* ret, int count, int size)\r
 {      \r
-       // jobnr global for all threads? Doesn't order matter?\r
     tbb::atomic<int> counter;\r
        counter = 0;\r
                \r
@@ -62,17 +59,17 @@ int thread_execute2(AVCodecContext* s, int (*func)(AVCodecContext* c2, void* arg
 \r
 int thread_init(AVCodecContext *s)\r
 {\r
-       // Only makes sense for slicing since decode is already called through task scheduler.\r
     if(!(s->thread_type & FF_THREAD_SLICE))           \r
        return 0;    \r
 \r
        static const size_t MAX_THREADS = 16; // See mpegvideo.h\r
+       static int dummy_opaque;\r
 \r
     s->active_thread_type = FF_THREAD_SLICE;\r
-       s->thread_opaque          = malloc(sizeof(thread_context));      \r
+       s->thread_opaque          = &dummy_opaque; \r
     s->execute                   = thread_execute;\r
     s->execute2                          = thread_execute2;\r
-    s->thread_count              = MAX_THREADS; // We are using a taskscheduler, so use as many "threads/tasks" as possible. \r
+    s->thread_count              = MAX_THREADS; // We are using a task-scheduler, so use as many "threads/tasks" as possible. \r
 \r
        CASPAR_LOG(info) << "Initialized ffmpeg tbb context.";\r
 \r
@@ -81,12 +78,7 @@ int thread_init(AVCodecContext *s)
 \r
 void thread_free(AVCodecContext* s)\r
 {\r
-       if(!s->thread_opaque)\r
-               return;\r
-       \r
-       free(s->thread_opaque); \r
        s->thread_opaque = nullptr;\r
-\r
        CASPAR_LOG(info) << "Released ffmpeg tbb context.";\r
 }\r
 \r