Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
From: "Raphaël Zumer" <raphael.zumer@vimeo.com>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH v6 1/2] avcodec/avutil: move dynamic HDR10+ metadata parsing to libavutil
Date: Tue, 14 Mar 2023 19:04:15 -0400
Message-ID: <2fc25cbf-a823-2c39-3b8d-17cfc1691f75@vimeo.com> (raw)
In-Reply-To: <AS8P250MB07447454F9589F99E31A59A18FBE9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM>

On 3/13/23 20:44, Andreas Rheinhardt wrote:
> Looking at the calculation in av_dynamic_hdr_plus_to_t35(), it seems
> that the maximum bitlength of a valid ITU-T T.35 payload is
> 48+2×937+27+1+10+25×25×4+3×82+(3×15×24)+(1+10+25×25×4+3×1)+(3×(28+15×10))+3+3×6
> = 8855 bits (please double-check this). This means we can just copy that
> much into a padded buffer on the stack and ignore the padding. We may
> then remove the padding from the serialization function, too.

I went over the calculations again and found a couple of places where size was overestimated due to fields that can fit larger values than their specified maximum. 937 also seems like a typo on my part (unsure how that happened, maybe multiplied instead of added some number), it should be 153. I re-ran the numbers for everything and rewrote/expanded the size calculation code somewhat to make reading alongside the spec or block comment easier.

I also removed another 40 bits from the header to match the parsing function, which begins parsing at the application mode, rather than at the terminal provider code. That means we exclude 48 bits in total from the header, and the calculation should be as follows:

8 + 2 +
2 * 153 +
27 +
1 + 10 + 25 * 25 * 4 +
3 * (72 + 15 * 24 + 10) +
1 + 10 + 25 * 25 * 4 +
3 * (1 + 28 + 15 * 10) +
3 * (1 + 6) =

7249 bits maximum (907 bytes rounded up).

Can we correct the padding amount along with get_bits.h in a separate patch? I would like to avoid scope creep.

Will send a new version with the changes mentioned above. I've tested the round trip (HEVC decode -> parse -> serialize -> HEVC encode).

RZ

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

      parent reply	other threads:[~2023-03-14 23:04 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-13 23:36 Raphaël Zumer
2023-03-14  0:44 ` Andreas Rheinhardt
2023-03-14 15:30   ` Raphaël Zumer
2023-03-14 15:38     ` Andreas Rheinhardt
2023-03-14 23:04   ` Raphaël Zumer [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=2fc25cbf-a823-2c39-3b8d-17cfc1691f75@vimeo.com \
    --to=raphael.zumer@vimeo.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