From: Andreas Rheinhardt <andreas.rheinhardt@outlook.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 16:38:44 +0100 Message-ID: <AS8P250MB0744FB72ADDB352D347068D68FBE9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM> (raw) In-Reply-To: <1030e792-3e8e-fdbf-de9b-39cc9cd04faf@vimeo.com> Raphaël Zumer: > On 3/13/23 20:44, Andreas Rheinhardt wrote: >>> diff --git a/libavutil/hdr_dynamic_metadata.h b/libavutil/hdr_dynamic_metadata.h >>> index 2d72de56ae..3d327241c1 100644 >>> --- a/libavutil/hdr_dynamic_metadata.h >>> +++ b/libavutil/hdr_dynamic_metadata.h >>> @@ -340,4 +340,15 @@ AVDynamicHDRPlus *av_dynamic_hdr_plus_alloc(size_t *size); >>> */ >>> AVDynamicHDRPlus *av_dynamic_hdr_plus_create_side_data(AVFrame *frame); >>> >>> +/** >>> + * Parse the user data registered ITU-T T.35 to AVbuffer (AVDynamicHDRPlus). >>> + * @param s A pointer containing the decoded AVDynamicHDRPlus structure. >>> + * @param data The byte array containing the raw ITU-T T.35 data. >>> + * @param size Size of the data array in bytes. >> The implementation of this function uses the GetBit-API which requires >> the buffer to be padded; yet the documentation does not mention this. >> >> 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. >> >> (The GetBit-API btw actually does not need AV_INPUT_BUFFER_PADDING_SIZE >> bytes of padding, but way less (I think 8 bytes or so). I don't really >> like using AV_INPUT_BUFFER_PADDING_SIZE here.) > > Hi, > > From get_bits.h (init_get_bits()): "buffer, must be AV_INPUT_BUFFER_PADDING_SIZE bytes larger than the actual read bits". Is this wrong? If so, what is the correct value and is it defined anywhere? What about "other places where one needed a padded buffer" as mentioned in your previous comment? It is overtly pessimistic. In fact, AV_INPUT_BUFFER_PADDING_SIZE has been bumped several times with no changes to the GetBit API. The correct value is not defined anywhere; I'd need to take a closer look at it to find it out. > > Why is copying the buffer to the stack in the parsing function preferable to padding it when serializing? The vast majority of HDR10+ payloads will be well below the max size. > If the parsing function does not require padding, then it can be used with any buffer, not only those created by the serialization function. - Andreas _______________________________________________ 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".
next prev parent reply other threads:[~2023-03-14 15:38 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 [this message] 2023-03-14 23:04 ` Raphaël Zumer
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=AS8P250MB0744FB72ADDB352D347068D68FBE9@AS8P250MB0744.EURP250.PROD.OUTLOOK.COM \ --to=andreas.rheinhardt@outlook.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