}\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
\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
\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