From patchwork Mon Nov 22 21:58:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31589 Delivered-To: andriy.gelman@gmail.com Received: by 2002:ab0:6957:0:0:0:0:0 with SMTP id c23csp7338583uas; Mon, 22 Nov 2021 13:59:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJykTq+elzPi+eUwBbGIWYDcUyUgZ098BLptNjmCTHbryfpJhicIu/n99JEKooRaGSk4XUSo X-Received: by 2002:a05:6402:26d4:: with SMTP id x20mr578624edd.119.1637618396693; Mon, 22 Nov 2021 13:59:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637618396; cv=none; d=google.com; s=arc-20160816; b=oUYkBNusoWd0Y5CDjperuAIzsqsg1QU4py6vB2hqx+BcHC9P6xzoPg5J8EIGMko8dO ks+d2/faxAdNbvWFWl9zRYl4s7UfnwwOhfrsMM5zWqP1mz41GUCrp8Gf2JI2buEQa3z9 QVT/2kBUT7jdLGVwEUZPVBBkm4veWb+iDXaDnyicfAxoShH7M/jm9tUEN2SOsibwB1/4 vag1lqHEQOBL424l3eK4D3AXCfAsYXye8NhIJda01MkulvSChal1Bi7Imuhdi+JmIMUI YTiUKznUvZJU9HP/lAbM6bjaa9fUftAHFj8dzNfpiwRBlZM+EXXLTlA/KzpBLMJr6GZV PVvw== 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=LJxfDysbL/vc2NwA7oa1BBNqvN6yGETaVKisMsaMQEso9Gcfb7YM3jpsmKDXRtRNvp yp1nb8Vd/DbJFwePoHv+5CHOhxR0Ql7aBQaUuzres+fBW81yLB77mt9qcrwrJMjtHgbJ SfcHf3MB0GQkUmGrw9ETK9R23tKVjk5caLGvc1FSkwJak8paCeeVv1PgWe0fPCCk43op c/H550PQEOJwQXtiQfxCW557afzGmZ0ofkM9QHbFYVeoqWVh4/KgmWrQKdFwTm0yw0lF ZwlXwOLwb6PS6xryuLlTpoSlib9yIp5/SnK3PER1J6VBBPFYMJf7oPNTaNwu2vWlJ7vr 5GAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=IAE7h13k; 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 x10si20584816ejv.557.2021.11.22.13.59.56; Mon, 22 Nov 2021 13:59:56 -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=IAE7h13k; 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 D9DDF68AE8C; Mon, 22 Nov 2021 23:58:46 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f53.google.com (mail-io1-f53.google.com [209.85.166.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7285B68AC4D for ; Mon, 22 Nov 2021 23:58:38 +0200 (EET) Received: by mail-io1-f53.google.com with SMTP id c3so25390919iob.6 for ; Mon, 22 Nov 2021 13:58:38 -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=IAE7h13k7i9kX7uVFGEy3G+qbfH5diHHyuLh+MRBbpBpWMduYXAx0VI+GtKLOI1oaN 8NmKPT2C0nuyOwAL4AWhokWdhCt3MqVzcMHr/Ma8G/ogU9wKbZ7cF1eJdJWf9sfE4CgP dxbBjIWPzvtLXPjPi6pSeWLqM3lQMD74C0jY4W0oEC4R74kz2A15ABzZVl7AjHjqiOWL bySXo1PyjJFC0VE6lICzFkR7jz7+EfFSaS3UABY/4lRUfazYl21RiFETBLu5T8g6HsRn 2nl5RKRJYP7/XYQ62aJfdxnuC2pjRj45vEdnqneimHGvrNCQSmXR/KeDQ8TR6NpB6Xwu fEtw== 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=ExMYPCaLY5b9xKc0TlVq54Hl8L99mYOg1KLYdD52DhTzyDe+XElM71JxqKq4fq4xgZ 0gaW+LyNURXwo/icxbSJ/+z7wo9bHII3Z9/2evA6wo6MWXaJBGxtSNZucqafVTj11Ry+ j7rWvvedqj3LhWzipgi7daJyGwAbmmycblLSs7zHqGW3dyo7TWQsT0nG9wES3x2ClhUG 2heDBfH9i2pTPsJmtgJbaZn911PAJRp46Om7NJ7rhdMk6tsmlGoRWF0MyJTvFS9HlH9m 4xEbATCQ/1Gd5UrTsWT5O2JLi+25YCf+F9Ti9zUBAkscGr2UJ2PCNIG4EgKYvks2NZok qa2Q== X-Gm-Message-State: AOAM531yrw4+5ayepg/E1LmSajvbhLdlQV8TL3DN/HPabmhuN6lHZqQy 29VvTepfLx9n0DC+jin0IGQTFOJ2a/V1wrM= X-Received: by 2002:a05:6602:2b83:: with SMTP id r3mr127130iov.8.1637618316820; Mon, 22 Nov 2021 13:58:36 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id o1sm5668802ilj.41.2021.11.22.13.58.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 13:58:36 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 15:58:12 -0600 Message-Id: <20211122215821.9849-7-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122215821.9849-1-rcombs@rcombs.me> References: <20211122215821.9849-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: 1sIyPl4OsPeJ Content-Length: 1648 --- 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; }