X-Git-Url: https://git.carlh.net/gitweb/?p=dcpomatic.git;a=blobdiff_plain;f=src%2Flib%2Ffilter_graph.cc;fp=src%2Flib%2Ffilter_graph.cc;h=4564033d5379dd5d6770addfdac826cff447237f;hp=b0427a23d0566166921fd6e95eceb5b86c879505;hb=996b0c06e23bcb6b300d7b8799df94993692e07d;hpb=907735ee6ca162583c7c9d20f5603a6db83a149f diff --git a/src/lib/filter_graph.cc b/src/lib/filter_graph.cc index b0427a23d..4564033d5 100644 --- a/src/lib/filter_graph.cc +++ b/src/lib/filter_graph.cc @@ -33,7 +33,6 @@ extern "C" { #include "filter.h" #include "exceptions.h" #include "image.h" -#include "film.h" #include "ffmpeg_decoder.h" #include "i18n.h" @@ -42,15 +41,15 @@ using std::stringstream; using std::string; using std::list; using boost::shared_ptr; +using boost::weak_ptr; using libdcp::Size; -/** Construct a FFmpegFilterGraph for the settings in a film. - * @param film Film. - * @param decoder Decoder that we are using. +/** Construct a FilterGraph for the settings in a piece of content. + * @param content Content. * @param s Size of the images to process. * @param p Pixel format of the images to process. */ -FFmpegFilterGraph::FFmpegFilterGraph (shared_ptr film, FFmpegDecoder* decoder, libdcp::Size s, AVPixelFormat p) +FilterGraph::FilterGraph (shared_ptr content, libdcp::Size s, AVPixelFormat p) : _buffer_src_context (0) , _buffer_sink_context (0) , _size (s) @@ -58,12 +57,16 @@ FFmpegFilterGraph::FFmpegFilterGraph (shared_ptr film, FFmpegDecoder* deco { _frame = av_frame_alloc (); - string filters = Filter::ffmpeg_strings (film->filters()).first; + string filters = Filter::ffmpeg_strings (content->filters()).first; if (!filters.empty ()) { - filters += N_(","); + filters += ","; } - filters += crop_string (Position (film->crop().left, film->crop().top), film->cropped_size (decoder->native_size())); + Crop crop = content->crop (); + libdcp::Size cropped_size = _size; + cropped_size.width -= crop.left + crop.right; + cropped_size.height -= crop.top + crop.bottom; + filters += crop_string (Position (crop.left, crop.top), cropped_size); AVFilterGraph* graph = avfilter_graph_alloc(); if (graph == 0) { @@ -83,8 +86,8 @@ FFmpegFilterGraph::FFmpegFilterGraph (shared_ptr film, FFmpegDecoder* deco stringstream a; a << "video_size=" << _size.width << "x" << _size.height << ":" << "pix_fmt=" << _pixel_format << ":" - << "time_base=" << decoder->time_base_numerator() << "/" << decoder->time_base_denominator() << ":" - << "pixel_aspect=" << decoder->sample_aspect_ratio_numerator() << "/" << decoder->sample_aspect_ratio_denominator(); + << "time_base=0/1:" + << "pixel_aspect=0/1"; int r; @@ -127,7 +130,7 @@ FFmpegFilterGraph::FFmpegFilterGraph (shared_ptr film, FFmpegDecoder* deco /* XXX: leaking `inputs' / `outputs' ? */ } -FFmpegFilterGraph::~FFmpegFilterGraph () +FilterGraph::~FilterGraph () { av_frame_free (&_frame); } @@ -136,7 +139,7 @@ FFmpegFilterGraph::~FFmpegFilterGraph () * set of Images. Caller handles memory management of the input frame. */ list > -FFmpegFilterGraph::process (AVFrame* frame) +FilterGraph::process (AVFrame* frame) { list > images; @@ -160,25 +163,7 @@ FFmpegFilterGraph::process (AVFrame* frame) * @return true if this chain can process images with `s' and `p', otherwise false. */ bool -FFmpegFilterGraph::can_process (libdcp::Size s, AVPixelFormat p) const +FilterGraph::can_process (libdcp::Size s, AVPixelFormat p) const { return (_size == s && _pixel_format == p); } - -list > -EmptyFilterGraph::process (AVFrame* frame) -{ - list > im; - im.push_back (shared_ptr (new SimpleImage (frame))); - return im; -} - -shared_ptr -filter_graph_factory (shared_ptr film, FFmpegDecoder* decoder, libdcp::Size size, AVPixelFormat pixel_format) -{ - if (film->filters().empty() && film->crop() == Crop()) { - return shared_ptr (new EmptyFilterGraph); - } - - return shared_ptr (new FFmpegFilterGraph (film, decoder, size, pixel_format)); -}