From: Niklas Haas <ffmpeg@haasn.xyz>
To: ffmpeg-devel@ffmpeg.org
Subject: Re: [FFmpeg-devel] [PATCH v2] avcodec/pngenc: support writing iCCP chunks
Date: Sat, 12 Mar 2022 12:10:47 +0100
Message-ID: <20220312121047.GB102875@haasn.xyz> (raw)
In-Reply-To: <AM7PR03MB6660DE23419DE359048AB3F78F0C9@AM7PR03MB6660.eurprd03.prod.outlook.com>
On Fri, 11 Mar 2022 12:18:13 +0100 Andreas Rheinhardt <andreas.rheinhardt@outlook.com> wrote:
> 2. Using an AVBPrint with its dynamic reallocations is probably not good
> here at all: It is easy to get a good upper bound via deflateBound()
> which allows to omit the reallocations/the loop. (I should probably have
> applied
So, I rewrote the code to only use a single av_bprint_get_buffer() call,
rather than looping through it. This is semantically identical to doing
an extra malloc(), but also allows the 1K buffer on the stack.
I did a survey of all (compressed) iCCP chunks found in PNG files in my
"collection" (home folder..), and this is what I found:
Min. 1st Qu. Median Mean 3rd Qu. Max.
275 2619 2639 3000 2639 14813
Only roughly 11.57% of files are below the "1K" cutoff threshold for
using the small buffer optimization.
In light of this, I don't think the 1K optimization is hugely important.
But, using the AVBPrint does make the code slightly easier to work with
in my eyes.
The cleanest alternative, I think, would be to store the deflateBound
on the ICC profile somewhere in the PNGEncContext, and then use
av_malloc to get a temporary buffer inside `png_get_iccp`. It's of
course possible to somehow write directly to the output packet buffer,
but I don't think avoiding a ~4K malloc/memcpy is worth the hassle and
bug risk of sidestepping png_write_chunk in favor of some custom chunk
writing code.
Thoughts?
_______________________________________________
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:[~2022-03-12 11:10 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-11 10:14 [FFmpeg-devel] [PATCH] " Niklas Haas
2022-03-11 10:17 ` [FFmpeg-devel] [PATCH v2] " Niklas Haas
2022-03-11 10:21 ` Niklas Haas
2022-03-11 11:05 ` Andreas Rheinhardt
2022-03-11 13:11 ` Niklas Haas Haas
2022-03-11 11:18 ` Andreas Rheinhardt
2022-03-11 13:37 ` Niklas Haas
2022-03-12 11:10 ` Niklas Haas [this message]
2022-03-12 12:04 ` [FFmpeg-devel] [PATCH v3] " Niklas Haas
2022-03-15 6:44 ` Andreas Rheinhardt
2022-03-15 11:10 ` [FFmpeg-devel] [PATCH v4] " Niklas Haas
2022-03-15 11:34 ` [FFmpeg-devel] [PATCH v5] " Niklas Haas
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=20220312121047.GB102875@haasn.xyz \
--to=ffmpeg@haasn.xyz \
--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