demux_lavf: extract is_image function

This commit is contained in:
Guido Cella 2022-08-21 21:10:59 +02:00 committed by sfan5
parent 565e7d906c
commit 7f2bc43a68
1 changed files with 13 additions and 8 deletions

View File

@ -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;