#include <gl/glew.h>
#include <boost/range/algorithm_ext/erase.hpp>
+#include <boost/range/algorithm/max_element.hpp>
#include <boost/thread/future.hpp>
#include <algorithm>
}
};
+std::size_t get_max_video_format_size()
+{
+ return *boost::range::max_element(
+ iterate_enum<core::video_format>()
+ | boost::adaptors::transformed(
+ [] (core::video_format format)
+ {
+ return core::video_format_desc(format).size;
+ }));
+}
+
class image_renderer
{
spl::shared_ptr<device> ogl_;
{
if(layers.empty())
{ // Bypass GPU with empty frame.
- auto buffer = spl::make_shared<const cache_aligned_vector<uint8_t>>(format_desc.size, 0);
- return make_ready_future(array<const std::uint8_t>(buffer->data(), format_desc.size, true, buffer));
- }
+ static const cache_aligned_vector<uint8_t> buffer(get_max_video_format_size(), 0);
+ return make_ready_future(array<const std::uint8_t>(buffer.data(), format_desc.size, true));
+ }
if(format_desc.field_mode != core::field_mode::progressive)
{ // Remove jitter from still.
, storage_(new boost::any(std::forward<T>(storage)))
{
}
-
+
+ explicit array(const std::uint8_t* ptr, std::size_t size, bool cacheable)
+ : ptr_(ptr)
+ , size_(size)
+ , cacheable_(cacheable)
+ , storage_(new boost::any)
+ {
+ }
+
array(const array& other)
: ptr_(other.ptr_)
, size_(other.size_)
#include <type_traits>
+#include <boost/range/adaptor/transformed.hpp>
+#include <boost/range/irange.hpp>
+
// Macro that defines & and &= for an enum class. Add more when needed.
#define ENUM_ENABLE_BITWISE(enum_class) \
lhs = lhs & rhs; \
return lhs; \
};
+
+namespace caspar {
+
+template<typename E>
+struct enum_from_int
+{
+ typedef E result_type;
+
+ E operator()(typename std::underlying_type<E>::type i) const
+ {
+ return static_cast<E>(i);
+ }
+};
+
+// For enum classes starting at 0 and without any gaps with a terminating count constant.
+template <typename E>
+boost::transformed_range<enum_from_int<E>, const boost::integer_range<typename std::underlying_type<E>::type>> iterate_enum()
+{
+ typedef typename std::underlying_type<E>::type integer;
+ return boost::irange(static_cast<integer>(0), static_cast<integer>(E::count)) | boost::adaptors::transformed(enum_from_int<E>());
+}
+
+}
\ No newline at end of file
double fps = static_cast<double>(time_base.den) / static_cast<double>(time_base.num);
double closest_fps = 0.0;
- for(int n = 0; n < static_cast<int>(core::video_format::count); ++n)
+
+ for (auto video_mode : iterate_enum<core::video_format>())
{
- auto format = core::video_format_desc(core::video_format(n));
+ auto format = core::video_format_desc(core::video_format(video_mode));
double diff1 = std::abs(format.fps - fps);
double diff2 = std::abs(closest_fps - fps);
<TreatWarningAsError>true</TreatWarningAsError>
<MultiProcessorCompilation>true</MultiProcessorCompilation>
<ForcedIncludeFiles>common/compiler/vs/disable_silly_warnings.h</ForcedIncludeFiles>
+ <MinimalRebuild>false</MinimalRebuild>
</ClCompile>
<Link>
<SubSystem>Windows</SubSystem>
<Configuration>Release</Configuration>\r
<Platform>x64</Platform>\r
</ProjectConfiguration>\r
+ <ProjectConfiguration Include="Release|Win32"> <!-- Only to enable profiling. See http://stackoverflow.com/questions/13934895/profiling-with-cmake-c-and-visual-studio-2012 -->\r
+ <Configuration>Release</Configuration>\r
+ <Platform>Win32</Platform>\r
+ </ProjectConfiguration>\r
</ItemGroup>\r
<ItemGroup>\r
<ClCompile Include="server.cpp">\r