]> git.sesse.net Git - casparcg/commitdiff
2.0. scalable_yadif: Reduced overhead and fixed bug where parallel execution was...
authorRonag <Ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 31 Jul 2011 16:05:37 +0000 (16:05 +0000)
committerRonag <Ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Sun, 31 Jul 2011 16:05:37 +0000 (16:05 +0000)
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches/2.0.0.2@1030 362d55ac-95cf-4e76-9f9a-cbaa9c17b72d

casparcg.sln
modules/ffmpeg/producer/filter/scalable_yadif.cpp

index bd760c768c807cf78fd1efd8d5698fdb8d228597..c288c0593814e3448973ed2af75588303d2a33c3 100644 (file)
@@ -16,6 +16,9 @@ Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "documentation", "documentat
        EndProjectSection\r
 EndProject\r
 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "modules", "modules", "{C54DA43E-4878-45DB-B76D-35970553672C}"\r
+       ProjectSection(SolutionItems) = preProject\r
+               README.txt = README.txt\r
+       EndProjectSection\r
 EndProject\r
 Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "bluefish", "modules\bluefish\bluefish.vcxproj", "{69313D25-9F54-4FC9-9872-628A4DD79464}"\r
 EndProject\r
index 5c256d0ceaf22b55fbad742fadd0dfd83d562ec0..1dee933bdabcb7b463d43f44545b9a88af606840 100644 (file)
@@ -4,15 +4,7 @@
 \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
@@ -29,38 +21,45 @@ typedef struct {
     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