]> git.sesse.net Git - casparcg/blob - core/video_format.cpp
608282ee4ea1fcd7de84549b06ab1ba06c27bc8b
[casparcg] / core / video_format.cpp
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 #include "StdAfx.h"\r
23 \r
24 #include "video_format.h"\r
25 \r
26 #include <boost/algorithm/string.hpp>\r
27 #include <boost/assign.hpp>\r
28 \r
29 #define DEFINE_VIDEOFORMATDESC(fmt, w, h, sw, sh, m, scale, duration, audio_samples, name) \\r
30 { \\r
31         (fmt), \\r
32         (w), \\r
33         (h), \\r
34         (sw),\\r
35         (sh),\\r
36         (m), \\r
37         ((double)scale/(double)duration),\\r
38         (scale),\\r
39         (duration),\\r
40         (m == field_mode::progressive ? 1 : 2),\\r
41         ((w)*(h)*4),\\r
42         (name),\\r
43         (48000),\\r
44         (audio_samples)\\r
45 }\r
46 \r
47 \r
48 namespace caspar { namespace core {\r
49         \r
50 const video_format_desc format_descs[video_format::count] =  \r
51 {                                                                          \r
52         DEFINE_VIDEOFORMATDESC(video_format::pal                ,720,  576,  1024, 576,  field_mode::upper,                     25,             1,              boost::assign::list_of(1920),                                                                                           L"PAL"), \r
53         DEFINE_VIDEOFORMATDESC(video_format::ntsc               ,720,  486,  720,  540,  field_mode::lower,                     30000,  1001,   boost::assign::list_of(1602)    (1601)    (1602)    (1601)    (1602),           L"NTSC"), \r
54         DEFINE_VIDEOFORMATDESC(video_format::x576p2500  ,1024, 576,  1024, 576,  field_mode::progressive,       25,             1,              boost::assign::list_of(1920),                                                                                           L"576p2500"),\r
55         DEFINE_VIDEOFORMATDESC(video_format::x720p2398  ,1280, 720,  1280, 720,  field_mode::progressive,       24000,  1001,   boost::assign::list_of(2002),                                                                                           L"720p2398"),\r
56         DEFINE_VIDEOFORMATDESC(video_format::x720p2400  ,1280, 720,  1280, 720,  field_mode::progressive,       24,             1,              boost::assign::list_of(2000),                                                                                           L"720p2400"),\r
57         DEFINE_VIDEOFORMATDESC(video_format::x720p2500  ,1280, 720,  1280, 720,  field_mode::progressive,       25,             1,              boost::assign::list_of(1920),                                                                                           L"720p2500"), \r
58         DEFINE_VIDEOFORMATDESC(video_format::x720p5000  ,1280, 720,  1280, 720,  field_mode::progressive,       50,             1,              boost::assign::list_of(960),                                                                                            L"720p5000"), \r
59         DEFINE_VIDEOFORMATDESC(video_format::x720p2997  ,1280, 720,  1280, 720,  field_mode::progressive,       30000,  1001,   boost::assign::list_of(1602)    (1601)    (1602)    (1601)    (1602),           L"720p2997"),\r
60         DEFINE_VIDEOFORMATDESC(video_format::x720p5994  ,1280, 720,  1280, 720,  field_mode::progressive,       60000,  1001,   boost::assign::list_of(801)(801)(800)(801)(801)(801)(800)(801)(801)(801),       L"720p5994"),\r
61         DEFINE_VIDEOFORMATDESC(video_format::x720p3000  ,1280, 720,  1280, 720,  field_mode::progressive,       30,             1,              boost::assign::list_of(1600),                                                                                           L"720p3000"),\r
62         DEFINE_VIDEOFORMATDESC(video_format::x720p6000  ,1280, 720,  1280, 720,  field_mode::progressive,       60,             1,              boost::assign::list_of(800),                                                                                            L"720p6000"),\r
63         DEFINE_VIDEOFORMATDESC(video_format::x1080p2398 ,1920, 1080, 1920, 1080, field_mode::progressive,       24000,  1001,   boost::assign::list_of(2002),                                                                                           L"1080p2398"),\r
64         DEFINE_VIDEOFORMATDESC(video_format::x1080p2400 ,1920, 1080, 1920, 1080, field_mode::progressive,       24,             1,              boost::assign::list_of(2000),                                                                                           L"1080p2400"),\r
65         DEFINE_VIDEOFORMATDESC(video_format::x1080i5000 ,1920, 1080, 1920, 1080, field_mode::upper,                     25,             1,              boost::assign::list_of(1920),                                                                                           L"1080i5000"),\r
66         DEFINE_VIDEOFORMATDESC(video_format::x1080i5994 ,1920, 1080, 1920, 1080, field_mode::upper,                     30000,  1001,   boost::assign::list_of(1602)    (1601)    (1602)    (1601)    (1602),           L"1080i5994"),\r
67         DEFINE_VIDEOFORMATDESC(video_format::x1080i6000 ,1920, 1080, 1920, 1080, field_mode::upper,                     30,             1,              boost::assign::list_of(1600),                                                                                           L"1080i6000"),\r
68         DEFINE_VIDEOFORMATDESC(video_format::x1080p2500 ,1920, 1080, 1920, 1080, field_mode::progressive,       25,             1,              boost::assign::list_of(1920),                                                                                           L"1080p2500"),\r
69         DEFINE_VIDEOFORMATDESC(video_format::x1080p2997 ,1920, 1080, 1920, 1080, field_mode::progressive,       30000,  1001,   boost::assign::list_of(1602)    (1601)    (1602)    (1601)    (1602),           L"1080p2997"),\r
70         DEFINE_VIDEOFORMATDESC(video_format::x1080p3000 ,1920, 1080, 1920, 1080, field_mode::progressive,       30,             1,              boost::assign::list_of(1600),                                                                                           L"1080p3000"),\r
71         DEFINE_VIDEOFORMATDESC(video_format::x1080p5000 ,1920, 1080, 1920, 1080, field_mode::progressive,       50,             1,              boost::assign::list_of(960),                                                                                            L"1080p5000"),\r
72         DEFINE_VIDEOFORMATDESC(video_format::x1080p5994 ,1920, 1080, 1920, 1080, field_mode::progressive,       60000,  1001,   boost::assign::list_of(801)(801)(800)(801)(801)(801)(800)(801)(801)(801),       L"1080p5994"),\r
73         DEFINE_VIDEOFORMATDESC(video_format::x1080p6000 ,1920, 1080, 1920, 1080, field_mode::progressive,       60,             1,              boost::assign::list_of(800),                                                                                            L"1080p6000"),\r
74         DEFINE_VIDEOFORMATDESC(video_format::x1556p2398 ,2048, 1556, 2048, 1556, field_mode::progressive,       24000,  1001,   boost::assign::list_of(2002),                                                                                           L"1556p2398"),\r
75         DEFINE_VIDEOFORMATDESC(video_format::x1556p2400 ,2048, 1556, 2048, 1556, field_mode::progressive,       24,             1,              boost::assign::list_of(2000),                                                                                           L"1556p2400"),\r
76         DEFINE_VIDEOFORMATDESC(video_format::x1556p2500 ,2048, 1556, 2048, 1556, field_mode::progressive,       25,             1,              boost::assign::list_of(1920),                                                                                           L"1556p2500"),\r
77         DEFINE_VIDEOFORMATDESC(video_format::x2160p2398 ,3840, 2160, 3840, 2160, field_mode::progressive,       24000,  1001,   boost::assign::list_of(2002),                                                                                           L"2160p2398"),\r
78         DEFINE_VIDEOFORMATDESC(video_format::x2160p2400 ,3840, 2160, 3840, 2160, field_mode::progressive,       24,             1,              boost::assign::list_of(2000),                                                                                           L"2160p2400"),\r
79         DEFINE_VIDEOFORMATDESC(video_format::x2160p2500 ,3840, 2160, 3840, 2160, field_mode::progressive,       25,             1,              boost::assign::list_of(1920),                                                                                           L"2160p2500"),\r
80         DEFINE_VIDEOFORMATDESC(video_format::x2160p2997 ,3840, 2160, 3840, 2160, field_mode::progressive,       30000,  1001,   boost::assign::list_of(1602)    (1601)    (1602)    (1601)    (1602),           L"2160p2997"),\r
81         DEFINE_VIDEOFORMATDESC(video_format::x2160p3000 ,3840, 2160, 3840, 2160, field_mode::progressive,       30,             1,              boost::assign::list_of(1600),                                                                                           L"2160p3000"),\r
82         DEFINE_VIDEOFORMATDESC(video_format::invalid    ,0,             0,   0,         0,   field_mode::progressive,   1,              1,              boost::assign::list_of(1),                                                                                                      L"invalid")\r
83 };\r
84 \r
85 const video_format_desc& video_format_desc::get(video_format::type format)      \r
86 {\r
87         return format_descs[format];\r
88 }\r
89 \r
90 const video_format_desc& video_format_desc::get(const std::wstring& name)       \r
91 {\r
92         for(int n = 0; n < video_format::invalid; ++n)\r
93         {\r
94                 if(boost::iequals(format_descs[n].name, name))\r
95                         return format_descs[n];\r
96         }\r
97         return format_descs[video_format::invalid];\r
98 }\r
99 \r
100 }}\r
101 \r