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.
This commit is contained in:
wm4 2019-05-22 21:57:08 +02:00
parent 32e3033666
commit b90723bccb
1 changed files with 1 additions and 2 deletions

View File

@ -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;
}