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 090784ACFB for ; Mon, 20 May 2024 01:12:27 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 7BFF768CFFE; Mon, 20 May 2024 04:12:26 +0300 (EEST) Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3019068C73D for ; Mon, 20 May 2024 04:12:20 +0300 (EEST) Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-572e48f91e9so7512273a12.0 for ; Sun, 19 May 2024 18:12:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716167539; x=1716772339; darn=ffmpeg.org; h=subject:date:from:to:message-id:from:to:cc:subject:date:message-id :reply-to; bh=ttbkVFqlgD/RG0re9BkIJje5GiYiJJW11dmCi1IcAb0=; b=JotRPbiWxUSF40yIqpKVMpzg+h85mSN9LRs/H1lRqr/aOazL6GqXqnpvBjD6nEd1PM +gQpSKeohmpc8JnHbhANuRVa+kL5sctLEvw7EP8lhiy+wuhzK6FBMkx13Bux1BNOqi2+ IkVkiFcRVBkgv5yLvCkAT3XS9dl5jLipwrbE5IoenKgqRuBX9ZbTjW0Ed+ce/macqe6I p2SLVsg851pJ3uKj+5SxURFdBCBTDR8VeKPIbnpM9kb1cRHGhiCtQOdKewjmIQQbRW5y rqmzAgv/xV7SFKstjIO4hCSxUlumhj4zWL4YylAuNV0HWC+iEEjU8eNO8YHs/mH87eDG MKhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716167539; x=1716772339; h=subject:date:from:to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ttbkVFqlgD/RG0re9BkIJje5GiYiJJW11dmCi1IcAb0=; b=RqvwV+m62drI6rYMGjJjgGlGy8cz2Jf2Fw5t/55XCBmcKPwCZoe+CSeHTk2BYS7uUp XrofKdie6HEWKzfhUUod6gx4GhCsq3Qlqq3IHVbGhhFdloD1GCIwmsqyYhkX2NhPZ5Zx S6LYBdxpm6wdEMzy8n14HxKzS662HkRGeATN8k4o73EVJ7doW9csrVFZdlL4rqfpdTzo 38fw05TOst3wELV12Rrcf12glUPQqEWIGU6DlpKZtPw6MGfg3Z6r+N40XyKZtGwhniWT YKuDMt3dwM2srGJvQ0n3MSqjJWbIQiTde984n1a4TeUfEGsf5ylJmAEK/Rsfh72hZp74 is/Q== X-Gm-Message-State: AOJu0YzreQXvEMFIOIeBbilWclNvAK08pjl1jrWebmKE7ZI71feoLeZe ZPiAjCOP+esYytnZdm1JhkcJslWjNmLps2/H5GtYFblWpe99m/IS+1gePA== X-Google-Smtp-Source: AGHT+IFNmem1UOyeSIRNVHsvOHwg56ZF/kAwO7TEvyBo2rpqfOAv+bKj+rRGZtTF0mvc0os2F16TPg== X-Received: by 2002:a17:907:7fa4:b0:a59:9fc8:38c2 with SMTP id a640c23a62f3a-a5a2d58550dmr2131481666b.31.1716167538839; Sun, 19 May 2024 18:12:18 -0700 (PDT) Received: from localhost (dynamic-2a01-0c23-6407-8e00-d884-7274-911c-dd1d.c23.pool.telefonica.de. [2a01:c23:6407:8e00:d884:7274:911c:dd1d]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a5cdd7f8ea1sm556979566b.109.2024.05.19.18.12.17 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 19 May 2024 18:12:18 -0700 (PDT) Message-Id: To: From: "Marvin Scholz" Date: Mon, 20 May 2024 03:12:01 +0200 Subject: [FFmpeg-devel] [PATCH] avutil/hwcontext: 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 MIME-Version: 1.0 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: 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"); + + 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".