]> git.sesse.net Git - casparcg/blob - core/video_format.h
Made the server more portable
[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 namespace caspar { namespace core {
31         
32 enum class video_format
33
34         pal,            
35         ntsc,           
36         x576p2500,      
37         x720p2500,      
38         x720p5000,
39         x720p2398,
40         x720p2400,
41         x720p2997,
42         x720p5994,
43         x720p3000,
44         x720p6000,
45         x1080p2398,
46         x1080p2400,     
47         x1080i5000,     
48         x1080i5994,     
49         x1080i6000,     
50         x1080p2500,     
51         x1080p2997,     
52         x1080p3000,     
53         x1080p5000,
54         x1080p5994,
55         x1080p6000,
56         x2k2398,
57         x2k2400,
58         x2k2500,
59         x4k2398,
60         x4k2400,
61         x4k2500,
62         x4k2997,
63         x4k3000,
64         invalid,
65         count
66 };
67
68 enum class field_mode
69 {
70         empty           = 0,
71         lower           = 1,
72         upper           = 2,
73         progressive = 3 // NOTE: progressive == lower | upper;
74 };
75 ENUM_ENABLE_BITWISE(field_mode);
76 //static_assert((field_mode::lower | field_mode::upper) == field_mode::progressive, "");
77
78 struct video_format_desc final
79 {
80         video_format            format;         
81
82         int                                     width;          
83         int                                     height;         
84         int                                     square_width;
85         int                                     square_height;
86         core::field_mode        field_mode;     // progressive, interlaced upper field first, interlaced lower field first
87         double                          fps;            // actual framerate = duration/time_scale, e.g. i50 = 25 fps, p50 = 50 fps
88         int                                     time_scale;
89         int                                     duration;
90         int                                     field_count;
91         std::size_t                     size;           // frame size in bytes 
92         std::wstring            name;           // name of output format
93
94         int                                     audio_sample_rate;
95         int                                     audio_channels;
96         std::vector<int>        audio_cadence;  // rotating optimal number of samples per frame
97
98         video_format_desc(video_format format,
99                                           int width,
100                                           int height,
101                                           int square_width,
102                                           int square_height,
103                                           core::field_mode field_mode,
104                                           int time_scale,
105                                           int duration,
106                                           const std::wstring& name,
107                                           const std::vector<int>& audio_cadence);
108                 
109         video_format_desc(video_format format = video_format::invalid);
110         video_format_desc(const std::wstring& name);
111 };
112
113 bool operator==(const video_format_desc& rhs, const video_format_desc& lhs);
114 bool operator!=(const video_format_desc& rhs, const video_format_desc& lhs);
115
116 std::wostream& operator<<(std::wostream& out, const video_format_desc& format_desc);
117
118 }}