Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: Mark Thompson <sw@jkqxz.net>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH 2/2] avcodec/cbs_av1: also copy the last frame header's decomposed content when parsing redundant frame headers
Date: Sat, 30 Apr 2022 19:50:20 +0100
Message-ID: <433be244-75d7-93c4-d741-7ac48d16e2a6@jkqxz.net> (raw)
In-Reply-To: <20220328010851.1193-2-jamrial@gmail.com>

On 28/03/2022 02:08, James Almer wrote:
> This prevents CBS from propagating zeroed AV1RawFrameHeader units in reading
> scenarios.
> Writing scenarios remain unaffected as the content of these units is not used
> to assemble the bitstream.
> 
> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>   libavcodec/cbs_av1.c                 | 11 +++++++++++
>   libavcodec/cbs_av1.h                 |  2 ++
>   libavcodec/cbs_av1_syntax_template.c |  6 ++++++
>   3 files changed, 19 insertions(+)

I took me a while to work out what the issue was here, maybe make it a bit clearer that the problematic thing is that decomposed unit content for the redundant frame header OBU isn't filled if there was a frame header (in which case that content is never used, but someone could technically look at it if they wanted and observe that it is wrong).

> diff --git a/libavcodec/cbs_av1.c b/libavcodec/cbs_av1.c
> index ecd775ea2a..6cb832210c 100644
> --- a/libavcodec/cbs_av1.c
> +++ b/libavcodec/cbs_av1.c
> @@ -969,6 +969,15 @@ static int cbs_av1_read_unit(CodedBitstreamContext *ctx,
>                                                   unit->data_ref);
>               if (err < 0)
>                   return err;
> +
> +            if (priv->frame_header)
> +                break;
> +
> +            av_buffer_unref(&priv->frame_header_ref);
> +            priv->frame_header_ref = av_buffer_ref(unit->content_ref);
> +            if (!priv->frame_header_ref)
> +                return AVERROR(ENOMEM);
> +            priv->frame_header = &obu->obu.frame_header;
>           }
>           break;
>       case AV1_OBU_TILE_GROUP:
> @@ -1251,6 +1260,7 @@ static void cbs_av1_flush(CodedBitstreamContext *ctx)
>   
>       av_buffer_unref(&priv->frame_header_data_ref);
>       priv->sequence_header = NULL;
> +    priv->frame_header = NULL;
>       priv->frame_header_data = NULL;
>   
>       memset(priv->ref, 0, sizeof(priv->ref));
> @@ -1264,6 +1274,7 @@ static void cbs_av1_close(CodedBitstreamContext *ctx)
>       CodedBitstreamAV1Context *priv = ctx->priv_data;
>   
>       av_buffer_unref(&priv->sequence_header_ref);
> +    av_buffer_unref(&priv->frame_header_ref);
>       av_buffer_unref(&priv->frame_header_data_ref);
>   }
>   
> diff --git a/libavcodec/cbs_av1.h b/libavcodec/cbs_av1.h
> index d4776b7a30..138b273470 100644
> --- a/libavcodec/cbs_av1.h
> +++ b/libavcodec/cbs_av1.h
> @@ -431,6 +431,8 @@ typedef struct CodedBitstreamAV1Context {
>       AVBufferRef          *sequence_header_ref;
>   
>       int     seen_frame_header;
> +    AVBufferRef *frame_header_ref;
> +    AV1RawFrameHeader *frame_header;
>       AVBufferRef *frame_header_data_ref;
>       uint8_t     *frame_header_data;
>       size_t       frame_header_data_size;
> diff --git a/libavcodec/cbs_av1_syntax_template.c b/libavcodec/cbs_av1_syntax_template.c
> index bd50cfbe38..aadfa34b3c 100644
> --- a/libavcodec/cbs_av1_syntax_template.c
> +++ b/libavcodec/cbs_av1_syntax_template.c
> @@ -1708,6 +1708,11 @@ static int FUNC(frame_header_obu)(CodedBitstreamContext *ctx, RWContext *rw,
>                   xf(b, frame_header_copy[i],
>                      val, val, val, 1, i / 8);
>               }
> +
> +#ifdef READ
> +            av_assert0(priv->frame_header_ref && priv->frame_header);
> +            memcpy(current, priv->frame_header, sizeof(*current));
> +#endif
>           }
>       } else {
>           if (redundant)
> @@ -1730,6 +1735,7 @@ static int FUNC(frame_header_obu)(CodedBitstreamContext *ctx, RWContext *rw,
>           } else {
>               priv->seen_frame_header = 1;
>   
> +            priv->frame_header = NULL;
>               av_buffer_unref(&priv->frame_header_data_ref);
>   
>   #ifdef READ

LGTM in any case.  (Previous patch fine too given this one.)

- Mark
_______________________________________________
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-04-30 18:50 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-03-28  1:08 [FFmpeg-devel] [PATCH 1/2] avcodec/cbs_av1: rename the private frame_header fields to frame_header_data James Almer
2022-03-28  1:08 ` [FFmpeg-devel] [PATCH 2/2] avcodec/cbs_av1: also copy the last frame header's decomposed content when parsing redundant frame headers James Almer
2022-04-30 18:50   ` Mark Thompson [this message]

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=433be244-75d7-93c4-d741-7ac48d16e2a6@jkqxz.net \
    --to=sw@jkqxz.net \
    --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