]> git.sesse.net Git - casparcg/blobdiff - modules/decklink/producer/decklink_producer.cpp
2.0. audio: Audio pipeline is now in 32 bit.
[casparcg] / modules / decklink / producer / decklink_producer.cpp
index 00e7766ecb5f24fac5a321706cb29445c8a6757a..3ab2706499a86fd5b4aac598139009f8271334e0 100644 (file)
 #include "../../ffmpeg/producer/util.h"\r
 #include "../../ffmpeg/producer/frame_muxer.h"\r
 \r
+#include <common/log/log.h>\r
 #include <common/diagnostics/graph.h>\r
 #include <common/concurrency/com_context.h>\r
 #include <common/exception/exceptions.h>\r
 #include <common/memory/memclr.h>\r
 \r
 #include <core/mixer/write_frame.h>\r
-#include <core/producer/frame/audio_transform.h>\r
+#include <core/producer/frame/frame_transform.h>\r
 #include <core/producer/frame/frame_factory.h>\r
 \r
 #include <tbb/concurrent_queue.h>\r
-#include <tbb/atomic.h>\r
 \r
 #include <boost/algorithm/string.hpp>\r
+#include <boost/foreach.hpp>\r
 #include <boost/timer.hpp>\r
 \r
 #if defined(_MSC_VER)\r
@@ -103,13 +104,13 @@ public:
                , device_index_(device_index)\r
                , frame_factory_(frame_factory)\r
                , filter_(filter)\r
-               , muxer_(double_rate(filter) ? format_desc.fps * 2.0 : format_desc.fps, frame_factory->get_video_format_desc(), frame_factory)\r
+               , muxer_(double_rate(filter) ? format_desc.fps * 2.0 : format_desc.fps, frame_factory)\r
        {\r
                frame_buffer_.set_capacity(2);\r
                \r
                graph_ = diagnostics::create_graph(boost::bind(&decklink_producer::print, this));\r
                graph_->add_guide("tick-time", 0.5);\r
-               graph_->set_color("tick-time", diagnostics::color(0.1f, 0.7f, 0.8f));\r
+               graph_->set_color("tick-time", diagnostics::color(0.0f, 0.6f, 0.9f));   \r
                graph_->set_color("late-frame", diagnostics::color(0.6f, 0.3f, 0.3f));\r
                graph_->set_color("frame-time", diagnostics::color(1.0f, 0.0f, 0.0f));\r
                graph_->set_color("dropped-frame", diagnostics::color(0.3f, 0.6f, 0.3f));\r
@@ -183,22 +184,24 @@ public:
                        av_frame->format                        = PIX_FMT_UYVY422;\r
                        av_frame->width                         = video->GetWidth();\r
                        av_frame->height                        = video->GetHeight();\r
-                       av_frame->interlaced_frame      = format_desc_.mode != core::video_mode::progressive;\r
-                       av_frame->top_field_first       = format_desc_.mode == core::video_mode::upper ? 1 : 0;\r
+                       av_frame->interlaced_frame      = format_desc_.field_mode != core::field_mode::progressive;\r
+                       av_frame->top_field_first       = format_desc_.field_mode == core::field_mode::upper ? 1 : 0;\r
                                        \r
                        BOOST_FOREACH(auto& av_frame2, filter_.execute(av_frame))\r
-                               muxer_.push(make_write_frame(this, av_frame2, frame_factory_));         \r
+                               muxer_.push(av_frame2);         \r
                                                                        \r
                        // It is assumed that audio is always equal or ahead of video.\r
                        if(audio && SUCCEEDED(audio->GetBytes(&bytes)))\r
                        {\r
                                auto sample_frame_count = audio->GetSampleFrameCount();\r
                                auto audio_data = reinterpret_cast<short*>(bytes);\r
-                               muxer_.push(std::make_shared<std::vector<int16_t>>(audio_data, audio_data + sample_frame_count*2));\r
+                               muxer_.push(std::make_shared<std::vector<int32_t>>(audio_data, audio_data + sample_frame_count*2));\r
                        }\r
                        else\r
-                               muxer_.push(std::make_shared<std::vector<int16_t>>(frame_factory_->get_video_format_desc().audio_samples_per_frame, 0));\r
+                               muxer_.push(std::make_shared<std::vector<int32_t>>(frame_factory_->get_video_format_desc().audio_samples_per_frame, 0));\r
                                        \r
+                       muxer_.commit();\r
+\r
                        while(!muxer_.empty())\r
                        {\r
                                if(!frame_buffer_.try_push(muxer_.pop()))\r
@@ -249,7 +252,7 @@ public:
                context_.reset([&]{return new decklink_producer(format_desc, device_index, frame_factory, filter_str);}); \r
        }\r
                                \r
-       virtual safe_ptr<core::basic_frame> receive()\r
+       virtual safe_ptr<core::basic_frame> receive(int)\r
        {\r
                auto frame = context_->get_frame();\r
                if(frame != core::basic_frame::late())\r