]> git.sesse.net Git - casparcg/blobdiff - core/video_format.h
Added boost::rational framerate in video_format_desc for convenience.
[casparcg] / core / video_format.h
index 713ae6cc39a7058ebe54d95ad3481ddd32f46f36..0016f2d24b47449a20db02b235e498d9066775ee 100644 (file)
 
 #pragma once
 
-#include <common/enum_class.h>
-
 #include <vector>
 #include <string>
 #include <cstddef>
 
+#include <common/enum_class.h>
+
+#include <boost/rational.hpp>
+
 namespace caspar { namespace core {
        
-struct video_format_def 
+enum class video_format
 { 
-       enum type 
-       {
-               pal,            
-               ntsc,           
-               x576p2500,      
-               x720p2500,      
-               x720p5000,      
-               x720p5994,      
-               x720p6000,      
-               x1080p2397,     
-               x1080p2400,     
-               x1080i5000,     
-               x1080i5994,     
-               x1080i6000,     
-               x1080p2500,     
-               x1080p2997,     
-               x1080p3000,     
-               x1080p5000,     
-               invalid,
-               count
-       };
+       pal,            
+       ntsc,           
+       x576p2500,      
+       x720p2500,      
+       x720p5000,
+       x720p2398,
+       x720p2400,
+       x720p2997,
+       x720p5994,
+       x720p3000,
+       x720p6000,
+       x1080p2398,
+       x1080p2400,     
+       x1080i5000,     
+       x1080i5994,     
+       x1080i6000,     
+       x1080p2500,     
+       x1080p2997,     
+       x1080p3000,     
+       x1080p5000,
+       x1080p5994,
+       x1080p6000,
+       x1556p2398,
+       x1556p2400,
+       x1556p2500,
+       dci1080p2398,
+       dci1080p2400,
+       dci1080p2500,
+       x2160p2398,
+       x2160p2400,
+       x2160p2500,
+       x2160p2997,
+       x2160p3000,
+       dci2160p2398,
+       dci2160p2400,
+       dci2160p2500,
+       invalid,
+       count
 };
-typedef enum_class<video_format_def> video_format;
 
-struct field_mode_def
+enum class field_mode
 {
-       enum type 
-       {
-               empty           = 0,
-               lower           = 1,
-               upper           = 2,
-               progressive = 3, // NOTE: progressive == lower | upper;
-       };
-       static_assert((lower | upper) == progressive, "");
+       empty           = 0,
+       lower           = 1,
+       upper           = 2,
+       progressive = 3 // NOTE: progressive == lower | upper;
 };
-typedef enum_class<field_mode_def> field_mode;
+ENUM_ENABLE_BITWISE(field_mode);
+//static_assert((field_mode::lower | field_mode::upper) == field_mode::progressive, "");
 
-struct video_format_desc sealed
+struct video_format_desc final
 {
-       video_format            format;         
+       video_format                    format;         
 
-       int                                     width;          
-       int                                     height;         
-       int                                     square_width;
-       int                                     square_height;
-       field_mode                      field_mode;     // progressive, interlaced upper field first, interlaced lower field first
-       double                          fps;            // actual framerate = duration/time_scale, e.g. i50 = 25 fps, p50 = 50 fps
-       int                                     time_scale;
-       int                                     duration;
-       int                                     field_count;
-       std::size_t                     size;           // frame size in bytes 
-       std::wstring            name;           // name of output format
+       int                                             width;          
+       int                                             height;         
+       int                                             square_width;
+       int                                             square_height;
+       core::field_mode                field_mode;     // progressive, interlaced upper field first, interlaced lower field first
+       double                                  fps;            // actual framerate = duration/time_scale, e.g. i50 = 25 fps, p50 = 50 fps
+       boost::rational<int>    framerate;
+       int                                             time_scale;
+       int                                             duration;
+       int                                             field_count;
+       std::size_t                             size;           // frame size in bytes 
+       std::wstring                    name;           // name of output format
 
-       int                                     audio_sample_rate;
-       int                                     audio_channels;
-       std::vector<int>        audio_cadence;
+       int                                             audio_sample_rate;
+       std::vector<int>                audio_cadence;  // rotating optimal number of samples per frame
 
        video_format_desc(video_format format,
                                          int width,
@@ -108,4 +123,4 @@ bool operator!=(const video_format_desc& rhs, const video_format_desc& lhs);
 
 std::wostream& operator<<(std::wostream& out, const video_format_desc& format_desc);
 
-}}
\ No newline at end of file
+}}