]> git.sesse.net Git - casparcg/commitdiff
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
authorronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Wed, 9 Mar 2011 13:05:49 +0000 (13:05 +0000)
committerronag <ronag@362d55ac-95cf-4e76-9f9a-cbaa9c17b72d>
Wed, 9 Mar 2011 13:05:49 +0000 (13:05 +0000)
core/video_format.cpp [new file with mode: 0644]
core/video_format.h [new file with mode: 0644]

diff --git a/core/video_format.cpp b/core/video_format.cpp
new file mode 100644 (file)
index 0000000..09217a8
--- /dev/null
@@ -0,0 +1,69 @@
+/*\r
+* copyright (c) 2010 Sveriges Television AB <info@casparcg.com>\r
+*\r
+*  This file is part of CasparCG.\r
+*\r
+*    CasparCG is free software: you can redistribute it and/or modify\r
+*    it under the terms of the GNU General Public License as published by\r
+*    the Free Software Foundation, either version 3 of the License, or\r
+*    (at your option) any later version.\r
+*\r
+*    CasparCG is distributed in the hope that it will be useful,\r
+*    but WITHOUT ANY WARRANTY; without even the implied warranty of\r
+*    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\r
+*    GNU General Public License for more details.\r
+\r
+*    You should have received a copy of the GNU General Public License\r
+*    along with CasparCG.  If not, see <http://www.gnu.org/licenses/>.\r
+*\r
+*/\r
\r
+#include "StdAfx.h"\r
+\r
+#include "video_format.h"\r
+\r
+#include <boost/algorithm/string.hpp>\r
+\r
+#include <array>\r
+\r
+#define DEFINE_VIDEOFORMATDESC(w, h, m, f, s, fmt) { (fmt), (w), (h), (m), (m == video_mode::progressive ? f : f/2.0), (1.0/(m == video_mode::progressive ? f : f/2.0)), ((w)*(h)*4), (s)}\r
+\r
+namespace caspar { namespace core {\r
+       \r
+const video_format_desc format_descs[video_format::count] =  \r
+{                                                                         \r
+       DEFINE_VIDEOFORMATDESC(720,  576,  video_mode::upper,                   50,                     TEXT("pal"),            video_format::pal               ), \r
+       DEFINE_VIDEOFORMATDESC(720,  486,  video_mode::lower,                   60/1.001,       TEXT("ntsc"),           video_format::ntsc              ), \r
+       DEFINE_VIDEOFORMATDESC(720,  576,  video_mode::progressive,             25,                     TEXT("576p2500"),       video_format::x576p2500 ),\r
+       DEFINE_VIDEOFORMATDESC(1280, 720,  video_mode::progressive,             25,                     TEXT("720p2500"),       video_format::x720p2500 ), \r
+       DEFINE_VIDEOFORMATDESC(1280, 720,  video_mode::progressive,             50,                     TEXT("720p5000"),       video_format::x720p5000 ), \r
+       DEFINE_VIDEOFORMATDESC(1280, 720,  video_mode::progressive,             60/1.001,       TEXT("720p5994"),       video_format::x720p5994 ),\r
+       DEFINE_VIDEOFORMATDESC(1280, 720,  video_mode::progressive,             60,                     TEXT("720p6000"),       video_format::x720p6000 ),\r
+       DEFINE_VIDEOFORMATDESC(1920, 1080, video_mode::progressive,             24/1.001,       TEXT("1080p2397"),      video_format::x1080p2397),\r
+       DEFINE_VIDEOFORMATDESC(1920, 1080, video_mode::progressive,             24,                     TEXT("1080p2400"),      video_format::x1080p2400),\r
+       DEFINE_VIDEOFORMATDESC(1920, 1080, video_mode::upper,                   50,                     TEXT("1080i5000"),      video_format::x1080i5000),\r
+       DEFINE_VIDEOFORMATDESC(1920, 1080, video_mode::upper,                   60/1.001,       TEXT("1080i5994"),      video_format::x1080i5994),\r
+       DEFINE_VIDEOFORMATDESC(1920, 1080, video_mode::upper,                   60,                     TEXT("1080i6000"),      video_format::x1080i6000),\r
+       DEFINE_VIDEOFORMATDESC(1920, 1080, video_mode::progressive,             25,                     TEXT("1080p2500"),      video_format::x1080p2500),\r
+       DEFINE_VIDEOFORMATDESC(1920, 1080, video_mode::progressive,             30/1.001,       TEXT("1080p2997"),      video_format::x1080p2997),\r
+       DEFINE_VIDEOFORMATDESC(1920, 1080, video_mode::progressive,             30,                     TEXT("1080p3000"),      video_format::x1080p3000),\r
+       DEFINE_VIDEOFORMATDESC(0,               0, video_mode::invalid,                 -1,                     TEXT("invalid"),        video_format::invalid   )\r
+};\r
+\r
+const video_format_desc& video_format_desc::get(video_format::type format)     \r
+{\r
+       return format_descs[format];\r
+}\r
+\r
+const video_format_desc& video_format_desc::get(const std::wstring& name)      \r
+{\r
+       for(int n = 0; n < video_format::invalid; ++n)\r
+       {\r
+               if(boost::iequals(format_descs[n].name, name))\r
+                       return format_descs[n];\r
+       }\r
+       return format_descs[video_format::invalid];\r
+}\r
+\r
+}}\r
+\r
diff --git a/core/video_format.h b/core/video_format.h
new file mode 100644 (file)
index 0000000..672e18f
--- /dev/null
@@ -0,0 +1,77 @@
+#pragma once\r
+\r
+#include <string>\r
+\r
+#include <common/compiler/vs/disable_silly_warnings.h>\r
+\r
+namespace caspar { namespace core {\r
+       \r
+struct video_format \r
+{ \r
+       enum type\r
+       {\r
+               pal = 0,\r
+               ntsc,\r
+               x576p2500,\r
+               x720p2500,\r
+               x720p5000,\r
+               x720p5994,\r
+               x720p6000,\r
+               x1080p2397,\r
+               x1080p2400,\r
+               x1080i5000,\r
+               x1080i5994,\r
+               x1080i6000,\r
+               x1080p2500,\r
+               x1080p2997,\r
+               x1080p3000,\r
+               invalid,\r
+               count\r
+       };\r
+};\r
+\r
+struct video_mode \r
+{ \r
+       enum type\r
+       {\r
+               progressive,\r
+               lower,\r
+               upper,\r
+               count,\r
+               invalid\r
+       };\r
+};\r
+\r
+struct video_format_desc\r
+{\r
+       video_format::type              format;         // video output format\r
+\r
+       size_t                                  width;          // output frame width\r
+       size_t                                  height;         // output frame height\r
+       video_mode::type                mode;           // progressive, interlaced upper field first, interlaced lower field first\r
+       double                                  fps;            // actual framerate, e.g. i50 = 25 fps, p50 = 50 fps\r
+       double                                  interval;       // time between frames\r
+       size_t                                  size;           // output frame size in bytes \r
+       std::wstring                    name;           // name of output format\r
+\r
+       static const video_format_desc& get(video_format::type format);\r
+       static const video_format_desc& get(const std::wstring& name);\r
+};\r
+\r
+inline bool operator==(const video_format_desc& rhs, const video_format_desc& lhs)\r
+{\r
+       return rhs.format == lhs.format;\r
+}\r
+\r
+inline bool operator!=(const video_format_desc& rhs, const video_format_desc& lhs)\r
+{\r
+       return !(rhs == lhs);\r
+}\r
+\r
+inline std::wostream& operator<<(std::wostream& out, const video_format_desc& format_desc)\r
+{\r
+       out << format_desc.name.c_str();\r
+       return out;\r
+}\r
+\r
+}}
\ No newline at end of file