for(int n = 0; n < 128 && muxer_.size() < 2; ++n)\r
decode_frame();\r
}\r
+\r
+ ~ffmpeg_producer()\r
+ {\r
+ tasks_.cancel();\r
+ tasks_.wait();\r
+ }\r
\r
virtual safe_ptr<core::basic_frame> receive()\r
{\r
- // TODO: Do rendering asynchronously.\r
-\r
- frame_timer_.restart();\r
+ tasks_.wait();\r
\r
- for(int n = 0; n < 64 && muxer_.size() < 2; ++n)\r
- decode_frame();\r
-\r
- graph_->update_value("frame-time", static_cast<float>(frame_timer_.elapsed()*format_desc_.fps*0.5));\r
+ auto frame = core::basic_frame::late();\r
\r
if(!muxer_.empty())\r
- return last_frame_ = muxer_.pop(); \r
+ frame = last_frame_ = muxer_.pop(); \r
+ else\r
+ {\r
+ if(input_.eof())\r
+ frame = core::basic_frame::eof();\r
+ else\r
+ {\r
+ graph_->add_tag("underflow"); \r
+ ++nb_frames_; \r
+ }\r
+ }\r
\r
- if(input_.eof())\r
- return core::basic_frame::eof();\r
+ tasks_.run([this]\r
+ {\r
+ frame_timer_.restart();\r
\r
- graph_->add_tag("underflow"); \r
- ++nb_frames_; \r
+ for(int n = 0; n < 64 && muxer_.size() < 2; ++n)\r
+ decode_frame();\r
\r
- return core::basic_frame::late();\r
+ graph_->update_value("frame-time", static_cast<float>(frame_timer_.elapsed()*format_desc_.fps*0.5));\r
+ });\r
+ \r
+ return frame;\r
}\r
\r
virtual safe_ptr<core::basic_frame> last_frame() const\r
#include <libavfilter/avfilter.h>\r
}\r
\r
+#include <tbb/parallel_for.h>\r
+\r
#include <boost/thread/once.hpp>\r
\r
typedef struct {\r
ff(0); ff(1); ff(2); ff(3); ff(4); ff(5); ff(6); ff(7); ff(8); ff(9); ff(10); ff(11); ff(12); ff(13); ff(14); ff(15); ff(16); ff(17);\r
\r
void (*fs[])(uint8_t *dst, uint8_t *prev, uint8_t *cur, uint8_t *next, int w, int prefs, int mrefs, int parity, int mode) = \r
-\r
{f0, f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, f13, f14, f15, f16, f17};\r
\r
namespace caspar {\r
\r
void init_pool()\r
{\r
- for(int n = 0; n < sizeof(fs)/sizeof(decltype(org_yadif_filter_line)); ++n)\r
+ for(int n = 0; n < sizeof(fs)/sizeof(fs[0]); ++n)\r
parallel_line_func_pool.push(fs[n]);\r
}\r
\r
void return_parallel_yadif(void* func)\r
{\r
if(func != nullptr)\r
- parallel_line_func_pool.push(reinterpret_cast<decltype(org_yadif_filter_line)>(func));\r
+ parallel_line_func_pool.push(reinterpret_cast<decltype(fs[0])>(func));\r
}\r
\r
std::shared_ptr<void> make_parallel_yadif(AVFilterContext* ctx)\r
return;\r
\r
auto frame1 = pop_video();\r
- frame1->commit();\r
frame1->audio_data() = pop_audio();\r
\r
dest.push_back(frame1); \r
return;\r
\r
auto frame = pop_video();\r
- frame->commit();\r
\r
auto frame1 = make_safe<core::write_frame>(*frame); // make a copy\r
frame1->audio_data() = pop_audio();\r
return;\r
\r
auto frame1 = pop_video();\r
- frame1->commit();\r
frame1->audio_data() = pop_audio();\r
\r
video_streams_.front().pop(); // Throw away\r
return;\r
\r
auto frame1 = pop_video();\r
- frame1->commit();\r
-\r
frame1->audio_data() = pop_audio();\r
\r
auto frame2 = pop_video();\r