summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-12-16 13:43:25 +0000
committerCarl Hetherington <cth@carlh.net>2012-12-16 13:43:25 +0000
commit3171c89fef95b19c8889996caaac73eea71cf388 (patch)
treedeeeda477690ff9af5a67bd210270b5da7806371 /src/lib
parent1f2bc4d8f3601ad1e12b94f37b3889fcd003509b (diff)
Decoder handles crop changing.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/decoder.h2
-rw-r--r--src/lib/ffmpeg_decoder.cc27
-rw-r--r--src/lib/ffmpeg_decoder.h5
3 files changed, 34 insertions, 0 deletions
diff --git a/src/lib/decoder.h b/src/lib/decoder.h
index be1fe38b6..0d35ebb3a 100644
--- a/src/lib/decoder.h
+++ b/src/lib/decoder.h
@@ -63,6 +63,8 @@ public:
*/
virtual bool seek (SourceFrame);
+ boost::signals2::signal<void()> OutputChanged;
+
protected:
/** our Film */
boost::shared_ptr<Film> _film;
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index b3b1acbbb..51afc461a 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -77,6 +77,8 @@ FFmpegDecoder::FFmpegDecoder (shared_ptr<Film> f, shared_ptr<const DecodeOptions
setup_video ();
setup_audio ();
setup_subtitle ();
+
+ f->Changed.connect (bind (&FFmpegDecoder::film_changed, this, _1));
}
FFmpegDecoder::~FFmpegDecoder ()
@@ -526,6 +528,8 @@ FFmpegDecoder::set_subtitle_stream (shared_ptr<SubtitleStream> s)
void
FFmpegDecoder::filter_and_emit_video (AVFrame* frame)
{
+ boost::mutex::scoped_lock lm (_filter_graphs_mutex);
+
shared_ptr<FilterGraph> graph;
list<shared_ptr<FilterGraph> >::iterator i = _filter_graphs.begin();
@@ -554,6 +558,11 @@ FFmpegDecoder::seek (SourceFrame f)
int64_t const t = static_cast<int64_t>(f) / (av_q2d (_format_context->streams[_video_stream]->time_base) * frames_per_second());
int const r = av_seek_frame (_format_context, _video_stream, t, 0);
avcodec_flush_buffers (_video_codec_context);
+
+ if (r >= 0) {
+ OutputChanged ();
+ }
+
return r < 0;
}
@@ -655,3 +664,21 @@ FFmpegDecoder::out_careful ()
_film->log()->log (String::compose ("Frame removed at %1s", out_pts_seconds));
}
}
+
+void
+FFmpegDecoder::film_changed (Film::Property p)
+{
+ switch (p) {
+ case Film::CROP:
+ {
+ boost::mutex::scoped_lock lm (_filter_graphs_mutex);
+ _filter_graphs.clear ();
+ }
+ OutputChanged ();
+ break;
+
+ default:
+ break;
+ }
+}
+
diff --git a/src/lib/ffmpeg_decoder.h b/src/lib/ffmpeg_decoder.h
index d483db1d9..d5753393e 100644
--- a/src/lib/ffmpeg_decoder.h
+++ b/src/lib/ffmpeg_decoder.h
@@ -26,6 +26,7 @@
#include <stdint.h>
#include <boost/shared_ptr.hpp>
#include <boost/optional.hpp>
+#include <boost/thread/mutex.hpp>
extern "C" {
#include <libavcodec/avcodec.h>
#include <libpostproc/postprocess.h>
@@ -34,6 +35,7 @@ extern "C" {
#include "decoder.h"
#include "video_decoder.h"
#include "audio_decoder.h"
+#include "film.h"
struct AVFilterGraph;
struct AVCodecContext;
@@ -117,6 +119,8 @@ private:
void maybe_add_subtitle ();
boost::shared_ptr<AudioBuffers> deinterleave_audio (uint8_t* data, int size);
+ void film_changed (Film::Property);
+
std::string stream_name (AVStream* s) const;
AVFormatContext* _format_context;
@@ -137,4 +141,5 @@ private:
boost::optional<double> _first_audio;
std::list<boost::shared_ptr<FilterGraph> > _filter_graphs;
+ boost::mutex _filter_graphs_mutex;
};