summaryrefslogtreecommitdiff
path: root/src/lib
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2013-05-31 17:21:35 +0100
committerCarl Hetherington <cth@carlh.net>2013-05-31 17:21:35 +0100
commitf45cbb73068321d857249aaa21f770b87493c7c2 (patch)
tree9e98c39274a47c0906a79dbb18f067fc9963fb62 /src/lib
parentf385ef03e5ea27519a31c0839447735a7fba0602 (diff)
Test filling of stuff with black.
Diffstat (limited to 'src/lib')
-rw-r--r--src/lib/audio_content.cc2
-rw-r--r--src/lib/audio_decoder.cc12
-rw-r--r--src/lib/audio_decoder.h1
-rw-r--r--src/lib/black_decoder.cc8
-rw-r--r--src/lib/black_decoder.h1
-rw-r--r--src/lib/decoder.h2
-rw-r--r--src/lib/ffmpeg_decoder.cc7
-rw-r--r--src/lib/ffmpeg_decoder.h1
-rw-r--r--src/lib/imagemagick_content.cc1
-rw-r--r--src/lib/imagemagick_content.h5
-rw-r--r--src/lib/imagemagick_decoder.cc8
-rw-r--r--src/lib/imagemagick_decoder.h1
-rw-r--r--src/lib/player.cc11
-rw-r--r--src/lib/silence_decoder.cc11
-rw-r--r--src/lib/silence_decoder.h1
-rw-r--r--src/lib/sndfile_decoder.cc6
-rw-r--r--src/lib/sndfile_decoder.h1
-rw-r--r--src/lib/video_decoder.cc9
-rw-r--r--src/lib/video_decoder.h1
19 files changed, 83 insertions, 6 deletions
diff --git a/src/lib/audio_content.cc b/src/lib/audio_content.cc
index fb196c776..9940574f9 100644
--- a/src/lib/audio_content.cc
+++ b/src/lib/audio_content.cc
@@ -19,6 +19,7 @@
#include <libcxml/cxml.h>
#include "audio_content.h"
+#include "film.h"
using std::string;
using boost::shared_ptr;
@@ -92,4 +93,3 @@ AudioContent::set_audio_delay (int d)
signal_changed (AudioContentProperty::AUDIO_DELAY);
}
-
diff --git a/src/lib/audio_decoder.cc b/src/lib/audio_decoder.cc
index 9b8d15bf1..bbd4ced6c 100644
--- a/src/lib/audio_decoder.cc
+++ b/src/lib/audio_decoder.cc
@@ -27,6 +27,7 @@
using std::stringstream;
using std::list;
using std::pair;
+using std::cout;
using boost::optional;
using boost::shared_ptr;
@@ -151,7 +152,16 @@ AudioDecoder::audio (shared_ptr<const AudioBuffers> data, Time time)
}
Audio (dcp_mapped, time);
+ cout << "bumping n.a. by " << data->frames() << " ie " << film->audio_frames_to_time(data->frames()) << "\n";
_next_audio = time + film->audio_frames_to_time (data->frames());
}
-
+bool
+AudioDecoder::audio_done () const
+{
+ shared_ptr<const Film> film = _film.lock ();
+ assert (film);
+
+ return (_audio_content->length() - _next_audio) < film->audio_frames_to_time (1);
+}
+
diff --git a/src/lib/audio_decoder.h b/src/lib/audio_decoder.h
index fb9f23f03..1da8a676f 100644
--- a/src/lib/audio_decoder.h
+++ b/src/lib/audio_decoder.h
@@ -44,6 +44,7 @@ public:
protected:
void audio (boost::shared_ptr<const AudioBuffers>, Time);
+ bool audio_done () const;
Time _next_audio;
boost::shared_ptr<const AudioContent> _audio_content;
diff --git a/src/lib/black_decoder.cc b/src/lib/black_decoder.cc
index 3cdd5eef5..ce79ba0d7 100644
--- a/src/lib/black_decoder.cc
+++ b/src/lib/black_decoder.cc
@@ -92,3 +92,11 @@ BlackDecoder::seek_forward ()
_next_video += f->video_frames_to_time (1);
}
+
+bool
+BlackDecoder::done () const
+{
+ return video_done ();
+}
+
+
diff --git a/src/lib/black_decoder.h b/src/lib/black_decoder.h
index 3aa63e22f..622489646 100644
--- a/src/lib/black_decoder.h
+++ b/src/lib/black_decoder.h
@@ -33,6 +33,7 @@ public:
void seek_back ();
void seek_forward ();
Time next () const;
+ bool done () const;
/* VideoDecoder */
diff --git a/src/lib/decoder.h b/src/lib/decoder.h
index edb532b9c..b550bf5cb 100644
--- a/src/lib/decoder.h
+++ b/src/lib/decoder.h
@@ -72,6 +72,8 @@ public:
*/
virtual Time next () const = 0;
+ virtual bool done () const = 0;
+
protected:
/** The Film that we are decoding in */
diff --git a/src/lib/ffmpeg_decoder.cc b/src/lib/ffmpeg_decoder.cc
index c148bc530..67587a564 100644
--- a/src/lib/ffmpeg_decoder.cc
+++ b/src/lib/ffmpeg_decoder.cc
@@ -615,3 +615,10 @@ FFmpegDecoder::next () const
return _next_video;
}
+
+bool
+FFmpegDecoder::done () const
+{
+ return (!_decode_audio || !_audio_codec_context || audio_done()) && (!_decode_video || video_done());
+}
+
diff --git a/src/lib/ffmpeg_decoder.h b/src/lib/ffmpeg_decoder.h
index 7b8e1b50c..2d295db7b 100644
--- a/src/lib/ffmpeg_decoder.h
+++ b/src/lib/ffmpeg_decoder.h
@@ -69,6 +69,7 @@ public:
void seek_back ();
void seek_forward ();
Time next () const;
+ bool done () const;
/* VideoDecoder */
diff --git a/src/lib/imagemagick_content.cc b/src/lib/imagemagick_content.cc
index a4777e3cd..2b7449a6e 100644
--- a/src/lib/imagemagick_content.cc
+++ b/src/lib/imagemagick_content.cc
@@ -105,3 +105,4 @@ ImageMagickContent::length () const
FrameRateConversion frc (24, film->dcp_video_frame_rate ());
return video_length() * frc.factor() * TIME_HZ / film->dcp_video_frame_rate ();
}
+
diff --git a/src/lib/imagemagick_content.h b/src/lib/imagemagick_content.h
index e3e827892..8ed6b0873 100644
--- a/src/lib/imagemagick_content.h
+++ b/src/lib/imagemagick_content.h
@@ -17,6 +17,9 @@
*/
+#ifndef DVDOMATIC_IMAGEMAGICK_CONTENT_H
+#define DVDOMATIC_IMAGEMAGICK_CONTENT_H
+
#include <boost/enable_shared_from_this.hpp>
#include "video_content.h"
@@ -44,3 +47,5 @@ public:
static bool valid_file (boost::filesystem::path);
};
+
+#endif
diff --git a/src/lib/imagemagick_decoder.cc b/src/lib/imagemagick_decoder.cc
index 15c919e87..7da0ed551 100644
--- a/src/lib/imagemagick_decoder.cc
+++ b/src/lib/imagemagick_decoder.cc
@@ -138,3 +138,11 @@ ImageMagickDecoder::next () const
{
return _next_video;
}
+
+
+bool
+ImageMagickDecoder::done () const
+{
+ return video_done ();
+}
+
diff --git a/src/lib/imagemagick_decoder.h b/src/lib/imagemagick_decoder.h
index 6640032ba..82c87876b 100644
--- a/src/lib/imagemagick_decoder.h
+++ b/src/lib/imagemagick_decoder.h
@@ -37,6 +37,7 @@ public:
void seek_back ();
void seek_forward ();
Time next () const;
+ bool done () const;
/* VideoDecoder */
diff --git a/src/lib/player.cc b/src/lib/player.cc
index e64e1e011..757f9bbce 100644
--- a/src/lib/player.cc
+++ b/src/lib/player.cc
@@ -101,8 +101,12 @@ Player::pass ()
shared_ptr<Piece> earliest;
for (list<shared_ptr<Piece> >::iterator i = _pieces.begin(); i != _pieces.end(); ++i) {
-// cout << "check " << (*i)->content->file() << " start=" << (*i)->content->start() << ", next=" << (*i)->decoder->next() << ", end=" << (*i)->content->end() << "\n";
- if (((*i)->decoder->next() + (*i)->content->start()) >= (*i)->content->end()) {
+ cout << "check " << (*i)->content->file()
+ << " start=" << (*i)->content->start()
+ << ", next=" << (*i)->decoder->next()
+ << ", end=" << (*i)->content->end() << "\n";
+
+ if ((*i)->decoder->done ()) {
continue;
}
@@ -112,7 +116,7 @@ Player::pass ()
Time const t = (*i)->content->start() + (*i)->decoder->next();
if (t < earliest_t) {
-// cout << "\t candidate; " << t << " " << (t / TIME_HZ) << ".\n";
+ cout << "\t candidate; " << t << " " << (t / TIME_HZ) << ".\n";
earliest_t = t;
earliest = *i;
}
@@ -248,6 +252,7 @@ void
Player::add_black_piece (Time s, Time len)
{
shared_ptr<NullContent> nc (new NullContent (_film, s, len));
+ nc->set_ratio (_film->container ());
shared_ptr<BlackDecoder> bd (new BlackDecoder (_film, nc));
bd->Video.connect (bind (&Player::process_video, this, nc, _1, _2, _3));
_pieces.push_back (shared_ptr<Piece> (new Piece (nc, bd)));
diff --git a/src/lib/silence_decoder.cc b/src/lib/silence_decoder.cc
index 6cf91b41f..c8aa5c632 100644
--- a/src/lib/silence_decoder.cc
+++ b/src/lib/silence_decoder.cc
@@ -22,6 +22,7 @@
#include "audio_buffers.h"
using std::min;
+using std::cout;
using boost::shared_ptr;
SilenceDecoder::SilenceDecoder (shared_ptr<const Film> f, shared_ptr<NullContent> c)
@@ -36,8 +37,9 @@ SilenceDecoder::pass ()
{
shared_ptr<const Film> film = _film.lock ();
assert (film);
-
+
Time const this_time = min (_audio_content->length() - _next_audio, TIME_HZ / 2);
+ cout << "silence emit " << this_time << " from " << _audio_content->length() << "\n";
shared_ptr<AudioBuffers> data (new AudioBuffers (film->dcp_audio_channels(), film->time_to_audio_frames (this_time)));
data->make_silent ();
audio (data, _next_audio);
@@ -76,3 +78,10 @@ SilenceDecoder::next () const
{
return _next_audio;
}
+
+bool
+SilenceDecoder::done () const
+{
+ return audio_done ();
+}
+
diff --git a/src/lib/silence_decoder.h b/src/lib/silence_decoder.h
index 8452bc43f..d05376a14 100644
--- a/src/lib/silence_decoder.h
+++ b/src/lib/silence_decoder.h
@@ -33,4 +33,5 @@ public:
void seek_back ();
void seek_forward ();
Time next () const;
+ bool done () const;
};
diff --git a/src/lib/sndfile_decoder.cc b/src/lib/sndfile_decoder.cc
index c4c6e5f4e..c12152e67 100644
--- a/src/lib/sndfile_decoder.cc
+++ b/src/lib/sndfile_decoder.cc
@@ -117,3 +117,9 @@ SndfileDecoder::next () const
{
return _next_audio;
}
+
+bool
+SndfileDecoder::done () const
+{
+ return audio_done ();
+}
diff --git a/src/lib/sndfile_decoder.h b/src/lib/sndfile_decoder.h
index b4fa5bc58..a5edc196c 100644
--- a/src/lib/sndfile_decoder.h
+++ b/src/lib/sndfile_decoder.h
@@ -34,6 +34,7 @@ public:
void seek_back () {}
void seek_forward () {}
Time next () const;
+ bool done () const;
int audio_channels () const;
ContentAudioFrame audio_length () const;
diff --git a/src/lib/video_decoder.cc b/src/lib/video_decoder.cc
index cba21d280..086a6b552 100644
--- a/src/lib/video_decoder.cc
+++ b/src/lib/video_decoder.cc
@@ -112,3 +112,12 @@ VideoDecoder::subtitle (shared_ptr<TimedSubtitle> s)
_timed_subtitle->subtitle()->set_position (Position (p.x - _video_content->crop().left, p.y - _video_content->crop().top));
}
}
+
+bool
+VideoDecoder::video_done () const
+{
+ shared_ptr<const Film> film = _film.lock ();
+ assert (film);
+
+ return (_video_content->length() - _next_video) < film->video_frames_to_time (1);
+}
diff --git a/src/lib/video_decoder.h b/src/lib/video_decoder.h
index b31766b50..5073efead 100644
--- a/src/lib/video_decoder.h
+++ b/src/lib/video_decoder.h
@@ -44,6 +44,7 @@ protected:
void video (boost::shared_ptr<Image>, bool, Time);
void subtitle (boost::shared_ptr<TimedSubtitle>);
+ bool video_done () const;
Time _next_video;
boost::shared_ptr<const VideoContent> _video_content;