Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Paul B Mahol <onemda@gmail.com>
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, 2 Jun 2022 14:06:26 +0200
Message-ID: <CAPYw7P6GB8QoxF+dfvrkZgy78iWKMB1--UYU9p6qsc1F=FtmaA@mail.gmail.com> (raw)
In-Reply-To: <480fc02207de10aead2fa7021ff3ce04790b8045.camel@acc.umu.se>

On Thu, Jun 2, 2022 at 1:58 PM Tomas Härdin <tjoppen@acc.umu.se> wrote:

> tor 2022-06-02 klockan 12:59 +0200 skrev Paul B Mahol:
> > +++ b/libavcodec/qoidec.c
> >
> > +#define QOI_OP_INDEX  0x00 /* 00xxxxxx */
> > +#define QOI_OP_DIFF   0x40 /* 01xxxxxx */
> > +#define QOI_OP_LUMA   0x80 /* 10xxxxxx */
> > +#define QOI_OP_RUN    0xc0 /* 11xxxxxx */
> > +#define QOI_OP_RGB    0xfe /* 11111110 */
> > +#define QOI_OP_RGBA   0xff /* 11111111 */
> > +
> > +#define QOI_MASK_2    0xc0 /* 11000000 */
> > +
> > +#define QOI_COLOR_HASH(px) (px[0]*3 + px[1]*5 + px[2]*7 + px[3]*11)
>
> Put these in a common header
>
> > +static int qoi_decode_frame(AVCodecContext *avctx, AVFrame *p,
> > +                            int *got_frame, AVPacket *avpkt)
> > +{
> > +    const uint8_t *buf = avpkt->data;
> > +    int ret, buf_size = avpkt->size;
> > +    int width, height, run = 0;
> > +    uint8_t index[64][4] = { 0 };
>
> I think some compilers require {{0}}
>
> > +    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?


>
> > +
> > +    if ((ret = ff_set_dimensions(avctx, width, height)) < 0)
> > +        return ret;
> > +
> > +    if ((ret = av_image_check_size(avctx->width, avctx->height, 0,
> > NULL)) < 0)
> > +        return ret;
>
> This call looks unnecessary as ff_set_dimensions() calls
> av_image_check_size2()
>

OK

>
> > +    avctx->pix_fmt = AV_PIX_FMT_RGBA;
>
> Still not a fan of this. Now users can encode RGB yet they unexpectedly
> get RGBA back.
>
> > +++ 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?


>
> /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".
>
_______________________________________________
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:03 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 [this message]
2022-06-02 12:26     ` Tomas Härdin
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='CAPYw7P6GB8QoxF+dfvrkZgy78iWKMB1--UYU9p6qsc1F=FtmaA@mail.gmail.com' \
    --to=onemda@gmail.com \
    --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