struct frame_muxer2::implementation : public Concurrency::agent, boost::noncopyable\r
{ \r
ITarget<safe_ptr<core::basic_frame>>& target_;\r
- display_mode::type display_mode_;\r
+ mutable single_assignment<display_mode::type> display_mode_;\r
const double in_fps_;\r
const video_format_desc format_desc_;\r
bool auto_transcode_;\r
\r
- filter filter_;\r
+ mutable single_assignment<safe_ptr<filter>> filter_;\r
const safe_ptr<core::frame_factory> frame_factory_;\r
\r
call<safe_ptr<AVFrame>> push_video_;\r
const safe_ptr<core::frame_factory>& frame_factory,\r
const std::wstring& filter)\r
: target_(target)\r
- , display_mode_(display_mode::invalid)\r
, in_fps_(in_fps)\r
, format_desc_(frame_factory->get_video_format_desc())\r
, auto_transcode_(env::properties().get("configuration.producers.auto-transcode", false))\r
, push_audio_(std::bind(&implementation::push_audio, this, std::placeholders::_1))\r
, video_(std::bind(&implementation::transform_video, this, std::placeholders::_1))\r
, audio_(std::bind(&implementation::transform_audio, this, std::placeholders::_1))\r
- , filter_str_(filter)\r
{\r
if(video_source)\r
video_source->link_target(&push_video_);\r
\r
auto frame = safe_ptr<core::basic_frame>(video);\r
\r
- switch(display_mode_)\r
+ switch(display_mode_.value())\r
{\r
case display_mode::simple: \r
case display_mode::deinterlace:\r
\r
try\r
{\r
- if(display_mode_ == display_mode::invalid)\r
+ if(!display_mode_.has_value())\r
initialize_display_mode(*video_frame);\r
\r
//if(hints & core::frame_producer::ALPHA_HINT)\r
if(video_frame->format == CASPAR_PIX_FMT_LUMA) // CASPAR_PIX_FMT_LUMA is not valid for filter, change it to GRAY8\r
video_frame->format = PIX_FMT_GRAY8;\r
\r
- filter_.push(video_frame);\r
+ filter_.value()->push(video_frame);\r
\r
while(true)\r
{\r
- auto frame = filter_.poll();\r
+ auto frame = filter_.value()->poll();\r
if(!frame)\r
break; \r
\r
\r
void initialize_display_mode(AVFrame& frame)\r
{\r
+ auto display_mode = display_mode::invalid;\r
+\r
if(auto_transcode_)\r
{\r
auto mode = get_mode(frame);\r
if(is_double_rate(filter_str_))\r
fps *= 2;\r
\r
- display_mode_ = get_display_mode(mode, fps, format_desc_.field_mode, format_desc_.fps);\r
+ display_mode = get_display_mode(mode, fps, format_desc_.field_mode, format_desc_.fps);\r
\r
- if(display_mode_ == display_mode::simple && mode != core::field_mode::progressive && format_desc_.field_mode != core::field_mode::progressive && frame.height != static_cast<int>(format_desc_.height))\r
- display_mode_ = display_mode::deinterlace_bob_reinterlace; // The frame will most likely be scaled, we need to deinterlace->reinterlace \r
+ if(display_mode == display_mode::simple && mode != core::field_mode::progressive && format_desc_.field_mode != core::field_mode::progressive && frame.height != static_cast<int>(format_desc_.height))\r
+ display_mode = display_mode::deinterlace_bob_reinterlace; // The frame will most likely be scaled, we need to deinterlace->reinterlace \r
\r
- if(display_mode_ == display_mode::deinterlace)\r
+ if(display_mode == display_mode::deinterlace)\r
append_filter(filter_str_, L"YADIF=0:-1");\r
- else if(display_mode_ == display_mode::deinterlace_bob || display_mode_ == display_mode::deinterlace_bob_reinterlace)\r
+ else if(display_mode == display_mode::deinterlace_bob || display_mode == display_mode::deinterlace_bob_reinterlace)\r
append_filter(filter_str_, L"YADIF=1:-1");\r
}\r
else\r
- display_mode_ = display_mode::simple;\r
+ display_mode = display_mode::simple;\r
\r
- if(display_mode_ == display_mode::invalid)\r
+ if(display_mode == display_mode::invalid)\r
{\r
CASPAR_LOG(warning) << L"[frame_muxer] Failed to detect display-mode.";\r
- display_mode_ = display_mode::simple;\r
+ display_mode = display_mode::simple;\r
}\r
\r
- filter_ = filter(filter_str_);\r
+ send(filter_, make_safe<filter>(filter_str_));\r
+\r
+ CASPAR_LOG(info) << "[frame_muxer] " << display_mode::print(display_mode);\r
\r
- CASPAR_LOG(info) << "[frame_muxer] " << display_mode::print(display_mode_);\r
+ send(display_mode_, display_mode);\r
}\r
\r
int64_t calc_nb_frames(int64_t nb_frames) const\r
{\r
- switch(display_mode_) // Take into account transformation in run.\r
+ switch(display_mode_.value()) // Take into account transformation in run.\r
{\r
case display_mode::deinterlace_bob_reinterlace:\r
case display_mode::interlace: \r
break;\r
}\r
\r
- if(is_double_rate(filter_str_)) // Take into account transformations in filter.\r
+ if(is_double_rate(widen(filter_.value()->filter_str()))) // Take into account transformations in filter.\r
nb_frames *= 2;\r
\r
return nb_frames;\r