]> git.sesse.net Git - casparcg/blobdiff - core/frame/frame_transform.h
changed the casing of the config-parameter mipmapping_default_on to mipmapping-defaul...
[casparcg] / core / frame / frame_transform.h
index a109f429eec4f5d44a17798f46319da4b04530b1..e21e17fb2bd60d276b32ef534381b62d61455ab8 100644 (file)
 #pragma once
 
 #include <common/tweener.h>
+#include <common/env.h>
+
 #include <core/video_format.h>
+#include <core/mixer/image/blend_modes.h>
 
 #include <boost/array.hpp>
+#include <boost/property_tree/ptree.hpp>
 
 namespace caspar { namespace core {
-                       
-struct levels /* final */
+
+struct chroma
 {
-       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;
+       enum class type
+       {
+               none,
+               green,
+               blue
+       };
+
+       type    key                     = type::none;
+       double  threshold       = 0.0;
+       double  softness        = 0.0;
+       double  spill           = 0.0;
 };
 
-struct image_transform /* final */
+struct levels 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;  
-       levels                                  levels;
-
-       field_mode                              field_mode;
-       bool                                    is_key;
-       bool                                    is_mix;
-       bool                                    is_still;
+       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 corners final
+{
+       boost::array<double, 2> ul = boost::array<double, 2> { { 0.0, 0.0 } };
+       boost::array<double, 2> ur = boost::array<double, 2> { { 1.0, 0.0 } };
+       boost::array<double, 2> lr = boost::array<double, 2> { { 1.0, 1.0 } };
+       boost::array<double, 2> ll = boost::array<double, 2> { { 0.0, 1.0 } };
+};
+
+struct rectangle final
+{
+       boost::array<double, 2> ul = boost::array<double, 2> { { 0.0, 0.0 } };
+       boost::array<double, 2> lr = boost::array<double, 2> { { 1.0, 1.0 } };
+};
+
+struct image_transform final
+{
+       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> anchor                          = boost::array<double, 2> { { 0.0, 0.0 } };
+       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 } };
+       double                                  angle                           = 0.0;
+       rectangle                               crop;
+       corners                                 perspective;
+       core::levels                    levels;
+       core::chroma                    chroma;
+
+       core::field_mode                field_mode                      = core::field_mode::progressive;
+       bool                                    is_key                          = false;
+       bool                                    is_mix                          = false;
+       bool                                    is_still                        = false;
+       bool                                    use_mipmap                      = false;
+       core::blend_mode                blend_mode                      = core::blend_mode::normal;
+       int                                             layer_depth                     = 0;
        
        image_transform& operator*=(const image_transform &other);
        image_transform operator*(const image_transform &other) const;
@@ -74,13 +108,10 @@ public:
 bool operator==(const image_transform& lhs, const image_transform& rhs);
 bool operator!=(const image_transform& lhs, const image_transform& rhs);
 
-struct audio_transform /* final */
+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;
@@ -92,15 +123,15 @@ bool operator==(const audio_transform& lhs, const audio_transform& rhs);
 bool operator!=(const audio_transform& lhs, const audio_transform& rhs);
 
 //__declspec(align(16)) 
-struct frame_transform /* final */
+struct frame_transform final
 {
 public:
        frame_transform();
        
-       image_transform image_transform;
-       audio_transform audio_transform;
+       core::image_transform image_transform;
+       core::audio_transform audio_transform;
 
-       char padding[3];
+       //char padding[(sizeof(core::image_transform) + sizeof(core::audio_transform)) % 16];
        
        frame_transform& operator*=(const frame_transform &other);
        frame_transform operator*(const frame_transform &other) const;
@@ -123,6 +154,7 @@ public:
                : duration_(0)
                , time_(0)
        {
+               dest_.image_transform.use_mipmap = env::properties().get(L"configuration.mixer.mipmapping-default-on", false);
        }
 
        tweened_transform(const frame_transform& source, const frame_transform& dest, int duration, const tweener& tween)
@@ -133,6 +165,11 @@ public:
                , tweener_(tween)
        {
        }
+
+       const frame_transform& dest() const
+       {
+               return dest_;
+       }
        
        frame_transform fetch()
        {
@@ -146,4 +183,12 @@ public:
        }
 };
 
-}}
\ No newline at end of file
+chroma::type get_chroma_mode(const std::wstring& str);
+std::wstring get_chroma_mode(chroma::type type);
+
+namespace detail {
+
+void set_current_aspect_ratio(double aspect_ratio);
+double get_current_aspect_ratio();
+
+}}}