From 8812530b312c8beeaeefdaaa54fc26cf779cb3c2 Mon Sep 17 00:00:00 2001 From: wm4 Date: Fri, 31 May 2019 16:24:06 +0200 Subject: demux: more backwards playback preroll packets for vorbis and mp3 Together with the previous commit, this seems to make backward playback work in files with vorbis and mp3 audio codecs. For Vorbis (with libavcodec's decoder, didn't test libvorbis), the first packet was just always completely discarded. This happened even though we tell libavcodec that we do discarding of padding manually. It simply happened inside the codec, not libavcodec's general initial padding handling. In addition, the first output decoded frame seems to contain partial data. (Unlike the opus decoder, it doesn't report any padding at all.) The Opus decoder (again libavcodec only tested) reports an initial padding, but it appears to be too small, and it sounds right only with 2 packets discarded. So its status doesn't change. I'm not sure why I need 2 frames for mp3, but with that value I had success on the samples I tested. --- demux/demux.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'demux') diff --git a/demux/demux.c b/demux/demux.c index 9cbc88cf62..f65d606b92 100644 --- a/demux/demux.c +++ b/demux/demux.c @@ -949,7 +949,9 @@ static void demux_add_sh_stream_locked(struct demux_internal *in, ds->back_preroll = in->opts->audio_back_preroll; if (ds->back_preroll < 0) { // auto ds->back_preroll = mp_codec_is_lossless(sh->codec->codec) ? 0 : 1; - if (sh->codec->codec && strcmp(sh->codec->codec, "opus") == 0) + if (sh->codec->codec && (strcmp(sh->codec->codec, "opus") == 0 || + strcmp(sh->codec->codec, "vorbis") == 0 || + strcmp(sh->codec->codec, "mp3") == 0)) ds->back_preroll = 2; } break; -- cgit v1.2.3