mirror of
https://github.com/mpv-player/mpv
synced 2025-03-06 22:28:01 +00:00
demux_mkv: Stop moving FLAC extradata into stream packets
The Matroska demuxer didn't place FLAC codec extradata in the normal extradata field but instead constructed a fake data packet and inserted that at the start of the demuxer stream. Current FFmpeg FLAC decoder can read the data from the proper extradata field too, so use that mechanism instead. This fixes a problem with files that use ordered chapters to load external segments from other files that have FLAC audio. In that case there can be a seek before the audio decoder is first initialized, and the seek will flush all stream packets so the decoder would never see the inserted extra packet. That particular issue could be fixed by initializing the decoder before any seeks instead (and there could still be other similar problem cases where doing that would be more robust), but this change is still generally right. I think the previous code would also cause problems in case there are multiple audio streams; there's only a single demuxer stream used for data packets, meaning that a packet inserted for the sake of a secondary audio stream could be read by the codec of the default stream (possibly not FLAC at all) and the packet would not be available when switching to the secondary audio stream later.
This commit is contained in:
parent
f43c06930f
commit
786df56047
@ -1721,7 +1721,6 @@ demux_mkv_open_audio (demuxer_t *demuxer, mkv_track_t *track, int aid)
|
||||
{
|
||||
mkv_demuxer_t *mkv_d = (mkv_demuxer_t *) demuxer->priv;
|
||||
sh_audio_t *sh_a = new_sh_audio_aid(demuxer, track->tnum, aid);
|
||||
demux_packet_t *dp;
|
||||
if(!sh_a) return 1;
|
||||
mkv_d->audio_tracks[mkv_d->last_aid] = track->tnum;
|
||||
|
||||
@ -2015,17 +2014,16 @@ demux_mkv_open_audio (demuxer_t *demuxer, mkv_track_t *track, int aid)
|
||||
if (size < 4 || ptr[0] != 'f' || ptr[1] != 'L' ||
|
||||
ptr[2] != 'a' || ptr[3] != 'C')
|
||||
{
|
||||
dp = new_demux_packet (4);
|
||||
memcpy (dp->buffer, "fLaC", 4);
|
||||
sh_a->codecdata = malloc(4);
|
||||
sh_a->codecdata_len = 4;
|
||||
memcpy(sh_a->codecdata, "fLaC", 4);
|
||||
}
|
||||
else
|
||||
{
|
||||
dp = new_demux_packet (size);
|
||||
memcpy (dp->buffer, ptr, size);
|
||||
sh_a->codecdata = malloc(size);
|
||||
sh_a->codecdata_len = size;
|
||||
memcpy(sh_a->codecdata, ptr, size);
|
||||
}
|
||||
dp->pts = 0;
|
||||
dp->flags = 0;
|
||||
ds_add_packet (demuxer->audio, dp);
|
||||
}
|
||||
else if (track->a_formattag == mmioFOURCC('W', 'V', 'P', 'K') ||
|
||||
track->a_formattag == mmioFOURCC('T', 'R', 'H', 'D'))
|
||||
|
Loading…
Reference in New Issue
Block a user