From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <ffmpeg-devel-bounces@ffmpeg.org>
Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100])
	by master.gitmailbox.com (Postfix) with ESMTP id C238B40204
	for <ffmpegdev@gitmailbox.com>; Thu, 20 Jan 2022 12:48:45 +0000 (UTC)
Received: from [127.0.1.1] (localhost [127.0.0.1])
	by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D72EA68B170;
	Thu, 20 Jan 2022 14:48:42 +0200 (EET)
Received: from mail-ed1-f52.google.com (mail-ed1-f52.google.com
 [209.85.208.52])
 by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5336468B036
 for <ffmpeg-devel@ffmpeg.org>; Thu, 20 Jan 2022 14:48:36 +0200 (EET)
Received: by mail-ed1-f52.google.com with SMTP id a18so28187817edj.7
 for <ffmpeg-devel@ffmpeg.org>; Thu, 20 Jan 2022 04:48:36 -0800 (PST)
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112;
 h=mime-version:references:in-reply-to:from:date:message-id:subject:to;
 bh=mzDW4yaNV4nB8EMHuswl+0AJo+pLFj3CWng3LeSfj/U=;
 b=logLsSrDlPTpmceny06v1vaMjx2XsdJ/DOnlImsU7dJEGsu89FABxLT3VP2UmhCTWy
 JMFEqdhpuFKIPtUM9o+GXDX43VEV8bvlmWs4t+N1wV4rSu7xJz6XU12jLRnTbeZ22KN2
 aCHV/1fzt47fmb5w20wstE6xwcTEpJKEooruY34kb+FcLQWNDH3KKNYqlXPkDbywwKg1
 LMkO3zSo7QePOOaGzRx6dKs8B9WIEUjDwwqslKTidJ/HcQ6a2PLu46d2BNjD2J1+06q0
 FV1gu7o9SLj91AqnqlaMFthJ+Xs/msUp5rCSk7tbr46TsxBbQYl4VV/PWtAYyuRFXUqQ
 I4nQ==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
 d=1e100.net; s=20210112;
 h=x-gm-message-state:mime-version:references:in-reply-to:from:date
 :message-id:subject:to;
 bh=mzDW4yaNV4nB8EMHuswl+0AJo+pLFj3CWng3LeSfj/U=;
 b=q2v+ab0lqo4iSbqyhjJ2hfq37XaU3s0Vc9s9lWCbkjcYZbBqCNlT0H2FKz8OgDrNb8
 reqCDch7AK7zULfS6Rq25LbGpn98PqZtYhC+ZoJ5WwZCAPFBq62TfYw9OlflqKsAvGs4
 9D5Vc1gVPGMb6yMFUoYq11rMS7fzWZqxW1YtrPS8GM/rrGYXmNM3zXBVSkOMyci4N3+Q
 9MZ8Wb+JXc44Cp5Tt4tZpvl9T1Ztm6Pq7w9EoDikEO+CLjNVkraapSNZCeAut18vrlmj
 Hr7y4bC5qzznjUR/yCr8Mt/V02qK9dmb2vZ/k6nI4wFMR9g4gZx981Qqvtxusl5a6kzA
 MViw==
X-Gm-Message-State: AOAM530nZ4B9avab++ZZ6P0EapEeHNkMiF+g5z6SLYH7EIOxoi7Q1Gw/
 xsyu+byLjDlm7C8+qg5xPVnLe0C57HDFriaR7aXcyO2U
X-Google-Smtp-Source: ABdhPJyhP3qKN54HNYW/20dys9ns4GiRyIm6EerxRH8oEBq6V9+uz5w4dpKCTqeWzfCBbG2qP3PK5IWmSRu4oC7TyXQ=
X-Received: by 2002:a17:907:7601:: with SMTP id
 jx1mr28598962ejc.696.1642682915339; 
 Thu, 20 Jan 2022 04:48:35 -0800 (PST)
MIME-Version: 1.0
References: <755fd91b4ae6c9327668f339acfc67fcdd02c0bd.1631867851.git.pross@xvid.org>
 <54d14822e998e9f1ac99e919fe223433d3c509e2.1631867851.git.pross@xvid.org>
In-Reply-To: <54d14822e998e9f1ac99e919fe223433d3c509e2.1631867851.git.pross@xvid.org>
From: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Date: Thu, 20 Jan 2022 13:48:23 +0100
Message-ID: <CAKfdkRcf__66OiY6xVeHEbyc7yg7X=OsERGpSHzmLH20WdAeEg@mail.gmail.com>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH 2/2] avformat/img2dec: add GEM Raster
 image demuxer
