From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id 4542948C9D for ; Thu, 23 May 2024 18:42:07 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id ED90568D4AF; Thu, 23 May 2024 21:42:04 +0300 (EEST) Received: from mail-ej1-f53.google.com (mail-ej1-f53.google.com [209.85.218.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D10AB68CF9D for ; Thu, 23 May 2024 21:41:58 +0300 (EEST) Received: by mail-ej1-f53.google.com with SMTP id a640c23a62f3a-a6269ad7db2so861966b.2 for ; Thu, 23 May 2024 11:41:58 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716489718; x=1717094518; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=rpihhLISW6mQU4xRjYbDt+NSZ/sa3pVj4Yyuy3jjQXc=; b=ZBLTB+lR8fzCVfkt6qi81SJbBiOKuy96nutUuflB4GrABHaye1gtp0YFII4DVa60B7 SfeWnIYZVxu7+/KD05ZZAsM3GgdhTZMybUA1QdNRnx+m/4zAfcta5c2Z96qFsTSJcpTc tAAkY14hBxd5IbDyXPNPxaujyyB5WixydPajKeejRo4iDpT0M+/4VYKkDril0Z9wJZYR 56RiIW5PZ5iFW64KaMmAGU2gkA7/kg1fwea7OtBkmVWoigBqIk9McR1aMGZEbJ801m2+ DGESbP/G3Ve1VM1+fvnkMewS84t2eysPbvETcfOS6ZcVSl+cpmk8bSqjQQNc0tsr4yo6 SH0A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716489718; x=1717094518; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=rpihhLISW6mQU4xRjYbDt+NSZ/sa3pVj4Yyuy3jjQXc=; b=smKPxup6Da9Hkdqm67t+KeafTVHfgxToH7mzwdBc9qBxzEcrazesxmvEC19ZpRhwig YEhmmgdWF0GYOBfTCaJMli/uq0jjM7+Tn8wmbVKWcuqyvTD1CygI7li0n6o6C7Ck6sZ1 c0s/SJxM7B2k5VJC5iSc+2Uz7E+gbMyH2CEiQgbaBES58J+pENZLPuWocEiisLwLKghD 4N3x79vw2QU5g3AbH8BuWZGrbN+yJa03pfT3BREiGAFWvt+3ZWxeX6NGaJI9rKHUN8+O eWgZfsV8eURRG5eFeYngvqGj1oaLwbSziIkEpTn1X49aoWG0F2WJaSQESrjRvGo+K711 VuKg== X-Gm-Message-State: AOJu0Yy45rKUh/a+9XtARDyav2/sMuuMnQrxwf32k9UDwS593fhyiNfA YB//DPvIPWigu4DUh/3HeQzzY86GYt6jgyp+pmlrl+3gNXdVqDVCPunVFg== X-Google-Smtp-Source: AGHT+IF/4zcsR/flAi0XheFGTH3axj03xiW4XfpM5AKfjyHzSaTkemcdKlpDAPQZ6Eqtupf9lybFig== X-Received: by 2002:a17:906:d057:b0:a59:a112:add2 with SMTP id a640c23a62f3a-a62651122demr8500566b.69.1716489717815; Thu, 23 May 2024 11:41:57 -0700 (PDT) Received: from [192.168.178.30] (p200300cccf204f00d49273e464cc1dca.dip0.t-ipconnect.de. [2003:cc:cf20:4f00:d492:73e4:64cc:1dca]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5cec3d9b5csm1065904066b.16.2024.05.23.11.41.56 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 May 2024 11:41:57 -0700 (PDT) From: epirat07@gmail.com To: FFmpeg development discussions and patches Date: Thu, 23 May 2024 20:41:56 +0200 X-Mailer: MailMate (1.14r6022) Message-ID: <4FD87372-BB7E-4B74-B639-7322AFD73D47@gmail.com> In-Reply-To: References: <0112D1C4-AAE8-4CE4-83B5-3416DC6B0DDD@me.com> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH v2] avutil/hwcontext_videotoolbox: Set proper CVBuffer colorspace X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: On 23 May 2024, at 18:05, Zhao Zhili wrote: >> On May 21, 2024, at 09:56, Gnattu OC via ffmpeg-devel wrote: >> >>> >>> On May 20, 2024, at 09:12, Marvin Scholz 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. > > I will just remove the log message and apply the patch this week if no objection. > I will do some more tests, if you want apply with the log message removed and I will do a follow up patch if I find another solution. >> >>> + >>> + 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". > > _______________________________________________ > 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".