summaryrefslogtreecommitdiff
path: root/src/lib/decoder.cc
diff options
context:
space:
mode:
authorCarl Hetherington <cth@carlh.net>2012-11-04 17:37:07 +0000
committerCarl Hetherington <cth@carlh.net>2012-11-04 17:37:07 +0000
commitfe4e160ba2df273e8e065d0d12411eba35b00ebf (patch)
tree5cc49b274fd2d2b6e02b1fc62ea75b6193bc7175 /src/lib/decoder.cc
parent83c296968eb998ae5bdb210f37305fc49f308c4f (diff)
Partial small cleanup.
Diffstat (limited to 'src/lib/decoder.cc')
-rw-r--r--src/lib/decoder.cc14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/lib/decoder.cc b/src/lib/decoder.cc
index 673d571c4..4287a0d5f 100644
--- a/src/lib/decoder.cc
+++ b/src/lib/decoder.cc
@@ -173,6 +173,11 @@ Decoder::go ()
void
Decoder::process_audio (uint8_t* data, int size)
{
+ int const audio_frames_in_in_video_frames = _audio_frames_in * frames_per_second() / audio_sample_rate();
+ if (!within_range (audio_frames_in_in_video_frames)) {
+ return;
+ }
+
/* Push into the delay line */
size = _delay_line->feed (data, size);
@@ -282,7 +287,7 @@ Decoder::process_video (AVFrame* frame)
return;
}
- if (_film->dcp_trim_start() > _video_frames_in || (_film->length().get() + _film->dcp_trim_start()) < _video_frames_in) {
+ if (!within_range (_video_frames_in)) {
++_video_frames_in;
return;
}
@@ -352,3 +357,10 @@ Decoder::bytes_per_audio_sample () const
{
return av_get_bytes_per_sample (audio_sample_format ());
}
+
+/** @param s A video frame index within the source */
+bool
+Decoder::within_range (SourceFrames s) const
+{
+ return (s >= _film->dcp_trim_start() && s < (_film->length().get() + _film->dcp_trim_start()));
+}