From: Gnattu OC via ffmpeg-devel <ffmpeg-devel@ffmpeg.org>
To: FFmpeg development discussions and patches <ffmpeg-devel@ffmpeg.org>
Cc: Gnattu OC <gnattuoc@me.com>
Subject: Re: [FFmpeg-devel] [PATCH v2] avutil/hwcontext_videotoolbox: Set proper CVBuffer colorspace
Date: Tue, 21 May 2024 09:56:14 +0800
Message-ID: <0112D1C4-AAE8-4CE4-83B5-3416DC6B0DDD@me.com> (raw)
In-Reply-To: <D1EL5K8NDOCG.2FBQMLD51E4CM@gmail.com>
> On May 20, 2024, at 09:12, Marvin Scholz <epirat07@gmail.com> wrote:
>
> Fix #10884
> ---
> libavutil/hwcontext_videotoolbox.c | 54 +++++++++++++++++++++---------
> 1 file changed, 38 insertions(+), 16 deletions(-)
>
> diff --git a/libavutil/hwcontext_videotoolbox.c b/libavutil/hwcontext_videotoolbox.c
> index 9f82b104c3..4a35bfc7ff 100644
> --- a/libavutil/hwcontext_videotoolbox.c
> +++ b/libavutil/hwcontext_videotoolbox.c
> @@ -530,6 +530,8 @@ CFStringRef av_map_videotoolbox_color_trc_from_av(enum AVColorTransferCharacteri
> static int vt_pixbuf_set_colorspace(void *log_ctx,
> CVPixelBufferRef pixbuf, const AVFrame *src)
> {
> + CGColorSpaceRef colorspace = NULL;
> + CFMutableDictionaryRef attachments = NULL;
> CFStringRef colormatrix = NULL, colorpri = NULL, colortrc = NULL;
> Float32 gamma = 0;
>
> @@ -550,37 +552,57 @@ static int vt_pixbuf_set_colorspace(void *log_ctx,
> else if (src->color_trc == AVCOL_TRC_GAMMA28)
> gamma = 2.8;
>
> + attachments = CFDictionaryCreateMutable(NULL, 0,
> + &kCFTypeDictionaryKeyCallBacks,
> + &kCFTypeDictionaryValueCallBacks);
> + if (!attachments)
> + return AVERROR(ENOMEM);
> +
> if (colormatrix) {
> - CVBufferSetAttachment(
> - pixbuf,
> + CFDictionarySetValue(
> + attachments,
> kCVImageBufferYCbCrMatrixKey,
> - colormatrix,
> - kCVAttachmentMode_ShouldPropagate);
> + colormatrix);
> }
> if (colorpri) {
> - CVBufferSetAttachment(
> - pixbuf,
> + CFDictionarySetValue(
> + attachments,
> kCVImageBufferColorPrimariesKey,
> - colorpri,
> - kCVAttachmentMode_ShouldPropagate);
> + colorpri);
> }
> if (colortrc) {
> - CVBufferSetAttachment(
> - pixbuf,
> + CFDictionarySetValue(
> + attachments,
> kCVImageBufferTransferFunctionKey,
> - colortrc,
> - kCVAttachmentMode_ShouldPropagate);
> + colortrc);
> }
> if (gamma != 0) {
> CFNumberRef gamma_level = CFNumberCreate(NULL, kCFNumberFloat32Type, &gamma);
> - CVBufferSetAttachment(
> - pixbuf,
> + CFDictionarySetValue(
> + attachments,
> kCVImageBufferGammaLevelKey,
> - gamma_level,
> - kCVAttachmentMode_ShouldPropagate);
> + gamma_level);
> CFRelease(gamma_level);
> }
>
> + if (__builtin_available(macOS 10.8, iOS 10, *))
> + colorspace = CVImageBufferCreateColorSpaceFromAttachments(attachments);
> +
> + if (colorspace) {
> + CFDictionarySetValue(
> + attachments,
> + kCVImageBufferCGColorSpaceKey,
> + colorspace);
> + CFRelease(colorspace);
> + } else
> + av_log(log_ctx, AV_LOG_WARNING, "Unable to set proper colorspace for the CVImageBuffer.\n");
This will spam the console on SDR video inputs because they have nothing to be set as the attachment and the colorspace creation will always fail and return nil.
> +
> + CVBufferSetAttachments(
> + pixbuf,
> + attachments,
> + kCVAttachmentMode_ShouldPropagate);
> + CFRelease(attachments);
> +
> return 0;
> }
>
>
> base-commit: 463c573e6b6489c588bee90124d5cf92db8ccaaa
> --
> 2.39.3 (Apple Git-145)
> _______________________________________________
> 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".
_______________________________________________
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:[~2024-05-21 1:56 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-05-20 1:12 Marvin Scholz
2024-05-21 1:56 ` Gnattu OC via ffmpeg-devel [this message]
2024-05-23 16:05 ` Zhao Zhili
2024-05-23 18:41 ` epirat07
2024-05-24 2:27 ` Zhao Zhili
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=0112D1C4-AAE8-4CE4-83B5-3416DC6B0DDD@me.com \
--to=ffmpeg-devel@ffmpeg.org \
--cc=gnattuoc@me.com \
/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