]> git.sesse.net Git - casparcg/blobdiff - core/video_format.h
### Mayor refactoring. Simplified frame handling and image_mixer. Separated video...
[casparcg] / core / video_format.h
index bdcf3f8ac47d1167baf294e062e77968f7013337..34cd6f6cfbf1e7e5cbc212a71456da3b3d921c99 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 <string>\r
+#include <common/enum_class.h>\r
 \r
-#include <common/compiler/vs/disable_silly_warnings.h>\r
+#include <vector>\r
+#include <string>\r
+#include <cstddef>\r
 \r
 namespace caspar { namespace core {\r
        \r
-struct video_format \r
+struct video_format_def \r
 { \r
-       enum type\r
+       enum type \r
        {\r
-               pal = 0,\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
-               count,\r
-               invalid\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 video_mode \r
-{ \r
-       enum type\r
+struct field_mode_def\r
+{\r
+       enum type \r
        {\r
-               progressive,\r
-               lower,\r
-               upper,\r
-               count,\r
-               invalid\r
+               empty           = 0,\r
+               lower           = 1,\r
+               upper           = 2,\r
+               progressive = 3, // NOTE: progressive == lower | upper;\r
        };\r
+       static_assert((lower | upper) == progressive, "");\r
 };\r
+typedef enum_class<field_mode_def> field_mode;\r
 \r
-struct video_format_desc\r
+struct video_format_desc sealed\r
 {\r
-       video_format::type              format;         // video output format\r
+       video_format            format;         \r
 \r
-       size_t                                  width;          // output frame width\r
-       size_t                                  height;         // output frame height\r
-       video_mode::type                mode;           // progressive, interlaced upper field first, interlaced lower field first\r
-       double                                  fps;            // actual framerate, e.g. i50 = 25 fps, p50 = 50 fps\r
-       double                                  interval;       // time between frames\r
-       size_t                                  size;           // output frame size in bytes \r
-       std::wstring                    name;           // name of output format\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
-       static const video_format_desc& get(video_format::type format);\r
-       static const video_format_desc& get(const std::wstring& name);\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
-inline bool operator==(const video_format_desc& rhs, const video_format_desc& lhs)\r
-{\r
-       return rhs.format == lhs.format;\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
-inline bool operator!=(const video_format_desc& rhs, const video_format_desc& lhs)\r
-{\r
-       return !(rhs == lhs);\r
-}\r
-\r
-inline std::wostream& operator<<(std::wostream& out, const video_format_desc& format_desc)\r
-{\r
-       out << format_desc.name.c_str();\r
-       return out;\r
-}\r
+std::wostream& operator<<(std::wostream& out, const video_format_desc& format_desc);\r
 \r
 }}
\ No newline at end of file