]> 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 b6ae651ba57d0d55f549e914bac108faee2d6762..0016f2d24b47449a20db02b235e498d9066775ee 100644 (file)
-/*\r
-* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG (www.casparcg.com).\r
-*\r
-* CasparCG is free software: you can redistribute it and/or modify\r
-* it under the terms of the GNU General Public License as published by\r
-* the Free Software Foundation, either version 3 of the License, or\r
-* (at your option) any later version.\r
-*\r
-* CasparCG is distributed in the hope that it will be useful,\r
-* but WITHOUT ANY WARRANTY; without even the implied warranty of\r
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
-* GNU General Public License for more details.\r
-*\r
-* You should have received a copy of the GNU General Public License\r
-* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.\r
-*\r
-* Author: Robert Nagy, ronag89@gmail.com\r
-*/\r
-\r
-#pragma once\r
-\r
-#include <common/enum_class.h>\r
-\r
-#include <vector>\r
-#include <string>\r
-\r
-namespace caspar { namespace core {\r
-       \r
-struct video_format_def \r
-{ \r
-       enum type \r
-       {\r
-               pal,            \r
-               ntsc,           \r
-               x576p2500,      \r
-               x720p2500,      \r
-               x720p5000,      \r
-               x720p5994,      \r
-               x720p6000,      \r
-               x1080p2397,     \r
-               x1080p2400,     \r
-               x1080i5000,     \r
-               x1080i5994,     \r
-               x1080i6000,     \r
-               x1080p2500,     \r
-               x1080p2997,     \r
-               x1080p3000,     \r
-               x1080p5000,     \r
-               invalid,\r
-               count\r
-       };\r
-};\r
-typedef enum_class<video_format_def> video_format;\r
-\r
-struct field_mode_def\r
-{\r
-       enum type \r
-       {\r
-               empty           = 0,\r
-               lower           = 1,\r
-               upper           = 2,\r
-               progressive = 3, // NOTE: progressive == lower | upper;\r
-       };\r
-};\r
-typedef enum_class<field_mode_def> field_mode;\r
-\r
-struct video_format_desc sealed\r
-{\r
-       video_format            format;         \r
-\r
-       int                                     width;          \r
-       int                                     height;         \r
-       int                                     square_width;\r
-       int                                     square_height;\r
-       field_mode                      field_mode;     // progressive, interlaced upper field first, interlaced lower field first\r
-       double                          fps;            // actual framerate = duration/time_scale, e.g. i50 = 25 fps, p50 = 50 fps\r
-       int                                     time_scale;\r
-       int                                     duration;\r
-       int                                     field_count;\r
-       int                                     size;           // frame size in bytes \r
-       std::wstring            name;           // name of output format\r
-\r
-       int                                     audio_sample_rate;\r
-       int                                     audio_channels;\r
-       std::vector<int>        audio_cadence;\r
-\r
-       video_format_desc(video_format format,\r
-                                         int width,\r
-                                         int height,\r
-                                         int square_width,\r
-                                         int square_height,\r
-                                         core::field_mode field_mode,\r
-                                         int time_scale,\r
-                                         int duration,\r
-                                         const std::wstring& name,\r
-                                         const std::vector<int>& audio_cadence);\r
-               \r
-       video_format_desc(video_format format = video_format::invalid);\r
-       video_format_desc(const std::wstring& name);\r
-};\r
-\r
-bool operator==(const video_format_desc& rhs, const video_format_desc& lhs);\r
-bool operator!=(const video_format_desc& rhs, const video_format_desc& lhs);\r
-\r
-std::wostream& operator<<(std::wostream& out, const video_format_desc& format_desc);\r
-\r
-}}
\ No newline at end of file
+/*
+* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
+*
+* This file is part of CasparCG (www.casparcg.com).
+*
+* CasparCG is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* CasparCG is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
+*
+* Author: Robert Nagy, ronag89@gmail.com
+*/
+
+#pragma once
+
+#include <vector>
+#include <string>
+#include <cstddef>
+
+#include <common/enum_class.h>
+
+#include <boost/rational.hpp>
+
+namespace caspar { namespace core {
+       
+enum class video_format
+{ 
+       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
+};
+
+enum class field_mode
+{
+       empty           = 0,
+       lower           = 1,
+       upper           = 2,
+       progressive = 3 // NOTE: progressive == lower | upper;
+};
+ENUM_ENABLE_BITWISE(field_mode);
+//static_assert((field_mode::lower | field_mode::upper) == field_mode::progressive, "");
+
+struct video_format_desc final
+{
+       video_format                    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;
+       std::vector<int>                audio_cadence;  // rotating optimal number of samples per frame
+
+       video_format_desc(video_format format,
+                                         int width,
+                                         int height,
+                                         int square_width,
+                                         int square_height,
+                                         core::field_mode field_mode,
+                                         int time_scale,
+                                         int duration,
+                                         const std::wstring& name,
+                                         const std::vector<int>& audio_cadence);
+               
+       video_format_desc(video_format format = video_format::invalid);
+       video_format_desc(const std::wstring& name);
+};
+
+bool operator==(const video_format_desc& rhs, const video_format_desc& lhs);
+bool operator!=(const video_format_desc& rhs, const video_format_desc& lhs);
+
+std::wostream& operator<<(std::wostream& out, const video_format_desc& format_desc);
+
+}}