struct item
{
- core::pixel_format_desc pix_desc;
+ core::pixel_format_desc pix_desc = core::pixel_format::invalid;
std::array<const uint8_t*, 4> data;
core::image_transform transform;
item()
- : pix_desc(core::pixel_format::invalid)
{
data.fill(0);
}
struct draw_params final
{
- core::pixel_format_desc pix_desc;
+ core::pixel_format_desc pix_desc = core::pixel_format::invalid;
std::vector<spl::shared_ptr<class texture>> textures;
core::image_transform transform;
core::frame_geometry geometry;
- core::blend_mode blend_mode;
- keyer keyer;
+ core::blend_mode blend_mode = core::blend_mode::normal;
+ keyer keyer = keyer::linear;
std::shared_ptr<class texture> background;
std::shared_ptr<class texture> local_key;
std::shared_ptr<class texture> layer_key;
-
- draw_params()
- : pix_desc(core::pixel_format::invalid)
- , blend_mode(core::blend_mode::normal)
- , keyer(keyer::linear)
- {
- }
};
class image_kernel final
struct item
{
- core::pixel_format_desc pix_desc;
- std::vector<future_texture> textures;
- core::image_transform transform;
- core::frame_geometry geometry;
-
- item()
- : pix_desc(core::pixel_format::invalid)
- {
- }
+ core::pixel_format_desc pix_desc = core::pixel_format::invalid;
+ std::vector<future_texture> textures;
+ core::image_transform transform;
+ core::frame_geometry geometry;
};
struct layer
typedef typename Q::value_type value_type;
typedef unsigned int size_type;
private:
- semaphore space_available_;
- semaphore elements_available_;
- Q queue_;
- mutable boost::mutex capacity_mutex_;
- size_type capacity_;
+ mutable boost::mutex capacity_mutex_;
+ size_type capacity_;
+ semaphore space_available_ = capacity_;
+ semaphore elements_available_ = 0;
+ Q queue_;
public:
/**
* Constructor.
* @param capacity The capacity of the queue.
*/
blocking_bounded_queue_adapter(size_type capacity)
- : space_available_(capacity)
- , elements_available_(0)
- , capacity_(capacity)
+ : capacity_(capacity)
{
}
public:
typedef unsigned int size_type;
private:
- std::map<Prio, tbb::concurrent_queue<T>, std::greater<Prio>> queues_by_priority_;
- semaphore space_available_;
- semaphore elements_available_;
- mutable boost::mutex capacity_mutex_;
- size_type capacity_;
+ std::map<Prio, tbb::concurrent_queue<T>, std::greater<Prio>> queues_by_priority_;
+ size_type capacity_;
+ semaphore space_available_ = capacity_;
+ semaphore elements_available_ = 0u;
+ mutable boost::mutex capacity_mutex_;
public:
/**
* Constructor.
*/
template<class PrioList>
blocking_priority_queue(size_type capacity, const PrioList& priorities)
- : space_available_(capacity)
- , elements_available_(0u)
- , capacity_(capacity)
+ : capacity_(capacity)
{
for (Prio priority : priorities)
{
std::list<std::weak_ptr<drawable>> drawables_;
- executor executor_;
+ executor executor_ = L"diagnostics";
public:
static void register_drawable(const std::shared_ptr<drawable>& drawable)
get_instance().reset();
}
private:
- context() : executor_(L"diagnostics")
+ context()
{
executor_.begin_invoke([=]
{
tbb::spin_mutex mutex_;
std::wstring text_;
- bool auto_reset_;
+ bool auto_reset_ = false;
impl()
- : auto_reset_(false)
{
}
class directory_monitor
{
- bool report_already_existing_;
- boost::filesystem::wpath folder_;
- filesystem_event events_mask_;
- filesystem_monitor_handler handler_;
- initial_files_handler initial_files_handler_;
- bool first_scan_;
- std::map<boost::filesystem::wpath, std::time_t> files_;
- std::map<boost::filesystem::wpath, uintmax_t> being_written_sizes_;
+ bool report_already_existing_;
+ boost::filesystem::wpath folder_;
+ filesystem_event events_mask_;
+ filesystem_monitor_handler handler_;
+ initial_files_handler initial_files_handler_;
+ bool first_scan_ = true;
+ std::map<boost::filesystem::wpath, std::time_t> files_;
+ std::map<boost::filesystem::wpath, uintmax_t> being_written_sizes_;
public:
directory_monitor(
bool report_already_existing,
, events_mask_(events_mask)
, handler_(exception_protected_handler(handler))
, initial_files_handler_(initial_files_handler)
- , first_scan_(true)
{
}
struct output::impl
{
spl::shared_ptr<diagnostics::graph> graph_;
- spl::shared_ptr<monitor::subject> monitor_subject_;
+ spl::shared_ptr<monitor::subject> monitor_subject_ = spl::make_shared<monitor::subject>("/output");
const int channel_index_;
video_format_desc format_desc_;
std::map<int, port> ports_;
prec_timer sync_timer_;
boost::circular_buffer<const_frame> frames_;
- executor executor_;
+ executor executor_ = { L"output" };
public:
impl(spl::shared_ptr<diagnostics::graph> graph, const video_format_desc& format_desc, int channel_index)
: graph_(std::move(graph))
- , monitor_subject_(spl::make_shared<monitor::subject>("/output"))
, channel_index_(channel_index)
, format_desc_(format_desc)
- , executor_(L"output")
{
graph_->set_color("consume-time", diagnostics::color(1.0f, 0.4f, 0.0f, 0.8));
}
struct port::impl
{
- spl::shared_ptr<monitor::subject> monitor_subject_;
- std::shared_ptr<frame_consumer> consumer_;
int index_;
+ spl::shared_ptr<monitor::subject> monitor_subject_ = spl::make_shared<monitor::subject>("/port" + boost::lexical_cast<std::string>(index_));
+ std::shared_ptr<frame_consumer> consumer_;
int channel_index_;
public:
impl(int index, int channel_index, spl::shared_ptr<frame_consumer> consumer)
- : monitor_subject_(spl::make_shared<monitor::subject>(
- "/port" + boost::lexical_cast<std::string>(index)))
+ : index_(index)
, consumer_(std::move(consumer))
- , index_(index)
, channel_index_(channel_index)
{
consumer_->monitor_output().attach_parent(monitor_subject_);
core::audio_buffer audio_data_;
const core::pixel_format_desc desc_;
const void* tag_;
- core::frame_geometry geometry_;
+ core::frame_geometry geometry_ = frame_geometry::get_default();
impl(std::vector<array<std::uint8_t>> buffers, audio_buffer audio_buffer, const void* tag, const core::pixel_format_desc& desc)
: buffers_(std::move(buffers))
, audio_data_(std::move(audio_buffer))
, desc_(desc)
, tag_(tag)
- , geometry_(frame_geometry::get_default())
{
for (auto& buffer : buffers_)
if(!buffer.data())
#include "frame_transform.h"
#include <boost/range/algorithm/equal.hpp>
-#include <boost/range/algorithm/fill.hpp>
namespace caspar { namespace core {
// image_transform
-image_transform::image_transform()
- : opacity(1.0)
- , brightness(1.0)
- , contrast(1.0)
- , saturation(1.0)
- , field_mode(field_mode::progressive)
- , is_key(false)
- , is_mix(false)
- , is_still(false)
-{
- boost::range::fill(fill_translation, 0.0);
- boost::range::fill(fill_scale, 1.0);
- boost::range::fill(clip_translation, 0.0);
- boost::range::fill(clip_scale, 1.0);
-}
-
image_transform& image_transform::operator*=(const image_transform &other)
{
opacity *= other.opacity;
}
// audio_transform
-
-audio_transform::audio_transform()
- : volume(1.0)
- , is_still(false)
-{
-}
audio_transform& audio_transform::operator*=(const audio_transform &other)
{
struct levels final
{
- levels()
- : min_input(0.0)
- , max_input(1.0)
- , gamma(1.0)
- , min_output(0.0)
- , max_output(1.0)
- {
- }
- double min_input;
- double max_input;
- double gamma;
- double min_output;
- double max_output;
+ double min_input = 0.0;
+ double max_input = 1.0;
+ double gamma = 1.0;
+ double min_output = 0.0;
+ double max_output = 1.0;
};
struct image_transform final
{
-public:
- image_transform();
-
- double opacity;
- double contrast;
- double brightness;
- double saturation;
- boost::array<double, 2> fill_translation;
- boost::array<double, 2> fill_scale;
- boost::array<double, 2> clip_translation;
- boost::array<double, 2> clip_scale;
+ double opacity = 1.0;
+ double contrast = 1.0;
+ double brightness = 1.0;
+ double saturation = 1.0;
+
+ // A bug in VS 2013 prevents us from writing:
+ // boost::array<double, 2> fill_translation = { { 0.0, 0.0 } };
+ // See http://blogs.msdn.com/b/vcblog/archive/2014/08/19/the-future-of-non-static-data-member-initialization.aspx
+ boost::array<double, 2> fill_translation = boost::array<double, 2> { { 0.0, 0.0 } };
+ boost::array<double, 2> fill_scale = boost::array<double, 2> { { 1.0, 1.0 } };
+ boost::array<double, 2> clip_translation = boost::array<double, 2> { { 0.0, 0.0 } };
+ boost::array<double, 2> clip_scale = boost::array<double, 2> { { 1.0, 1.0 } };
levels levels;
- field_mode field_mode;
- bool is_key;
- bool is_mix;
- bool is_still;
+ field_mode field_mode = field_mode::progressive;
+ bool is_key = false;
+ bool is_mix = false;
+ bool is_still = false;
image_transform& operator*=(const image_transform &other);
image_transform operator*(const image_transform &other) const;
struct audio_transform final
{
-public:
- audio_transform();
-
- double volume;
- bool is_still;
+ double volume = 1.0;
+ bool is_still = false;
audio_transform& operator*=(const audio_transform &other);
audio_transform operator*(const audio_transform &other) const;
boost::optional<interaction_target> clicked_and_held_;
- int num_buttons_clicked_and_held_;
+ int num_buttons_clicked_and_held_ = 0;
public:
interaction_aggregator(const collission_detector& collission_detector)
: collission_detector_(collission_detector)
- , num_buttons_clicked_and_held_(0)
{
}
{
audio_transform prev_transform;
audio_buffer_ps audio_data;
- bool is_still;
-
- audio_stream()
- : is_still(false)
- {
- }
+ bool is_still = false;
};
struct audio_mixer::impl : boost::noncopyable
std::vector<audio_item> items_;
std::vector<int> audio_cadence_;
video_format_desc format_desc_;
- float master_volume_;
- float previous_master_volume_;
+ float master_volume_ = 1.0f;
+ float previous_master_volume_ = master_volume_;
public:
impl()
- : master_volume_(1.0f)
- , previous_master_volume_(master_volume_)
{
transform_stack_.push(core::audio_transform());
}
std::unordered_map<int, blend_mode> blend_modes_;
- executor executor_;
+ executor executor_ = L"mixer";
public:
impl(spl::shared_ptr<diagnostics::graph> graph, spl::shared_ptr<image_mixer> image_mixer)
: graph_(std::move(graph))
- , audio_mixer_()
, image_mixer_(std::move(image_mixer))
- , executor_(L"mixer")
{
graph_->set_color("mix-time", diagnostics::color(1.0f, 0.0f, 0.9f, 0.8));
}
struct layer::impl
{
spl::shared_ptr<monitor::subject> monitor_subject_;
- spl::shared_ptr<frame_producer> foreground_;
- spl::shared_ptr<frame_producer> background_;
+ spl::shared_ptr<frame_producer> foreground_ = frame_producer::empty();
+ spl::shared_ptr<frame_producer> background_ = frame_producer::empty();;
boost::optional<int32_t> auto_play_delta_;
- bool is_paused_;
+ bool is_paused_ = false;
public:
impl(int index)
"/layer/" + boost::lexical_cast<std::string>(index)))
// , foreground_event_subject_("")
// , background_event_subject_("background")
- , foreground_(frame_producer::empty())
- , background_(frame_producer::empty())
- , is_paused_(false)
{
// foreground_event_subject_.subscribe(event_subject_);
// background_event_subject_.subscribe(event_subject_);
class separated_producer : public frame_producer_base
{
spl::shared_ptr<monitor::subject> monitor_subject_;
- spl::shared_ptr<monitor::subject> key_monitor_subject_;
+ spl::shared_ptr<monitor::subject> key_monitor_subject_ = spl::make_shared<monitor::subject>("/keyer");
spl::shared_ptr<frame_producer> fill_producer_;
spl::shared_ptr<frame_producer> key_producer_;
- draw_frame fill_;
- draw_frame key_;
+ draw_frame fill_ = core::draw_frame::late();
+ draw_frame key_ = core::draw_frame::late();
public:
explicit separated_producer(const spl::shared_ptr<frame_producer>& fill, const spl::shared_ptr<frame_producer>& key)
- : key_monitor_subject_(spl::make_shared<monitor::subject>("/keyer"))
- , fill_producer_(fill)
+ : fill_producer_(fill)
, key_producer_(key)
- , fill_(core::draw_frame::late())
- , key_(core::draw_frame::late())
{
CASPAR_LOG(info) << print() << L" Initialized";
variable_impl<double> current_bearing_y_;
variable_impl<double> current_protrude_under_y_;
draw_frame frame_;
- text::texture_atlas atlas_;
+ text::texture_atlas atlas_ { 512, 512, 4 };
text::texture_font font_;
- bool dirty_;
+ bool dirty_ = false;
public:
explicit impl(const spl::shared_ptr<frame_factory>& frame_factory, int x, int y, const std::wstring& str, text::text_info& text_info, long parent_width, long parent_height, bool standalone)
, constraints_(parent_width, parent_height)
, x_(x), y_(y), parent_width_(parent_width), parent_height_(parent_height)
, standalone_(standalone)
- , atlas_(512,512,4)
, font_(atlas_, text::find_font_file(text_info), !standalone)
- , dirty_(false)
{
//TODO: examine str to determine which unicode_blocks to load
font_.load_glyphs(text::unicode_block::Basic_Latin, text_info.color);
struct string_metrics
{
- string_metrics()
- : width(0), bearingY(0), protrudeUnderY(0), height(0) {}
- int width;
- int bearingY;
- int protrudeUnderY;
- int height;
+ int width = 0;
+ int bearingY = 0;
+ int protrudeUnderY = 0;
+ int height = 0;
};
}}}
\ No newline at end of file
std::wstring font;
std::wstring font_file;
- float size;
+ float size = 0.0f;
color<float> color;
//int shadow_distance;
//int shadow_size;
//float shadow_spread;
//color<float> shadow_color;
- int baseline_shift;
- int tracking;
-
- text_info()
- : size(0.0f)
- , baseline_shift(0)
- , tracking(0)
- {
- }
+ int baseline_shift = 0;
+ int tracking = 0;
};
}}}
\ No newline at end of file
typedef std::list<node> node_list;
typedef std::list<node>::iterator node_iterator;
+ node_list nodes_;
+
+ size_t width_;
+ size_t height_;
+ size_t depth_;
+
+ std::vector<unsigned char> data_;
+ size_t used_ = 0;
+
public:
- impl(const size_t width, const size_t height, const size_t depth) : width_(width), height_(height), depth_(depth), used_(0), data_(width*height*depth, 0)
+ impl(const size_t width, const size_t height, const size_t depth) : width_(width), height_(height), depth_(depth), data_(width*height*depth, 0)
{
// We want a one pixel border around the whole atlas to avoid any artefact when sampling texture
- node n = {1, 1, (int)width_ - 2};
+ node n = {1, 1, static_cast<int>(width_) - 2};
nodes_.push_back(n);
}
rect get_region(int width, int height)
{
- rect region = {0,0,(int)width,(int)height};
+ rect region = { 0, 0, static_cast<int>(width), static_cast<int>(height) };
int best_height = INT_MAX;
int best_width = INT_MAX;
++it;
}
}
-
- node_list nodes_;
-
- size_t width_;
- size_t height_;
- size_t depth_;
-
- std::vector<unsigned char> data_;
- size_t used_;
};
texture_atlas::texture_atlas(const size_t w, const size_t h, const size_t d) : impl_(new impl(w, h, d)) {}
{
spl::shared_ptr<monitor::subject> monitor_subject_;
const field_mode mode_;
- int current_frame_;
+ int current_frame_ = 0;
const transition_info info_;
spl::shared_ptr<frame_producer> dest_producer_;
- spl::shared_ptr<frame_producer> source_producer_;
+ spl::shared_ptr<frame_producer> source_producer_ = frame_producer::empty();
- bool paused_;
+ bool paused_ = false;
public:
explicit transition_producer(const field_mode& mode, const spl::shared_ptr<frame_producer>& dest, const transition_info& info)
: mode_(mode)
- , current_frame_(0)
, info_(info)
, dest_producer_(dest)
- , source_producer_(frame_producer::empty())
- , paused_(false)
{
dest->monitor_output().attach_parent(monitor_subject_);
struct transition_info
{
- transition_info()
- : type(transition_type::cut)
- , duration(0)
- , direction(transition_direction::from_left)
- , tweener(L"linear"){}
-
- int duration;
- transition_direction direction;
- transition_type type;
- tweener tweener;
+ int duration = 0;
+ transition_direction direction = transition_direction::from_left;
+ transition_type type = transition_type::cut;
+ tweener tweener = { L"linear" };
};
spl::shared_ptr<class frame_producer> create_transition_producer(const field_mode& mode, const spl::shared_ptr<class frame_producer>& destination, const transition_info& info);
caspar::core::mixer mixer_;
caspar::core::stage stage_;
- executor executor_;
+ executor executor_ = L"video_channel";
public:
impl(int index, const core::video_format_desc& format_desc, std::unique_ptr<image_mixer> image_mixer)
: monitor_subject_(spl::make_shared<monitor::subject>(
, image_mixer_(std::move(image_mixer))
, mixer_(graph_, image_mixer_)
, stage_(graph_)
- , executor_(L"video_channel")
{
graph_->set_color("tick-time", diagnostics::color(0.0f, 0.6f, 0.9f));
graph_->set_text(print());
, square_width(square_width)
, square_height(square_height)
, field_mode(field_mode)
- , fps((double)time_scale/(double)duration)
+ , fps(static_cast<double>(time_scale) / static_cast<double>(duration))
, time_scale(time_scale)
, duration(duration)
, field_count(field_mode == field_mode::progressive ? 1 : 2)
default_latency
};
- int device_index;
- bool embedded_audio;
- keyer_t keyer;
- latency_t latency;
- bool key_only;
- int base_buffer_depth;
-
- configuration()
- : device_index(1)
- , embedded_audio(true)
- , keyer(keyer_t::default_keyer)
- , latency(latency_t::default_latency)
- , key_only(false)
- , base_buffer_depth(3)
- {
- }
+ int device_index = 1;
+ bool embedded_audio = true;
+ keyer_t keyer = keyer_t::default_keyer;
+ latency_t latency = latency_t::default_latency;
+ bool key_only = false;
+ int base_buffer_depth = 3;
int buffer_depth() const
{
const int channel_index_;
const configuration config_;
- CComPtr<IDeckLink> decklink_;
- CComQIPtr<IDeckLinkOutput> output_;
- CComQIPtr<IDeckLinkConfiguration> configuration_;
- CComQIPtr<IDeckLinkKeyer> keyer_;
- CComQIPtr<IDeckLinkAttributes> attributes_;
+ CComPtr<IDeckLink> decklink_ = get_device(config_.device_index);
+ CComQIPtr<IDeckLinkOutput> output_ = decklink_;
+ CComQIPtr<IDeckLinkConfiguration> configuration_ = decklink_;
+ CComQIPtr<IDeckLinkKeyer> keyer_ = decklink_;
+ CComQIPtr<IDeckLinkAttributes> attributes_ = decklink_;
tbb::spin_mutex exception_mutex_;
std::exception_ptr exception_;
tbb::atomic<bool> is_running_;
- const std::wstring model_name_;
+ const std::wstring model_name_ = get_model_name(decklink_);
const core::video_format_desc format_desc_;
- const int buffer_size_;
+ const int buffer_size_ = config_.buffer_depth(); // Minimum buffer-size 3.
- long long video_scheduled_;
- long long audio_scheduled_;
+ long long video_scheduled_ = 0;
+ long long audio_scheduled_ = 0;
- int preroll_count_;
+ int preroll_count_ = 0;
- boost::circular_buffer<std::vector<int32_t>> audio_container_;
+ boost::circular_buffer<std::vector<int32_t>> audio_container_ { buffer_size_ + 1 };
tbb::concurrent_bounded_queue<core::const_frame> video_frame_buffer_;
tbb::concurrent_bounded_queue<core::const_frame> audio_frame_buffer_;
decklink_consumer(const configuration& config, const core::video_format_desc& format_desc, int channel_index)
: channel_index_(channel_index)
, config_(config)
- , decklink_(get_device(config.device_index))
- , output_(decklink_)
- , configuration_(decklink_)
- , keyer_(decklink_)
- , attributes_(decklink_)
- , model_name_(get_model_name(decklink_))
, format_desc_(format_desc)
- , buffer_size_(config.buffer_depth()) // Minimum buffer-size 3.
- , video_scheduled_(0)
- , audio_scheduled_(0)
- , preroll_count_(0)
- , audio_container_(buffer_size_+1)
{
is_running_ = true;
class decklink_producer : boost::noncopyable, public IDeckLinkInputCallback
{
+ const int device_index_;
core::monitor::subject monitor_subject_;
spl::shared_ptr<diagnostics::graph> graph_;
boost::timer tick_timer_;
- CComPtr<IDeckLink> decklink_;
- CComQIPtr<IDeckLinkInput> input_;
- CComQIPtr<IDeckLinkAttributes > attributes_;
+ CComPtr<IDeckLink> decklink_ = get_device(device_index_);
+ CComQIPtr<IDeckLinkInput> input_ = decklink_;
+ CComQIPtr<IDeckLinkAttributes > attributes_ = decklink_;
- const std::wstring model_name_;
- const int device_index_;
+ const std::wstring model_name_ = get_model_name(decklink_);
const std::wstring filter_;
- std::vector<int> audio_cadence_;
- boost::circular_buffer<size_t> sync_buffer_;
- ffmpeg::frame_muxer muxer_;
-
- spl::shared_ptr<core::frame_factory> frame_factory_;
core::video_format_desc in_format_desc_;
core::video_format_desc out_format_desc_;
- core::constraints constraints_;
+ std::vector<int> audio_cadence_ = out_format_desc_.audio_cadence;
+ boost::circular_buffer<size_t> sync_buffer_ { audio_cadence_.size() };
+ spl::shared_ptr<core::frame_factory> frame_factory_;
+ ffmpeg::frame_muxer muxer_ { in_format_desc_.fps, frame_factory_, out_format_desc_, filter_ };
+
+ core::constraints constraints_ { in_format_desc_.width, in_format_desc_.height };
tbb::concurrent_bounded_queue<core::draw_frame> frame_buffer_;
std::exception_ptr exception_;
public:
- decklink_producer(const core::video_format_desc& in_format_desc,
- int device_index,
- const spl::shared_ptr<core::frame_factory>& frame_factory,
- const core::video_format_desc& out_format_desc,
- const std::wstring& filter)
- : decklink_(get_device(device_index))
- , input_(decklink_)
- , attributes_(decklink_)
- , model_name_(get_model_name(decklink_))
- , device_index_(device_index)
+ decklink_producer(
+ const core::video_format_desc& in_format_desc,
+ int device_index,
+ const spl::shared_ptr<core::frame_factory>& frame_factory,
+ const core::video_format_desc& out_format_desc,
+ const std::wstring& filter)
+ : device_index_(device_index)
, filter_(filter)
, in_format_desc_(in_format_desc)
, out_format_desc_(out_format_desc)
- , constraints_(in_format_desc.width, in_format_desc.height)
- , muxer_(in_format_desc.fps, frame_factory, out_format_desc, filter)
- , audio_cadence_(out_format_desc.audio_cadence)
- , sync_buffer_(out_format_desc.audio_cadence.size())
, frame_factory_(frame_factory)
{
frame_buffer_.set_capacity(2);
{
const spl::shared_ptr<diagnostics::graph> graph_;
const std::string filename_;
- const std::shared_ptr<AVFormatContext> oc_;
+ const std::shared_ptr<AVFormatContext> oc_ { avformat_alloc_context(), av_free };
const core::video_format_desc format_desc_;
core::monitor::subject monitor_subject_;
std::shared_ptr<SwrContext> swr_;
std::shared_ptr<SwsContext> sws_;
- int64_t frame_number_;
+ int64_t frame_number_ = 0;
output_format output_format_;
bool key_only_;
public:
ffmpeg_consumer(const std::string& filename, const core::video_format_desc& format_desc, std::vector<option> options, bool key_only)
: filename_(filename)
- , oc_(avformat_alloc_context(), av_free)
, format_desc_(format_desc)
- , frame_number_(0)
, output_format_(format_desc, filename, options)
, key_only_(key_only)
, executor_(print())
core::monitor::subject monitor_subject_;
input* input_;
int index_;
- const spl::shared_ptr<AVCodecContext> codec_context_;
const core::video_format_desc format_desc_;
-
- std::shared_ptr<SwrContext> swr_;
+ const spl::shared_ptr<AVCodecContext> codec_context_ = open_codec(input_->context(), AVMEDIA_TYPE_AUDIO, index_);
+
+ std::shared_ptr<SwrContext> swr_ {
+ swr_alloc_set_opts(
+ nullptr,
+ av_get_default_channel_layout(format_desc_.audio_channels),
+ AV_SAMPLE_FMT_S32,
+ format_desc_.audio_sample_rate,
+ get_channel_layout(codec_context_.get()),
+ codec_context_->sample_fmt,
+ codec_context_->sample_rate,
+ 0,
+ nullptr),
+ [](SwrContext* p){swr_free(&p); }
+ };
std::vector<uint8_t, tbb::cache_aligned_allocator<int8_t>> buffer_;
: input_(&in)
, format_desc_(format_desc)
, codec_context_(open_codec(input_->context(), AVMEDIA_TYPE_AUDIO, index_))
- , swr_(swr_alloc_set_opts(nullptr,
- av_get_default_channel_layout(format_desc_.audio_channels), AV_SAMPLE_FMT_S32, format_desc_.audio_sample_rate,
- get_channel_layout(codec_context_.get()), codec_context_->sample_fmt, codec_context_->sample_rate,
- 0, nullptr), [](SwrContext* p){swr_free(&p);})
- , buffer_(480000*4)
+ , buffer_(480000 * 4)
{
if(!swr_)
CASPAR_THROW_EXCEPTION(bad_alloc());
{
spl::shared_ptr<core::monitor::subject> monitor_subject_;
const std::wstring filename_;
- const std::wstring path_relative_to_media_;
+ const std::wstring path_relative_to_media_ = get_relative_or_original(filename_, env::media_folder());
const spl::shared_ptr<diagnostics::graph> graph_;
input input_;
- const double fps_;
+ const double fps_ = read_fps(input_.context(), format_desc_.fps);
const uint32_t start_;
std::unique_ptr<video_decoder> video_decoder_;
frame_muxer muxer_;
core::constraints constraints_;
- core::draw_frame last_frame_;
+ core::draw_frame last_frame_ = core::draw_frame::empty();
boost::optional<uint32_t> seek_target_;
uint32_t start,
uint32_t length)
: filename_(filename)
- , path_relative_to_media_(get_relative_or_original(filename, env::media_folder()))
, frame_factory_(frame_factory)
, format_desc_(format_desc)
, input_(graph_, filename_, loop, start, length)
, fps_(read_fps(input_.context(), format_desc_.fps))
, muxer_(fps_, frame_factory, format_desc_, filter)
, start_(start)
- , last_frame_(core::draw_frame::empty())
{
graph_->set_color("frame-time", diagnostics::color(0.1f, 1.0f, 0.1f));
graph_->set_color("underflow", diagnostics::color(0.6f, 0.3f, 0.9f));
AVFilterContext* video_graph_out_;
implementation(
- int in_width,
- int in_height,
- boost::rational<int> in_time_base,
- boost::rational<int> in_frame_rate,
- boost::rational<int> in_sample_aspect_ratio,
- AVPixelFormat in_pix_fmt,
- std::vector<AVPixelFormat> out_pix_fmts,
- const std::string& filtergraph)
+ int in_width,
+ int in_height,
+ boost::rational<int> in_time_base,
+ boost::rational<int> in_frame_rate,
+ boost::rational<int> in_sample_aspect_ratio,
+ AVPixelFormat in_pix_fmt,
+ std::vector<AVPixelFormat> out_pix_fmts,
+ const std::string& filtergraph)
: filtergraph_(boost::to_lower_copy(filtergraph))
{
if(out_pix_fmts.empty())
struct input::impl : boost::noncopyable
{
- const spl::shared_ptr<diagnostics::graph> graph_;
+ const spl::shared_ptr<diagnostics::graph> graph_;
- const spl::shared_ptr<AVFormatContext> format_context_; // Destroy this last
- const int default_stream_index_;
-
- const std::wstring filename_;
- tbb::atomic<uint32_t> start_;
- tbb::atomic<uint32_t> length_;
- tbb::atomic<bool> loop_;
- double fps_;
- uint32_t frame_number_;
-
- stream video_stream_;
- stream audio_stream_;
+ const std::wstring filename_;
+ const spl::shared_ptr<AVFormatContext> format_context_ = open_input(filename_); // Destroy this last
+ const int default_stream_index_ = av_find_default_stream_index(format_context_.get());
+
+ tbb::atomic<uint32_t> start_;
+ tbb::atomic<uint32_t> length_;
+ tbb::atomic<bool> loop_;
+ double fps_ = read_fps(*format_context_, 0.0);
+ uint32_t frame_number_ = 0;
+
+ stream video_stream_ = av_find_best_stream(format_context_.get(), AVMEDIA_TYPE_VIDEO, -1, -1, 0, 0);
+ stream audio_stream_ = av_find_best_stream(format_context_.get(), AVMEDIA_TYPE_AUDIO, -1, -1, 0, 0);
- boost::optional<uint32_t> seek_target_;
+ boost::optional<uint32_t> seek_target_;
- tbb::atomic<bool> is_running_;
- boost::mutex mutex_;
- boost::condition_variable cond_;
- boost::thread thread_;
+ tbb::atomic<bool> is_running_;
+ boost::mutex mutex_;
+ boost::condition_variable cond_;
+ boost::thread thread_;
impl(const spl::shared_ptr<diagnostics::graph> graph, const std::wstring& filename, const bool loop, const uint32_t start, const uint32_t length)
: graph_(graph)
- , format_context_(open_input(filename))
- , default_stream_index_(av_find_default_stream_index(format_context_.get()))
, filename_(filename)
- , frame_number_(0)
- , fps_(read_fps(*format_context_, 0.0))
- , video_stream_(av_find_best_stream(format_context_.get(), AVMEDIA_TYPE_VIDEO, -1, -1, 0, 0))
- , audio_stream_(av_find_best_stream(format_context_.get(), AVMEDIA_TYPE_AUDIO, -1, -1, 0, 0))
{
start_ = start;
length_ = length;
std::queue<core::mutable_frame> video_stream_;
core::audio_buffer audio_stream_;
std::queue<draw_frame> frame_buffer_;
- display_mode display_mode_;
+ display_mode display_mode_ = display_mode::invalid;
const double in_fps_;
const video_format_desc format_desc_;
- std::vector<int> audio_cadence_;
+ std::vector<int> audio_cadence_ = format_desc_.audio_cadence;
spl::shared_ptr<core::frame_factory> frame_factory_;
std::unique_ptr<filter> filter_;
const std::wstring filter_str_;
- bool force_deinterlacing_;
+ bool force_deinterlacing_ = env::properties().get(L"configuration.force-deinterlace", true);
impl(double in_fps, const spl::shared_ptr<core::frame_factory>& frame_factory, const core::video_format_desc& format_desc, const std::wstring& filter_str)
- : display_mode_(display_mode::invalid)
- , in_fps_(in_fps)
+ : in_fps_(in_fps)
, format_desc_(format_desc)
- , audio_cadence_(format_desc_.audio_cadence)
, frame_factory_(frame_factory)
, filter_str_(filter_str)
- , force_deinterlacing_(env::properties().get(L"configuration.force-deinterlace", true))
{
// Note: Uses 1 step rotated cadence for 1001 modes (1602, 1602, 1601, 1602, 1601)
// This cadence fills the audio mixer most optimally.
{
struct com_init
{
- HRESULT result_;
+ HRESULT result_ = CoInitialize(nullptr);
com_init()
- : result_(CoInitialize(nullptr))
{
if(FAILED(result_))
CASPAR_THROW_EXCEPTION(caspar_exception() << msg_info("Failed to initialize com-context for flash-player"));
}
} com_init_;
- core::monitor::subject& monitor_subject_;
+ core::monitor::subject& monitor_subject_;
- const std::wstring filename_;
+ const std::wstring filename_;
+ const int width_;
+ const int height_;
- const std::shared_ptr<core::frame_factory> frame_factory_;
+ const std::shared_ptr<core::frame_factory> frame_factory_;
- CComObject<caspar::flash::FlashAxContainer>* ax_;
- core::draw_frame head_;
- bitmap bmp_;
+ CComObject<caspar::flash::FlashAxContainer>* ax_ = nullptr;
+ core::draw_frame head_ = core::draw_frame::empty();
+ bitmap bmp_ { width_, height_ };
- spl::shared_ptr<diagnostics::graph> graph_;
+ spl::shared_ptr<diagnostics::graph> graph_;
- prec_timer timer_;
+ prec_timer timer_;
- const int width_;
- const int height_;
public:
flash_renderer(core::monitor::subject& monitor_subject, const spl::shared_ptr<diagnostics::graph>& graph, const std::shared_ptr<core::frame_factory>& frame_factory, const std::wstring& filename, int width, int height)
: monitor_subject_(monitor_subject)
, graph_(graph)
, filename_(filename)
- , frame_factory_(frame_factory)
- , ax_(nullptr)
- , head_(core::draw_frame::empty())
- , bmp_(width, height)
, width_(width)
, height_(height)
+ , frame_factory_(frame_factory)
+ , bmp_(width, height)
{
graph_->set_color("frame-time", diagnostics::color(0.1f, 1.0f, 0.1f));
graph_->set_color("param", diagnostics::color(1.0f, 0.5f, 0.0f));
const core::video_format_desc format_desc_;
const int width_;
const int height_;
- core::constraints constraints_;
- const int buffer_size_;
+ core::constraints constraints_ { static_cast<double>(width_), static_cast<double>(height_) };
+ const int buffer_size_ = env::properties().get(L"configuration.flash.buffer-depth", format_desc_.fps > 30.0 ? 4 : 2);
tbb::atomic<int> fps_;
boost::timer tick_timer_;
std::unique_ptr<flash_renderer> renderer_;
- executor executor_;
+ executor executor_ = L"flash_producer";
public:
flash_producer(const spl::shared_ptr<core::frame_factory>& frame_factory, const core::video_format_desc& format_desc, const std::wstring& filename, int width, int height)
: filename_(filename)
, format_desc_(format_desc)
, width_(width > 0 ? width : format_desc.width)
, height_(height > 0 ? height : format_desc.height)
- , constraints_(width_, height_)
- , buffer_size_(env::properties().get(L"configuration.flash.buffer-depth", format_desc.fps > 30.0 ? 4 : 2))
- , executor_(L"flash_producer")
{
fps_ = 0;
core::monitor::subject monitor_subject_;
const std::wstring description_;
const spl::shared_ptr<core::frame_factory> frame_factory_;
- core::draw_frame frame_;
+ core::draw_frame frame_ = core::draw_frame::empty();
core::constraints constraints_;
image_producer(const spl::shared_ptr<core::frame_factory>& frame_factory, const std::wstring& description)
: description_(description)
, frame_factory_(frame_factory)
- , frame_(core::draw_frame::empty())
{
load(load_image(description_));
image_producer(const spl::shared_ptr<core::frame_factory>& frame_factory, const void* png_data, size_t size)
: description_(L"png from memory")
, frame_factory_(frame_factory)
- , frame_(core::draw_frame::empty())
{
load(load_png_from_memory(png_data, size));
int height_;
core::constraints constraints_;
- double delta_;
+ double delta_ = 0.0;
double speed_;
- int start_offset_x_;
- int start_offset_y_;
+ int start_offset_x_ = 0;
+ int start_offset_y_ = 0;
bool progressive_;
explicit image_scroll_producer(
- const spl::shared_ptr<core::frame_factory>& frame_factory,
- const core::video_format_desc& format_desc,
- const std::wstring& filename,
- double speed,
- double duration,
- int motion_blur_px = 0,
- bool premultiply_with_alpha = false,
- bool progressive = false)
+ const spl::shared_ptr<core::frame_factory>& frame_factory,
+ const core::video_format_desc& format_desc,
+ const std::wstring& filename,
+ double speed,
+ double duration,
+ int motion_blur_px = 0,
+ bool premultiply_with_alpha = false,
+ bool progressive = false)
: filename_(filename)
- , delta_(0)
, format_desc_(format_desc)
, speed_(speed)
- , start_offset_x_(0)
- , start_offset_y_(0)
, progressive_(progressive)
{
auto bitmap = load_image(filename_);
*/
class rgba_weighting
{
- int r, g, b, a;
- int total_weight;
+ int r = 0;
+ int g = 0;
+ int b = 0;
+ int a = 0;
+ int total_weight = 0;
public:
- rgba_weighting()
- : r(0), g(0), b(0), a(0), total_weight(0)
- {
- }
-
template<class RGBAPixel>
inline void add_pixel(const RGBAPixel& pixel, uint8_t weight)
{
template<class PackedPixel>
class image_sub_view
{
+private:
+ image_view<PackedPixel> root_view_;
+ int relative_to_root_x_;
+ int relative_to_root_y_;
+ int width_;
+ int height_;
+ PackedPixel* raw_begin_ = root_view_.relative(root_view_.begin(), relative_to_root_x_, relative_to_root_y_);
+ PackedPixel* raw_end_ = root_view_.relative(raw_begin_, width_ - 1, height_ - 1) + 1;
public:
typedef PackedPixel pixel_type;
, relative_to_root_y_(y)
, width_(width)
, height_(height)
- , raw_begin_(root_view.relative(root_view.begin(), x, y))
- , raw_end_(root_view.relative(raw_begin_, width - 1, height_ - 1) + 1)
{
}
{
return root_view_.subview(relative_to_root_x_ + x, relative_to_root_y_ + y, width, height);
}
-private:
- image_view<PackedPixel> root_view_;
- int relative_to_root_x_;
- int relative_to_root_y_;
- int width_;
- int height_;
- PackedPixel* raw_begin_;
- PackedPixel* raw_end_;
};
}}
class device
{
- ALCdevice* device_;
- ALCcontext* context_;
+ ALCdevice* device_ = nullptr;
+ ALCcontext* context_ = nullptr;
public:
device()
- : device_(0)
- , context_(0)
{
device_ = alcOpenDevice(nullptr);
spl::shared_ptr<diagnostics::graph> graph_;
boost::timer perf_timer_;
- int channel_index_;
+ int channel_index_ = -1;
core::video_format_desc format_desc_;
- ALuint source_;
+ ALuint source_ = 0;
std::array<ALuint, 3> buffers_;
- executor executor_;
+ executor executor_ = L"oal_consumer";
public:
oal_consumer()
- : channel_index_(-1)
- , source_(0)
- , executor_(L"oal_consumer")
{
buffers_.assign(0);
template<typename T>
struct color
{
- color() : red(0), green(0), blue(0), alpha(0)
- {}
-
- T red;
- T green;
- T blue;
- T alpha;
+ T red = 0;
+ T green = 0;
+ T blue = 0;
+ T alpha = 0;
unsigned long to_uint32()
{
aspect_invalid,
};
- std::wstring name;
- int screen_index;
- stretch stretch;
- bool windowed;
- bool auto_deinterlace;
- bool key_only;
- aspect_ratio aspect;
- bool vsync;
- bool interactive;
-
- configuration()
- : name(L"ogl")
- , screen_index(0)
- , stretch(stretch::fill)
- , windowed(true)
- , auto_deinterlace(true)
- , key_only(false)
- , aspect(aspect_ratio::aspect_invalid)
- , vsync(true)
- , interactive(true)
- {
- }
+ std::wstring name = L"ogl";
+ int screen_index = 0;
+ stretch stretch = stretch::fill;
+ bool windowed = true;
+ bool auto_deinterlace = true;
+ bool key_only = false;
+ aspect_ratio aspect = aspect_ratio::aspect_invalid;
+ bool vsync = true;
+ bool interactive = true;
};
struct screen_consumer : boost::noncopyable
core::video_format_desc format_desc_;
int channel_index_;
- GLuint texture_;
- std::vector<GLuint> pbos_;
+ GLuint texture_ = 0;
+ std::vector<GLuint> pbos_ = std::vector<GLuint> { 0, 0 };
float width_;
float height_;
int screen_x_;
int screen_y_;
- int screen_width_;
- int screen_height_;
- int square_width_;
- int square_height_;
+ int screen_width_ = format_desc_.width;
+ int screen_height_ = format_desc_.height;
+ int square_width_ = format_desc_.square_width;
+ int square_height_ = format_desc_.square_height;
sf::Window window_;
: config_(config)
, format_desc_(format_desc)
, channel_index_(channel_index)
- , texture_(0)
- , pbos_(2, 0)
- , screen_width_(format_desc.width)
- , screen_height_(format_desc.height)
- , square_width_(format_desc.square_width)
- , square_height_(format_desc.square_height)
, sink_(sink)
, filter_([&]() -> ffmpeg::filter
{
class CLKProtocolStrategy : public IO::protocol_strategy<wchar_t>
{
+ enum class ParserState
+ {
+ ExpectingNewCommand,
+ ExpectingCommand,
+ ExpectingParameter
+ };
+
+ ParserState currentState_ = ParserState::ExpectingNewCommand;
+ std::wstringstream currentCommandString_;
+ std::wstring command_name_;
+ std::vector<std::wstring> parameters_;
+ clk_command_processor& command_processor_;
+ IO::client_connection<wchar_t>::ptr client_connection_;
public:
CLKProtocolStrategy(
- const IO::client_connection<wchar_t>::ptr& client_connection,
- clk_command_processor& command_processor)
- : currentState_(ParserState::ExpectingNewCommand)
- , command_processor_(command_processor)
+ const IO::client_connection<wchar_t>::ptr& client_connection,
+ clk_command_processor& command_processor)
+ : command_processor_(command_processor)
, client_connection_(client_connection)
{
}
command_name_.clear();
parameters_.clear();
}
-
- enum class ParserState
- {
- ExpectingNewCommand,
- ExpectingCommand,
- ExpectingParameter
- };
-
- ParserState currentState_;
- std::wstringstream currentCommandString_;
- std::wstring command_name_;
- std::vector<std::wstring> parameters_;
- clk_command_processor& command_processor_;
- IO::client_connection<wchar_t>::ptr client_connection_;
};
clk_protocol_strategy_factory::clk_protocol_strategy_factory(