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 7C29049874 for ; Tue, 21 May 2024 01:56:40 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 6392668D274; Tue, 21 May 2024 04:56:37 +0300 (EEST) Received: from mr85p00im-zteg06021501.me.com (mr85p00im-zteg06021501.me.com [17.58.23.183]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BDEE768CD5C for ; Tue, 21 May 2024 04:56:30 +0300 (EEST) Received: from smtpclient.apple (mr38p00im-dlb-asmtp-mailmevip.me.com [17.57.152.18]) by mr85p00im-zteg06021501.me.com (Postfix) with ESMTPSA id 27BCD2793E93 for ; Tue, 21 May 2024 01:56:26 +0000 (UTC) Mime-Version: 1.0 (Mac OS X Mail 16.0 \(3774.600.62\)) Date: Tue, 21 May 2024 09:56:14 +0800 References: To: FFmpeg development discussions and patches In-Reply-To: Message-Id: <0112D1C4-AAE8-4CE4-83B5-3416DC6B0DDD@me.com> X-Mailer: Apple Mail (2.3774.600.62) X-Proofpoint-GUID: xZiQIi73e7haGf0OY3B97mU6XnlxCg90 X-Proofpoint-ORIG-GUID: xZiQIi73e7haGf0OY3B97mU6XnlxCg90 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.272,Aquarius:18.0.1039,Hydra:6.0.650,FMLib:17.12.28.16 definitions=2024-05-20_13,2024-05-17_03,2024-05-17_01 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 clxscore=1015 spamscore=0 bulkscore=0 suspectscore=0 mlxscore=0 adultscore=0 mlxlogscore=999 phishscore=0 malwarescore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.19.0-2308100000 definitions=main-2405210014 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: , From: Gnattu OC via ffmpeg-devel Reply-To: FFmpeg development discussions and patches Cc: Gnattu OC 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 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. > + > + 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".