\r
#include <common/concurrency/executor.h>\r
#include <common/diagnostics/graph.h>\r
-#include <common/memory/memclr.h>\r
-#include <common/memory/memcpy.h>\r
#include <common/memory/memshfl.h>\r
-#include <common/utility/timer.h>\r
\r
#include <core/consumer/frame_consumer.h>\r
#include <core/mixer/audio/audio_util.h>\r
\r
#include <tbb/concurrent_queue.h>\r
\r
+#include <common/assert.h>\r
+#include <boost/lexical_cast.hpp>\r
#include <boost/timer.hpp>\r
#include <boost/range/algorithm.hpp>\r
#include <boost/property_tree/ptree.hpp>\r
\r
+#include <asmlib.h>\r
+\r
#include <memory>\r
#include <array>\r
\r
\r
executor executor_;\r
public:\r
- bluefish_consumer(const core::video_format_desc& format_desc, unsigned int device_index, bool embedded_audio, bool key_only, int channel_index) \r
+ bluefish_consumer(const core::video_format_desc& format_desc, int device_index, bool embedded_audio, bool key_only, int channel_index) \r
: blue_(create_blue(device_index))\r
, device_index_(device_index)\r
, format_desc_(format_desc) \r
{\r
executor_.set_capacity(1);\r
\r
- graph_->add_guide("tick-time", 0.5);\r
graph_->set_color("tick-time", diagnostics::color(0.0f, 0.6f, 0.9f)); \r
- graph_->add_guide("frame-time", 0.5f); \r
graph_->set_color("sync-time", diagnostics::color(1.0f, 0.0f, 0.0f));\r
graph_->set_color("frame-time", diagnostics::color(0.5f, 1.0f, 0.2f));\r
graph_->set_text(print());\r
\r
//Setting output Video mode\r
if(BLUE_FAIL(set_card_property(blue_, VIDEO_MODE, vid_fmt_))) \r
- BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(narrow(print()) + " Failed to set videomode."));\r
+ BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(print() + L" Failed to set videomode."));\r
\r
//Select Update Mode for output\r
if(BLUE_FAIL(set_card_property(blue_, VIDEO_UPDATE_TYPE, UPD_FMT_FRAME))) \r
- BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(narrow(print()) + " Failed to set update type."));\r
+ BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(print() + L" Failed to set update type."));\r
\r
disable_video_output();\r
\r
//Enable dual link output\r
if(BLUE_FAIL(set_card_property(blue_, VIDEO_DUAL_LINK_OUTPUT, 1)))\r
- BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(narrow(print()) + " Failed to enable dual link."));\r
+ BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(print() + L" Failed to enable dual link."));\r
\r
if(BLUE_FAIL(set_card_property(blue_, VIDEO_DUAL_LINK_OUTPUT_SIGNAL_FORMAT_TYPE, Signal_FormatType_4224)))\r
- BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(narrow(print()) + " Failed to set dual link format type to 4:2:2:4."));\r
+ BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(print() + L" Failed to set dual link format type to 4:2:2:4."));\r
\r
//Select output memory format\r
if(BLUE_FAIL(set_card_property(blue_, VIDEO_MEMORY_FORMAT, MEM_FMT_ARGB_PC))) \r
- BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(narrow(print()) + " Failed to set memory format."));\r
+ BOOST_THROW_EXCEPTION(caspar_exception() << msg_info(print() + L" Failed to set memory format."));\r
\r
//Select image orientation\r
if(BLUE_FAIL(set_card_property(blue_, VIDEO_IMAGE_ORIENTATION, ImageOrientation_Normal)))\r
- CASPAR_LOG(warning) << print() << TEXT(" Failed to set image orientation to normal."); \r
+ CASPAR_LOG(warning) << print() << L" Failed to set image orientation to normal."; \r
\r
// Select data range\r
if(BLUE_FAIL(set_card_property(blue_, VIDEO_RGB_DATA_RANGE, CGR_RANGE))) \r
- CASPAR_LOG(warning) << print() << TEXT(" Failed to set RGB data range to CGR."); \r
+ CASPAR_LOG(warning) << print() << L" Failed to set RGB data range to CGR."; \r
\r
if(BLUE_FAIL(set_card_property(blue_, VIDEO_PREDEFINED_COLOR_MATRIX, vid_fmt_ == VID_FMT_PAL ? MATRIX_601_CGR : MATRIX_709_CGR)))\r
- CASPAR_LOG(warning) << print() << TEXT(" Failed to set colormatrix to ") << (vid_fmt_ == VID_FMT_PAL ? TEXT("601 CGR") : TEXT("709 CGR")) << TEXT(".");\r
+ CASPAR_LOG(warning) << print() << L" Failed to set colormatrix to " << (vid_fmt_ == VID_FMT_PAL ? L"601 CGR" : L"709 CGR") << L".";\r
\r
if(!embedded_audio_)\r
{\r
try\r
{ \r
display_frame(frame); \r
- graph_->update_value("tick-time", static_cast<float>(tick_timer_.elapsed()*format_desc_.fps*0.5));\r
+ graph_->set_value("tick-time", static_cast<float>(tick_timer_.elapsed()*format_desc_.fps*0.5));\r
tick_timer_.restart();\r
}\r
catch(...)\r
sync_timer_.restart();\r
unsigned long n_field = 0;\r
blue_->wait_output_video_synch(UPD_FMT_FRAME, n_field);\r
- graph_->update_value("sync-time", sync_timer_.elapsed()*format_desc_.fps*0.5);\r
+ graph_->set_value("sync-time", sync_timer_.elapsed()*format_desc_.fps*0.5);\r
\r
frame_timer_.restart(); \r
\r
if(!frame->image_data().empty())\r
{\r
if(key_only_) \r
- fast_memshfl(reserved_frames_.front()->image_data(), std::begin(frame->image_data()), frame->image_data().size(), 0x0F0F0F0F, 0x0B0B0B0B, 0x07070707, 0x03030303);\r
+ aligned_memshfl(reserved_frames_.front()->image_data(), std::begin(frame->image_data()), frame->image_data().size(), 0x0F0F0F0F, 0x0B0B0B0B, 0x07070707, 0x03030303);\r
else\r
- fast_memcpy(reserved_frames_.front()->image_data(), std::begin(frame->image_data()), frame->image_data().size());\r
+ A_memcpy(reserved_frames_.front()->image_data(), std::begin(frame->image_data()), frame->image_data().size());\r
}\r
else\r
- fast_memclr(reserved_frames_.front()->image_data(), reserved_frames_.front()->image_size());\r
+ A_memset(reserved_frames_.front()->image_data(), 0, reserved_frames_.front()->image_size());\r
\r
\r
// Send and display\r
if(embedded_audio_)\r
{ \r
auto frame_audio = core::audio_32_to_24(frame->audio_data()); \r
- encode_hanc(reinterpret_cast<BLUE_UINT32*>(reserved_frames_.front()->hanc_data()), frame_audio.data(), frame->audio_data().size()/format_desc_.audio_channels, format_desc_.audio_channels);\r
+ encode_hanc(reinterpret_cast<BLUE_UINT32*>(reserved_frames_.front()->hanc_data()), \r
+ frame_audio.data(), \r
+ static_cast<int>(frame->audio_data().size()/format_desc_.audio_channels), \r
+ format_desc_.audio_channels);\r
\r
blue_->system_buffer_write_async(const_cast<uint8_t*>(reserved_frames_.front()->image_data()), \r
- reserved_frames_.front()->image_size(), \r
+ static_cast<unsigned long>(reserved_frames_.front()->image_size()), \r
nullptr, \r
BlueImage_HANC_DMABuffer(reserved_frames_.front()->id(), BLUE_DATA_IMAGE));\r
\r
blue_->system_buffer_write_async(reserved_frames_.front()->hanc_data(),\r
- reserved_frames_.front()->hanc_size(), \r
+ static_cast<unsigned long>(reserved_frames_.front()->hanc_size()), \r
nullptr, \r
BlueImage_HANC_DMABuffer(reserved_frames_.front()->id(), BLUE_DATA_HANC));\r
\r
else\r
{\r
blue_->system_buffer_write_async(const_cast<uint8_t*>(reserved_frames_.front()->image_data()),\r
- reserved_frames_.front()->image_size(), \r
+ static_cast<unsigned long>(reserved_frames_.front()->image_size()), \r
nullptr, \r
BlueImage_DMABuffer(reserved_frames_.front()->id(), BLUE_DATA_IMAGE));\r
\r
\r
boost::range::rotate(reserved_frames_, std::begin(reserved_frames_)+1);\r
\r
- graph_->update_value("frame-time", static_cast<float>(frame_timer_.elapsed()*format_desc_.fps*0.5));\r
+ graph_->set_value("frame-time", static_cast<float>(frame_timer_.elapsed()*format_desc_.fps*0.5));\r
}\r
\r
- void encode_hanc(BLUE_UINT32* hanc_data, void* audio_data, size_t audio_samples, size_t audio_nchannels)\r
+ void encode_hanc(BLUE_UINT32* hanc_data, void* audio_data, int audio_samples, int audio_nchannels)\r
{ \r
const auto sample_type = AUDIO_CHANNEL_24BIT | AUDIO_CHANNEL_LITTLEENDIAN;\r
const auto emb_audio_flag = blue_emb_audio_enable | blue_emb_audio_group1_enable;\r
\r
std::wstring print() const\r
{\r
- return model_name_ + L" [" + boost::lexical_cast<std::wstring>(channel_index_) + L"|device " + \r
+ return model_name_ + L" [" + boost::lexical_cast<std::wstring>(channel_index_) + L"-" + \r
boost::lexical_cast<std::wstring>(device_index_) + L"|" + format_desc_.name + L"]";\r
}\r
};\r
struct bluefish_consumer_proxy : public core::frame_consumer\r
{\r
std::unique_ptr<bluefish_consumer> consumer_;\r
- const size_t device_index_;\r
+ const int device_index_;\r
const bool embedded_audio_;\r
const bool key_only_;\r
- std::vector<size_t> audio_cadence_;\r
+ std::vector<int> audio_cadence_;\r
public:\r
\r
- bluefish_consumer_proxy(size_t device_index, bool embedded_audio, bool key_only)\r
+ bluefish_consumer_proxy(int device_index, bool embedded_audio, bool key_only)\r
: device_index_(device_index)\r
, embedded_audio_(embedded_audio)\r
, key_only_(key_only)\r
return info;\r
}\r
\r
- size_t buffer_depth() const override\r
+ int buffer_depth() const override\r
{\r
return 1;\r
}\r
if(params.size() < 1 || params[0] != L"BLUEFISH")\r
return core::frame_consumer::empty();\r
\r
- const auto device_index = params.size() > 1 ? lexical_cast_or_default<int>(params[1], 1) : 1;\r
+ const auto device_index = params.size() > 1 ? boost::lexical_cast<int>(params[1]) : 1;\r
\r
const auto embedded_audio = std::find(params.begin(), params.end(), L"EMBEDDED_AUDIO") != params.end();\r
const auto key_only = std::find(params.begin(), params.end(), L"KEY_ONLY") != params.end();\r
return make_safe<bluefish_consumer_proxy>(device_index, embedded_audio, key_only);\r
}\r
\r
-safe_ptr<core::frame_consumer> create_consumer(const boost::property_tree::ptree& ptree) \r
+safe_ptr<core::frame_consumer> create_consumer(const boost::property_tree::wptree& ptree) \r
{ \r
- const auto device_index = ptree.get("device", 1);\r
- const auto embedded_audio = ptree.get("embedded-audio", false);\r
- const auto key_only = ptree.get("key-only", false);\r
+ const auto device_index = ptree.get(L"device", 1);\r
+ const auto embedded_audio = ptree.get(L"embedded-audio", false);\r
+ const auto key_only = ptree.get(L"key-only", false);\r
\r
return make_safe<bluefish_consumer_proxy>(device_index, embedded_audio, key_only);\r
}\r