]> git.sesse.net Git - casparcg/blobdiff - modules/ffmpeg/producer/filter/filter.h
[ffmpeg] Ported 2.0.7 ffmpeg producer to 2.1.0 while still keeping the usage of the...
[casparcg] / modules / ffmpeg / producer / filter / filter.h
index 88548a087bd02f7d99bd51993b17a3e04bbd6a55..86cdba98f5c0ee3b535d02fea75fd570983d78db 100644 (file)
-/*\r
-* Copyright (c) 2011 Sveriges Television AB <info@casparcg.com>\r
-*\r
-* This file is part of CasparCG (www.casparcg.com).\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
-* Author: Robert Nagy, ronag89@gmail.com\r
-*/\r
-\r
-#pragma once\r
-\r
-#include <common/memory/safe_ptr.h>\r
-\r
-#include <boost/noncopyable.hpp>\r
-#include <boost/algorithm/string/case_conv.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(boost::to_upper_copy(filters).find(L"YADIF=1") != std::string::npos)\r
-               return true;\r
-       \r
-       if(boost::to_upper_copy(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(boost::to_upper_copy(filters).find(L"YADIF") != std::string::npos)\r
-               return true;    \r
-       return false;\r
-}      \r
-       \r
-static int filter_delay(const std::wstring& filters)\r
-{\r
-       if(is_double_rate(filters))\r
-               return 1;\r
-       \r
-       return 0;\r
-}\r
-\r
-static std::wstring append_filter(const std::wstring& filters, const std::wstring& filter)\r
-{\r
-       return filters + (filters.empty() ? L"" : L",") + filter;\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::wstring 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,
+               bool multithreaded = true);
+       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;
+
+               if (boost::to_upper_copy(filters).find(L"SEPARATEFIELDS") != 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;
+
+               if (boost::to_upper_copy(filters).find(L"SEPARATEFIELDS") != 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_;
+};
+
+}}