diff options
author | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2009-10-17 20:30:49 +0300 |
---|---|---|
committer | Uoti Urpala <uau@glyph.nonexistent.invalid> | 2009-10-17 20:58:21 +0300 |
commit | 786df56047e5d0f7a867e53fbd8195fb03b819f5 (patch) | |
tree | d3ba487dea7f6a1e724cb3bc3f6808569dafcee1 /libmpdemux | |
parent | f43c06930f8e5161e8b4ef079dec04eed99d942e (diff) | |
download | mpv-786df56047e5d0f7a867e53fbd8195fb03b819f5.tar.bz2 mpv-786df56047e5d0f7a867e53fbd8195fb03b819f5.tar.xz |
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.
Diffstat (limited to 'libmpdemux')
-rw-r--r-- | libmpdemux/demux_mkv.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/libmpdemux/demux_mkv.c b/libmpdemux/demux_mkv.c index 8280a8793e..759b8cf92f 100644 --- a/libmpdemux/demux_mkv.c +++ b/libmpdemux/demux_mkv.c @@ -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')) |