]> git.sesse.net Git - casparcg/blob - accelerator/cpu/image/deinterlacer.cpp
set svn:eol-style native on .h and .cpp files
[casparcg] / accelerator / cpu / image / deinterlacer.cpp
1 #include "../../StdAfx.h"
2
3 #include "deinterlacer.h"
4
5 #include <core/frame/frame_factory.h>
6
7 #include <modules/ffmpeg/producer/filter/filter.h>
8 #include <modules/ffmpeg/producer/util/util.h>
9
10 #include <tbb/concurrent_hash_map.h>
11
12 #include <tuple>
13
14 namespace caspar { namespace accelerator { namespace cpu {
15
16 struct deinterlacer::impl
17 {
18         ffmpeg::filter filter_; 
19
20 public:
21
22         impl() 
23                 : filter_(L"YADIF=1:-1")
24         {
25         }
26
27         std::vector<core::const_frame> operator()(const core::const_frame& frame, core::frame_factory& frame_factory)
28         {               
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());
32
33                 auto av_frame = ffmpeg::make_av_frame(data, frame.pixel_format_desc());
34
35                 filter_.push(av_frame);
36
37                 auto av_frames = filter_.poll_all();
38
39                 std::vector<core::const_frame> frames;
40
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));
43                 
44                 return frames;
45         }               
46 };
47
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);}
51
52 }}}