-#pragma once\r
-\r
-#include <common/memory/safe_ptr.h>\r
-\r
-#include <boost/noncopyable.hpp>\r
-\r
-#include <string>\r
-#include <vector>\r
-\r
-struct AVFrame;\r
-enum PixelFormat;\r
-\r
-namespace caspar { namespace ffmpeg {\r
- \r
-static bool is_double_rate(const std::wstring& filters)\r
-{\r
- if(filters.find(L"YADIF=1") != std::string::npos)\r
- return true;\r
- \r
- if(filters.find(L"YADIF=3") != std::string::npos)\r
- return true;\r
-\r
- return false;\r
-}\r
-\r
-static bool is_deinterlacing(const std::wstring& filters)\r
-{\r
- if(filters.find(L"YADIF") != std::string::npos)\r
- return true; \r
- return false;\r
-}\r
-\r
-class filter : boost::noncopyable\r
-{\r
-public:\r
- filter(const std::wstring& filters = L"", const std::vector<PixelFormat>& pix_fmts = std::vector<PixelFormat>());\r
- filter(filter&& other);\r
- filter& operator=(filter&& other);\r
-\r
- void push(const std::shared_ptr<AVFrame>& frame);\r
- std::shared_ptr<AVFrame> poll();\r
- std::vector<safe_ptr<AVFrame>> poll_all();\r
-\r
- std::string filter_str() const;\r
- \r
-private:\r
- struct implementation;\r
- safe_ptr<implementation> impl_;\r
-};\r
-\r
-}}
\ No newline at end of file
+/*
+* Copyright 2013 Sveriges Television AB http://casparcg.com/
+*
+* This file is part of CasparCG (www.casparcg.com).
+*
+* CasparCG is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+*
+* CasparCG is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with CasparCG. If not, see <http://www.gnu.org/licenses/>.
+*
+* Author: Robert Nagy, ronag89@gmail.com
+*/
+
+#pragma once
+
+#include <common/memory.h>
+
+#include <boost/rational.hpp>
+#include <boost/noncopyable.hpp>
+#include <boost/algorithm/string/case_conv.hpp>
+
+#include <string>
+#include <vector>
+
+#if defined(_MSC_VER)
+#pragma warning (push)
+#pragma warning (disable : 4244)
+#endif
+extern "C"
+{
+#include <libavutil/pixfmt.h>
+}
+#if defined(_MSC_VER)
+#pragma warning (pop)
+#endif
+
+struct AVFrame;
+
+namespace caspar { namespace ffmpeg {
+
+static std::wstring append_filter(const std::wstring& filters, const std::wstring& filter)
+{
+ return filters + (filters.empty() ? L"" : L",") + filter;
+}
+
+static std::wstring prepend_filter(const std::wstring& filters, const std::wstring& filter)
+{
+ return filter + (filters.empty() ? L"" : L",") + filters;
+}
+
+class filter : boost::noncopyable
+{
+public:
+ filter(
+ int in_width,
+ int in_height,
+ boost::rational<int> in_time_base,
+ boost::rational<int> in_frame_rate,
+ boost::rational<int> in_sample_aspect_ratio,
+ AVPixelFormat in_pix_fmt,
+ std::vector<AVPixelFormat> out_pix_fmts,
+ const std::string& filtergraph);
+ filter(filter&& other);
+ filter& operator=(filter&& other);
+
+ void push(const std::shared_ptr<AVFrame>& frame);
+ std::shared_ptr<AVFrame> poll();
+ std::vector<spl::shared_ptr<AVFrame>> poll_all();
+
+ std::wstring filter_str() const;
+
+ static bool is_double_rate(const std::wstring& filters)
+ {
+ if(boost::to_upper_copy(filters).find(L"YADIF=1") != std::string::npos)
+ return true;
+
+ if(boost::to_upper_copy(filters).find(L"YADIF=3") != std::string::npos)
+ return true;
+
+ return false;
+ }
+
+ static bool is_deinterlacing(const std::wstring& filters)
+ {
+ if(boost::to_upper_copy(filters).find(L"YADIF") != std::string::npos)
+ return true;
+ return false;
+ }
+
+ bool is_double_rate() const
+ {
+ return is_double_rate(filter_str());
+ }
+
+ bool is_deinterlacing() const
+ {
+ return is_deinterlacing(filter_str());
+ }
+private:
+ struct implementation;
+ spl::shared_ptr<implementation> impl_;
+};
+
+}}