-/** Finish off a decode processing run */
-void
-Decoder::process_end ()
-{
- if (_delay_in_bytes < 0) {
- uint8_t remainder[-_delay_in_bytes];
- _delay_line->get_remaining (remainder);
- _audio_frames_processed += _delay_in_bytes / (audio_channels() * bytes_per_audio_sample());
- emit_audio (remainder, -_delay_in_bytes);
- }
-
- /* If we cut the decode off, the audio may be short; push some silence
- in to get it to the right length.
- */
-
- int64_t const video_length_in_audio_frames = ((int64_t) video_frame_index() * audio_sample_rate() / frames_per_second());
- int64_t const audio_short_by_frames = video_length_in_audio_frames - _audio_frames_processed;
-
- _film->log()->log (
- String::compose ("DCP length is %1 (%2 audio frames); %3 frames of audio processed.",
- video_frame_index(),
- video_length_in_audio_frames,
- _audio_frames_processed)
- );
-
- if (audio_short_by_frames >= 0 && _opt->decode_audio) {
-
- _film->log()->log (String::compose ("DCP length is %1; %2 frames of audio processed.", video_frame_index(), _audio_frames_processed));
- _film->log()->log (String::compose ("Adding %1 frames of silence to the end.", audio_short_by_frames));
-
- /* XXX: this is slightly questionable; does memset () give silence with all
- sample formats?
- */
-
- int64_t bytes = audio_short_by_frames * _film->audio_channels() * bytes_per_audio_sample();
-
- int64_t const silence_size = 16 * 1024 * _film->audio_channels() * bytes_per_audio_sample();
- uint8_t silence[silence_size];
- memset (silence, 0, silence_size);
-
- while (bytes) {
- int64_t const t = min (bytes, silence_size);
- emit_audio (silence, t);
- bytes -= t;
- }
- }
-}
-
-/** Start decoding */
-void
-Decoder::go ()
-{
- process_begin ();
-
- if (_job && !_film->dcp_length()) {
- _job->set_progress_unknown ();
- }
-
- while (pass () == false) {
- if (_job && _film->dcp_length()) {
- _job->set_progress (float (_video_frame_index) / _film->dcp_length().get());
- }
- }
-
- process_end ();
-}
-
-/** Run one pass. This may or may not generate any actual video / audio data;
- * some decoders may require several passes to generate a single frame.
- * @return true if we have finished processing all data; otherwise false.