]> git.sesse.net Git - casparcg/blob - core/video_format.h
[general] Added cg_producer_registry as dependency in frame_producer_dependencies
[casparcg] / core / video_format.h
1 /*
2 * Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>
3 *
4 * This file is part of CasparCG (www.casparcg.com).
5 *
6 * CasparCG is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * CasparCG is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
18 *
19 * Author: Robert Nagy, ronag89@gmail.com
20 */
21
22 #pragma once
23
24 #include <vector>
25 #include <string>
26 #include <cstddef>
27
28 #include <common/enum_class.h>
29
30 #include <boost/rational.hpp>
31
32 namespace caspar { namespace core {
33         
34 enum class video_format
35
36         pal,            
37         ntsc,           
38         x576p2500,      
39         x720p2500,      
40         x720p5000,
41         x720p2398,
42         x720p2400,
43         x720p2997,
44         x720p5994,
45         x720p3000,
46         x720p6000,
47         x1080p2398,
48         x1080p2400,     
49         x1080i5000,     
50         x1080i5994,     
51         x1080i6000,     
52         x1080p2500,     
53         x1080p2997,     
54         x1080p3000,     
55         x1080p5000,
56         x1080p5994,
57         x1080p6000,
58         x1556p2398,
59         x1556p2400,
60         x1556p2500,
61         dci1080p2398,
62         dci1080p2400,
63         dci1080p2500,
64         x2160p2398,
65         x2160p2400,
66         x2160p2500,
67         x2160p2997,
68         x2160p3000,
69         x2160p5000,
70         x2160p5994,
71         x2160p6000,
72         dci2160p2398,
73         dci2160p2400,
74         dci2160p2500,
75         invalid,
76         count
77 };
78
79 enum class field_mode
80 {
81         empty           = 0,
82         lower           = 1,
83         upper           = 2,
84         progressive = 3 // NOTE: progressive == lower | upper;
85 };
86 ENUM_ENABLE_BITWISE(field_mode);
87 //static_assert((field_mode::lower | field_mode::upper) == field_mode::progressive, "");
88
89 struct video_format_desc final
90 {
91         video_format                    format;         
92
93         int                                             width;          
94         int                                             height;         
95         int                                             square_width;
96         int                                             square_height;
97         core::field_mode                field_mode;     // progressive, interlaced upper field first, interlaced lower field first
98         double                                  fps;            // actual framerate = duration/time_scale, e.g. i50 = 25 fps, p50 = 50 fps
99         boost::rational<int>    framerate;
100         int                                             time_scale;
101         int                                             duration;
102         int                                             field_count;
103         std::size_t                             size;           // frame size in bytes 
104         std::wstring                    name;           // name of output format
105
106         int                                             audio_sample_rate;
107         std::vector<int>                audio_cadence;  // rotating optimal number of samples per frame
108
109         video_format_desc(video_format format,
110                                           int width,
111                                           int height,
112                                           int square_width,
113                                           int square_height,
114                                           core::field_mode field_mode,
115                                           int time_scale,
116                                           int duration,
117                                           const std::wstring& name,
118                                           const std::vector<int>& audio_cadence);
119                 
120         video_format_desc(video_format format = video_format::invalid);
121         video_format_desc(const std::wstring& name);
122 };
123
124 bool operator==(const video_format_desc& rhs, const video_format_desc& lhs);
125 bool operator!=(const video_format_desc& rhs, const video_format_desc& lhs);
126
127 std::wostream& operator<<(std::wostream& out, const video_format_desc& format_desc);
128
129 }}