]> git.sesse.net Git - casparcg/blob - core/video_format.h
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
[casparcg] / core / video_format.h
1 /*\r
2 * copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
3 *\r
4 *  This file is part of CasparCG.\r
5 *\r
6 *    CasparCG is free software: you can redistribute it and/or modify\r
7 *    it under the terms of the GNU General Public License as published by\r
8 *    the Free Software Foundation, either version 3 of the License, or\r
9 *    (at your option) any later version.\r
10 *\r
11 *    CasparCG is distributed in the hope that it will be useful,\r
12 *    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
13 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
14 *    GNU General Public License for more details.\r
15 \r
16 *    You should have received a copy of the GNU General Public License\r
17 *    along with CasparCG.  If not, see <http://www.gnu.org/licenses/>.\r
18 *\r
19 */\r
20 \r
21 #pragma once\r
22 \r
23 #include <vector>\r
24 #include <string>\r
25 \r
26 namespace caspar { namespace core {\r
27         \r
28 struct video_format \r
29\r
30         enum type\r
31         {\r
32                 pal = 0,\r
33                 ntsc,\r
34                 x576p2500,\r
35                 x720p2500,\r
36                 x720p5000,\r
37                 x720p5994,\r
38                 x720p6000,\r
39                 x1080p2397,\r
40                 x1080p2400,\r
41                 x1080i5000,\r
42                 x1080i5994,\r
43                 x1080i6000,\r
44                 x1080p2500,\r
45                 x1080p2997,\r
46                 x1080p3000,\r
47                 x1080p5000,\r
48                 invalid,\r
49                 count\r
50         };\r
51 };\r
52 \r
53 struct field_mode \r
54\r
55         enum type\r
56         {\r
57                 empty           = 0,\r
58                 lower           = 1,\r
59                 upper           = 2,\r
60                 progressive = 3 // NOTE: progressive == lower | upper;\r
61         };\r
62 \r
63         static std::wstring print(field_mode::type value)\r
64         {\r
65                 switch(value)\r
66                 {\r
67                         case progressive:\r
68                                 return L"progressive"; \r
69                         case lower:\r
70                                 return L"lower";\r
71                         case upper:\r
72                                 return L"upper";\r
73                         default:\r
74                                 return L"invalid";\r
75                 }\r
76         }\r
77 };\r
78 \r
79 struct video_format_desc\r
80 {\r
81         video_format::type              format;         // video output format\r
82 \r
83         size_t                                  width;          // output frame width\r
84         size_t                                  height;         // output frame height\r
85         size_t                                  square_width;\r
86         size_t                                  square_height;\r
87         field_mode::type                field_mode;     // progressive, interlaced upper field first, interlaced lower field first\r
88         double                                  fps;            // actual framerate, e.g. i50 = 25 fps, p50 = 50 fps\r
89         size_t                                  time_scale;\r
90         size_t                                  duration;\r
91         size_t                                  field_count;\r
92         size_t                                  size;           // output frame size in bytes \r
93         std::wstring                    name;           // name of output format\r
94 \r
95         size_t                                  audio_sample_rate;\r
96         size_t                                  audio_channels;\r
97         std::vector<size_t>             audio_cadence;\r
98 \r
99         static const video_format_desc& get(video_format::type format);\r
100         static const video_format_desc& get(const std::wstring& name);\r
101         \r
102         bool operator==(const video_format_desc& lhs)\r
103         {\r
104                 return format == lhs.format;\r
105         }\r
106 \r
107         bool operator!=(const video_format_desc& lhs)\r
108         {\r
109                 return !(*this == lhs);\r
110         }\r
111 };\r
112 \r
113 inline std::wostream& operator<<(std::wostream& out, const video_format_desc& format_desc)\r
114 {\r
115         out << format_desc.name.c_str();\r
116         return out;\r
117 }\r
118 \r
119 }}