X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=src%2Flib%2Fdecoder.cc;h=4287a0d5f8d4d63ae9e69013eec286e54dbfb756;hb=fe4e160ba2df273e8e065d0d12411eba35b00ebf;hp=673d571c40078d1b7adc2e785f7d5f525bc29968;hpb=83c296968eb998ae5bdb210f37305fc49f308c4f;p=dcpomatic.git 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())); +}