]> git.sesse.net Git - casparcg/blob - core/video_format.h
Update README.txt
[casparcg] / core / video_format.h
1 /*\r
2 * Copyright 2013 Sveriges Television AB http://casparcg.com/\r
3 *\r
4 * This file is part of CasparCG (www.casparcg.com).\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 * Author: Robert Nagy, ronag89@gmail.com\r
20 */\r
21 \r
22 #pragma once\r
23 \r
24 #include <vector>\r
25 #include <string>\r
26 \r
27 namespace caspar { namespace core {\r
28         \r
29 struct video_format \r
30\r
31         enum type\r
32         {\r
33                 pal = 0,\r
34                 ntsc,\r
35                 x576p2500,\r
36                 x720p2500,\r
37                 x720p5000,\r
38                 x720p2398,\r
39                 x720p2400,\r
40                 x720p2997,\r
41                 x720p5994,\r
42                 x720p3000,\r
43                 x720p6000,\r
44                 x1080p2398,\r
45                 x1080p2400,\r
46                 x1080i5000,\r
47                 x1080i5994,\r
48                 x1080i6000,\r
49                 x1080p2500,\r
50                 x1080p2997,\r
51                 x1080p3000,\r
52                 x1080p5000,\r
53                 x1080p5994,\r
54                 x1080p6000,\r
55                 x1556p2398,\r
56                 x1556p2400,\r
57                 x1556p2500,\r
58                 x2160p2398,\r
59                 x2160p2400,\r
60                 x2160p2500,\r
61                 x2160p2997,\r
62                 x2160p3000,\r
63                 invalid,\r
64                 count\r
65         };\r
66 };\r
67 \r
68 struct field_mode \r
69\r
70         enum type\r
71         {\r
72                 empty           = 0,\r
73                 lower           = 1,\r
74                 upper           = 2,\r
75                 progressive = 3 // NOTE: progressive == lower | upper;\r
76         };\r
77 \r
78         static std::wstring print(field_mode::type value)\r
79         {\r
80                 switch(value)\r
81                 {\r
82                         case progressive:\r
83                                 return L"progressive"; \r
84                         case lower:\r
85                                 return L"lower";\r
86                         case upper:\r
87                                 return L"upper";\r
88                         default:\r
89                                 return L"invalid";\r
90                 }\r
91         }\r
92 };\r
93 \r
94 struct video_format_desc\r
95 {\r
96         video_format::type              format;         // video output format\r
97 \r
98         size_t                                  width;          // output frame width\r
99         size_t                                  height;         // output frame height\r
100         size_t                                  square_width;\r
101         size_t                                  square_height;\r
102         field_mode::type                field_mode;     // progressive, interlaced upper field first, interlaced lower field first\r
103         double                                  fps;            // actual framerate, e.g. i50 = 25 fps, p50 = 50 fps\r
104         size_t                                  time_scale;\r
105         size_t                                  duration;\r
106         size_t                                  field_count;\r
107         size_t                                  size;           // output frame size in bytes \r
108         std::wstring                    name;           // name of output format\r
109 \r
110         size_t                                  audio_sample_rate;\r
111         std::vector<size_t>             audio_cadence; // rotating optimal number of samples per frame\r
112 \r
113         static const video_format_desc& get(video_format::type format);\r
114         static const video_format_desc& get(const std::wstring& name);\r
115         \r
116         bool operator==(const video_format_desc& lhs)\r
117         {\r
118                 return format == lhs.format;\r
119         }\r
120 \r
121         bool operator!=(const video_format_desc& lhs)\r
122         {\r
123                 return !(*this == lhs);\r
124         }\r
125 };\r
126 \r
127 inline std::wostream& operator<<(std::wostream& out, const video_format_desc& format_desc)\r
128 {\r
129         out << format_desc.name.c_str();\r
130         return out;\r
131 }\r
132 \r
133 }}