class color_producer : public frame_producer\r
{\r
public:\r
- explicit color_producer(unsigned long color_value, const frame_format_desc& format_desc) : format_desc_(format_desc){}\r
+ explicit color_producer(unsigned int color_value, const frame_format_desc& format_desc) \r
+ : color_value_(color_value), format_desc_(format_desc){}\r
\r
- gpu_frame_ptr get_frame() { return frame_; }\r
+ gpu_frame_ptr get_frame()\r
+ { \r
+ frame_ = factory_->create_frame(format_desc_);\r
+ __stosd(reinterpret_cast<unsigned long*>(frame_->data()), color_value_, frame_->size() / sizeof(unsigned long));\r
+ return frame_;\r
+ }\r
const frame_format_desc& get_frame_format_desc() const { return format_desc_; }\r
\r
void initialize(const frame_factory_ptr& factory)\r
{\r
- frame_ = factory->create_frame(format_desc_);\r
- __stosd(reinterpret_cast<unsigned long*>(frame_->data()), color_value_, frame_->size() / sizeof(unsigned long));\r
+ factory_ = factory;\r
}\r
\r
frame_format_desc format_desc_;\r
gpu_frame_ptr frame_;\r
- unsigned long color_value_;\r
+ unsigned int color_value_;\r
+ frame_factory_ptr factory_;\r
};\r
\r
union Color \r
unsigned char b;\r
} comp;\r
\r
- unsigned long value;\r
+ unsigned int value;\r
};\r
\r
-unsigned long get_pixel_color_value(const std::wstring& parameter)\r
+unsigned int get_pixel_color_value(const std::wstring& parameter)\r
{\r
std::wstring color_code;\r
if(parameter.length() != 9 || parameter[0] != '#')\r
{\r
implementation(const frame_producer_ptr& dest, const transition_info& info, \r
const frame_format_desc& format_desc) \r
- : current_frame_(0), info_(info), format_desc_(format_desc), dest_(dest)\r
+ : current_frame_(0), info_(info), format_desc_(format_desc), dest_producer_(dest)\r
{\r
if(!dest)\r
BOOST_THROW_EXCEPTION(null_argument() << arg_name_info("dest"));\r
\r
frame_producer_ptr get_following_producer() const\r
{\r
- return dest_;\r
+ return dest_producer_;\r
}\r
\r
void set_leading_producer(const frame_producer_ptr& producer)\r
{\r
- source_ = producer;\r
+ source_producer_ = producer;\r
}\r
\r
gpu_frame_ptr get_frame()\r
if(++current_frame_ >= info_.duration)\r
return nullptr;\r
\r
- return compose(get_producer_frame(dest_), get_producer_frame(source_));\r
+ gpu_frame_ptr source;\r
+ gpu_frame_ptr dest;\r
+\r
+ tbb::parallel_invoke\r
+ (\r
+ [&]{dest = get_producer_frame(dest_producer_);},\r
+ [&]{source = get_producer_frame(source_producer_);}\r
+ );\r
+\r
+ return compose(dest, source);\r
}\r
\r
gpu_frame_ptr get_producer_frame(frame_producer_ptr& producer)\r
return frame;\r
}\r
\r
- gpu_frame_ptr compose(const gpu_frame_ptr& dest_frame, const gpu_frame_ptr& src_frame) \r
+ gpu_frame_ptr compose(const gpu_frame_ptr& dest_producer_frame, const gpu_frame_ptr& src_frame) \r
{ \r
if(!src_frame)\r
- return dest_frame;\r
+ return dest_producer_frame;\r
\r
- if(info_.type == transition_type::cut || !dest_frame) \r
+ if(info_.type == transition_type::cut || !dest_producer_frame) \r
return src_frame;\r
\r
int volume = static_cast<int>(static_cast<double>(current_frame_)/static_cast<double>(info_.duration)*256.0);\r
\r
- for(size_t n = 0; n < dest_frame->audio_data().size(); ++n)\r
- dest_frame->audio_data()[n] = static_cast<short>((static_cast<int>(dest_frame->audio_data()[n])*volume)>>8);\r
+ for(size_t n = 0; n < dest_producer_frame->audio_data().size(); ++n)\r
+ dest_producer_frame->audio_data()[n] = static_cast<short>((static_cast<int>(dest_producer_frame->audio_data()[n])*volume)>>8);\r
\r
for(size_t n = 0; n < src_frame->audio_data().size(); ++n)\r
src_frame->audio_data()[n] = static_cast<short>((static_cast<int>(src_frame->audio_data()[n])*(256-volume))>>8);\r
float alpha = static_cast<float>(current_frame_)/static_cast<float>(info_.duration);\r
auto composite = std::make_shared<gpu_composite_frame>();\r
composite->add(src_frame);\r
- composite->add(dest_frame);\r
+ composite->add(dest_producer_frame);\r
if(info_.type == transition_type::mix)\r
- dest_frame->alpha(alpha); \r
+ dest_producer_frame->alpha(alpha); \r
else if(info_.type == transition_type::slide)\r
{\r
if(info_.direction == transition_direction::from_left) \r
- dest_frame->translate(-1.0f+alpha, 0.0f); \r
+ dest_producer_frame->translate(-1.0f+alpha, 0.0f); \r
else if(info_.direction == transition_direction::from_right)\r
- dest_frame->translate(1.0f-alpha, 0.0f); \r
+ dest_producer_frame->translate(1.0f-alpha, 0.0f); \r
}\r
else if(info_.type == transition_type::push)\r
{\r
if(info_.direction == transition_direction::from_left) \r
{\r
- dest_frame->translate(-1.0f+alpha, 0.0f);\r
+ dest_producer_frame->translate(-1.0f+alpha, 0.0f);\r
src_frame->translate(0.0f+alpha, 0.0f);\r
}\r
else if(info_.direction == transition_direction::from_right)\r
{\r
- dest_frame->translate(1.0f-alpha, 0.0f);\r
+ dest_producer_frame->translate(1.0f-alpha, 0.0f);\r
src_frame->translate(0.0f-alpha, 0.0f);\r
}\r
}\r
{\r
if(info_.direction == transition_direction::from_left) \r
{\r
- dest_frame->translate(-1.0f+alpha, 0.0f);\r
- dest_frame->texcoords(rectangle(-1.0+alpha, 1.0, alpha, 0.0));\r
+ dest_producer_frame->translate(-1.0f+alpha, 0.0f);\r
+ dest_producer_frame->texcoords(rectangle(-1.0+alpha, 1.0, alpha, 0.0));\r
}\r
else if(info_.direction == transition_direction::from_right)\r
{\r
- dest_frame->translate(1.0f-alpha, 0.0f);\r
- dest_frame->texcoords(rectangle(1.0-alpha, 1.0, 2.0-alpha, 0.0));\r
+ dest_producer_frame->translate(1.0f-alpha, 0.0f);\r
+ dest_producer_frame->texcoords(rectangle(1.0-alpha, 1.0, 2.0-alpha, 0.0));\r
}\r
}\r
\r
\r
void initialize(const frame_factory_ptr& factory)\r
{\r
- dest_->initialize(factory);\r
+ dest_producer_->initialize(factory);\r
factory_ = factory;\r
}\r
\r
const frame_format_desc format_desc_;\r
\r
- frame_producer_ptr source_;\r
- frame_producer_ptr dest_;\r
+ frame_producer_ptr source_producer_;\r
+ frame_producer_ptr dest_producer_;\r
\r
unsigned short current_frame_;\r
\r
std::wstring wcmd;\r
std::getline(std::wcin, wcmd); // TODO: It's blocking...\r
is_running = wcmd != L"exit" && wcmd != L"q";\r
- if(wcmd == L"1")\r
- wcmd = L"LOADBG 1-1 DV SLIDE 100 LOOP AUTOPLAY";\r
- else if(wcmd == L"2")\r
- wcmd = L"LOADBG 1-1 DV PUSH 100 LOOP AUTOPLAY";\r
- else if(wcmd == L"3")\r
- wcmd = L"LOADBG 1-1 DV MIX 100 LOOP AUTOPLAY";\r
- else if(wcmd == L"4")\r
- wcmd = L"LOADBG 1-1 DV WIPE 100 LOOP AUTOPLAY";\r
+ if(wcmd.substr(0, 1) == L"1")\r
+ wcmd = L"LOADBG 1-1 " + wcmd.substr(1, wcmd.length()-1) + L" SLIDE 100 LOOP AUTOPLAY";\r
+ else if(wcmd.substr(0, 1) == L"2")\r
+ wcmd = L"LOADBG 1-1 " + wcmd.substr(1, wcmd.length()-1) + L" PUSH 100 LOOP AUTOPLAY";\r
+ else if(wcmd.substr(0, 1) == L"3")\r
+ wcmd = L"LOADBG 1-1 " + wcmd.substr(1, wcmd.length()-1) + L" MIX 100 LOOP AUTOPLAY";\r
+ else if(wcmd.substr(0, 1) == L"4")\r
+ wcmd = L"LOADBG 1-1 " + wcmd.substr(1, wcmd.length()-1) + L" WIPE 100 LOOP AUTOPLAY";\r
else if(wcmd == L"5")\r
- wcmd = L"LOADBG 1-1 DV CUT 100 LOOP AUTOPLAY";\r
- else if(wcmd == L"6")\r
+ wcmd = L"LOADBG 1-1 " + wcmd.substr(1, wcmd.length()-1) + L" CUT 100 LOOP AUTOPLAY";\r
+ else if(wcmd.substr(0, 1) == L"6")\r
wcmd = L"CG 1-2 ADD 1 BBTELEFONARE 1";\r
\r
wcmd += L"\r\n";\r