X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fffmpeg%2Fproducer%2Ffilter%2Ffilter.h;h=c5ddfcd9f3df2b49e6245e99411d4645f5344253;hb=044846ed2394747e8894b3ab394e336682d502e2;hp=c132675c1bc5950849a43cbc83f5366df5b6b4b2;hpb=0651f92441d115935d04da26bf80a2a53f18e96c;p=casparcg diff --git a/modules/ffmpeg/producer/filter/filter.h b/modules/ffmpeg/producer/filter/filter.h index c132675c1..c5ddfcd9f 100644 --- a/modules/ffmpeg/producer/filter/filter.h +++ b/modules/ffmpeg/producer/filter/filter.h @@ -1,25 +1,117 @@ -#pragma once - -#include - -#include - -struct AVFrame; - -namespace caspar { - -class filter -{ -public: - filter(const std::string& filters); - - void push(const safe_ptr& frame); - std::vector> poll(); - size_t delay() const; - -private: - struct implementation; - safe_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; +} + +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); + 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 : 1; + } + + 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 implementation; + spl::shared_ptr impl_; +}; + +}}