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 B23964B298 for ; Thu, 1 Aug 2024 22:48:15 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 53AB468D8D7; Fri, 2 Aug 2024 01:48:12 +0300 (EEST) Received: from mail-lf1-f41.google.com (mail-lf1-f41.google.com [209.85.167.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6EAAB68D49F for ; Fri, 2 Aug 2024 01:48:05 +0300 (EEST) Received: by mail-lf1-f41.google.com with SMTP id 2adb3069b0e04-52f025ab3a7so11012451e87.2 for ; Thu, 01 Aug 2024 15:48:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1722552484; x=1723157284; darn=ffmpeg.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=4mfBu9YLP47rcvjuW3hY5t7Zyu6lt6h+0AzZboMbMQU=; b=EROtOdMUXg8XamSYJJ1xH4dDFB3LATWsL+XOv+ZpGzUoz3HHFSi1jDlEjLIQOKwuEC bJ7lGHL3Fb1USlJySu9/11+uXytZmLEv7yv55Emrevm0CUB+L+GYm7cbolF0gsk3Eps5 YAB2/4b9Wr7ycVA4TFC2lpyGfzGLkWScPNCMmCKpR8aXPCh4TItclKMribr9iNyeVrMq NKRPJ5yAQS9RKhxbRahO3Y648QP8hiQ/Jkr9DaU6Ptb1m5vLuWXrmzc0rUzoJPHxgf6/ ZS2BxaqFO+eTyIGGmf7hLmF8D8N3jmD2Pofxxy0mgm8aSomdT/GwY6yhN4xMdSLdOPOA Y6Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1722552484; x=1723157284; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=4mfBu9YLP47rcvjuW3hY5t7Zyu6lt6h+0AzZboMbMQU=; b=eM1FaE92Ml7lyCfy4vHGPBi8c4HvUcxDcp/Z0yrzu6zjohQmsX7wJWVdReTToCiwI0 EkQ3sNp7tRs7ta1VdcPRSk2R554+yjE+tdmJHth7RTTMs5LQ2j4niOBBq6XEl60jYxVE nzhTaiO+sCLDp4csqB4SFSdzUdpbCLE2OPGIHutAFJvlsL5dPns7z7ZMA2lg5O3spH6M jW8+vLIHzzsYS3nGjnBCaZmPCZeFw/9L8tI+Nl3flo8TcxGr+DtS+g957lq8+hxRLPAk s44yS2EuN4z81v7DaKP6qg+s93F3OLmHHL184m4QdYgbrNWpUfr1UrB2fUUlyyORV307 /oRw== X-Gm-Message-State: AOJu0YxZKTSaQfwTQeqqWQ5gm5RZDQ70NICXmrJ7MtevtJjjWK4CmcUT I9XHQBlfP+p8ANOHZZF2lkqeyhiQToNj+GZGmric8geHrWn7gFxTCcTTIQ== X-Google-Smtp-Source: AGHT+IGCn6+XGiqxUj7KBDoGzrNtTYoFdQTQD5Iuws4vSZGSNdcFMXPKH9rquVMGn5+Oo2TOZVqKfw== X-Received: by 2002:a05:6512:128b:b0:52f:214:79b0 with SMTP id 2adb3069b0e04-530bb391bf7mr856913e87.13.1722552483973; Thu, 01 Aug 2024 15:48:03 -0700 (PDT) Received: from [192.168.178.30] (p200300cccf117800ad75327255682005.dip0.t-ipconnect.de. [2003:cc:cf11:7800:ad75:3272:5568:2005]) by smtp.gmail.com with ESMTPSA id a640c23a62f3a-a7dc9d88650sm27801466b.152.2024.08.01.15.48.03 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Thu, 01 Aug 2024 15:48:03 -0700 (PDT) From: epirat07@gmail.com To: FFmpeg development discussions and patches Date: Fri, 02 Aug 2024 00:47:54 +0200 X-Mailer: MailMate (1.14r6022) Message-ID: In-Reply-To: <20240801222526.69641-1-gnattuoc@me.com> References: <20240801222526.69641-1-gnattuoc@me.com> MIME-Version: 1.0 Subject: Re: [FFmpeg-devel] [PATCH] avutil/hwcontext_videotoolbox: Allocate attachments dictionary 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 Cc: gnattu 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 2 Aug 2024, at 0:25, gnattu via ffmpeg-devel wrote: > From: Gnattu OC > > Allocate a dedicated attachments dictionary instead of trying to get > one from the pixel buffer. The attachments got from the pixel buffer > confuses the CVImageBufferCreateColorSpaceFromAttachments method and > will make it to output a wrong colorspace that causes problem like > #10884. Thanks for the patch. Looks fine in principle given this was essentially how I did it before. Did you check if maybe removing the kCVImageBufferCGColorSpaceKey by doing CVBufferRemoveAttachment(pixbuf, kCVImageBufferCGColorSpaceKey); before calling CVImageBufferCreateColorSpaceFromAttachments() is enough to make it work with the attachments obtained from the pixel buffer? > > Signed-off-by: gnattu > --- > libavutil/hwcontext_videotoolbox.c | 35 ++++++++++++++++++------------ > 1 file changed, 21 insertions(+), 14 deletions(-) > > diff --git a/libavutil/hwcontext_videotoolbox.c b/libavutil/hwcontext_videotoolbox.c > index 1794459943..dda6ada1af 100644 > --- a/libavutil/hwcontext_videotoolbox.c > +++ b/libavutil/hwcontext_videotoolbox.c > @@ -569,11 +569,19 @@ static int vt_pixbuf_set_colorspace(void *log_ctx, > CGColorSpaceRef colorspace = NULL; > CFStringRef colormatrix = NULL, colorpri = NULL, colortrc = NULL; > Float32 gamma = 0; > + CFMutableDictionaryRef attachments = NULL; > + attachments = CFDictionaryCreateMutable(NULL, 0, > + &kCFTypeDictionaryKeyCallBacks, > + &kCFTypeDictionaryValueCallBacks); > + if (!attachments) > + return AVERROR(ENOMEM); > > colormatrix = av_map_videotoolbox_color_matrix_from_av(src->colorspace); > - if (colormatrix) > + if (colormatrix) { > + CFDictionarySetValue(attachments, kCVImageBufferYCbCrMatrixKey, colormatrix); > CVBufferSetAttachment(pixbuf, kCVImageBufferYCbCrMatrixKey, > - colormatrix, kCVAttachmentMode_ShouldPropagate); > + colormatrix, kCVAttachmentMode_ShouldPropagate); > + } > else { > CVBufferRemoveAttachment(pixbuf, kCVImageBufferYCbCrMatrixKey); > if (src->colorspace != AVCOL_SPC_UNSPECIFIED) > @@ -583,9 +591,11 @@ static int vt_pixbuf_set_colorspace(void *log_ctx, > } > > colorpri = av_map_videotoolbox_color_primaries_from_av(src->color_primaries); > - if (colorpri) > + if (colorpri) { > + CFDictionarySetValue(attachments, kCVImageBufferColorPrimariesKey, colorpri); > CVBufferSetAttachment(pixbuf, kCVImageBufferColorPrimariesKey, > - colorpri, kCVAttachmentMode_ShouldPropagate); > + colorpri, kCVAttachmentMode_ShouldPropagate); > + } > else { > CVBufferRemoveAttachment(pixbuf, kCVImageBufferColorPrimariesKey); > if (src->color_primaries != AVCOL_SPC_UNSPECIFIED) > @@ -595,9 +605,11 @@ static int vt_pixbuf_set_colorspace(void *log_ctx, > } > > colortrc = av_map_videotoolbox_color_trc_from_av(src->color_trc); > - if (colortrc) > + if (colortrc) { > + CFDictionarySetValue(attachments, kCVImageBufferTransferFunctionKey, colortrc); > CVBufferSetAttachment(pixbuf, kCVImageBufferTransferFunctionKey, > - colorpri, kCVAttachmentMode_ShouldPropagate); > + colorpri, kCVAttachmentMode_ShouldPropagate); > + } > else { > CVBufferRemoveAttachment(pixbuf, kCVImageBufferTransferFunctionKey); > if (src->color_trc != AVCOL_TRC_UNSPECIFIED) > @@ -622,17 +634,12 @@ static int vt_pixbuf_set_colorspace(void *log_ctx, > #if (TARGET_OS_OSX && __MAC_OS_X_VERSION_MAX_ALLOWED >= 100800) || \ > (TARGET_OS_IOS && __IPHONE_OS_VERSION_MAX_ALLOWED >= 100000) > if (__builtin_available(macOS 10.8, iOS 10, *)) { > - CFDictionaryRef attachments = > - vt_cv_buffer_copy_attachments(pixbuf, kCVAttachmentMode_ShouldPropagate); > - > - if (attachments) { > - colorspace = > - CVImageBufferCreateColorSpaceFromAttachments(attachments); > - CFRelease(attachments); > - } > + colorspace = CVImageBufferCreateColorSpaceFromAttachments(attachments); > } > #endif > > + CFRelease(attachments); > + > // Done outside the above preprocessor code and if's so that > // in any case a wrong kCVImageBufferCGColorSpaceKey is removed > // if the above code is not used or fails. > -- > 2.39.3 (Apple Git-146) > > _______________________________________________ > 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".