#include <common/memory.h>
#include <common/array.h>
#include <common/memshfl.h>
+#include <common/memcpy.h>
#include <common/utf.h>
#include <common/prec_timer.h>
#include <common/future.h>
#include <common/timer.h>
#include <common/param.h>
#include <common/os/general_protection_fault.h>
+#include <common/scope_exit.h>
//#include <windows.h>
aspect_invalid,
};
- std::wstring name = L"ogl";
+ std::wstring name = L"Screen consumer";
int screen_index = 0;
screen::stretch stretch = screen::stretch::fill;
bool windowed = true;
int square_height_ = format_desc_.square_height;
sf::Window window_;
+ tbb::atomic<bool> polling_event_;
+ std::int64_t pts_;
spl::shared_ptr<diagnostics::graph> graph_;
caspar::timer perf_timer_;
: config_(config)
, format_desc_(format_desc)
, channel_index_(channel_index)
+ , pts_(0)
, sink_(sink)
, filter_([&]() -> ffmpeg::filter
{
sample_aspect_ratio,
AV_PIX_FMT_BGRA,
{ AV_PIX_FMT_BGRA },
- format_desc.field_mode == core::field_mode::progressive || !config.auto_deinterlace ? "" : "YADIF=1:-1");
+ format_desc.field_mode == core::field_mode::progressive || !config.auto_deinterlace ? "" : "format=pix_fmts=gbrp,YADIF=1:-1");
}())
{
if (format_desc_.format == core::video_format::ntsc && config_.aspect == configuration::aspect_ratio::aspect_4_3)
screen_width_ = square_width_;
screen_height_ = square_height_;
+ polling_event_ = false;
is_running_ = true;
current_presentation_age_ = 0;
thread_ = boost::thread([this]{run();});
: (config_.windowed
? sf::Style::Resize | sf::Style::Close
: sf::Style::Fullscreen);
- window_.create(sf::VideoMode(screen_width_, screen_height_, 32), u8(L"Screen consumer " + channel_and_format()), window_style);
+ window_.create(sf::VideoMode(screen_width_, screen_height_, 32), u8(print()), window_style);
window_.setMouseCursorVisible(config_.interactive);
window_.setPosition(sf::Vector2i(screen_x_, screen_y_));
window_.setSize(sf::Vector2u(screen_width_, screen_height_));
{
try
{
- sf::Event e;
- while(window_.pollEvent(e))
+ auto poll_event = [this](sf::Event& e)
+ {
+ polling_event_ = true;
+ CASPAR_SCOPE_EXIT
+ {
+ polling_event_ = false;
+ };
+ return window_.pollEvent(e);
+ };
+
+ sf::Event e;
+ while(poll_event(e))
{
if (e.type == sf::Event::Resized)
calculate_aspect();
spl::shared_ptr<AVFrame> get_av_frame()
{
- spl::shared_ptr<AVFrame> av_frame(avcodec_alloc_frame(), av_free);
+ spl::shared_ptr<AVFrame> av_frame(av_frame_alloc(), [](AVFrame* p) { av_frame_free(&p); });
avcodec_get_frame_defaults(av_frame.get());
av_frame->linesize[0] = format_desc_.width*4;
av_frame->height = format_desc_.height;
av_frame->interlaced_frame = format_desc_.field_mode != core::field_mode::progressive;
av_frame->top_field_first = format_desc_.field_mode == core::field_mode::upper ? 1 : 0;
+ av_frame->pts = pts_++;
return av_frame;
}
});
}
else
- {
- tbb::parallel_for(tbb::blocked_range<int>(0, format_desc_.height), [&](const tbb::blocked_range<int>& r)
- {
- for(int n = r.begin(); n != r.end(); ++n)
- A_memcpy(ptr+n*format_desc_.width*4, av_frame->data[0]+n*av_frame->linesize[0], format_desc_.width*4);
- });
+ {
+ fast_memcpy(ptr, av_frame->data[0], format_desc_.size);
}
GL(glUnmapBuffer(GL_PIXEL_UNPACK_BUFFER)); // release the mapped buffer
std::future<bool> send(core::const_frame frame)
{
- if(!frame_buffer_.try_push(frame))
- graph_->set_tag("dropped-frame");
+ if(!frame_buffer_.try_push(frame) && !polling_event_)
+ graph_->set_tag(diagnostics::tag_severity::WARNING, "dropped-frame");
return make_ready_future(is_running_.load());
}
std::wstring print() const
{
- return config_.name + channel_and_format();
+ return config_.name + L" " + channel_and_format();
}
void calculate_aspect()