]> git.sesse.net Git - casparcg/blob - core/video_format.h
2.1.0: More refactoring.
[casparcg] / core / video_format.h
1 /*\r
2 * Copyright (c) 2011 Sveriges Television AB <info@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 <common/enum_class.h>\r
25 \r
26 #include <vector>\r
27 #include <string>\r
28 \r
29 namespace caspar { namespace core {\r
30         \r
31 struct video_format_def \r
32\r
33         enum type \r
34         {\r
35                 pal,            \r
36                 ntsc,           \r
37                 x576p2500,      \r
38                 x720p2500,      \r
39                 x720p5000,      \r
40                 x720p5994,      \r
41                 x720p6000,      \r
42                 x1080p2397,     \r
43                 x1080p2400,     \r
44                 x1080i5000,     \r
45                 x1080i5994,     \r
46                 x1080i6000,     \r
47                 x1080p2500,     \r
48                 x1080p2997,     \r
49                 x1080p3000,     \r
50                 x1080p5000,     \r
51                 invalid,\r
52                 count\r
53         };\r
54 };\r
55 typedef enum_class<video_format_def> video_format;\r
56 \r
57 struct field_mode_def\r
58 {\r
59         enum type \r
60         {\r
61                 empty           = 0,\r
62                 lower           = 1,\r
63                 upper           = 2,\r
64                 progressive = 3, // NOTE: progressive == lower | upper;\r
65         };\r
66 };\r
67 typedef enum_class<field_mode_def> field_mode;\r
68 \r
69 struct video_format_desc sealed\r
70 {\r
71         video_format            format;         // video output format\r
72 \r
73         int                                     width;          // output frame width\r
74         int                                     height;         // output frame height\r
75         int                                     square_width;\r
76         int                                     square_height;\r
77         field_mode                      field_mode;     // progressive, interlaced upper field first, interlaced lower field first\r
78         double                          fps;            // actual framerate, e.g. i50 = 25 fps, p50 = 50 fps\r
79         int                                     time_scale;\r
80         int                                     duration;\r
81         int                                     field_count;\r
82         int                                     size;           // output frame size in bytes \r
83         std::wstring            name;           // name of output format\r
84 \r
85         int                                     audio_sample_rate;\r
86         int                                     audio_channels;\r
87         std::vector<int>        audio_cadence;\r
88 \r
89         video_format_desc(video_format format,\r
90                                           int width,\r
91                                           int height,\r
92                                           int square_width,\r
93                                           int square_height,\r
94                                           core::field_mode field_mode,\r
95                                           int time_scale,\r
96                                           int duration,\r
97                                           const std::wstring& name,\r
98                                           const std::vector<int>& audio_cadence);\r
99                 \r
100         video_format_desc(video_format format = video_format::invalid);\r
101         video_format_desc(const std::wstring& name);\r
102 };\r
103 \r
104 bool operator==(const video_format_desc& rhs, const video_format_desc& lhs);\r
105 bool operator!=(const video_format_desc& rhs, const video_format_desc& lhs);\r
106 \r
107 std::wostream& operator<<(std::wostream& out, const video_format_desc& format_desc);\r
108 \r
109 }}