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 2/2] avutil: add HDR10+ dynamic metadata serialization function
Date: Thu, 2 Mar 2023 15:45:10 -0500
Message-ID: <95d93c03-9e3a-d478-955c-428bf0d718dd@vimeo.com> (raw)
In-Reply-To: <c7676f12-e8b1-0cda-637d-28aaa73337ed@gmail.com>

On 3/2/23 15:24, Leo Izen wrote:
> On 3/2/23 14:25, Raphaël Zumer wrote:
>> Signed-off-by: Raphaël Zumer <rzumer@tebako.net>
>> ---
>>   libavutil/hdr_dynamic_metadata.c | 146 +++++++++++++++++++++++++++++++
>>   libavutil/hdr_dynamic_metadata.h |  11 +++
>>   libavutil/version.h              |   2 +-
>>   3 files changed, 158 insertions(+), 1 deletion(-)
>>
> Why not put this in avcodec/dynamic_hdr10_plus.c? You reference 
> put_bits.h which is in avcodec, so that can possibly be an issue, even 
> though it is inlined (i.e. it sends the wrong message since avutil is 
> supposed to not depend on avcodec).

I agree it is somewhat awkward to introduce a circular dependency (albeit to header-only files). On the other hand, I think those functions make more sense in libavutil than libavcodec, and it improves readability by not splitting files that are logically connected between libraries. If there is a general consensus that it is better to keep them in libavcodec, I don't mind reverting that change, or moving get_bits and put_bits to libavutil if that is doable.

>> diff --git a/libavutil/hdr_dynamic_metadata.c b/libavutil/hdr_dynamic_metadata.c
>> index 98f399b032..39a7886a2e 100644
>> --- a/libavutil/hdr_dynamic_metadata.c
>> +++ b/libavutil/hdr_dynamic_metadata.c
>> @@ -225,3 +225,149 @@ int av_dynamic_hdr_plus_from_t35(AVDynamicHDRPlus *s, const uint8_t *data,
>>   
>>       return 0;
>>   }
>> +
>> +AVBufferRef *av_dynamic_hdr_plus_to_t35(AVDynamicHDRPlus *s)
>> +{
> av_dynamic_hdr_plus_from_t35 returns an int status code and takes a 
> pointer as an argument, is there any particular reason you didn't mirror 
> user interface here?

Mainly the added complexity of buffer size calculation. I think it would be doable by adding an additional function such as av_dynamic_hdr_plus_to_t35_size() that would return the serialized buffer size, which could be then used by the user to allocate a buffer to be written by av_dynamic_hdr_plus_to_t35(). But adding an additional function just to make the function signatures consistent feels contrived to me, and there aren't several errors that could happen in that function that would need to be disambiguated by the user.

>> +    AVBufferRef *buf;
>> +    size_t size_bits, size_bytes;
>> +    PutBitContext pbc, *pb = &pbc;
>> +
>> +    if (!s)
>> +        return NULL;
>> +
>> +    // Buffer size per CTA-861-H p.253-254:
>> +    size_bits =
>> +    // 56 bits for the header, minus 8-bit excluded country code
>> +    48 +
>> +    // 2 bits for num_windows
>> +    2 +
>> +    // 937 bits for window geometry for each window above 1
>> +    FFMAX((s->num_windows - 1), 0) * 937 +
>> +    // 27 bits for targeted_system_display_maximum_luminance
>> +    27 +
>> +    // 1-3855 bits for targeted system display peak luminance information
>> +    1 + (s->targeted_system_display_actual_peak_luminance_flag ? 10 +
>> +        s->num_rows_targeted_system_display_actual_peak_luminance *
>> +        s->num_cols_targeted_system_display_actual_peak_luminance * 4 : 0) +
>> +    // 0-442 bits for intra-window pixel distribution information
>> +    s->num_windows * 82;
> This sequence above is difficult to read due to the inline // comments. 
> It should be more readable to just have the entire expression be 
> contiguous with a /* */ multiline block comment above it explaining each 
> item.
>> +    for (int w = 0; w < s->num_windows; w++) {
>> +        size_bits += s->params[w].num_distribution_maxrgb_percentiles * 24;
>> +    }
> Likewise, another code style issue, don't use {} to enclose a single 
> line unless it's unavoidable. This occurs in several places in this patch.

OK, will correct.


Thanks
Raphaël Zumer

_______________________________________________
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-02 20:45 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-02 19:25 Raphaël Zumer
2023-03-02 20:24 ` Leo Izen
2023-03-02 20:37   ` Derek Buitenhuis
2023-03-02 20:45   ` Raphaël Zumer [this message]
  -- strict thread matches above, loose matches on Subject: below --
2023-03-02 21:43 Raphaël Zumer
2023-03-09 14:18 ` Raphaël Zumer
2023-03-12 15:21   ` James Almer
2023-03-13 22:25     ` Andreas Rheinhardt
2023-03-13 22:32       ` James Almer
2023-03-12 16:25 ` Zhao Zhili
2023-03-12 19:48 ` Anton Khirnov
2023-03-12 21:50   ` Raphaël Zumer
2023-03-12 21:52     ` James Almer
2023-03-12 21:56       ` Raphaël Zumer
2023-03-13 13:36     ` Anton Khirnov
2023-02-27 17:34 Raphaël Zumer
2023-03-02 18:33 ` quietvoid
2023-03-02 18:57   ` Raphaël Zumer
2023-03-02 18:57   ` James Almer
2023-03-02 19:14     ` Raphaël Zumer
     [not found] <62782188-8dba-b4f0-6e54-571149f09040@tebako.net>
2023-02-27 16:54 ` 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=95d93c03-9e3a-d478-955c-428bf0d718dd@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