text.push_back (make_shared<TextDecoder>(this, c->only_text(), ContentTime()));
}
- _next_time.resize (_format_context->nb_streams);
+ for (auto i: c->ffmpeg_audio_streams()) {
+ _next_time[i] = {};
+ }
}
_have_current_subtitle = false;
for (auto& i: _next_time) {
- i = optional<ContentTime>();
+ i.second = {};
}
}
void
-FFmpegDecoder::process_audio_frame (shared_ptr<FFmpegAudioStream> stream, int stream_index, int64_t packet_pts)
+FFmpegDecoder::process_audio_frame (shared_ptr<FFmpegAudioStream> stream, int64_t packet_pts)
{
auto data = deinterleave_audio (stream);
that have AV_NOPTS_VALUE we need to work out the timestamp ourselves. This is
particularly noticeable with TrueHD streams (see #1111).
*/
- if (_next_time[stream_index]) {
- ct = *_next_time[stream_index];
+ if (_next_time[stream]) {
+ ct = *_next_time[stream];
}
} else {
ct = ContentTime::from_seconds (
+ _pts_offset;
}
- _next_time[stream_index] = ct + ContentTime::from_frames(data->frames(), stream->frame_rate());
+ _next_time[stream] = ct + ContentTime::from_frames(data->frames(), stream->frame_rate());
if (ct < ContentTime()) {
/* Discard audio data that comes before time 0 */
"Crazy timestamp %1 for %2 samples in stream %3 packet pts %4 (ts=%5 tb=%6, off=%7)",
to_string(ct),
data->frames(),
- stream_index,
+ stream->id(),
packet_pts,
_frame->best_effort_timestamp,
av_q2d(stream->stream(_format_context)->time_base),
void
FFmpegDecoder::decode_audio_packet (AVPacket* packet)
{
- int const stream_index = packet->stream_index;
- auto stream = audio_stream_from_index (stream_index);
+ auto stream = audio_stream_from_index (packet->stream_index);
if (!stream) {
return;
}
}
if (frame_finished) {
- process_audio_frame (stream, stream_index, copy_packet.pts);
+ process_audio_frame (stream, copy_packet.pts);
}
copy_packet.data += decode_result;
int bytes_per_audio_sample (std::shared_ptr<FFmpegAudioStream> stream) const;
std::shared_ptr<FFmpegAudioStream> audio_stream_from_index (int index) const;
- void process_audio_frame (std::shared_ptr<FFmpegAudioStream> stream, int stream_index, int64_t packet_pts);
+ void process_audio_frame (std::shared_ptr<FFmpegAudioStream> stream, int64_t packet_pts);
bool decode_video_packet (AVPacket* packet);
void decode_audio_packet (AVPacket* packet);
std::shared_ptr<Image> _black_image;
- std::vector<boost::optional<dcpomatic::ContentTime> > _next_time;
+ std::map<std::shared_ptr<FFmpegAudioStream>, boost::optional<dcpomatic::ContentTime>> _next_time;
};