- _packet.data = nullptr;
- _packet.size = 0;
- /* XXX: I'm not sure this makes any sense: how does _packet.stream_index get the right value here? */
-DCPOMATIC_DISABLE_WARNINGS
- auto context = _format_context->streams[_packet.stream_index]->codec;
-DCPOMATIC_ENABLE_WARNINGS
- while (_video_stream && video_packet(context, temporal_reference)) {}
- for (size_t i = 0; i < _audio_streams.size(); ++i) {
- if (_audio_streams[i]->uses_index (_format_context, _packet.stream_index)) {
- audio_packet (context, _audio_streams[i]);
- }
+ if (_video_stream) {
+ auto context = _codec_context[_video_stream.get()];
+ while (video_packet(context, temporal_reference, nullptr)) {}
+ }
+
+ for (auto i: _audio_streams) {
+ auto context = _codec_context[i->index(_format_context)];
+ audio_packet(context, i, nullptr);