\r
extern "C" \r
{\r
- #define __STDC_CONSTANT_MACROS\r
- #define __STDC_LIMIT_MACROS\r
- #include <libavutil/avutil.h>\r
- #include <libavutil/imgutils.h>\r
#include <libavfilter/avfilter.h>\r
- #include <libavfilter/avcodec.h>\r
- #include <libavfilter/avfiltergraph.h>\r
- #include <libavfilter/vsink_buffer.h>\r
- #include <libavfilter/vsrc_buffer.h>\r
}\r
\r
#include <boost/thread/once.hpp>\r
void (*filter_line)(uint8_t *dst,\r
uint8_t *prev, uint8_t *cur, uint8_t *next,\r
int w, int prefs, int mrefs, int parity, int mode);\r
- const AVPixFmtDescriptor *csp;\r
+ //const AVPixFmtDescriptor *csp;\r
} YADIFContext;\r
\r
struct scalable_yadif_context\r
{\r
- std::vector<std::function<void()>> calls;\r
- int end_prefs;\r
-\r
- scalable_yadif_context() : end_prefs(std::numeric_limits<int>::max()){}\r
+ struct arg\r
+ {\r
+ uint8_t *dst;\r
+ uint8_t *prev;\r
+ uint8_t *cur; \r
+ uint8_t *next; \r
+ int w; \r
+ int prefs; \r
+ int mrefs;\r
+ int parity;\r
+ int mode;\r
+ };\r
+\r
+ arg args[64];\r
+ int index;\r
+\r
+ scalable_yadif_context() : index(0){}\r
};\r
\r
void (*org_yadif_filter_line)(uint8_t *dst, uint8_t *prev, uint8_t *cur, uint8_t *next, int w, int prefs, int mrefs, int parity, int mode) = 0;\r
\r
void scalable_yadif_filter_line(scalable_yadif_context& ctx, uint8_t *dst, uint8_t *prev, uint8_t *cur, uint8_t *next, int w, int prefs, int mrefs, int parity, int mode)\r
{\r
- if(ctx.end_prefs == std::numeric_limits<int>::max())\r
- ctx.end_prefs = -prefs;\r
-\r
- ctx.calls.push_back([=]\r
- {\r
- org_yadif_filter_line(dst, prev, cur, next, w, prefs, mrefs, parity, mode);\r
- });\r
-\r
- if(prefs == ctx.end_prefs)\r
+ scalable_yadif_context::arg arg = {dst, prev, cur, next, w, prefs, mrefs, parity, mode};\r
+ ctx.args[ctx.index++] = arg;\r
+ \r
+ if(ctx.index == 64)\r
{ \r
- tbb::parallel_for(tbb::blocked_range<size_t>(0, ctx.calls.size()), [=](const tbb::blocked_range<size_t>& r)\r
+ tbb::parallel_for(tbb::blocked_range<size_t>(0, ctx.index), [=](const tbb::blocked_range<size_t>& r)\r
{\r
for(auto n = r.begin(); n != r.end(); ++n)\r
- ctx.calls[n]();\r
+ org_yadif_filter_line(ctx.args[n].dst, ctx.args[n].prev, ctx.args[n].cur, ctx.args[n].next, ctx.args[n].w, ctx.args[n].prefs, ctx.args[n].mrefs, ctx.args[n].parity, ctx.args[n].mode);\r
});\r
- ctx.calls = std::vector<std::function<void()>>();\r
- ctx.end_prefs = std::numeric_limits<int>::max();\r
+ ctx.index = 0;\r
}\r
}\r
\r