From: Soft Works <softworkz@hotmail.com> To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org> Subject: [FFmpeg-devel] [RFC] Bug in colorspace.c Date: Tue, 28 Jun 2022 21:38:42 +0000 Message-ID: <DM8P223MB0365773FC9287BD33B998B12BAB89@DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM> (raw) Hi, in colorspace.c, there are two functions with contradicting behavior regarding reading/writing the max_luminance value from/to AVMasteringDisplayMetadata. The code seems to be unchanged since 3 years: 1. ff_determine_signal_peak() sd = av_frame_get_side_data(in, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); if (!peak && sd) { AVMasteringDisplayMetadata *metadata = (AVMasteringDisplayMetadata *)sd->data; if (metadata->has_luminance) peak = av_q2d(metadata->max_luminance) / REFERENCE_WHITE; } 2. ff_update_hdr_metadata() sd = av_frame_get_side_data(in, AV_FRAME_DATA_MASTERING_DISPLAY_METADATA); if (sd) { AVMasteringDisplayMetadata *metadata = (AVMasteringDisplayMetadata *)sd->data; if (metadata->has_luminance) metadata->max_luminance = av_d2q(peak * REFERENCE_WHITE, 10000); } The latter function writes the value as an AVRational with a denominator of 10000, but the former function doesn't multiply the value by 10000. So - both cannot be right. In fact, there seems to be some confusion about the base/range of this value. I had found contradicting code somewhere in libva or Intel Media Driver code a while ago, and I have also seen videos with both "kinds" of values. This might be a chicken-egg issue, though: maybe those other files I've seen were created by ffmpeg and subject to this bug. I'm not sure.. As I needed a practical rather than an academical solution, I ended up using a check on the value range to determine whether to multiply by 10000 or not (function 1). I won't submit this as a patch because somebody would shout out "hack" anyway, while I see it more as an adaption to reality :-) Anyway, the second function for writing the value should definitely do it in the right way - unfortunately it can't do without a sane input parameter, which in turn can only be ensured with said "hack". For now, I just want to point at the problem as I don't have a clean solution to offer, but I'd be interested in others' thoughts. Best wishes, softworkz _______________________________________________ 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 reply other threads:[~2022-06-28 21:38 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2022-06-28 21:38 Soft Works [this message] 2022-06-29 4:34 ` Hendrik Leppkes 2022-06-29 7:50 ` Hendrik Leppkes 2022-06-29 21:38 ` Soft Works
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=DM8P223MB0365773FC9287BD33B998B12BAB89@DM8P223MB0365.NAMP223.PROD.OUTLOOK.COM \ --to=softworkz@hotmail.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