X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fffmpeg%2Fproducer%2Ffilter%2Ffilter.h;h=86cdba98f5c0ee3b535d02fea75fd570983d78db;hb=726897adbf881d3b75f171fff24f2b917ba5f05a;hp=da472f0e45a9b64421f38e3b98028843d4c08660;hpb=01e3b9986d7a5b3de63cceac50b623fb54c9865d;p=casparcg diff --git a/modules/ffmpeg/producer/filter/filter.h b/modules/ffmpeg/producer/filter/filter.h index da472f0e4..86cdba98f 100644 --- a/modules/ffmpeg/producer/filter/filter.h +++ b/modules/ffmpeg/producer/filter/filter.h @@ -1,97 +1,120 @@ -/* -* Copyright (c) 2011 Sveriges Television AB -* -* 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 . -* -* Author: Robert Nagy, ronag89@gmail.com -*/ - -#pragma once - -#include - -#include -#include - -#include -#include - -struct AVFrame; -enum PixelFormat; - -namespace caspar { namespace ffmpeg { - -static std::wstring append_filter(const std::wstring& filters, const std::wstring& filter) -{ - return filters + (filters.empty() ? L"" : L",") + filter; -} - -class filter : boost::noncopyable -{ -public: - filter(const std::wstring& filters = L"", const std::vector& pix_fmts = std::vector()); - filter(filter&& other); - filter& operator=(filter&& other); - - void push(const std::shared_ptr& frame); - std::shared_ptr poll(); - std::vector> 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; - } - - static int delay(const std::wstring& filters) - { - return is_double_rate(filters) ? 1 : 0; - } - - int delay() const - { - return delay(filter_str()); - } - - bool is_double_rate() const - { - return is_double_rate(filter_str()); - } - - bool is_deinterlacing() const - { - return is_deinterlacing(filter_str()); - } -private: - struct impl; - spl::shared_ptr impl_; -}; - -}} \ 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 . +* +* Author: Robert Nagy, ronag89@gmail.com +*/ + +#pragma once + +#include + +#include +#include +#include + +#include +#include + +#if defined(_MSC_VER) +#pragma warning (push) +#pragma warning (disable : 4244) +#endif +extern "C" +{ +#include +} +#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 in_time_base, + boost::rational in_frame_rate, + boost::rational in_sample_aspect_ratio, + AVPixelFormat in_pix_fmt, + std::vector out_pix_fmts, + const std::string& filtergraph, + bool multithreaded = true); + filter(filter&& other); + filter& operator=(filter&& other); + + void push(const std::shared_ptr& frame); + std::shared_ptr poll(); + std::vector> 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 impl_; +}; + +}}