Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "Tomas Härdin" <tjoppen@acc.umu.se>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH] avcodec: add QOI decoder and demuxer and parser and encoder and muxer
Date: Thu, 02 Jun 2022 14:26:04 +0200
Message-ID: <2a28a7793ae888f2ede23812c8d0bbdc6b16ab4a.camel@acc.umu.se> (raw)
In-Reply-To: <CAPYw7P6GB8QoxF+dfvrkZgy78iWKMB1--UYU9p6qsc1F=FtmaA@mail.gmail.com>

tor 2022-06-02 klockan 14:06 +0200 skrev Paul B Mahol:
> On Thu, Jun 2, 2022 at 1:58 PM Tomas Härdin <tjoppen@acc.umu.se>
> wrote:
> > 
> > > +    uint8_t px[4] = { 0, 0, 0, 255 };
> > > +    GetByteContext gb;
> > > +    uint8_t *dst;
> > > +    uint64_t len;
> > > +
> > > +    if (buf_size < 20)
> > > +        return AVERROR_INVALIDDATA;
> > > +
> > > +    bytestream2_init(&gb, buf, buf_size);
> > > +    bytestream2_skip(&gb, 4);
> > > +    width  = bytestream2_get_be32(&gb);
> > > +    height = bytestream2_get_be32(&gb);
> > > +    bytestream2_skip(&gb, 2);
> > 
> > This should reject linear RGB, not silently treat it as sRGB.
> > 
> 
> Reject?

From the spec:

>    uint8_t  colorspace; // 0 = sRGB with linear alpha
>                         // 1 = all channels linear

RGB in lavc is always sRGB as far as I'm aware.
> 

> > > +++ b/libavcodec/qoienc.c
> > > 
> > > +static int qoi_encode_frame(AVCodecContext *avctx, AVPacket
> > > *pkt,
> > > +                            const AVFrame *pict, int
> > > *got_packet)
> > > +{
> > > [...]
> > > +                index_pos = QOI_COLOR_HASH(px) & 63;
> > > +
> > > +                if (!memcmp(index[index_pos], px, 4)) {
> > > +                    bytestream_put_byte(&buf, QOI_OP_INDEX |
> > > index_pos);
> > 
> > This needs protection against outputting 0x0000000000000001
> > 
> 
> What?

I had the notion that the encoder could produce runs of index_pos == 0
followed by a single index_pos == 1, thus accidentally signalling end
of image. But the RLE stuff ensures that can't happen. The closest we
can get is an QOI_OP_RGBA with {0,0,0,0} followed by QOI_OP_INDEX with
index_pos == 0 which is five 0x00 in a row. A further match for
index_pos == 0 would be handled as a run. So there's no risk of
accidentally marking end of image. This is why the spec says an encoder
must not output consecutive QOI_OP_INDEX with the same index.

/Tomas

_______________________________________________
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".

  reply	other threads:[~2022-06-02 12:26 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-02 10:59 Paul B Mahol
2022-06-02 11:58 ` Tomas Härdin
2022-06-02 12:06   ` Paul B Mahol
2022-06-02 12:26     ` Tomas Härdin [this message]
2022-06-02 19:34       ` Leo Izen
2022-06-02 16:01 Paul B Mahol
2022-06-03  9:22 ` Tomas Härdin
2022-06-03 16:17 ` Andreas Rheinhardt
2022-06-03 16:22   ` Paul B Mahol
2022-06-03 16:21     ` Andreas Rheinhardt
2022-06-03 16:34       ` Paul B Mahol

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=2a28a7793ae888f2ede23812c8d0bbdc6b16ab4a.camel@acc.umu.se \
    --to=tjoppen@acc.umu.se \
    --cc=ffmpeg-devel@ffmpeg.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git