diff options
Diffstat (limited to 'demux/demux_lavf.c')
-rw-r--r-- | demux/demux_lavf.c | 32 |
1 files changed, 20 insertions, 12 deletions
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index 182642494e..3ac915cdfb 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -21,7 +21,6 @@ #include <limits.h> #include <stdbool.h> #include <string.h> -#include <strings.h> #include <errno.h> #include <assert.h> @@ -41,6 +40,7 @@ #include "audio/chmap_avchannel.h" +#include "common/common.h" #include "common/msg.h" #include "common/tags.h" #include "common/av_common.h" @@ -152,6 +152,7 @@ struct format_hack { bool no_pcm_seek : 1; bool no_seek_on_no_duration : 1; bool readall_on_no_streamseek : 1; + bool first_frame_only : 1; }; #define BLACKLIST(fmt) {fmt, .ignore = true} @@ -190,6 +191,10 @@ static const struct format_hack format_hacks[] = { // reset timestamps, which causes all sorts of problems. {"ogg", .linearize_audio_ts = true, .use_stream_ids = true}, + // Ignore additional metadata as frames from some single frame JPEGs + // (e.g. gain map) + {"jpeg_pipe", .first_frame_only = true}, + // At some point, FFmpeg lost the ability to read gif from unseekable // streams. {"gif", .readall_on_no_streamseek = true}, @@ -465,18 +470,12 @@ static int lavf_check_file(demuxer_t *demuxer, enum demux_check check) } } - // HLS streams do not seem to be well tagged, so matching by MIME type is - // not enough - we need to strip the query string and match by their - // extensions. We also pass jpg filenames to fix issues like #13192 (jpgs - // being treated as videos due to a bogus second frame) and #13431 (jpgs - // misdetected as mpegts). We don't pass filenames otherwise to not - // misdetect files with a wrong extension, as described in 74e62ed2d1. - bstr ext = bstr_get_ext(mp_is_url(bstr0(priv->filename)) - ? bstr_split(bstr0(priv->filename), "?#", NULL) - : bstr0(priv->filename)); + // HLS streams seems to be not well tagged, so matching mime type is not + // enough. Strip URL parameters and match extension. + bstr ext = bstr_get_ext(bstr_split(bstr0(priv->filename), "?#", NULL)); AVProbeData avpd = { + // Disable file-extension matching with normal checks, except for HLS .filename = !bstrcasecmp0(ext, "m3u8") || !bstrcasecmp0(ext, "m3u") || - !bstrcasecmp0(ext, "jpg") || !bstrcasecmp0(ext, "jpeg") || check <= DEMUX_CHECK_REQUEST ? priv->filename : "", .buf_size = 0, .buf = av_mallocz(PROBE_BUF_SIZE + AV_INPUT_BUFFER_PADDING_SIZE), @@ -796,6 +795,9 @@ static void handle_new_stream(demuxer_t *demuxer, int i) MP_VERBOSE(demuxer, "Found Dolby Vision config record: profile " "%d level %d\n", cfg->dv_profile, cfg->dv_level); av_format_inject_global_side_data(avfc); + sh->codec->dovi = true; + sh->codec->dv_profile = cfg->dv_profile; + sh->codec->dv_level = cfg->dv_level; } // This also applies to vfw-muxed mkv, but we can't detect these easily. @@ -948,7 +950,7 @@ static int nested_io_open(struct AVFormatContext *s, AVIOContext **pb, struct demuxer *demuxer = s->opaque; lavf_priv_t *priv = demuxer->priv; - if (priv->opts->propagate_opts) { + if (options && priv->opts->propagate_opts) { // Copy av_opts to options, but only entries that are not present in // options. (Hope this will break less by not overwriting important // settings.) @@ -1263,6 +1265,12 @@ static bool demux_lavf_read_packet(struct demuxer *demux, return true; // don't signal EOF if skipping a packet } + // Never send additional frames for streams that are a single frame. + if (stream->image && priv->format_hack.first_frame_only && pkt->pos != 0) { + av_packet_unref(pkt); + return true; + } + struct demux_packet *dp = new_demux_packet_from_avpacket(pkt); if (!dp) { av_packet_unref(pkt); |