diff options
author | Guido Cella <guido@guidocella.xyz> | 2022-08-21 21:10:59 +0200 |
---|---|---|
committer | sfan5 <sfan5@live.de> | 2022-09-20 19:35:25 +0200 |
commit | 7f2bc43a686ef59d2e6ea1a7a5cf95b55ee10d71 (patch) | |
tree | 835eed4cb3d8f1ee7174aa3d8ac96f47c2ff76fe | |
parent | 565e7d906c0da59739b60f5a3760ed9eb067f1f9 (diff) | |
download | mpv-7f2bc43a686ef59d2e6ea1a7a5cf95b55ee10d71.tar.bz2 mpv-7f2bc43a686ef59d2e6ea1a7a5cf95b55ee10d71.tar.xz |
demux_lavf: extract is_image function
-rw-r--r-- | demux/demux_lavf.c | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/demux/demux_lavf.c b/demux/demux_lavf.c index 160ce6cd97..22e6531f8b 100644 --- a/demux/demux_lavf.c +++ b/demux/demux_lavf.c @@ -647,6 +647,18 @@ static int dict_get_decimal(AVDictionary *dict, const char *entry, int def) return def; } +static bool is_image(AVStream *st, bool attached_picture, const AVInputFormat *avif) +{ + return st->nb_frames <= 1 && ( + attached_picture || + bstr_endswith0(bstr0(avif->name), "_pipe") || + strcmp(avif->name, "alias_pix") == 0 || + strcmp(avif->name, "gif") == 0 || + strcmp(avif->name, "image2pipe") == 0 || + (st->codecpar->codec_id == AV_CODEC_ID_AV1 && st->nb_frames == 1) + ); +} + static void handle_new_stream(demuxer_t *demuxer, int i) { lavf_priv_t *priv = demuxer->priv; @@ -718,14 +730,7 @@ static void handle_new_stream(demuxer_t *demuxer, int i) sh->codec->disp_h = codec->height; if (st->avg_frame_rate.num) sh->codec->fps = av_q2d(st->avg_frame_rate); - if (st->nb_frames <= 1 && ( - sh->attached_picture || - bstr_endswith0(bstr0(priv->avif->name), "_pipe") || - strcmp(priv->avif->name, "alias_pix") == 0 || - strcmp(priv->avif->name, "gif") == 0 || - strcmp(priv->avif->name, "image2pipe") == 0 || - (codec->codec_id == AV_CODEC_ID_AV1 && st->nb_frames == 1) - )) { + if (is_image(st, sh->attached_picture, priv->avif)) { MP_VERBOSE(demuxer, "Assuming this is an image format.\n"); sh->image = true; sh->codec->fps = priv->mf_fps; |