Use newer format to specify filter graphs; don't filter unless necessary; fix tiny...
[dcpomatic.git] / src / lib / filter_graph.cc
index f0c49b37c07e6a12c0969ff61f2e7b3da0eb6bc2..2624bc4d7c0354a9bf46a48348a6c75d38dd5872 100644 (file)
@@ -79,17 +79,14 @@ FilterGraph::FilterGraph (shared_ptr<Film> film, FFmpegDecoder* decoder, libdcp:
        }
 
        stringstream a;
-       a << _size.width << N_(":")
-         << _size.height << N_(":")
-         << _pixel_format << N_(":")
-         << decoder->time_base_numerator() << N_(":")
-         << decoder->time_base_denominator() << N_(":")
-         << decoder->sample_aspect_ratio_numerator() << N_(":")
-         << decoder->sample_aspect_ratio_denominator();
+       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();
 
        int r;
 
-       if ((r = avfilter_graph_create_filter (&_buffer_src_context, buffer_src, N_("in"), a.str().c_str(), 0, graph)) < 0) {
+       if ((r = avfilter_graph_create_filter (&_buffer_src_context, buffer_src, "in", a.str().c_str(), 0, graph)) < 0) {
                throw DecodeError (N_("could not create buffer source"));
        }
 
@@ -103,6 +100,8 @@ FilterGraph::FilterGraph (shared_ptr<Film> film, FFmpegDecoder* decoder, libdcp:
                throw DecodeError (N_("could not create buffer sink."));
        }
 
+       av_free (sink_params);
+
        AVFilterInOut* outputs = avfilter_inout_alloc ();
        outputs->name = av_strdup(N_("in"));
        outputs->filter_ctx = _buffer_src_context;
@@ -133,7 +132,7 @@ list<shared_ptr<Image> >
 FilterGraph::process (AVFrame* frame)
 {
        list<shared_ptr<Image> > images;
-       
+
        if (av_buffersrc_write_frame (_buffer_src_context, frame) < 0) {
                throw DecodeError (N_("could not push buffer into filter chain."));
        }
@@ -146,7 +145,7 @@ FilterGraph::process (AVFrame* frame)
                }
 
                /* This takes ownership of the AVFrame */
-               images.push_back (shared_ptr<Image> (new FrameImage (frame)));
+               images.push_back (shared_ptr<Image> (new FrameImage (frame, true)));
        }
        
        return images;