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 C99AA49839 for ; Mon, 20 May 2024 15:43:59 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id CC97268D15B; Mon, 20 May 2024 18:43:56 +0300 (EEST) Received: from mail-lj1-f169.google.com (mail-lj1-f169.google.com [209.85.208.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E001268CE20 for ; Mon, 20 May 2024 18:43:49 +0300 (EEST) Received: by mail-lj1-f169.google.com with SMTP id 38308e7fff4ca-2e1fa1f1d9bso52128251fa.0 for ; Mon, 20 May 2024 08:43:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1716219829; x=1716824629; darn=ffmpeg.org; h=subject:date:from:to:message-id:from:to:cc:subject:date:message-id :reply-to; bh=ttbkVFqlgD/RG0re9BkIJje5GiYiJJW11dmCi1IcAb0=; b=LcAKbQjT0zzLS6QHaQZ5mZdZjdBWak10MJVLXmywZ2UnkdUTr/teCN1i8GWlKvDa+2 y3UUeacVWwHlwoORmCk7Tn3t/c8WhBa3mhZlUpdWn6GIyZ62NtKNwo0mwn6tQA2ZRS8T C66tiJJfhk1bg8VUzLAMZTO1wdSiAqql2sBjStXXOVeK33yHhUH6+TDf5HwaWppX+oJ4 sQmo+/DOfAgFdLc3PHiP/Kt8jKIHIrZOB5SoQmGBSoE4PLe6Xp8/cRl2wdLJeIuRJegl MGTeh3oFUvg7/1yI+yfanxTUjl7nSQrtOLKa34G9NxZ6hPn5I5Pg/Eq1XQQzF1xMDvTb 2BuQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1716219829; x=1716824629; h=subject:date:from:to:message-id:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=ttbkVFqlgD/RG0re9BkIJje5GiYiJJW11dmCi1IcAb0=; b=nN9CNyEbRMO51BqMcZGYx+vMKNADUw/BJQom6VZM7m/TvvkCh9lQO0EEWOF4ld3ADL CMjXLM6+Os3TH0mnqteB7Y+A7f9tf50xuYNBaOx88Kw8YsyP7EiJMJyH0RJMopPtJDPW FbQfN4LHf1oE5v5I423M+F+nOpoDEws8wfF7FBJFHpVp16yH72hoB1TTXyskytDOSGE3 fg7XBV9c4LusBQmhqCBYG78Mw/ed9x7ORr9naukcUMvRu9Vp1x9Sn++1Rpnq1IcgRffm XD6S40F+OS48lSrVPYQrMQNhlsdTUIsrC0+dYErcg3pa/sFdVQdeAY9UR4P3vZhzDKzZ 32cQ== X-Gm-Message-State: AOJu0YywK6eM961A0TPvZI/TTL/+6ivM3taDpurPvYIvQCSvKsM6OfLA jkXA0IsYkZ5IyrcfnoAyadDaqrzxq7La6hufDDuJUKr7yDhCO7UtOfGrTw== X-Google-Smtp-Source: AGHT+IFP7YLlUKpdqWh7WVqKUvvc6q3uABHKEejDyDjoqJyPog+zhMStsP8x6Gens7WY45prmh9UQA== X-Received: by 2002:a2e:681a:0:b0:2e5:67a7:e449 with SMTP id 38308e7fff4ca-2e567a7e8b4mr221958681fa.6.1716219828852; Mon, 20 May 2024 08:43:48 -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-a5a179c7d2bsm1457444466b.120.2024.05.20.08.43.48 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 20 May 2024 08:43:48 -0700 (PDT) Message-Id: To: From: "Marvin Scholz" Date: Mon, 20 May 2024 03:12:01 +0200 Subject: [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 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".