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