]> git.sesse.net Git - casparcg/blob - server/frame/Frame.cpp
8cf282cff5e2f6cbc5549a4e81608bc37329e045
[casparcg] / server / frame / Frame.cpp
1 /*\r
2 * copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
3 *\r
4 *  This file is part of CasparCG.\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 */\r
20  \r
21 #include "..\StdAfx.h"\r
22 #include "Frame.h"\r
23 #include "..\utils\allocator.h"\r
24 #include "..\utils\ID.h"\r
25 #include "..\utils\image\Image.hpp"\r
26 #include "FrameManager.h"\r
27 #include <algorithm>\r
28 \r
29 #include <intrin.h>\r
30 #pragma intrinsic(__movsd, __stosd)\r
31 \r
32 #define DEFINE_VIDEOFORMATDESC(w, h, m, f, s) { (w), (h), (m), (f), (w)*(h)*4, s }\r
33 \r
34 namespace caspar {\r
35 \r
36 const FrameFormatDescription FrameFormatDescription::FormatDescriptions[FrameFormatCount] =  {  \r
37         DEFINE_VIDEOFORMATDESC(720, 576, Interlaced, 50, TEXT("PAL")), \r
38         DEFINE_VIDEOFORMATDESC(720, 486, Interlaced, 60/1.001, TEXT("NTSC")), \r
39         DEFINE_VIDEOFORMATDESC(720, 576, Progressive, 25, TEXT("576p2500")),\r
40         DEFINE_VIDEOFORMATDESC(1280, 720, Progressive, 50, TEXT("720p5000")), \r
41         DEFINE_VIDEOFORMATDESC(1280, 720, Progressive, 60/1.001, TEXT("720p5994")),\r
42         DEFINE_VIDEOFORMATDESC(1280, 720, Progressive, 60, TEXT("720p6000")),\r
43         DEFINE_VIDEOFORMATDESC(1920, 1080, Progressive, 24/1.001, TEXT("1080p2397")),\r
44         DEFINE_VIDEOFORMATDESC(1920, 1080, Progressive, 24, TEXT("1080p2400")),\r
45         DEFINE_VIDEOFORMATDESC(1920, 1080, Interlaced, 50, TEXT("1080i5000")),\r
46         DEFINE_VIDEOFORMATDESC(1920, 1080, Interlaced, 60/1.001, TEXT("1080i5994")),\r
47         DEFINE_VIDEOFORMATDESC(1920, 1080, Interlaced, 60, TEXT("1080i6000")),\r
48         DEFINE_VIDEOFORMATDESC(1920, 1080, Progressive, 25, TEXT("1080p2500")),\r
49         DEFINE_VIDEOFORMATDESC(1920, 1080, Progressive, 30/1.001, TEXT("1080p2997")),\r
50         DEFINE_VIDEOFORMATDESC(1920, 1080, Progressive, 30, TEXT("1080p3000"))\r
51 };\r
52 \r
53 \r
54 FrameFormat GetVideoFormat(const tstring& strVideoMode)\r
55 {\r
56         for(int index = 0; index < FrameFormatCount; ++index)\r
57         {\r
58                 const FrameFormatDescription& fmtDesc = FrameFormatDescription::FormatDescriptions[index];\r
59 \r
60                 tstring strVideoModeUpper = strVideoMode;\r
61                 tstring strFmtDescUpper = fmtDesc.name;\r
62 \r
63                 std::transform(strVideoModeUpper.begin(), strVideoModeUpper.end(), strVideoModeUpper.begin(), toupper);\r
64                 std::transform(strFmtDescUpper.begin(), strFmtDescUpper.end(), strFmtDescUpper.begin(), toupper);\r
65 \r
66                 if(strVideoModeUpper == strFmtDescUpper) {\r
67                         return (FrameFormat)index;                      \r
68                 }\r
69         }\r
70         return FFormatInvalid;\r
71 }\r
72 \r
73 ///////////////\r
74 // Frame\r
75 Frame::Frame() : bHasVideo_(false)\r
76 {}\r
77 \r
78 Frame::~Frame() {\r
79 }\r
80 \r
81 }       //namespace caspar