Fix crash on enabling telecine filter. v2.13.21
authorCarl Hetherington <cth@carlh.net>
Tue, 15 May 2018 22:17:18 +0000 (23:17 +0100)
committerCarl Hetherington <cth@carlh.net>
Tue, 15 May 2018 22:17:18 +0000 (23:17 +0100)
Apparently we have to pass frame_rate as a parameter when making the buffer
source for the filter chain.

ChangeLog
src/lib/ffmpeg_decoder.cc
src/lib/filter_graph.cc
src/lib/video_filter_graph.cc
src/lib/video_filter_graph.h

index 98f6c7d9093184f2e7c6fcfdffbd0085e1442d94..dd554346a62fcc691d724cb41b0ab19c8ab097bf 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,7 @@
 2018-05-15  Carl Hetherington  <cth@carlh.net>
 
+       * Fix crash on enabling telecine filter.
+
        * Fix incorrect subtitle positining in a VF when there are more than
        two consecutive reels with no subtitles.
 
index ea41acf23fc9be3e969ac2c9fc9d86859bd9ad8a..55ff01046f761ec61ff73990d142ec9720db6620 100644 (file)
@@ -508,7 +508,8 @@ FFmpegDecoder::decode_video_packet ()
        }
 
        if (i == _filter_graphs.end ()) {
-               graph.reset (new VideoFilterGraph (dcp::Size (_frame->width, _frame->height), (AVPixelFormat) _frame->format));
+               dcp::Fraction vfr (lrint(_ffmpeg_content->video_frame_rate().get() * 1000), 1000);
+               graph.reset (new VideoFilterGraph (dcp::Size (_frame->width, _frame->height), (AVPixelFormat) _frame->format, vfr));
                graph->setup (_ffmpeg_content->filters ());
                _filter_graphs.push_back (graph);
                LOG_GENERAL (N_("New graph for %1x%2, pixel format %3"), _frame->width, _frame->height, _frame->format);
index 52826f3d0566cb0a4745a6472fb201b0c4d5a101..daceeaf2d96924b97fb5af633927e73e04fdd2f7 100644 (file)
@@ -111,8 +111,9 @@ FilterGraph::setup (vector<Filter const *> filters)
                throw DecodeError (N_("could not set up filter graph."));
        }
 
-       if (avfilter_graph_config (_graph, 0) < 0) {
-               throw DecodeError (N_("could not configure filter graph."));
+       int e = avfilter_graph_config (_graph, 0);
+       if (e < 0) {
+               throw DecodeError (String::compose (N_("could not configure filter graph (%1)"), e));
        }
 }
 
index 534dd6142fce4e9765245f6b25df273e68e427fe..6075500e9d9148f5af103e9f56f6034dbdc3ab58 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -35,9 +35,10 @@ using std::string;
 using std::make_pair;
 using boost::shared_ptr;
 
-VideoFilterGraph::VideoFilterGraph (dcp::Size s, AVPixelFormat p)
+VideoFilterGraph::VideoFilterGraph (dcp::Size s, AVPixelFormat p, dcp::Fraction r)
        : _size (s)
        , _pixel_format (p)
+       , _frame_rate (r)
 {
 
 }
@@ -85,7 +86,13 @@ string
 VideoFilterGraph::src_parameters () const
 {
        char buffer[256];
-       snprintf (buffer, sizeof(buffer), "video_size=%dx%d:pix_fmt=%d:time_base=1/1:pixel_aspect=1/1", _size.width, _size.height, _pixel_format);
+       snprintf (
+               buffer, sizeof(buffer),
+               "video_size=%dx%d:pix_fmt=%d:frame_rate=%d/%d:time_base=1/1:pixel_aspect=1/1",
+               _size.width, _size.height,
+               _pixel_format,
+               _frame_rate.numerator, _frame_rate.denominator
+               );
        return buffer;
 }
 
index 5eff1d5c4e24296319c0517f074954e48cec1a7a..19cb24e363c4b34c540fa6b8df5dcc2129bcf633 100644 (file)
@@ -1,5 +1,5 @@
 /*
-    Copyright (C) 2012-2015 Carl Hetherington <cth@carlh.net>
+    Copyright (C) 2012-2018 Carl Hetherington <cth@carlh.net>
 
     This file is part of DCP-o-matic.
 
@@ -23,7 +23,7 @@
 class VideoFilterGraph : public FilterGraph
 {
 public:
-       VideoFilterGraph (dcp::Size s, AVPixelFormat p);
+       VideoFilterGraph (dcp::Size s, AVPixelFormat p, dcp::Fraction r);
 
        bool can_process (dcp::Size s, AVPixelFormat p) const;
        std::list<std::pair<boost::shared_ptr<Image>, int64_t> > process (AVFrame * frame);
@@ -37,4 +37,5 @@ protected:
 private:
        dcp::Size _size; ///< size of the images that this chain can process
        AVPixelFormat _pixel_format; ///< pixel format of the images that this chain can process
+       dcp::Fraction _frame_rate;
 };