Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: James Zern <jzern-at-google.com@ffmpeg.org>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Subject: Re: [FFmpeg-devel] [PATCH v2 2/5] avcodec/webp_parser: parse each frame into one packet
Date: Tue, 11 Jul 2023 15:36:56 -0700
Message-ID: <CABWgkXKJpgmd4vjB=iCzSd9TB98ZQmSb-nUhfJ+FSV8Bs_nLSQ@mail.gmail.com> (raw)
In-Reply-To: <20230706112731.35895-3-thilo.borgmann@mail.de>

On Thu, Jul 6, 2023 at 4:28 AM Thilo Borgmann <thilo.borgmann@mail.de> wrote:
>
> ---
>  libavcodec/webp_parser.c | 132 ++++++++++++++++++++++++++-------------
>  1 file changed, 90 insertions(+), 42 deletions(-)
>
> [...]
> +            } else {
> +                /* read the next tag */
> +                ctx->remaining_file_size--;
> +                if (ctx->remaining_file_size == 0) {
>                      ctx->pc.frame_start_found = 0;
>                      continue;
>                  }
>                  ctx->pc.frame_start_found++;
> -                ctx->remaining_size = ctx->fsize + i - 15;
> -                if (ctx->pc.index + i > 15) {
> -                    next = i - 15;
> -                    state = 0;
> -                    break;
> -                } else {
> -                    ctx->pc.state64 = 0;
> -                    goto restart;
> +                if (ctx->pc.frame_start_found < 8)
> +                    continue;
> +
> +                switch (state >> 32) {
> +                    case MKBETAG('A', 'N', 'M', 'F'):
> +                    case MKBETAG('V', 'P', '8', ' '):
> +                    case MKBETAG('V', 'P', '8', 'L'):

No indent on the case statements.

> +                        if (ctx->frame) {
> +                            ctx->frame = 0;
> +                            next = i - 8;
> +                            state = 0;
> +                            ctx->pc.frame_start_found = 0;
> +                            goto flush;
> +                        }
> +                        ctx->frame = 1;
> +                        break;
> +                    default:
> +                        break;
>                  }
> -            } else if (ctx->pc.frame_start_found)
> -                ctx->pc.frame_start_found++;
> -        }
> -        ctx->pc.state64 = state;
> -    } else {
> -        if (ctx->remaining_size) {
> -            i = FFMIN(ctx->remaining_size, buf_size);
> -            ctx->remaining_size -= i;
> -            if (ctx->remaining_size)
> -                goto flush;
>
> -            ctx->pc.frame_start_found = 0;
> -            goto restart;
> +                ctx->remaining_tag_size = av_bswap32(state);
> +                ctx->remaining_tag_size += ctx->remaining_tag_size & 1;
> +                if (ctx->remaining_tag_size > ctx->remaining_file_size) {
> +                    /* this is probably trash at the end of file */

This would instead mean the file was truncated if remaining_tag_size
fits within the RIFF chunk size. Parsing also looks like it can
continue past the end of the RIFF chunk.
_______________________________________________
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:[~2023-07-11 22:37 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-07-06 11:27 [FFmpeg-devel] [PATCH v2 0/5] webp: add support for animated WebP decoding Thilo Borgmann
2023-07-06 11:27 ` [FFmpeg-devel] [PATCH v2 1/5] avcodec/webp: move definitions into header Thilo Borgmann
2023-07-11 22:19   ` James Zern
2023-07-06 11:27 ` [FFmpeg-devel] [PATCH v2 2/5] avcodec/webp_parser: parse each frame into one packet Thilo Borgmann
2023-07-11 22:36   ` James Zern [this message]
2023-07-06 11:27 ` [FFmpeg-devel] [PATCH v2 3/5] libavcodec/webp: add support for animated WebP decoding Thilo Borgmann
2023-07-12  0:20   ` James Zern
2023-07-20 23:07     ` Thilo Borgmann
2023-07-06 11:27 ` [FFmpeg-devel] [PATCH v2 4/5] avcodec/webp: make init_canvas_frame static Thilo Borgmann
2023-07-12  0:20   ` James Zern
2023-07-06 11:27 ` [FFmpeg-devel] [PATCH v2 5/5] libavformat/webp: add WebP demuxer Thilo Borgmann
2023-07-06 20:24   ` James Zern
2023-07-06 21:08     ` Thilo Borgmann
2023-07-12  1:22   ` James Zern
2023-07-20 23:07     ` Thilo Borgmann

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='CABWgkXKJpgmd4vjB=iCzSd9TB98ZQmSb-nUhfJ+FSV8Bs_nLSQ@mail.gmail.com' \
    --to=jzern-at-google.com@ffmpeg.org \
    --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