From patchwork Mon Nov 22 20:53:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31535 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7583995iob; Mon, 22 Nov 2021 12:55:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJygDhpe2EPMrgH+3b3XCspPxVFRDEma+nQHzQ2VYTw8Ur3sjBsQUwaIefj5K8HTu3xaXzHV X-Received: by 2002:a17:907:3fa3:: with SMTP id hr35mr59741ejc.397.1637614517533; Mon, 22 Nov 2021 12:55:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637614517; cv=none; d=google.com; s=arc-20160816; b=C/ddF571meCkFTnl/Z102LSHBL9l+ZYFkAMmDc6Ufqfdnq/Wd9UKCE0AasVEqOXsfg rdfSEyfE6wP2WecNUV3ez4UxnbbxySJEnoPxcLr+B4e+UkEX6x4Izt2RpffvVh4b6wWA pBPAwmJ8lTcNzcOaDzDBmR+Rf8019HafUJ3hNlEjM0+Ukoumuvx4KMqIubu/IK8gEdiG DHhT9tv7TXDG8lktv3tTxbV7VQmAA44TBzPMAZUlE3InQRvpKk9kJZfYiispe10JcL0o c8AxY7NMM795V2OuxZBHEWET8Li33mRp6D7XtifVN5g4M8QS1WunmK6DTJ29XEkPSvvo fpGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=td8/WBf/+aJX+fJWTY+47chij11JhuaO26DL/CIj/K0=; b=I0RxQbo6A5QolpV0HOIzhCai0qGzo8qoPKNIewuWNLrNMNmHqAFLkZUtgsL081+eoq pkRFCsR0eriPDN0QDkTxKrB5NZ9YN8ezlfXcWY3jd+3QAQGn0SKj1s7mgOl8MZaV2mDR B4mGiOv27uhyrySvHiAcdAk1ZPt5vF3c6S8Opc8yc9LMJqMPGvCtBGK0VGusO0CN/WVk vwZvFjjhUYgi5s3fgZh13W3P6AYSax3fdQOYr+Nxh9SIzjyEMO8pULcsmseyGF0zi8LR 7teufxJAyIIhCmAKNr72V708sMqIiS9EY8fBGpymwwgoMFT4oOWO2sJyRBDgFngg1tgY 1fWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=Uh9gFuVI; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=rcombs.me Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id m21si22442837edb.268.2021.11.22.12.55.17; Mon, 22 Nov 2021 12:55:17 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=Uh9gFuVI; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=rcombs.me Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3EDD268A9A5; Mon, 22 Nov 2021 22:53:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A125468A8A5 for ; Mon, 22 Nov 2021 22:53:40 +0200 (EET) Received: by mail-il1-f174.google.com with SMTP id j7so12167481ilk.13 for ; Mon, 22 Nov 2021 12:53:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rcombs.me; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=upUIvvpvRy/e5dsIWKyQ97yjTuI/f7NAfK8jw8wrof8=; b=Uh9gFuVICylkSUBRqpaWxSJmld3Exgz4SxYlkdiEUGGyYdrSjOcMfZ9RTqpTcwQwmC ZwTQiyg05TKNpZ8UFdPh8vX/3TWvLy9ugIXX3JqIZhzd6c6/vpb5jWE6qFFzBdyTk74+ BqQ0kNLg3jrnt6TJAaC/15GmSrQYC0fjAnc7ss0nRaSwmy8zln9/YrzNcvEULPzvBLHF RhmjKpzH7mr5UT+whZIEqI0T9L4akHzH/CVWr6IB8zCj2Kco7UQPUPLWYLXso7ipp67o Rx35WvDrnBMaDmn0G0kJSilcXJlfL0CMbErZcYHQaIpD/kyu7mYNa3Zw2LaKcl2/ocQR kzRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=upUIvvpvRy/e5dsIWKyQ97yjTuI/f7NAfK8jw8wrof8=; b=JxsGTpALfYmeSStAy8agdYOFN0bACzfTB8dNGpkIjpndFztgTNZ1zxz6bZ+JzuLLGn wLLGmgBu78elWrRbmqDJn7Hk/hKTrTyBNOo7DBEhJrPP4Y5GEJmWspDm5ZEs+ZSYqyaH Egs3oWxfwtnsDCDd3XYO1gUbaMhiOObRMxHVfaROmyogudegHS7WBDTW4WZMn4I6ONqe VVehSGWEzSnp6M5UUebnh5b4+VpL5HtFXqFPsqtz41/ze7/FZto/lSj2HutcjHYw7ybK aMJbNPWCka9xPOlnURMVHkpdgyaW/u6zS9coOqu4PRHrL+TDxamnYi/xf5NQsKeuxWE8 /YPQ== X-Gm-Message-State: AOAM532rJPieARv5i4Z/T+qmWrpiV2kGc/u1sgDBJ9Y14A7cxCxZXzaG IFCJqMZNEwpDR3vSA/SqlkurRcfQXHSwGkA= X-Received: by 2002:a05:6e02:214b:: with SMTP id d11mr12623202ilv.241.1637614419005; Mon, 22 Nov 2021 12:53:39 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id b3sm3571580ile.26.2021.11.22.12.53.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 12:53:38 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 14:53:21 -0600 Message-Id: <20211122205330.43546-7-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122205330.43546-1-rcombs@rcombs.me> References: <20211122205330.43546-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/16] lavc/videotoolbox: select 4:2:2 and 4:4:4 formats when applicable 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ofzcxaY/Qgtu --- libavcodec/videotoolbox.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index 010f553e57..57b37bf3bf 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -1064,9 +1064,35 @@ static enum AVPixelFormat videotoolbox_best_pixel_format(AVCodecContext *avctx) return AV_PIX_FMT_NV12; // same as av_videotoolbox_alloc_context() int depth = descriptor->comp[0].depth; + +#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR16BIPLANARVIDEORANGE + if (depth > 10) + return descriptor->log2_chroma_w == 0 ? AV_PIX_FMT_P416 : AV_PIX_FMT_P216; +#endif + +#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR10BIPLANARVIDEORANGE + if (descriptor->log2_chroma_w == 0) { +#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR8BIPLANARVIDEORANGE + if (depth <= 8) + return AV_PIX_FMT_NV24; +#endif + return AV_PIX_FMT_P410; + } +#endif +#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR10BIPLANARVIDEORANGE + if (descriptor->log2_chroma_h == 0) { +#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR8BIPLANARVIDEORANGE + if (depth <= 8) + return AV_PIX_FMT_NV16; +#endif + return AV_PIX_FMT_P210; + } +#endif +#if HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE if (depth > 8) { return AV_PIX_FMT_P010; } +#endif return AV_PIX_FMT_NV12; }