summaryrefslogtreecommitdiffstats
path: root/demux
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2019-05-22 21:57:08 +0200
committerwm4 <wm4@nowhere>2019-09-19 20:37:04 +0200
commitb90723bccbe6a58bdfa7e8ba0e25922eada9e295 (patch)
treedba0839f8e3f56bce77138d04555ebe16e014090 /demux
parent32e303366615f4d70dd2c820c2ecc294378a2cf9 (diff)
downloadmpv-b90723bccbe6a58bdfa7e8ba0e25922eada9e295.tar.bz2
mpv-b90723bccbe6a58bdfa7e8ba0e25922eada9e295.tar.xz
demux_mkv: stop setting per-packet initial padding from codec delay
This is a bad approach, and should be handled by a codec parameter field (in mp_codec_params or AVCodecParameters). It's bad because it's overly complicated, and has potential to break demuxer cache assumptions: packets that were "intended" for seek resuming may suddenly appear in the middle of a stream, when you seek back and play a cached part again. (In general it was fine though, because seek range joining tends to remove the first audio packet of the next range when trying to find an overlap.) demux_mkv.c does not try to export its codec_delay field through the codec parameters mentioned above. In the only case I spotted this element, the codec itself (opus) set this field within libavcodec. And I think that's actually how it should be. On the other hand, a file could in theory set this field via mkv headers if the codec is too stupid to have such a field internally. But I don't really care until I see such a file. The end trimming is still sort of needed (though not sure if anything uses it, other than the opus/mkv test sample I was using). The decoder can't know whether something is the last packet, until it's too late. The codec_delay field is still needed to offset timestamps.
Diffstat (limited to 'demux')
-rw-r--r--demux/demux_mkv.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/demux/demux_mkv.c b/demux/demux_mkv.c
index 9545cb161b..67eb9c7af6 100644
--- a/demux/demux_mkv.c
+++ b/demux/demux_mkv.c
@@ -2705,8 +2705,7 @@ static int handle_block(demuxer_t *demuxer, struct block_info *block_info)
dp->duration = block_duration / 1e9;
if (stream->type == STREAM_AUDIO) {
unsigned int srate = stream->codec->samplerate;
- demux_packet_set_padding(dp,
- mkv_d->a_skip_preroll ? track->codec_delay * srate : 0,
+ demux_packet_set_padding(dp, 0,
block_info->discardpadding / 1e9 * srate);
mkv_d->a_skip_preroll = 0;
}