+ } else {
+ ct = ContentTime::from_seconds (
+ frame->best_effort_timestamp *
+ av_q2d(time_base))
+ + _pts_offset;
+ LOG_DEBUG_PLAYER(
+ "Process audio with timestamp %1 (BET %2, timebase %3/%4, (PTS offset %5)",
+ to_string(ct),
+ frame->best_effort_timestamp,
+ time_base.num,
+ time_base.den,
+ to_string(_pts_offset)
+ );
+ }
+
+ _next_time[stream] = ct + ContentTime::from_frames(data->frames(), stream->frame_rate());
+
+ if (ct < ContentTime()) {
+ /* Discard audio data that comes before time 0 */
+ auto const remove = min (int64_t(data->frames()), (-ct).frames_ceil(double(stream->frame_rate())));
+ data->move (data->frames() - remove, remove, 0);
+ data->set_frames (data->frames() - remove);
+ ct += ContentTime::from_frames (remove, stream->frame_rate());
+ }
+
+ if (ct < ContentTime()) {
+ LOG_WARNING (
+ "Crazy timestamp %1 for %2 samples in stream %3 (ts=%4 tb=%5, off=%6)",
+ to_string(ct),
+ data->frames(),
+ stream->id(),
+ frame->best_effort_timestamp,
+ av_q2d(time_base),
+ to_string(_pts_offset)
+ );
+ }
+
+ /* Give this data provided there is some, and its time is sane */
+ if (ct >= ContentTime() && data->frames() > 0) {
+ audio->emit (film(), stream, data, ct);
+ }
+}