]> git.sesse.net Git - casparcg/commitdiff
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Fri, 29 Jul 2011 15:14:05 +0000 (15:14 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Fri, 29 Jul 2011 15:14:05 +0000 (15:14 +0000)
modules/ffmpeg/ffmpeg.cpp
modules/ffmpeg/producer/ffmpeg_producer.cpp
modules/ffmpeg/producer/util.h
modules/ffmpeg/producer/video/video_decoder.cpp
shell/main.cpp

index 8508c74b4ee727b12b78d3b9362bf2c93bdbb438..6dfb68b6a0fb708bb541ffb1cadeda9d7e595862 100644 (file)
@@ -28,7 +28,7 @@
 #include <core/consumer/frame_consumer.h>\r
 #include <core/producer/frame_producer.h>\r
 \r
-#include <tbb/mutex.h>\r
+#include <tbb/recursive_mutex.h>\r
 \r
 #if defined(_MSC_VER)\r
 #pragma warning (disable : 4244)\r
@@ -53,13 +53,13 @@ int ffmpeg_lock_callback(void **mutex, enum AVLockOp op)
        if(!mutex)\r
                return 0;\r
 \r
-       auto my_mutex = reinterpret_cast<tbb::mutex*>(*mutex);\r
+       auto my_mutex = reinterpret_cast<tbb::recursive_mutex*>(*mutex);\r
        \r
        switch(op) \r
        { \r
                case AV_LOCK_CREATE: \r
                { \r
-                       *mutex = new tbb::mutex(); \r
+                       *mutex = new tbb::recursive_mutex(); \r
                        break; \r
                } \r
                case AV_LOCK_OBTAIN: \r
@@ -84,59 +84,59 @@ int ffmpeg_lock_callback(void **mutex, enum AVLockOp op)
        return 0; \r
 } \r
 \r
-static void sanitize(uint8_t *line)
-{
-    while(*line)
-       {
-        if(*line < 0x08 || (*line > 0x0D && *line < 0x20))
-            *line='?';
-        line++;
-    }
+static void sanitize(uint8_t *line)\r
+{\r
+    while(*line)\r
+       {\r
+        if(*line < 0x08 || (*line > 0x0D && *line < 0x20))\r
+            *line='?';\r
+        line++;\r
+    }\r
 }\r
 \r
 void log_callback(void* ptr, int level, const char* fmt, va_list vl)\r
-{
-    static int print_prefix=1;
-    static int count;
-    static char prev[1024];
-    char line[8192];
-    static int is_atty;
-    AVClass* avc= ptr ? *(AVClass**)ptr : NULL;
-    if(level > av_log_get_level())
-        return;
-    line[0]=0;
-       
-#undef fprintf
-    if(print_prefix && avc) 
-       {
-        if (avc->parent_log_context_offset) 
-               {
-            AVClass** parent= *(AVClass***)(((uint8_t*)ptr) + avc->parent_log_context_offset);
-            if(parent && *parent)
-                std::sprintf(line, "[%s @ %p] ", (*parent)->item_name(parent), parent);            
-        }
-        std::sprintf(line + strlen(line), "[%s @ %p] ", avc->item_name(ptr), ptr);
-    }
-
-    std::vsprintf(line + strlen(line), fmt, vl);
-
-    print_prefix = strlen(line) && line[strlen(line)-1] == '\n';
-       
-    //if(print_prefix && !strcmp(line, prev)){
-    //    count++;
-    //    if(is_atty==1)
-    //        fprintf(stderr, "    Last message repeated %d times\r", count);
-    //    return;
-    //}
-    //if(count>0){
-    //    fprintf(stderr, "    Last message repeated %d times\n", count);
-    //    count=0;
-    //}
-    strcpy(prev, line);
-    sanitize((uint8_t*)line);
-       
-       CASPAR_LOG(trace) << L"[FFMPEG] [" << av_clip(level>>3, 0, 6) << L"] " << line;
-
+{\r
+    static int print_prefix=1;\r
+    static int count;\r
+    static char prev[1024];\r
+    char line[8192];\r
+    static int is_atty;\r
+    AVClass* avc= ptr ? *(AVClass**)ptr : NULL;\r
+    if(level > av_log_get_level())\r
+        return;\r
+    line[0]=0;\r
+       \r
+#undef fprintf\r
+    if(print_prefix && avc) \r
+       {\r
+        if (avc->parent_log_context_offset) \r
+               {\r
+            AVClass** parent= *(AVClass***)(((uint8_t*)ptr) + avc->parent_log_context_offset);\r
+            if(parent && *parent)\r
+                std::sprintf(line, "[%s @ %p] ", (*parent)->item_name(parent), parent);            \r
+        }\r
+        std::sprintf(line + strlen(line), "[%s @ %p] ", avc->item_name(ptr), ptr);\r
+    }\r
+\r
+    std::vsprintf(line + strlen(line), fmt, vl);\r
+\r
+    print_prefix = strlen(line) && line[strlen(line)-1] == '\n';\r
+       \r
+    //if(print_prefix && !strcmp(line, prev)){\r
+    //    count++;\r
+    //    if(is_atty==1)\r
+    //        fprintf(stderr, "    Last message repeated %d times\r", count);\r
+    //    return;\r
+    //}\r
+    //if(count>0){\r
+    //    fprintf(stderr, "    Last message repeated %d times\n", count);\r
+    //    count=0;\r
+    //}\r
+    strcpy(prev, line);\r
+    sanitize((uint8_t*)line);\r
+       \r
+       CASPAR_LOG(trace) << L"[FFMPEG] [" << av_clip(level>>3, 0, 6) << L"] " << line;\r
+\r
     //colored_fputs(av_clip(level>>3, 0, 6), line);\r
 }\r
 \r
index 21618aa991a9b90d464566a00bec99dc7f1dc92b..251803132b3f2fdd2ae32d78f213c3efc9b68e86 100644 (file)
@@ -84,7 +84,7 @@ public:
                graph_->set_color("frame-time", diagnostics::color(1.0f, 0.0f, 0.0f));\r
                graph_->set_color("underflow", diagnostics::color(0.6f, 0.3f, 0.9f));           \r
                \r
-               for(int n = 0; n < 128 && muxer_.size() < 4; ++n)\r
+               for(int n = 0; n < 128 && muxer_.size() < 2; ++n)\r
                        decode_frame();\r
        }\r
 \r
index 08de69699b5b29ee08c5bc8afa3bb7eba21fcd80..77cddc41ab274a3c7333c62aaaa3b1d218908f6a 100644 (file)
@@ -8,6 +8,8 @@
 #include <core/producer/frame/frame_factory.h>\r
 #include <core/mixer/write_frame.h>\r
 \r
+#include <common/memory/memcpy.h>\r
+\r
 #if defined(_MSC_VER)\r
 #pragma warning (push)\r
 #pragma warning (disable : 4244)\r
@@ -208,7 +210,7 @@ static safe_ptr<core::write_frame> make_write_frame(const void* tag, const safe_
                        tbb::parallel_for(tbb::blocked_range<size_t>(0, static_cast<int>(desc.planes[n].height)), [&](const tbb::blocked_range<size_t>& r)\r
                        {\r
                                for(size_t y = r.begin(); y != r.end(); ++y)\r
-                                       memcpy(result + y*plane.linesize, decoded + y*decoded_linesize, plane.linesize);\r
+                                       fast_memcpy(result + y*plane.linesize, decoded + y*decoded_linesize, plane.linesize);\r
                        });\r
 \r
                        write->commit(n);\r
index 6b87f4a1368887e0e50cb6f5bd39f07e5757c99f..b44f62f495c9ceae96ae9f0eb7a12e0faeec6f9b 100644 (file)
@@ -125,20 +125,27 @@ public:
                        std::vector<safe_ptr<AVFrame>> av_frames;\r
 \r
                        auto packet = std::move(packet_buffer_.front());\r
-                       packet_buffer_.pop();\r
                \r
                        if(packet)\r
-                               decode(*packet, av_frames);                     \r
+                       {\r
+                               decode(*packet, av_frames);                                     \r
+                               packet_buffer_.pop();\r
+                       }\r
                        else\r
                        {\r
+                               bool flush = true;\r
+\r
                                if(codec_context_->codec->capabilities | CODEC_CAP_DELAY)\r
                                {\r
-                                       // FIXME: This might cause bad performance.\r
                                        AVPacket pkt = {0};\r
-                                       for(int n = 0; n < 8 && decode(pkt, av_frames); ++n){}\r
+                                       flush = !decode(pkt, av_frames);\r
                                }\r
 \r
-                               avcodec_flush_buffers(codec_context_.get());\r
+                               if(flush)\r
+                               {                                       \r
+                                       packet_buffer_.pop();\r
+                                       avcodec_flush_buffers(codec_context_.get());\r
+                               }\r
                        }\r
 \r
                        if(filter_)\r
index b2129b0abdf35c41eb32bb23d4c8a460749dab36..e52ab6dbecbd65757276585ffabe27119b3824d7 100644 (file)
@@ -169,7 +169,11 @@ int main(int argc, wchar_t* argv[])
        struct tbb_thread_installer : public tbb::task_scheduler_observer\r
        {\r
                tbb_thread_installer(){observe(true);}\r
-               void on_scheduler_entry(bool is_worker){caspar::win32_exception::install_handler();}\r
+               void on_scheduler_entry(bool is_worker)\r
+               {\r
+                       caspar::detail::SetThreadName(GetCurrentThreadId(), "tbb-worker-thread");\r
+                       caspar::win32_exception::install_handler();\r
+               }\r
        } tbb_thread_installer;\r
        \r
        try \r