1 #include "../../StdAfx.h"
3 #include "deinterlacer.h"
5 #include <core/frame/frame_factory.h>
7 #include <modules/ffmpeg/producer/filter/filter.h>
8 #include <modules/ffmpeg/producer/util/util.h>
10 #include <tbb/concurrent_hash_map.h>
14 namespace caspar { namespace accelerator { namespace cpu {
16 struct deinterlacer::impl
18 ffmpeg::filter filter_;
23 : filter_(L"YADIF=1:-1")
27 std::vector<core::const_frame> operator()(const core::const_frame& frame, core::frame_factory& frame_factory)
29 std::array<uint8_t*, 4> data = {};
30 for(int n = 0; n < frame.pixel_format_desc().planes.size(); ++n)
31 data[n] = const_cast<uint8_t*>(frame.image_data(n).begin());
33 auto av_frame = ffmpeg::make_av_frame(data, frame.pixel_format_desc());
35 filter_.push(av_frame);
37 auto av_frames = filter_.poll_all();
39 std::vector<core::const_frame> frames;
41 BOOST_FOREACH(auto av_frame, av_frames)
42 frames.push_back(ffmpeg::make_frame(frame.stream_tag(), av_frame, frame.frame_rate(), frame_factory));
48 deinterlacer::deinterlacer() : impl_(new impl()){}
49 deinterlacer::~deinterlacer(){}
50 std::vector<core::const_frame> deinterlacer::operator()(const core::const_frame& frame, core::frame_factory& frame_factory){return (*impl_)(frame, frame_factory);}