X-BeenThere: ffmpeg-devel@ffmpeg.org
X-Mailman-Version: 2.1.29
Precedence: list
List-Id: FFmpeg development discussions and patches <ffmpeg-devel.ffmpeg.org>
List-Unsubscribe: <https://ffmpeg.org/mailman/options/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=unsubscribe>
List-Archive: <https://ffmpeg.org/pipermail/ffmpeg-devel>
List-Post: <mailto:ffmpeg-devel@ffmpeg.org>
List-Help: <mailto:ffmpeg-devel-request@ffmpeg.org?subject=help>
List-Subscribe: <https://ffmpeg.org/mailman/listinfo/ffmpeg-devel>,
 <mailto:ffmpeg-devel-request@ffmpeg.org?subject=subscribe>
Reply-To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Content-Type: text/plain; charset="us-ascii"
Content-Transfer-Encoding: 7bit
Errors-To: ffmpeg-devel-bounces@ffmpeg.org
Sender: "ffmpeg-devel" <ffmpeg-devel-bounces@ffmpeg.org>
Archived-At: <https://master.gitmailbox.com/ffmpegdev/CAKfdkRcf__66OiY6xVeHEbyc7yg7X=OsERGpSHzmLH20WdAeEg@mail.gmail.com/>
List-Archive: <https://master.gitmailbox.com/ffmpegdev/>
List-Post: <mailto:ffmpegdev@gitmailbox.com>

On Fri, Sep 17, 2021 at 10:39 AM Peter Ross <pross@xvid.org> wrote:
>
> ---
>  libavformat/allformats.c |  1 +
>  libavformat/img2.c       |  3 +++
>  libavformat/img2dec.c    | 22 ++++++++++++++++++++++
>  3 files changed, 26 insertions(+)
>
> diff --git a/libavformat/allformats.c b/libavformat/allformats.c
> index 5471f7c16f..99d8c91e00 100644
> --- a/libavformat/allformats.c
> +++ b/libavformat/allformats.c
> @@ -499,6 +499,7 @@ extern const AVInputFormat  ff_image_cri_pipe_demuxer;
>  extern const AVInputFormat  ff_image_dds_pipe_demuxer;
>  extern const AVInputFormat  ff_image_dpx_pipe_demuxer;
>  extern const AVInputFormat  ff_image_exr_pipe_demuxer;
> +extern const AVInputFormat  ff_image_gem_pipe_demuxer;
>  extern const AVInputFormat  ff_image_gif_pipe_demuxer;
>  extern const AVInputFormat  ff_image_j2k_pipe_demuxer;
>  extern const AVInputFormat  ff_image_jpeg_pipe_demuxer;
> diff --git a/libavformat/img2.c b/libavformat/img2.c
> index 6bdd7efe26..4153102c92 100644
> --- a/libavformat/img2.c
> +++ b/libavformat/img2.c
> @@ -84,6 +84,9 @@ const IdStrMap ff_img_tags[] = {
>      { AV_CODEC_ID_XPM,        "xpm"      },
>      { AV_CODEC_ID_XFACE,      "xface"    },
>      { AV_CODEC_ID_XWD,        "xwd"      },
> +    { AV_CODEC_ID_GEM,        "img"      },
> +    { AV_CODEC_ID_GEM,        "ximg"     },
> +    { AV_CODEC_ID_GEM,        "timg"     },
>      { AV_CODEC_ID_NONE,       NULL       }
>  };
>
> diff --git a/libavformat/img2dec.c b/libavformat/img2dec.c
> index 485444ed31..acfd5910de 100644
> --- a/libavformat/img2dec.c
> +++ b/libavformat/img2dec.c
> @@ -1105,6 +1105,27 @@ static int photocd_probe(const AVProbeData *p)
>      return AVPROBE_SCORE_MAX - 1;
>  }
>
> +static int gem_probe(const AVProbeData *p)
> +{
> +    const uint8_t *b = p->buf;
> +    int ret = 0;
> +    if ( AV_RB16(b     ) >= 1 && AV_RB16(b    ) <= 3  &&
> +         AV_RB16(b +  2) >= 8 && AV_RB16(b + 2) <= 779 &&
> +        (AV_RB16(b +  4) > 0  || AV_RB16(b + 4) <= 8) &&
> +        (AV_RB16(b +  6) > 0  || AV_RB16(b + 6) <= 8) &&

The above two lines are tautologically true, suggesting that something
else was intended here.
Looking at the decoder shows that this is the aspect ratio, so
checking for them being >0 makes sense,
yet the checks for them being <= 8 doesn't.
(This has been reported in ticket #9605.)

> +         AV_RB16(b +  8) &&
> +         AV_RB16(b + 10) &&
> +         AV_RB16(b + 12) &&
> +         AV_RB16(b + 14)) {
> +        ret = AVPROBE_SCORE_EXTENSION / 4;
> +        if (AV_RN32(b + 16) == AV_RN32("STTT") ||
> +            AV_RN32(b + 16) == AV_RN32("TIMG") ||
> +            AV_RN32(b + 16) == AV_RN32("XIMG"))
> +            ret += 1;
> +    }
> +    return ret;
> +}
> +
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".