From patchwork Fri Dec 17 00:12:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 32669 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp1001533iog; Thu, 16 Dec 2021 16:12:40 -0800 (PST) X-Google-Smtp-Source: ABdhPJyL+Cg9eAqX5mv76XL7XLN00jOa2wDpj5Ha/qTs8nRdnfNgC9EWBnFwTCnmoPb6d1gHPjfZ X-Received: by 2002:a17:906:e118:: with SMTP id gj24mr442984ejb.138.1639699960747; Thu, 16 Dec 2021 16:12:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639699960; cv=none; d=google.com; s=arc-20160816; b=TpiyrUx/jS1tcnsFHRCKkhFn9vXhRweEgiNc+kKnG37yt/1tiA03UzRRD1rH2q86JM kAss9Opdq4gb34sj+gKYD2ZmKINS+vQer7IV0tVqGc64+1hor5S4+XlLGWP9c2Si9ZA6 8AW7bBBV6B1yRbtQQiPC3UJ3BQSbLHaM5AMJhc+8KDBI/zag++sl7iogsCoZJDnpGEQZ PpNBl+xKvwUZVRvK6wiUNqBaixuX+FFCvJcnszj5o9IB8qetHFJGuPVww6QdWYdPMLeT z44PrAAapFmkXvYVTN1pJ0bOWwRZu9DgK1dUhRWiL+Q7jfPVyImQ1Y4lVXfuVa4TUNlj mUsg== 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=xxKIjgzGH2OsW4GdGv59wmK6NQtXn6FlQQ7YLDJKY2c=; b=jMnCepTp3tfghc0v1yi5+tHDwdqViE/+cuqSp59jr8sW2rE3a8lNQYuiJVLdWB+ni2 yR6Nc7cjibpnaN7x+FX9BoUd8fnG8QPx2cjlz/YvqM7S3zfGBrqJp7Fu+XFkjjn9ONBR Eh6FUcKENdcBH9a6NOdVtNpxCnm6ZP26sLaM0CQ/FftpJE55nZGloecCba2oFLG6JH6U 0sbZYOTV+HsECOGgYStN6H6gYZ4KU/hhh2A2TVJs3vcqvJdHlnb6L7H2IXP2I9hPUCWf uWkmlznLjGSMdMmlQqFsRqWEkZ8UKPQTeQH8oFkltjsEUvlYJ+tp+LMmVYAOG4YQNpo3 jxTQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=ZeoDuBts; 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 ji1si4160754ejc.121.2021.12.16.16.12.40; Thu, 16 Dec 2021 16:12:40 -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=ZeoDuBts; 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 35D1F68AFCB; Fri, 17 Dec 2021 02:12:30 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f43.google.com (mail-io1-f43.google.com [209.85.166.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C325768A852 for ; Fri, 17 Dec 2021 02:12:21 +0200 (EET) Received: by mail-io1-f43.google.com with SMTP id k21so741127ioh.4 for ; Thu, 16 Dec 2021 16:12:21 -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=iY9j1tUgehu/kcTw6agrlWCMz2/XTxqD90C/Ko67Zoo=; b=ZeoDuBtsWnfpcZg2rC/E1izIXasqK2N0+uotSvq9A4D/jjck/9PmYGI4py2kzgna70 f/gKQdQhKFnJL6q/UECYvfr9RI+gTeMSuB2qjtS3GGGyrUEvsf1vDPoEy841IHEDluaG 7F7urksdiGIshm7ZRF2bMWb8mBFgjWM2xTuiwjGO3leiN8z/aUVOXaZildi7t7OJlpTa aSDTQxgQcMMJA5C/kUbkD0bSfQRnddx3oEbRFt+8TqGcNtx/kpGTKZ8+5dFyWMs+SbtZ ZPaTWFuEcRDJTKKtCJsE/vhBmfBz/MOm8sjbtnsfBCkJK6rrZlKY/ByGHbDRSfZ8Yy/9 dmJg== 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=iY9j1tUgehu/kcTw6agrlWCMz2/XTxqD90C/Ko67Zoo=; b=DgdmjV3e5vyJdnPwJ/m5rBPJIzioDbz1KW+gccANfDz4GbDMC6eYwvgahZCXFyT5dh 8EQELnah23dWBD/DKVfsjXQdPIUDr/l4i+IfMiW5kYub+5n5uPSo5VjhnK9Rv/6aGqSV W+OvVF9NIir8D6pLlT7/FzNvilJzFoVkNZV0g6WdoEIHHye9VJAie9hlLY6T8/osYTAd cJAjwcm9jmhDSlOgWbwzHcbrEm0wwrXFRSrRz33sD/IBC4HSH4x2TZsZg0khvhj/dpuw cj+5pamJVYDFAYZxjYWmFcLNHE3T4ieWkUVKIjQerdJZCjz3wBmIzKHLzPB/uDNVdZtE TcMg== X-Gm-Message-State: AOAM530RdsMh5rS87SzuhoVPeXtWNFx3oAvKOQlo2Z0itOcC2VC7dgtZ dMHewqpOoTpO8vxojmHo0co4ow9BDfyj1rY= X-Received: by 2002:a05:6638:10ea:: with SMTP id g10mr258139jae.117.1639699939819; Thu, 16 Dec 2021 16:12:19 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:1163:bda5:7473:fab3]) by smtp.gmail.com with ESMTPSA id z13sm1571257iln.43.2021.12.16.16.12.19 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 16 Dec 2021 16:12:19 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Thu, 16 Dec 2021 18:12:06 -0600 Message-Id: <20211217001215.75135-2-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211217001215.75135-1-rcombs@rcombs.me> References: <20211217001215.75135-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/10] lavc/videotoolboxenc: use common routine for pixfmt conversion 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: e8QUbswLgtCs --- libavcodec/videotoolboxenc.c | 21 +++------------------ 1 file changed, 3 insertions(+), 18 deletions(-) diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index ebaa3ebdc8..1e7c164a97 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -29,6 +29,7 @@ #include "libavutil/avstring.h" #include "libavcodec/avcodec.h" #include "libavutil/pixdesc.h" +#include "libavutil/hwcontext_videotoolbox.h" #include "internal.h" #include #include "atsc_a53.h" @@ -797,25 +798,9 @@ static int get_cv_pixel_format(AVCodecContext* avctx, range != AVCOL_RANGE_JPEG; //MPEG range is used when no range is set - if (fmt == AV_PIX_FMT_NV12) { - *av_pixel_format = range == AVCOL_RANGE_JPEG ? - kCVPixelFormatType_420YpCbCr8BiPlanarFullRange : - kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange; - } else if (fmt == AV_PIX_FMT_YUV420P) { - *av_pixel_format = range == AVCOL_RANGE_JPEG ? - kCVPixelFormatType_420YpCbCr8PlanarFullRange : - kCVPixelFormatType_420YpCbCr8Planar; - } else if (fmt == AV_PIX_FMT_BGRA) { - *av_pixel_format = kCVPixelFormatType_32BGRA; - } else if (fmt == AV_PIX_FMT_P010LE) { - *av_pixel_format = range == AVCOL_RANGE_JPEG ? - kCVPixelFormatType_420YpCbCr10BiPlanarFullRange : - kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange; - } else { - return AVERROR(EINVAL); - } + *av_pixel_format = av_map_videotoolbox_format_from_pixfmt2(fmt, range == AVCOL_RANGE_JPEG); - return 0; + return *av_pixel_format ? 0 : AVERROR(EINVAL); } static void add_color_attr(AVCodecContext *avctx, CFMutableDictionaryRef dict) { From patchwork Fri Dec 17 00:12:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 32670 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp1001669iog; Thu, 16 Dec 2021 16:12:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJxVoIHM29UtACdBN6yizpU3qgu6kc1gm4XHtNGOBqHa+j/ZuHLcGCSC2VjrXZ8LN5fTb2DY X-Received: by 2002:a17:907:608e:: with SMTP id ht14mr402102ejc.259.1639699970013; Thu, 16 Dec 2021 16:12:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639699970; cv=none; d=google.com; s=arc-20160816; b=nbz5IeHQCqia2CakAT3cPLZDWQrgBB04NlGa4puwLOSeIc6rcDpOWk+sac4Yr8RZVq P8n99fFQmpfhVRuYqVgRCVXpeAacdTIkDt8z3xFkYrcp2jdg5ocNR4mFCM2UKikdWMqL Prng/QSl7yX/uzfg9SziWgq6xBGDwSAjRexeBnA2e/PiaozLw+iauNZB4jP4zl5Briwr g9tLX2fvEgd1+TEBwd0pRIRA2T9c0w8UDkstfAmnUwgprSHTlbSfAHzqVoHhF1BPH76u 60Cvwd8t515aXcDnkTCNe4rEndU7ikob4HRrhqE53/WOG9aEqnh4wMPhCURI8cDLiF51 AdZQ== 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=jDOnf2G6geR4ssbuDflNJjKr/NXioQTjoTfc6bL9bsU=; b=VGjNORJMy8rIFXGZOYF6G5etAfUAIDnRgoCYzFSzbLl+GS+DDFiH0Dpr6IAkB/OWx4 wc2krSE8eP5YB3EX/KZPyCeXA2j7pmYnhidke4Fva+KPgOKoFnxmAxpVPneE7qWFm31s 2wnqAhwDasRb9yTKHFgafqK/QTDRekmHboBdTqryK1DCxoXWfMl4hgRr1yJKZfSHCl5o Zqj4xFUvUaptr4g3UxGhL8oy38Tl/ptSl4x8ZvxrbAkT+2pLYsZM3gFD/AewzUWcV2Jd 1aQwRUNxPjiRQOFFUgA1rzWunupqqwuplN5V4c8+68tyVzCicxhcmxVIUcxl5hmI6wEu Z6Pw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=FU8sRaeV; 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 gs30si6065216ejc.247.2021.12.16.16.12.49; Thu, 16 Dec 2021 16:12:50 -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=FU8sRaeV; 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 4912468AD0A; Fri, 17 Dec 2021 02:12:31 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 427E068AF91 for ; Fri, 17 Dec 2021 02:12:22 +0200 (EET) Received: by mail-io1-f51.google.com with SMTP id z18so730902iof.5 for ; Thu, 16 Dec 2021 16:12:22 -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=HU/Ttpyc3aZRbCeM8Asb5VIbiEX9QZhtC3J3lPUFkZ8=; b=FU8sRaeVdSSfbwQ8QFKecjKPWobLhdDZK5d/V04EXwvVu3ShcVoc49D5NXGMQt4ZIj aNQO7EUoGQjtBuIE8YiorXp93QUQ8dYzCDA/pD5VME+GiRM5uOCn7eHrVdcWjwAVpfma /DFvsDJabe5Zly2Wxl1iAm9/LMB8Fbw1HjOnFUIe/tNA3L+P2LouOfLoR2MEEjwr7arC IYUqiCZC+9zLapLTBblLd4QKHa4AOWezn+z1uBEbm3yo7zk5BkVxefodxTlI93mrU5j7 88XsgYEgVb0fEqYaaImAu7W7a6N9aH8Ul+IhpxXg3MlTUfjA0lzGwuzSdbhhw6LLvgzr ePpg== 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=HU/Ttpyc3aZRbCeM8Asb5VIbiEX9QZhtC3J3lPUFkZ8=; b=wH/PKx1hlvM6+xZn0Qk7AqPbr+VaGyh6YO0AuIO4Xs+x13rUxb8FVqEEwigMXFAu1f G/QLoqsZ32Sp5biUhq3S4sA6aZfLeWdf7eMLTxknQxd7F8piFNXehSB5bAUA4K2/aqIP MMqp0KVLmLLGhpbn1IkbsX96+V5F6YpmkY3rtRifrxrzqgG7noXKaZDBAstp8sBvN5lm h0km+l6AtQahiuLPineXwoFUMNX58CrjA5nYQDvNuLrKjycOPDmj0RcXemwV3oGPuXj+ caJoglOlB/j+meXNOfaBEjw9dV+cOmrCaIwJR1dCxHvW2/a4IIvxokoLZCbP8rlr76fA cqrQ== X-Gm-Message-State: AOAM532ib0JGCQryqAXO9S7oqj5KG+7TC28f6J2WIpRR47cErkBlGNC2 DEeU8GeT8jcCpmShDFVJGipWSE/D2N7IFIo= X-Received: by 2002:a05:6638:40ac:: with SMTP id m44mr262318jam.168.1639699940486; Thu, 16 Dec 2021 16:12:20 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:1163:bda5:7473:fab3]) by smtp.gmail.com with ESMTPSA id z13sm1571257iln.43.2021.12.16.16.12.19 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 16 Dec 2021 16:12:20 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Thu, 16 Dec 2021 18:12:07 -0600 Message-Id: <20211217001215.75135-3-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211217001215.75135-1-rcombs@rcombs.me> References: <20211217001215.75135-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/10] lavc/videotoolboxenc: don't access int64_t member as int 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: FpWChi8IwjZi --- libavcodec/videotoolboxenc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index 1e7c164a97..9857e55fdc 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -2618,7 +2618,7 @@ static const enum AVPixelFormat hevc_pix_fmts[] = { #define OFFSET(x) offsetof(VTEncContext, x) static const AVOption h264_options[] = { - { "profile", "Profile", OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = H264_PROF_AUTO }, H264_PROF_AUTO, H264_PROF_COUNT, VE, "profile" }, + { "profile", "Profile", OFFSET(profile), AV_OPT_TYPE_INT64, { .i64 = H264_PROF_AUTO }, H264_PROF_AUTO, H264_PROF_COUNT, VE, "profile" }, { "baseline", "Baseline Profile", 0, AV_OPT_TYPE_CONST, { .i64 = H264_PROF_BASELINE }, INT_MIN, INT_MAX, VE, "profile" }, { "main", "Main Profile", 0, AV_OPT_TYPE_CONST, { .i64 = H264_PROF_MAIN }, INT_MIN, INT_MAX, VE, "profile" }, { "high", "High Profile", 0, AV_OPT_TYPE_CONST, { .i64 = H264_PROF_HIGH }, INT_MIN, INT_MAX, VE, "profile" }, @@ -2672,7 +2672,7 @@ const AVCodec ff_h264_videotoolbox_encoder = { }; static const AVOption hevc_options[] = { - { "profile", "Profile", OFFSET(profile), AV_OPT_TYPE_INT, { .i64 = HEVC_PROF_AUTO }, HEVC_PROF_AUTO, HEVC_PROF_COUNT, VE, "profile" }, + { "profile", "Profile", OFFSET(profile), AV_OPT_TYPE_INT64, { .i64 = HEVC_PROF_AUTO }, HEVC_PROF_AUTO, HEVC_PROF_COUNT, VE, "profile" }, { "main", "Main Profile", 0, AV_OPT_TYPE_CONST, { .i64 = HEVC_PROF_MAIN }, INT_MIN, INT_MAX, VE, "profile" }, { "main10", "Main10 Profile", 0, AV_OPT_TYPE_CONST, { .i64 = HEVC_PROF_MAIN10 }, INT_MIN, INT_MAX, VE, "profile" }, From patchwork Fri Dec 17 00:12:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 32671 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp1001809iog; Thu, 16 Dec 2021 16:13:01 -0800 (PST) X-Google-Smtp-Source: ABdhPJyqvzktSCnF1h03CFAt25wk+phoS4Ibq+x769e06YsdAsQDP8Oc9ARZbzKWZgcsbpBCrTJD X-Received: by 2002:a05:6402:c0a:: with SMTP id co10mr362703edb.295.1639699981039; Thu, 16 Dec 2021 16:13:01 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639699981; cv=none; d=google.com; s=arc-20160816; b=VnJ/XC4qLKGabxdScvm55HeyPM6LN4ZdQcfwXyFwJ58KEEOO9oYyuyEFTWNCpVf+qn LPhKsDDaQRq9hARj8X5EFB8+6pfUbAtRFOVCDo8rlivy4dh/5MXD4QC2PEusvV2O/VVi m6A3/jQGUc3SvS+AEkUlm7xiKVEL1LdAp4dOnU9SnJBpsQHdh5u30ePcbPHGD+zAFrJ+ JUZ9vKxei9/RKAPoUT3gdntr9fa1/qaG+QcyvcxS9ZS8bV2870WuZhNsXrkHGgJlCtvn 2+w5zgLZhkZeYyFNmnRIq2DxsEB+vzWs7I/BUE8Nwn1C5of6/Kz/+Ec2J3Z8mgF+RSRE eNUg== 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=Xafq2m9x3KuJQx0xF0lZm2s/j8GMT3i7smqtbSAS9KY=; b=Y44A833t0fMKNEMBjJgQPNUS0wIS82dSvmYY0uC530w9W+o+wNkuoWCpB6BsMQmsvn Ete29GkDlq1COVDlQAgK7TuXbrT+rmjA8OLLzO5P1KwFloQ+p45aO7WCSUcS/9GQmfy2 yzR7KIcwurkN73EPjh2X21mDCfkMq+ozfyD/jcdU3rc+jXa3BDuSUB/G13+Dpf4yTMrF Z6sTHlu3h7FKw22KaCDcQthaBzrFKmJuyhoBRxUPak51bZGTY0/v7ZgRSHkwKgBIDQMv Ser7Ubzq713/mrEAEGr6g2a98TvdkP+ZHJy2eVHzdac1Rzw0ozMvmuQV5x7zlYdS4KV2 cGMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=c4rsUJbH; 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 d3si4747600edo.485.2021.12.16.16.13.00; Thu, 16 Dec 2021 16:13:01 -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=c4rsUJbH; 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 4028468AFD4; Fri, 17 Dec 2021 02:12:32 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f52.google.com (mail-io1-f52.google.com [209.85.166.52]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D5B1968A786 for ; Fri, 17 Dec 2021 02:12:22 +0200 (EET) Received: by mail-io1-f52.google.com with SMTP id x10so704181ioj.9 for ; Thu, 16 Dec 2021 16:12:22 -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=r7VF92SVjudlxE7DN4zIictBRpLo4pxVucK4VDOjJ5U=; b=c4rsUJbHwAbu0gpUptAxma6VYPDOZcIbCkALY+l/JjJt/N8nZDChvLVT/+BwtBRGYQ G2l2rDhEeq5Y73yUGziyIUCGq6hYvQol7Fw4p9On30P9hTg2rRuqJrr5Q72JZ9WGXkHz gOxbjk1Akv6ljHc4P5LhCvoqAABSBxfMdVGpH3Ph9ijIotUuv0wB8MDizMsXT/94gOCV E/L4Vae9E1mt/kO6ey8XO1unxZQzPhid5PDPKLaz3knRHLi5T7HI/nq6+1Vvn+0PGwy4 9S/zUEha4jyliVkt4sbfiNZVTCR+wJcgR2ZhCgXQd0pm+mvW9HU5Epv3pXY1qJVxFNq1 481g== 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=r7VF92SVjudlxE7DN4zIictBRpLo4pxVucK4VDOjJ5U=; b=NSSA/n1GiWWs8D9PFl2JnJW0pQyyAyEcbIx1yPUGtdDoV3LDJAfuO1KkFx2rXZ2JcX 4FZmVANgLwIoe8LKNJQENVLN5lrA5h7B0btZlp8RXiflloF07TvivQu4WobgWDKcOC/q ts3slDqK0r3TuSlv0dFi6yYLsuoalhHvXqpNe/+EvS7L8zaD+QdtJkDpKf+A/GlpRtcW /ClxvIZpuub9gScBUJJFiS02QELy5zm+fhvjiRe7hisoabasc+8XYpWUMr+KBscTCJO0 cpczgLr0lJmjRDen291ZQgIRLhyImzqX4zyppaLEgNtzOwRASenZycgacJg5mvkSIYKk qxOw== X-Gm-Message-State: AOAM532yBZbs1mVi7qxlsYqqwvhtBVdHr+efThJCLTwvC3fRAXEBc6dN vQf8ua3q0kijwCs3V6KdCe2Y9cbsF/eem60= X-Received: by 2002:a05:6638:33a6:: with SMTP id h38mr238795jav.151.1639699941217; Thu, 16 Dec 2021 16:12:21 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:1163:bda5:7473:fab3]) by smtp.gmail.com with ESMTPSA id z13sm1571257iln.43.2021.12.16.16.12.20 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 16 Dec 2021 16:12:20 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Thu, 16 Dec 2021 18:12:08 -0600 Message-Id: <20211217001215.75135-4-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211217001215.75135-1-rcombs@rcombs.me> References: <20211217001215.75135-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/10] lavc/videotoolboxenc: detect alpha more generically 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: OtYbNwESg5rS Fixes support for alpha in hardware input frames --- libavcodec/videotoolboxenc.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index 9857e55fdc..fa8f717a6c 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -406,14 +406,14 @@ static int count_nalus(size_t length_code_size, return 0; } -static CMVideoCodecType get_cm_codec_type(enum AVCodecID id, - enum AVPixelFormat fmt, +static CMVideoCodecType get_cm_codec_type(AVCodecContext *avctx, double alpha_quality) { - switch (id) { + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt == AV_PIX_FMT_VIDEOTOOLBOX ? avctx->sw_pix_fmt : avctx->pix_fmt); + switch (avctx->codec_id) { case AV_CODEC_ID_H264: return kCMVideoCodecType_H264; case AV_CODEC_ID_HEVC: - if (fmt == AV_PIX_FMT_BGRA && alpha_quality > 0.0) { + if (desc && (desc->flags & AV_PIX_FMT_FLAG_ALPHA) && alpha_quality > 0.0) { return kCMVideoCodecType_HEVCWithAlpha; } return kCMVideoCodecType_HEVC; @@ -1376,7 +1376,7 @@ static int vtenc_configure_encoder(AVCodecContext *avctx) CFNumberRef gamma_level = NULL; int status; - codec_type = get_cm_codec_type(avctx->codec_id, avctx->pix_fmt, vtctx->alpha_quality); + codec_type = get_cm_codec_type(avctx, vtctx->alpha_quality); if (!codec_type) { av_log(avctx, AV_LOG_ERROR, "Error: no mapping for AVCodecID %d\n", avctx->codec_id); return AVERROR(EINVAL); From patchwork Fri Dec 17 00:12:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 32672 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp1001979iog; Thu, 16 Dec 2021 16:13:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4ZQ6jhKmEAkNVCJ+B+7OF+DPmhXS1zCF4sZwpMZjmu2abP7SxNoE+kuw4Os32DrBPCqaE X-Received: by 2002:a17:907:7796:: with SMTP id ky22mr359201ejc.545.1639699992464; Thu, 16 Dec 2021 16:13:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639699992; cv=none; d=google.com; s=arc-20160816; b=0JTRRNJ1iSDTFEdh82ToUunIYVCere5KkRysWmxYWHKVgjA9E5he1ve5cm3B71ZQca 2FSbmfeMig70IxMSub9xhEPHfWls0km14KsnaDpzywqwgDb3SOAEztlrhh4bLqGzyxPi 7bfoFfnx1n6thh7Ts7pJhjeogYFDutLojbuUrV4lsZlEGUPeDJGUFYjNVlzFxZzLfTSB gzS0yfweIhM1DvPfXQ38qSVlNboAEsKUqmtiHvD96KdordBUfC22o6Uu8CgtI03ijz71 GHscNVb2NWnYE5H6uiOvPhGxIYAahcG7MIQAhx0tGS54OL16rRRxJ9UJsGXRNF016y2l JH/w== 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=7x7nFVB9adb+tZZqqXlMlwk0pxav2j8Hv/xbi+Ra5Hc=; b=kJljD6RciNbGzTfT03PnSf15BJ37ZPfHhibgeX4OrTIlXY1K1HftyZZCNkYcSlB4Xf aeEHHlZIAsFIsIv6ui21+JvwOlHPwvmr3otT2aE66fSXJNeT8hPT0Y6qnmxVW3sK+n19 MAiDsflej0rB0HnzNvUcXrwDoSgwO75PEOaplCtaW73C8lPwMeBJkrdajnUR3CunfS8e lkWzOoVWGdj1/FDb9rfTNvtpbZPhean7lk97CrzooNjp4WBaM7jBipY/Cn8YfHItjE24 6Mrk9Q5O5a1RHQ4s3Q7u4DWHGqg15PD0zoPEtEUAKFhhaQ5KAuvYRc4xjPgvSxPsPW3J erlw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=euCBCxYQ; 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 oz13si4085627ejc.610.2021.12.16.16.13.12; Thu, 16 Dec 2021 16:13:12 -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=euCBCxYQ; 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 2EDFD68AFF1; Fri, 17 Dec 2021 02:12:33 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-il1-f182.google.com (mail-il1-f182.google.com [209.85.166.182]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id B70B768A786 for ; Fri, 17 Dec 2021 02:12:23 +0200 (EET) Received: by mail-il1-f182.google.com with SMTP id a11so383300ilj.6 for ; Thu, 16 Dec 2021 16:12:23 -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=hW5WcVy+rM4JdcQtaP4pbEdzj2hDseMggrYLltve6e8=; b=euCBCxYQ3CObpyDq2gxwDmihPk6GaZ0qmX9cr8lZr4m85LO+I1hkhARor3UfOnQ5Yz aHJRVMXgNQh1heDrUmCBQtrhw9i8RDyEFkYyP5DhIx7wIpc0wUd/reTf6YW8VLyzdfry SCVErhANVz2h7ZZMYDSPP5YCPjkK9nMsAjkvhzdU4W5o4HvRjN+Whn5qHEcq2NTbzEM5 6hHYja/5Z3DU6vy5UXqkDLr57O7d2QXGoLSvrR6iBSHeu6RMmUJ+khR7J32CHfXHJsdi WkCOArQVPYRvgzBotCc1WuYaBm9el8MQY7m6NexE/aObbYF8vybBkl/2T718/nDgONUQ Yp7A== 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=hW5WcVy+rM4JdcQtaP4pbEdzj2hDseMggrYLltve6e8=; b=0KP9poFwmEH/fczXdTRqiL0bQRdeJx/zdtmyP9YVguMbP6WV0OaIOkkq+s3Llh/cKd nJUGieNA72ue6YPRtEy5iudtJ5Ht8V42YwRz7ZhgWuN9sGYSB+sjVw/Mv93zUcz+3Czn /O0rEmAeXIypninhAM0fVlPWTesY1SYPXXPDRLO7H5jmsZhleI6n1XHMzD1z6QUzKLS5 OgGQlw4Xv/cyr1y7GgwWwOh0L0NpteB5IpCwr0FMCM3iAs80r5CmuKM6c9A54k9s3NNN 3p3h7bpcIMJYu9CLUyQa+5y4cshC7TpsdSRAsF1MpFOZYOd5uZsnGppfkjR8RPQAK8km xOkA== X-Gm-Message-State: AOAM531NepBclNdiI5jcxzrn2WortG+yl7rcycJ3PLkf0oaDaxfzLHNK QMfrczsMJTQQVbxwLjnsIpO9DBthjQh2Rkg= X-Received: by 2002:a05:6e02:1b84:: with SMTP id h4mr290677ili.62.1639699941989; Thu, 16 Dec 2021 16:12:21 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:1163:bda5:7473:fab3]) by smtp.gmail.com with ESMTPSA id z13sm1571257iln.43.2021.12.16.16.12.21 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 16 Dec 2021 16:12:21 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Thu, 16 Dec 2021 18:12:09 -0600 Message-Id: <20211217001215.75135-5-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211217001215.75135-1-rcombs@rcombs.me> References: <20211217001215.75135-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/10] lavc/videotoolboxenc: fix RGB support 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: hGUOwhOYYF02 --- libavcodec/videotoolboxenc.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index fa8f717a6c..e10373dded 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -1012,6 +1012,9 @@ static int get_cv_ycbcr_matrix(AVCodecContext *avctx, CFStringRef *matrix) { *matrix = compat_keys.kCVImageBufferYCbCrMatrix_ITU_R_2020; break; + case AVCOL_SPC_RGB: + break; + default: av_log(avctx, AV_LOG_ERROR, "Color space %s is not supported.\n", av_color_space_name(avctx->colorspace)); return -1; From patchwork Fri Dec 17 00:12:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 32673 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp1002098iog; Thu, 16 Dec 2021 16:13:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJwcSC7Ep71boeIa2azug2DP2AsCZLpjhR4dTyGuslSeAF+S2ohUh9WNmCmCswXv5LbR56ex X-Received: by 2002:a17:907:7211:: with SMTP id dr17mr410542ejc.204.1639700002711; Thu, 16 Dec 2021 16:13:22 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639700002; cv=none; d=google.com; s=arc-20160816; b=uO/dA7reVvD8VvZ9HPHpTdYB+DP/Kty5jORdgHLWiTDgmOR6voL2zob2T6oMXG8vkY wwijPlnMJZ0b78aiquT1V/Qa07FEqrzDnEbIl1ACuITUeRK2hOwr8QpaZJX4MH+4wYu4 CdXxlAevPE1nni+Knf6VIfLdwbFu5YyY5PfCcyT2RtoLtqSYucbnTwjXmykkUZ61eVR5 44OjFz9GPZd6fZmS6fXxK4gCS8itrVrPHyQ633CNoZEdlA6wSvY7w1zJJAnh29Qgze8P 3VTIZMyHZcjDKKVyjD8TW8wESN48+ZwL+jkvHKpECKfsOnDplS3pkzKV3o3B9/UIAg22 CEAA== 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=0g0ZyDK3gUHNrOMycKABiJ3lp1ZVFlPajcD/1M2D63g=; b=0plHkZ8HGgRPSPMrG59OCzY3ubsKD5N/ma3HWPJ7pcduf5vTATCrD0W6IrInlVktUT IqF2tHPb5JYTceU/bULNsJ4EYz1JrOYvRxT/hYHH/UaSrybnCi0At/TMmSRtBdSoMalf GFgIUKclo9gj6YWNK98HTJpNXklK1vf8yIvFcshEnm6xPiQFdbi0+/QObgDLUYu13t4p wo20ymh5kqog1iR2U6iKYK7Yg3vzdH1JcxZ7kMc4EKAn8LbX70w8R/N31DhUkk2JWwik FqhJ4aItTe0dqufIL3Wt5zXYWTQD2NgRLBakIbwOTk3g6F01werBYrEQ7Bc+XIlkJ50T L7jQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b="jVU6/IWH"; 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 hs36si4204410ejc.181.2021.12.16.16.13.22; Thu, 16 Dec 2021 16:13:22 -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="jVU6/IWH"; 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 4039668B000; Fri, 17 Dec 2021 02:12:34 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f47.google.com (mail-io1-f47.google.com [209.85.166.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8187A68AFCB for ; Fri, 17 Dec 2021 02:12:24 +0200 (EET) Received: by mail-io1-f47.google.com with SMTP id 14so750511ioe.2 for ; Thu, 16 Dec 2021 16:12:24 -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=nTMeDD/yczLqjUUsJCJnl38/Z1NwVnU6gde61o0FbP8=; b=jVU6/IWH7PM8ZbtjDa5lX+dRgy6XHgpCouE7Ev+gJn743EKqc738WtyX37cxRzg3S2 6b0aHgI20pcGfDXNFDnb7M1Kzg5UmaV6l1hHjm0O3tWrr7GCur62RJP6EhcORrjW3Pn3 NKcKpwFQXtHoace1aPf8wtftc8yYXQoPFTURruJqGF4P4+qtAcoYKSMJbbzTCYjjVLNy 1K0kXHX23z/LuFZPeeovUqUkm6aEMznmSsQdzJuXXguCy7dU+LdmvI09GrmTImu02OwO S/oLGBaMZnjZtFQe+GzZDcIg07vvbBgKHCF62h9nUPA51/RhzhvzQNtuOhdVxV+wTgbc BgGQ== 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=nTMeDD/yczLqjUUsJCJnl38/Z1NwVnU6gde61o0FbP8=; b=YKiwpw9fEvTneXqS+iFkgFE/BEj9gGkPkEQDMv4CMjd3T802C+MXvvwHxcyiqxFID7 xQ4K9ZXm+3fBr1kQUanJOtsIfwkyCCBrs7qP90+qOm1OPI3h/q83aiMHL6OzwwifWI5f rGYyPmwBLXQj/Ms3+q8M0pYstgCbTerx9MhwQ5nb6yveiELy542YvpAKQB9OoVthqv1o nrU+4Mee+53WvzFfotY5G5wvBjCJExUaNS4Yad3TmOWPbOlN+yTc8KnyhKJIfA7aQLe6 ThbF47IsRIuoTDGa3ZPiItCvNTyqGWfao2U1RILtmAzhqm9BDXG6rax+y+vIzgICK9YP zKaw== X-Gm-Message-State: AOAM532KJGtLE624Op0dOvZf4ps1UoCOZe6cUsNavoIorNhn+tu3LVvK q01WbCdBG6FmiNuxEbZVnrLwQ7YoyG6pPX4= X-Received: by 2002:a05:6638:24d1:: with SMTP id y17mr271073jat.300.1639699942825; Thu, 16 Dec 2021 16:12:22 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:1163:bda5:7473:fab3]) by smtp.gmail.com with ESMTPSA id z13sm1571257iln.43.2021.12.16.16.12.22 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 16 Dec 2021 16:12:22 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Thu, 16 Dec 2021 18:12:10 -0600 Message-Id: <20211217001215.75135-6-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211217001215.75135-1-rcombs@rcombs.me> References: <20211217001215.75135-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/10] lavc/videotoolboxenc: config-gate ATSC CC support 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: kiTG5MjO+tMl --- libavcodec/videotoolboxenc.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index e10373dded..b66d44f6b7 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -2363,6 +2363,7 @@ static int vtenc_send_frame(AVCodecContext *avctx, return status; } +#if CONFIG_ATSC_A53 side_data = av_frame_get_side_data(frame, AV_FRAME_DATA_A53_CC); if (vtctx->a53_cc && side_data && side_data->size) { sei = av_mallocz(sizeof(*sei)); @@ -2377,6 +2378,7 @@ static int vtenc_send_frame(AVCodecContext *avctx, } } } +#endif time = CMTimeMake(frame->pts * avctx->time_base.num, avctx->time_base.den); status = VTCompressionSessionEncodeFrame( From patchwork Fri Dec 17 00:12:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 32674 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp1002244iog; Thu, 16 Dec 2021 16:13:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQ+Qw/iXaSwO5UmYeNr95qfwaU8YuUQCbabcmBNEF3EX2PpkjwZ9/I3IouVE5sheDG/5r3 X-Received: by 2002:a17:907:2da0:: with SMTP id gt32mr406277ejc.711.1639700012693; Thu, 16 Dec 2021 16:13:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639700012; cv=none; d=google.com; s=arc-20160816; b=Em5Y3hWmPC0CPDOHd51C6mPdr/FlCf0ZnBGFSZUPZo6ef439sYPdGv0aRRwwal4hM0 8oud0CHh5QFSmKBgF+/DPwS8uvs49CHMzONcfDH+mreyDD2uwCmW6rCiaB2ihoNWsZOE serwMwb/0LqVIlFYNbZYrKHTxvsWMnCkd3WvIl+zuNaVYDrgV4KEaOYKUwYiRh4pF+eb OhcN/WWydT3oYfBYO96FomXQWqiRF+O2BAnK8jinJNO4OSlInAPUoUN3ijEwstmH3LXS DRkLbXSfav/i5lhu7bVMYkL2VAzez+S5aAN4kVHOscVF1PTES2RccPtLub+x1q4c36za WA4w== 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=zMeGMv/MgvGkzFqdHuoQv9qiNwLCPellGxsRjqytC/Y=; b=QbDRkJbkak00tjqFWU/Q2RPsm3ck5Mo7MuQU1K4jrvlEPO7hPy6QYlqy1Sj0gkPRsl SFarddXC0ZNiGDQHr0+xIqcOlfD25NZ8+zEGmJ1yIPlPJlW/xV4a+qTz/fGy+241lJAA aHhpvCPIyWpikCTz1Gp7+SW9fFLYoxlgPrrIwNM4+NVPjpdhBt1McvqKhyF9DrbJyqlg PZT11cI4YQniTeECcUZ2AVJi0/N1q178YmKjUvuoCnqIkJ7tJex4wc7tt9WGj2A7iNgr 8WzvQ7j9J2NKtWdc88IQ2yThJBH7XVTtUE/9/b0f9oEASOI7upHB8S9znkGaZxvGIakN MlDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=K1DrHAly; 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 s3si4377907eji.349.2021.12.16.16.13.32; Thu, 16 Dec 2021 16:13:32 -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=K1DrHAly; 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 508B268B003; Fri, 17 Dec 2021 02:12:35 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f43.google.com (mail-io1-f43.google.com [209.85.166.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8A64568AFDE for ; Fri, 17 Dec 2021 02:12:25 +0200 (EET) Received: by mail-io1-f43.google.com with SMTP id 14so750571ioe.2 for ; Thu, 16 Dec 2021 16:12:25 -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=lcK/svsQRKORVvm33/JTt4tCzVC0fXTgguAGt/zvo+A=; b=K1DrHAlyFkATc5TWH7hMWSBQn0OiyOKqUmLffONyGq7PBihXmKZQtSXB+11S+8To2O dMJm4+xySs7A4xY67vDHRYTFXOgjgICLS5rK2VQoIKvB3wv5Cxhv5xUh8sxJSeFGQG0Q BGpLfw5V+gqHN391tYYC6Ge09wgpQEhE9qUqYltKD113mu0A1uP/pOS5KFhMKEG2E0d2 PnJ+QuqR2JOZFdBdiIRzXYLRy3eJHahFASouJwmpup2zb9uXiFAImOchtFON5ut1BPvM c5wWuLXzqI44xYkYWEhZdvNNpEOrIu5XWu7hCW9stNPps/MgKYzsiAMlcR5m8MwMaKjc Er8g== 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=lcK/svsQRKORVvm33/JTt4tCzVC0fXTgguAGt/zvo+A=; b=mUlrXWpRput8I/VjKjDRor3pga83UdpiLUtMDfD+8odcXSLp0OcevQzVYrEfKdEiuR KYFG6GNVNWqRzJuUqwFvzpcBMzcZL3o6XVNX7EvYf3Kq/Vw0kutjnUvKS7Q509GFULP1 VlAyci1ybWLE4ZdiNLrAu22VF5tK6SPKvc6L3TXKmcJ+bTGThTJNJbX3vC6nxP0tg+EZ OguRXa2ZQr/RsgeEdUUu8eKyceecNKzm+6KJobmRiO4yen0o9ubPxhQ7OV5POYp+VzHB Lym6TScIPC22KP9nnHeUH484WxsgpxbhSzntbAsm8/zQR2PkBpxuDlGz+3xClLN5eAFk umTA== X-Gm-Message-State: AOAM5337+30LH1LpoMC/zHsFwDYir5hLToZRrtgLQ2QtZTrmgzYhrzTl PCnpS3/Pwz6ICaYuub5XXwV+6xLtFblYmV0= X-Received: by 2002:a05:6638:4183:: with SMTP id az3mr271108jab.56.1639699943683; Thu, 16 Dec 2021 16:12:23 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:1163:bda5:7473:fab3]) by smtp.gmail.com with ESMTPSA id z13sm1571257iln.43.2021.12.16.16.12.22 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 16 Dec 2021 16:12:23 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Thu, 16 Dec 2021 18:12:11 -0600 Message-Id: <20211217001215.75135-7-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211217001215.75135-1-rcombs@rcombs.me> References: <20211217001215.75135-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/10] lavc/videotoolboxenc: vastly simplify get_cv_pixel_info 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: cIcaBfLdKLFY No longer requires per-format switch cases. The frame==0 path was unused (and would've crashed anyway). --- libavcodec/videotoolboxenc.c | 69 +++++++----------------------------- 1 file changed, 13 insertions(+), 56 deletions(-) diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index b66d44f6b7..82e01fbe29 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -2034,6 +2034,7 @@ static int get_cv_pixel_info( size_t *strides, size_t *contiguous_buf_size) { + const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt); VTEncContext *vtctx = avctx->priv_data; int av_format = frame->format; int av_color_range = frame->color_range; @@ -2041,6 +2042,9 @@ static int get_cv_pixel_info( int range_guessed; int status; + if (!desc) + return AVERROR(EINVAL); + status = get_cv_pixel_format(avctx, av_format, av_color_range, color, &range_guessed); if (status) { av_log(avctx, @@ -2065,63 +2069,16 @@ static int get_cv_pixel_info( } } - switch (av_format) { - case AV_PIX_FMT_NV12: - *plane_count = 2; - - widths [0] = avctx->width; - heights[0] = avctx->height; - strides[0] = frame ? frame->linesize[0] : avctx->width; - - widths [1] = (avctx->width + 1) / 2; - heights[1] = (avctx->height + 1) / 2; - strides[1] = frame ? frame->linesize[1] : (avctx->width + 1) & -2; - break; - - case AV_PIX_FMT_YUV420P: - *plane_count = 3; - - widths [0] = avctx->width; - heights[0] = avctx->height; - strides[0] = frame ? frame->linesize[0] : avctx->width; - - widths [1] = (avctx->width + 1) / 2; - heights[1] = (avctx->height + 1) / 2; - strides[1] = frame ? frame->linesize[1] : (avctx->width + 1) / 2; - - widths [2] = (avctx->width + 1) / 2; - heights[2] = (avctx->height + 1) / 2; - strides[2] = frame ? frame->linesize[2] : (avctx->width + 1) / 2; - break; + *plane_count = av_pix_fmt_count_planes(avctx->pix_fmt); - case AV_PIX_FMT_BGRA: - *plane_count = 1; - - widths [0] = avctx->width; - heights[0] = avctx->height; - strides[0] = frame ? frame->linesize[0] : avctx->width * 4; - break; - - case AV_PIX_FMT_P010LE: - *plane_count = 2; - widths[0] = avctx->width; - heights[0] = avctx->height; - strides[0] = frame ? frame->linesize[0] : (avctx->width * 2 + 63) & -64; - - widths[1] = (avctx->width + 1) / 2; - heights[1] = (avctx->height + 1) / 2; - strides[1] = frame ? frame->linesize[1] : ((avctx->width + 1) / 2 + 63) & -64; - break; - - default: - av_log( - avctx, - AV_LOG_ERROR, - "Could not get frame format info for color %d range %d.\n", - av_format, - av_color_range); - - return AVERROR(EINVAL); + for (i = 0; i < desc->nb_components; i++) { + int p = desc->comp[i].plane; + int chroma = (p != 0) && (!(desc->flags & AV_PIX_FMT_FLAG_ALPHA) || p + 1 != *plane_count); + int shiftw = chroma ? desc->log2_chroma_w : 0; + int shifth = chroma ? desc->log2_chroma_h : 0; + widths[p] = (avctx->width + ((1 << shiftw) >> 1)) >> shiftw; + heights[p] = (avctx->height + ((1 << shifth) >> 1)) >> shifth; + strides[p] = frame->linesize[p]; } *contiguous_buf_size = 0; From patchwork Fri Dec 17 00:12: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: 32675 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp1002374iog; Thu, 16 Dec 2021 16:13:43 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+qJDjk/s4I4nEakrWPevhAH/8sWjTu3QFoiDCpCqWPC5CG5Xo70KOqAo8sXY6Uy1bQzT5 X-Received: by 2002:a17:906:4407:: with SMTP id x7mr393331ejo.51.1639700023034; Thu, 16 Dec 2021 16:13:43 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639700023; cv=none; d=google.com; s=arc-20160816; b=C1wHmLFiSMNV99d6LAUAkFv7Z7QT+IIbzKGU+fUBfM1nauw421EtaQkf40AI4nH/+p AwI0Wqjmw9BJ1WrOKdCn3trgZDZD/2uxlwmvj4wZxwCmO4dLtbmmO/xH30/GgPL6wtDi H52pKjjIIA7Vut65eLw5EfR8sU9O7Ggsc+yw8GZs5prOIsm2BafW3GBt3FjjZl6EkrZO fy6kfDVQiYn6rn+rVPjxGClmFWumyyAXPJ6DROHdrPl5wtSdzXFZBPTGjstcjnR90NEj pymtQ8Q9STEC+vd/cvdyN2bzm8sU5TojaQ1EiQYN9Q3tehzqcmFtTZVy5QnYGX9ho4an BvfA== 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=/H+PKXIqiLTEWJkXSJ3UU3KO9HFzwzeR+AtKBLtsUNY=; b=rt553IciUWzvBcfp6XbMxmHgZSwDmnX9uOGlLbHUk8zlaSHbha/gV0PpD/kqHMh/I9 yjGH0mZwowAU9wiQJofjW59tjtqeQQ3kG8hkWrdeU+KmelqNlsHxElPEwn9knEefB70B 9feikMZpopbw5fEVK77g83WAJbwwTwcT64T/lqFikClOemWKskvncwD9RdATTEPGfKlG LBvO0LHA30qJYzk7rm3kv01vetFuo3W80diwDItsdq0pPKKc6RpMihAmEbwn+5KvFNgz iL2xG8UD1XuFLf4agO6saZZ0z1p89E3kLzgUWZ8a03W2EHVQBevjF8z5xY9KSU/zh20H EkzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b="E5Zz/G1Z"; 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 x10si4163670ejv.557.2021.12.16.16.13.42; Thu, 16 Dec 2021 16:13:43 -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="E5Zz/G1Z"; 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 59E5C68AFEC; Fri, 17 Dec 2021 02:12:36 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-il1-f176.google.com (mail-il1-f176.google.com [209.85.166.176]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 0588168AFE1 for ; Fri, 17 Dec 2021 02:12:26 +0200 (EET) Received: by mail-il1-f176.google.com with SMTP id f17so363076ilj.11 for ; Thu, 16 Dec 2021 16:12:25 -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=T5kmcBHkq5HZ0nAIuQYmOiwY79tms9x+PW3nVfBKsw0=; b=E5Zz/G1Zt6Jf7SDl+mqd2SSRc9jCxxXqCWZWv3PkaXjmKNHhbpBlQE44dV9WiKmsoT IFLZ2s7XBtw59aLPkGuCV2Ei45Pr7LbEQ+SMuYhrFiqsjuseYa4DkFzUNG9ON2J3aOrh NLd5hakqY7f2BhgbOz4lASeLquhdmn58fM7OaY40lORgQFjPW9eBW+8D8zrEytZ0rx/U 04dwKMYa+IM+mUl5whfG/h85djXpm3HJjP/Rxe8qpxUtr0zIN1shFhh5siYFGZHoYx1U XBcOL1+JxlA8CbRqJ6BrpShWO+SL77CEMiw/ZGQXs/NgS/F6H6KO+aHMEX5NhOLreBV0 IWzw== 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=T5kmcBHkq5HZ0nAIuQYmOiwY79tms9x+PW3nVfBKsw0=; b=zr2SnQHeiynZDlZU0246w5uLU2oJkXNxGiNSEPbZlcHlTnDlwGK6pBRj52H+sa/0q3 f97J79FnyzWCEQ4EDLH+3g1MCvfYweSplMUEN0+jnwL7Z9vi63T1EakDvcRdUSkCPeMz t/E6EamyfRwbKMpoJlOWlOVt+XX/wpQQ8ivPmromEdvyu9BZmfvba/o6pkuMTCZKtYyd 19o/Pz6EksmHFgugSMzTBaIXJkgHA7jJvlV/2p+D7TdXhW6HJc1ZaVU1o9tH+HI1NriR kK42+po0fkMQF19lYQyn/aDXfJrzOFmWzu6h0U5sj+n1o9gEiUekDJjtuf69SO6CpduM /JFA== X-Gm-Message-State: AOAM530u4O4YKa+s9sCDZnEkQuUrioq38yWXDHKWh255fAAkdWqtS5Yy eWmgaJ8ETREMb1jmP8tgqdmXbSYbVeVtB80= X-Received: by 2002:a92:d58a:: with SMTP id a10mr263576iln.81.1639699944355; Thu, 16 Dec 2021 16:12:24 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:1163:bda5:7473:fab3]) by smtp.gmail.com with ESMTPSA id z13sm1571257iln.43.2021.12.16.16.12.23 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 16 Dec 2021 16:12:24 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Thu, 16 Dec 2021 18:12:12 -0600 Message-Id: <20211217001215.75135-8-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211217001215.75135-1-rcombs@rcombs.me> References: <20211217001215.75135-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/10] lavc/videotoolboxenc: add handling for non-NAL-based codecs 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: o3lTPoN8tlCK --- libavcodec/videotoolboxenc.c | 149 +++++++++++++++++++++-------------- 1 file changed, 92 insertions(+), 57 deletions(-) diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index 82e01fbe29..67bb563639 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -549,6 +549,7 @@ static int copy_param_sets( static int set_extradata(AVCodecContext *avctx, CMSampleBufferRef sample_buffer) { + VTEncContext *vtctx = avctx->priv_data; CMVideoFormatDescriptionRef vid_fmt; size_t total_size; int status; @@ -559,23 +560,37 @@ static int set_extradata(AVCodecContext *avctx, CMSampleBufferRef sample_buffer) return AVERROR_EXTERNAL; } - status = get_params_size(avctx, vid_fmt, &total_size); - if (status) { - av_log(avctx, AV_LOG_ERROR, "Could not get parameter sets.\n"); - return status; - } + if (vtctx->get_param_set_func) { + status = get_params_size(avctx, vid_fmt, &total_size); + if (status) { + av_log(avctx, AV_LOG_ERROR, "Could not get parameter sets.\n"); + return status; + } - avctx->extradata = av_mallocz(total_size + AV_INPUT_BUFFER_PADDING_SIZE); - if (!avctx->extradata) { - return AVERROR(ENOMEM); - } - avctx->extradata_size = total_size; + avctx->extradata = av_mallocz(total_size + AV_INPUT_BUFFER_PADDING_SIZE); + if (!avctx->extradata) { + return AVERROR(ENOMEM); + } + avctx->extradata_size = total_size; - status = copy_param_sets(avctx, vid_fmt, avctx->extradata, total_size); + status = copy_param_sets(avctx, vid_fmt, avctx->extradata, total_size); - if (status) { - av_log(avctx, AV_LOG_ERROR, "Could not copy param sets.\n"); - return status; + if (status) { + av_log(avctx, AV_LOG_ERROR, "Could not copy param sets.\n"); + return status; + } + } else { + CFDataRef data = CMFormatDescriptionGetExtension(vid_fmt, kCMFormatDescriptionExtension_VerbatimSampleDescription); + if (data && CFGetTypeID(data) == CFDataGetTypeID()) { + CFIndex size = CFDataGetLength(data); + + avctx->extradata = av_mallocz(size + AV_INPUT_BUFFER_PADDING_SIZE); + if (!avctx->extradata) + return AVERROR(ENOMEM); + avctx->extradata_size = size; + + CFDataGetBytes(data, CFRangeMake(0, size), avctx->extradata); + } } return 0; @@ -1938,62 +1953,82 @@ static int vtenc_cm_to_avpacket( CMTime dts; CMVideoFormatDescriptionRef vid_fmt; - vtenc_get_frame_info(sample_buffer, &is_key_frame); - status = get_length_code_size(avctx, sample_buffer, &length_code_size); - if (status) return status; - add_header = is_key_frame && !(avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER); + if (vtctx->get_param_set_func) { + status = get_length_code_size(avctx, sample_buffer, &length_code_size); + if (status) return status; - if (add_header) { - vid_fmt = CMSampleBufferGetFormatDescription(sample_buffer); - if (!vid_fmt) { - av_log(avctx, AV_LOG_ERROR, "Cannot get format description.\n"); - return AVERROR_EXTERNAL; + add_header = is_key_frame && !(avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER); + + if (add_header) { + vid_fmt = CMSampleBufferGetFormatDescription(sample_buffer); + if (!vid_fmt) { + av_log(avctx, AV_LOG_ERROR, "Cannot get format description.\n"); + return AVERROR_EXTERNAL; + } + + int status = get_params_size(avctx, vid_fmt, &header_size); + if (status) return status; } - int status = get_params_size(avctx, vid_fmt, &header_size); - if (status) return status; - } + status = count_nalus(length_code_size, sample_buffer, &nalu_count); + if(status) + return status; - status = count_nalus(length_code_size, sample_buffer, &nalu_count); - if(status) - return status; + if (sei) { + size_t msg_size = get_sei_msg_bytes(sei, + SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35); - if (sei) { - size_t msg_size = get_sei_msg_bytes(sei, - SEI_TYPE_USER_DATA_REGISTERED_ITU_T_T35); + sei_nalu_size = sizeof(start_code) + 1 + msg_size + 1; + } - sei_nalu_size = sizeof(start_code) + 1 + msg_size + 1; - } + in_buf_size = CMSampleBufferGetTotalSampleSize(sample_buffer); + out_buf_size = header_size + + in_buf_size + + sei_nalu_size + + nalu_count * ((int)sizeof(start_code) - (int)length_code_size); - in_buf_size = CMSampleBufferGetTotalSampleSize(sample_buffer); - out_buf_size = header_size + - in_buf_size + - sei_nalu_size + - nalu_count * ((int)sizeof(start_code) - (int)length_code_size); + status = ff_get_encode_buffer(avctx, pkt, out_buf_size, 0); + if (status < 0) + return status; - status = ff_get_encode_buffer(avctx, pkt, out_buf_size, 0); - if (status < 0) - return status; + if (add_header) { + status = copy_param_sets(avctx, vid_fmt, pkt->data, out_buf_size); + if(status) return status; + } - if (add_header) { - status = copy_param_sets(avctx, vid_fmt, pkt->data, out_buf_size); - if(status) return status; - } + status = copy_replace_length_codes( + avctx, + length_code_size, + sample_buffer, + sei, + pkt->data + header_size, + pkt->size - header_size + ); - status = copy_replace_length_codes( - avctx, - length_code_size, - sample_buffer, - sei, - pkt->data + header_size, - pkt->size - header_size - ); + if (status) { + av_log(avctx, AV_LOG_ERROR, "Error copying packet data: %d\n", status); + return status; + } + } else { + CMBlockBufferRef buf = CMSampleBufferGetDataBuffer(sample_buffer); + if (!buf) { + av_log(avctx, AV_LOG_ERROR, "Error getting block buffer\n"); + return AVERROR_EXTERNAL; + } - if (status) { - av_log(avctx, AV_LOG_ERROR, "Error copying packet data: %d\n", status); - return status; + size_t len = CMBlockBufferGetDataLength(buf); + + status = ff_get_encode_buffer(avctx, pkt, len, 0); + if (status < 0) + return status; + + status = CMBlockBufferCopyDataBytes(buf, 0, len, pkt->data); + if (status) { + av_log(avctx, AV_LOG_ERROR, "Error copying packet data: %d\n", status); + return AVERROR_EXTERNAL; + } } if (is_key_frame) { From patchwork Fri Dec 17 00:12:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 32676 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp1002509iog; Thu, 16 Dec 2021 16:13:53 -0800 (PST) X-Google-Smtp-Source: ABdhPJz5CBVsx3bD6U8wpKdrXN5w+WS6XhTvcz/+QOhJNasbfsDcCyGukhQU3kjquIlYd6EChsHn X-Received: by 2002:a05:6402:1012:: with SMTP id c18mr380557edu.67.1639700032960; Thu, 16 Dec 2021 16:13:52 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639700032; cv=none; d=google.com; s=arc-20160816; b=X8d6+XbCX2iDGsfL9kbViESf96OTcaxAJdgEZbpSxn5V1o4BeGspXRs+l7+n9sfrZ9 dVms88cLtqthRCr24iByEpkWmTQhu8qphLRrOTWdDCRZyZ9JLS49z11ggy7UCSf+Tvd+ o3Ea7RRsPK6yd0fXMr3WH1IQ9/MNc9GMF8dtg1BkGk1DP2PQy5H2o92mc7KO2fIqArcV KuIhBqwK3/Qd3BIeaAtbFkohYOrdKgv+Fpxxbq6RfioGcbg1zhpMV15xcFj4I3DWiIpL 2V1OeJGVSQNS6Rne4N8UdxOTrk4Zv52f7G8NQoiwShqsQ4X/G9MrqsPTrfxS4V+g+D4f gbXA== 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=e2x87Znvcc/0R859TMWOw1mGpiHL1c3nyq/uC+VKv8k=; b=A5k5xF2ZaQCk+jiqreazczzlxxoMragYA9+OV4m9eBJ3djzerliZDZTNkk8hqzaXvB 43lkYU4vp0SJ0078GqCKPne5NwfjFlWFkh0D+nQKWIBoUR/4kvtlA/mgacQGMXCT5jgO lPsISddaNRBJrdeMsHP7wC1n5AF/BQOZo9q4Oaz+0DWvAumbB1Puh51QU0vnMVpKC7MP QB9GJ4qXyo+pT5ciVtzRn4VBYzf7iDAytWaCPcPxV7AdCHjhmP0YICPw1MupCWucgXz/ RhHwu1TZHvJfB51ytm86fhNfMWx/JZFrL6l0l1DIhyqXDTMnJAFP/Hfqjx9gVgi5C/3d u35A== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=AXh5LEOC; 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 h10si3801773ejx.712.2021.12.16.16.13.52; Thu, 16 Dec 2021 16:13:52 -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=AXh5LEOC; 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 4837A68B00E; Fri, 17 Dec 2021 02:12:37 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-il1-f179.google.com (mail-il1-f179.google.com [209.85.166.179]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id D1AC568AFDF for ; Fri, 17 Dec 2021 02:12:26 +0200 (EET) Received: by mail-il1-f179.google.com with SMTP id m12so433762ild.0 for ; Thu, 16 Dec 2021 16:12:26 -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=Fu/esj887rt2KJx2t3MHpxTZmIwQCLnC8lmCgPC6/HY=; b=AXh5LEOCmUNj2i7zXlKFTRSYyI5sPuwyijwN6aE4Fs1ii0YiEfQsbB/seaLAFuOe1+ GZlKm3IhEu5MWjm9ZKvqlKo9hLxTKH40Sa4ovilV1N9DIHuhUfVDpnamqXTc6oohn3Nv WmTzWkPR8c/543zO3TkHpgs93Y4qGforwqbKEeAMEftayNTVBIamFz2XyHjy39N4PEXm gGaZtoiOiiq7tRiYTQiTYz+mf3TUeKSICSTtAVn0pz0TgEM2JHzxNjGR4OXrUXId2dqI 2AaXFGXDvtB56uU4h0AHPhzvX7y12PTmiD5s2dCEPdwf4ZOs8Xnkl6MIItuHupE4tAEj +jgA== 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=Fu/esj887rt2KJx2t3MHpxTZmIwQCLnC8lmCgPC6/HY=; b=S9Hi+BxEEiIlXMVFgzZ4tpNifdR8zzBUwkzkAeLeFSAML0Ssq9g8Leqlt3Z3hrTj7h CjFLb6W09ehHwnxeikYkp8NGWWQWNMTIiZbpLLffJKjjjqU6kpLhWEmzwKOMQeEBX4j5 C7LTz3vL5OvrR+P6J52FZygj8Yk6nBsF2GmOrKf5e6ocdAq1wzVZ5UtuIQ60mrndaHeM vYStAzT9pdhqRCDgCvP8AGgPWciisYYG/iBEmsGDzz77+UhjuKIQLKgGQJunX0RPxx23 xFYNAMNyftort+Io637wT0p9F5mhLWlFQugoMujQ2Ne9a3zLGF2xW/u83+XdcZVIjKLP kFoA== X-Gm-Message-State: AOAM532Gpky4Q1WjX8nqxhzT+HmcAsJhSBLdJu2UbDNEeiroNZ+ZN7z7 ZqEgbKuwj+zsv7ooyre3WIgu6gZtouDg+Fc= X-Received: by 2002:a92:c089:: with SMTP id h9mr236541ile.289.1639699945139; Thu, 16 Dec 2021 16:12:25 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:1163:bda5:7473:fab3]) by smtp.gmail.com with ESMTPSA id z13sm1571257iln.43.2021.12.16.16.12.24 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 16 Dec 2021 16:12:24 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Thu, 16 Dec 2021 18:12:13 -0600 Message-Id: <20211217001215.75135-9-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211217001215.75135-1-rcombs@rcombs.me> References: <20211217001215.75135-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/10] lavc/Makefile: fix missing hevc_videotoolbox case 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: 0txbLEvRlp7y --- libavcodec/Makefile | 1 + 1 file changed, 1 insertion(+) diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 4122a9b144..beb91e8c12 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -403,6 +403,7 @@ OBJS-$(CONFIG_HEVC_RKMPP_DECODER) += rkmppdec.o OBJS-$(CONFIG_HEVC_VAAPI_ENCODER) += vaapi_encode_h265.o h265_profile_level.o OBJS-$(CONFIG_HEVC_V4L2M2M_DECODER) += v4l2_m2m_dec.o OBJS-$(CONFIG_HEVC_V4L2M2M_ENCODER) += v4l2_m2m_enc.o +OBJS-$(CONFIG_HEVC_VIDEOTOOLBOX_ENCODER) += videotoolboxenc.o OBJS-$(CONFIG_HNM4_VIDEO_DECODER) += hnm4video.o OBJS-$(CONFIG_HQ_HQA_DECODER) += hq_hqa.o hq_hqadata.o hq_hqadsp.o \ canopus.o From patchwork Fri Dec 17 00:12:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 32677 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp1002647iog; Thu, 16 Dec 2021 16:14:02 -0800 (PST) X-Google-Smtp-Source: ABdhPJyEP4T2Nzr/wlz+XPHBUcLM1z5pwjz1QLvHnzUpajszDf/p5J00XR0G5cdpSZJByG0nPDeV X-Received: by 2002:a17:907:97d5:: with SMTP id js21mr385896ejc.445.1639700042664; Thu, 16 Dec 2021 16:14:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639700042; cv=none; d=google.com; s=arc-20160816; b=VzggOBBEm4kHBqvTAjgJAx6ZYTdfPkfjRnSmMmfH6gdO3UVkMvjql9zdNOzXIwwdtv bStFfMBIIxv/QNjA85YbBo57/RzTAd1XV4RV+YqO7dabZcq4Y/19CKCGsVD9S7nTIzfH Z7JFHJk0WcdHyjQLPmARKXDJC6sbdaGQN10Bi3B81Vtp/fQYKUvOm6V7gAsQhBKwzDU7 csweY6xEJXV6VjtE+8SbJ0ksCH9eL46z+BsIz8E3iRgCV/y5UL53q+FePMOD6vEnWXc4 jKluthoaZsLveDQkLrH/W85zHQDkadj5f85biFI4lShMQio7PhtZY3rcY+FNxcy7NBkD wvug== 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=AOYcac98WJ/WomPnX16PpsUJj+A6nzO9W3Jann6UYAw=; b=k81uH9YaQItl1K15JVoyiwi7DZYO2wD4kXlteCojNV95tM0ZbAR1r/4ghmx8dJs9qu Ac6ARNztn4129P647dCZtRRD5Hxsh0+6hMx8qYb/iz7XNHe/UPuxnbtOV/ka1usX16KE j3iX/5nHkcdum6b75LveuWBy+eu1DZmCsC1Yv8SOPMehlrdN7aDgwGIfzqxOYQUIQVT9 EH5in/l20JydwM33rWyfvYBncsUIXOTALjTNOcrmvn/XkhoCFekh20cxQnDl03lDOadE voLtmajyFt62FRh5NK/7zIaUlxkAVpDo7dSm8rX8kTsbm6VYNcUWgiHQE86xQyVoa7iG L0zQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=hb9MZ7o8; 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 dr2si5790255ejc.435.2021.12.16.16.14.02; Thu, 16 Dec 2021 16:14:02 -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=hb9MZ7o8; 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 2F0E568AFF6; Fri, 17 Dec 2021 02:12:38 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f44.google.com (mail-io1-f44.google.com [209.85.166.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E898468AFF1 for ; Fri, 17 Dec 2021 02:12:27 +0200 (EET) Received: by mail-io1-f44.google.com with SMTP id x10so704421ioj.9 for ; Thu, 16 Dec 2021 16:12:27 -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=U9QONINNgGHhaqg8JxILG5IaAjCQXLJlp4NPOujY2Uk=; b=hb9MZ7o8T/HJhkh0cduAe4P/1mpO1Re/uaUaUgPn83p80WGiLMj+noDG04J6eZEBcJ yc6JhHvGgaNYFRzui3kFDiP1IE0lmjE0G0V6hitwfT3P+TbXc4QlUQC3r3T4i/iHItVf qfQpxTc677In9qQ/1hCt6eeTYdoqKk+EtLH8/9sjZ41EfFNa61c6rKk/STPsF5c931O+ 9TxZlq4BMs73n6Qz32SyTefRzTNXC1394tnKcvHhRLmyZACrXfULxPbqQJjavWk5ZzFM YanQgBBAVwD0zvV73TnbAw+mYKrJ8gTinIE+y6BsNN5FIhUk5SaFa348P7kOlJpRFS8I JywQ== 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=U9QONINNgGHhaqg8JxILG5IaAjCQXLJlp4NPOujY2Uk=; b=RXPLbwUKxIrCyme7sscPoDakzYvmP3sA0RHy3RtVp28Z3W3y/M0dOGaK8+czoXms12 KBEF//nUupvxTxzIPyACXYY8fxlOVX4YdbL5yOMgiAev/VIv1j30x6G7p1iHSFOS9OIy 8qtp4PLlBQY1dbADsAN9B6AOgUEjpB3jcqft5ONrdGXc2UabkBp3HIlh1DJbHQr+GO7B ZuD3lhC4N7ukKPdMStCQfF0gECdry4DWkWNP3QWJKhu0qNvgaAklsQ6G0XBhzCPfGNX3 lcmfP/WXwOo5aT26chToyqORiNPfuJzkPNzUBGUi3/yDlWMGSncIGsXCD8pMwwJA1Cvx pang== X-Gm-Message-State: AOAM532v3TaoEI1v3uNbgkkjLEeQZ6JZWLqGWYTV+eOeU5wOyaBQyYHQ +S4PuHiRogWbHLa2IctyCToPE6vqLfExouY= X-Received: by 2002:a05:6602:1592:: with SMTP id e18mr396418iow.142.1639699946031; Thu, 16 Dec 2021 16:12:26 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:1163:bda5:7473:fab3]) by smtp.gmail.com with ESMTPSA id z13sm1571257iln.43.2021.12.16.16.12.25 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 16 Dec 2021 16:12:25 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Thu, 16 Dec 2021 18:12:14 -0600 Message-Id: <20211217001215.75135-10-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211217001215.75135-1-rcombs@rcombs.me> References: <20211217001215.75135-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/10] swscale: add P210/P410/P216/P416 output 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: S1FXX7AJOtqZ --- libswscale/output.c | 8 ++++++-- libswscale/utils.c | 16 ++++++++-------- libswscale/version.h | 2 +- 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/libswscale/output.c b/libswscale/output.c index 58b10f85a5..4b4b186be9 100644 --- a/libswscale/output.c +++ b/libswscale/output.c @@ -2563,14 +2563,18 @@ av_cold void ff_sws_init_output_funcs(SwsContext *c, enum AVPixelFormat dstFormat = c->dstFormat; const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(dstFormat); - if (dstFormat == AV_PIX_FMT_P010LE || dstFormat == AV_PIX_FMT_P010BE) { + if (dstFormat == AV_PIX_FMT_P010LE || dstFormat == AV_PIX_FMT_P010BE || + dstFormat == AV_PIX_FMT_P210LE || dstFormat == AV_PIX_FMT_P210BE || + dstFormat == AV_PIX_FMT_P410LE || dstFormat == AV_PIX_FMT_P410BE) { *yuv2plane1 = isBE(dstFormat) ? yuv2p010l1_BE_c : yuv2p010l1_LE_c; *yuv2planeX = isBE(dstFormat) ? yuv2p010lX_BE_c : yuv2p010lX_LE_c; *yuv2nv12cX = yuv2p010cX_c; } else if (is16BPS(dstFormat)) { *yuv2planeX = isBE(dstFormat) ? yuv2planeX_16BE_c : yuv2planeX_16LE_c; *yuv2plane1 = isBE(dstFormat) ? yuv2plane1_16BE_c : yuv2plane1_16LE_c; - if (dstFormat == AV_PIX_FMT_P016LE || dstFormat == AV_PIX_FMT_P016BE) { + if (dstFormat == AV_PIX_FMT_P016LE || dstFormat == AV_PIX_FMT_P016BE || + dstFormat == AV_PIX_FMT_P216LE || dstFormat == AV_PIX_FMT_P216BE || + dstFormat == AV_PIX_FMT_P416LE || dstFormat == AV_PIX_FMT_P416BE) { *yuv2nv12cX = yuv2p016cX_c; } } else if (isNBPS(dstFormat)) { diff --git a/libswscale/utils.c b/libswscale/utils.c index d4a72d3ce1..c80b4f3e35 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -268,14 +268,14 @@ static const FormatEntry format_entries[] = { [AV_PIX_FMT_Y210LE] = { 1, 0 }, [AV_PIX_FMT_X2RGB10LE] = { 1, 1 }, [AV_PIX_FMT_X2BGR10LE] = { 1, 1 }, - [AV_PIX_FMT_P210BE] = { 1, 0 }, - [AV_PIX_FMT_P210LE] = { 1, 0 }, - [AV_PIX_FMT_P410BE] = { 1, 0 }, - [AV_PIX_FMT_P410LE] = { 1, 0 }, - [AV_PIX_FMT_P216BE] = { 1, 0 }, - [AV_PIX_FMT_P216LE] = { 1, 0 }, - [AV_PIX_FMT_P416BE] = { 1, 0 }, - [AV_PIX_FMT_P416LE] = { 1, 0 }, + [AV_PIX_FMT_P210BE] = { 1, 1 }, + [AV_PIX_FMT_P210LE] = { 1, 1 }, + [AV_PIX_FMT_P410BE] = { 1, 1 }, + [AV_PIX_FMT_P410LE] = { 1, 1 }, + [AV_PIX_FMT_P216BE] = { 1, 1 }, + [AV_PIX_FMT_P216LE] = { 1, 1 }, + [AV_PIX_FMT_P416BE] = { 1, 1 }, + [AV_PIX_FMT_P416LE] = { 1, 1 }, }; void ff_shuffle_filter_coefficients(SwsContext *c, int *filterPos, int filterSize, int16_t *filter, int dstW){ diff --git a/libswscale/version.h b/libswscale/version.h index 15ad54319c..8f7b56df9a 100644 --- a/libswscale/version.h +++ b/libswscale/version.h @@ -28,7 +28,7 @@ #define LIBSWSCALE_VERSION_MAJOR 6 #define LIBSWSCALE_VERSION_MINOR 1 -#define LIBSWSCALE_VERSION_MICRO 101 +#define LIBSWSCALE_VERSION_MICRO 102 #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \ LIBSWSCALE_VERSION_MINOR, \ From patchwork Fri Dec 17 00:12:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 32678 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:cd86:0:0:0:0:0 with SMTP id d128csp1002774iog; Thu, 16 Dec 2021 16:14:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQHf2+p7bhUj8vqeXYL7yk5jtRwaxFh+3bHNP/ZPr7FBV8k647MkoJjB52LYh85F8p4LWr X-Received: by 2002:a05:6402:1768:: with SMTP id da8mr409468edb.252.1639700052695; Thu, 16 Dec 2021 16:14:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1639700052; cv=none; d=google.com; s=arc-20160816; b=g7kwqPgC+i89/iVCTg4s+gfUsj6JKcLowNnm4bz1H/0cAsm0o9UFFGR78qefmuI/bZ 1kS+Y6mcq7yhCPrSCljRck08+wJPscELGWqkZqB0a2SpiSBHDZjE6pKqhpBPLXHjR5jI x6hhv0nkqwYesBt/x0GH54xb2/Dz49qO3HR4H40dlrt4+953FW5xuncVrhzrQAV9Mgqg duB5VWnINf1ZjU9zTUgMD4Usft5ha0+7hhmx7/XkFla6jFLyZIyy3uwkmylzNIhuGbob FYOORWcSRuiRBKOfzDoJT26iZUgh2hDdwGG9RKUobd3xvr3eoQO5GfpoA//+l0qKa2OE pPRQ== 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=hKKu0rzgDluejoyir8Pb/iI9R+CrivXKu3TdPL6Wzwk=; b=ohh3dRAHsr8yw3CSGc7EKvcmmCnwYx6lz3Q+FetEdfq/Ljq11J6LRWtqp8hiaOLJ5C IptlGqpkyy6q8/fYTF4af2VrN0prXllgSxK0kHIHA701lJV2aGoo8HfxWjc1Zr/GWj5V ZfJXhudezuwYZF7VRgqZ9W2vwRqka5UQ+xnxlRDPKYAulLFy7VWpHmLYFm5TYCQSABNy vWseMUz/9Ry7ZxL8KSxxuEl+AGdAkJiXmgec61IOA4oCQwK11OLooWRzPZ1Pw/fs0IkS JQA42qg1lXCAdkIJJK07Hv/o/8MlepOYWh8YfU+ZRUeTyn5lRS8Ja7B4f3nF5hniNFCA 9V0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=LVUlaqZY; 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 gk1si5405899ejc.516.2021.12.16.16.14.12; Thu, 16 Dec 2021 16:14:12 -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=LVUlaqZY; 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 3561D68B01B; Fri, 17 Dec 2021 02:12:39 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f54.google.com (mail-io1-f54.google.com [209.85.166.54]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 95B4A68AFEF for ; Fri, 17 Dec 2021 02:12:28 +0200 (EET) Received: by mail-io1-f54.google.com with SMTP id p65so748739iof.3 for ; Thu, 16 Dec 2021 16:12:28 -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=zogxGJq7PjzXjQNjZ21iIbEL2KNXdJULIORrvJZSSUg=; b=LVUlaqZYestEtt3kl6hHLSyP6UKSMaNnRv/mzL8w4tD6Akq9OBUxb2JZ4x6ZLKoxhT FJPsUUdA78twsWAKx+gfyFXDkjSRDDiZIRyNT4NDVYT6XxRM5jm4SPVJJ1dIQeZaI2bZ g3JbYudRI8snVNOKVoJN26bKqeKvWxwiwG8sGWVHwohUv4yGTHjxkydObwumwqJrmeDY bYNtLZ9bqvxbzztuPfRfuxUNV9ssMDNUUSsaWTlUu8kEfvAjRR+fEd6MTPtEAaEUGmaZ NXW92uNpHskhwaMPaZm7w/9hU5bhrQ5zhZfS5yDOzeCDhmT8uh0aKMEnjRRGFKM+lKPM xEaQ== 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=zogxGJq7PjzXjQNjZ21iIbEL2KNXdJULIORrvJZSSUg=; b=244vvyaIQAW16Mku3ND8IjaIhHR5fwVliKJVc3NAorc34jFkexOYkBP1Kcxi3ZIfBT UdDOJlKF42jRw020KTLv2Y2kOrM7obQHusV+jyjnomar4zbYLUUDIIerTPkulyculkuc 86Fxjq+v1kfFfN/OqvSquIltBIxx1Cs8SVnk+qzKQD43MbU7PBpFX0UW2YWY+Rq4qIJe iP+ByNzS9gU6FCBnpUulm8EvVc7QA7dKddrFgvUPdi/WSLPNH/Mns39buJlzmjFb+O7T 8y04fbWhIrHikuZB1Hlax2gHUYxJHut9GSNUWPoHDfoY2YqlSsQItoyHws+HXeeOQgp2 98ZQ== X-Gm-Message-State: AOAM530aj4H1HcskiI0feFyj1QHzuJX+5weVy47+2aHHZQ2L1P1918ao l8sOWGRj2MUYYat2i3Fo3WzVihAtXcY1H68= X-Received: by 2002:a05:6638:3001:: with SMTP id r1mr223883jak.263.1639699946742; Thu, 16 Dec 2021 16:12:26 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:1163:bda5:7473:fab3]) by smtp.gmail.com with ESMTPSA id z13sm1571257iln.43.2021.12.16.16.12.26 for (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 16 Dec 2021 16:12:26 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Thu, 16 Dec 2021 18:12:15 -0600 Message-Id: <20211217001215.75135-11-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211217001215.75135-1-rcombs@rcombs.me> References: <20211217001215.75135-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/10] lavc/videotoolboxenc: add ProRes support 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: DWJ3gBO7HANY --- Changelog | 1 + configure | 2 + libavcodec/Makefile | 1 + libavcodec/allcodecs.c | 1 + libavcodec/version.h | 2 +- libavcodec/videotoolboxenc.c | 119 +++++++++++++++++++++++++++++++++-- 6 files changed, 119 insertions(+), 7 deletions(-) diff --git a/Changelog b/Changelog index 5c6adc0fa7..ebbfed14a0 100644 --- a/Changelog +++ b/Changelog @@ -41,6 +41,7 @@ version : - libplacebo filter - vflip_vulkan, hflip_vulkan and flip_vulkan filters - adynamicequalizer audio filter +- VideoToolbox ProRes encoder version 4.4: diff --git a/configure b/configure index 5fffcb8afe..0146b28ff1 100755 --- a/configure +++ b/configure @@ -3300,6 +3300,8 @@ h264_videotoolbox_encoder_deps="pthreads" h264_videotoolbox_encoder_select="atsc_a53 videotoolbox_encoder" hevc_videotoolbox_encoder_deps="pthreads" hevc_videotoolbox_encoder_select="atsc_a53 videotoolbox_encoder" +prores_videotoolbox_encoder_deps="pthreads" +prores_videotoolbox_encoder_select="videotoolbox_encoder" libaom_av1_decoder_deps="libaom" libaom_av1_encoder_deps="libaom" libaom_av1_encoder_select="extract_extradata_bsf" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index beb91e8c12..f15a56eabd 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -565,6 +565,7 @@ OBJS-$(CONFIG_PRORES_DECODER) += proresdec2.o proresdsp.o proresdata.o OBJS-$(CONFIG_PRORES_ENCODER) += proresenc_anatoliy.o proresdata.o OBJS-$(CONFIG_PRORES_AW_ENCODER) += proresenc_anatoliy.o proresdata.o OBJS-$(CONFIG_PRORES_KS_ENCODER) += proresenc_kostya.o proresdata.o +OBJS-$(CONFIG_PRORES_VIDEOTOOLBOX_ENCODER) += videotoolboxenc.o OBJS-$(CONFIG_PROSUMER_DECODER) += prosumer.o OBJS-$(CONFIG_PSD_DECODER) += psd.o OBJS-$(CONFIG_PTX_DECODER) += ptx.o diff --git a/libavcodec/allcodecs.c b/libavcodec/allcodecs.c index 89d65266c8..d1e10197de 100644 --- a/libavcodec/allcodecs.c +++ b/libavcodec/allcodecs.c @@ -837,6 +837,7 @@ extern const AVCodec ff_mpeg4_cuvid_decoder; extern const AVCodec ff_mpeg4_mediacodec_decoder; extern const AVCodec ff_mpeg4_omx_encoder; extern const AVCodec ff_mpeg4_v4l2m2m_encoder; +extern const AVCodec ff_prores_videotoolbox_encoder; extern const AVCodec ff_vc1_cuvid_decoder; extern const AVCodec ff_vp8_cuvid_decoder; extern const AVCodec ff_vp8_mediacodec_decoder; diff --git a/libavcodec/version.h b/libavcodec/version.h index 8a0b94f5aa..db71fb1130 100644 --- a/libavcodec/version.h +++ b/libavcodec/version.h @@ -28,7 +28,7 @@ #include "libavutil/version.h" #define LIBAVCODEC_VERSION_MAJOR 59 -#define LIBAVCODEC_VERSION_MINOR 14 +#define LIBAVCODEC_VERSION_MINOR 15 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \ diff --git a/libavcodec/videotoolboxenc.c b/libavcodec/videotoolboxenc.c index 67bb563639..8453da7bc4 100644 --- a/libavcodec/videotoolboxenc.c +++ b/libavcodec/videotoolboxenc.c @@ -407,6 +407,7 @@ static int count_nalus(size_t length_code_size, } static CMVideoCodecType get_cm_codec_type(AVCodecContext *avctx, + int64_t profile, double alpha_quality) { const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt == AV_PIX_FMT_VIDEOTOOLBOX ? avctx->sw_pix_fmt : avctx->pix_fmt); @@ -417,6 +418,31 @@ static CMVideoCodecType get_cm_codec_type(AVCodecContext *avctx, return kCMVideoCodecType_HEVCWithAlpha; } return kCMVideoCodecType_HEVC; + case AV_CODEC_ID_PRORES: + switch (profile) { + case FF_PROFILE_PRORES_PROXY: + return MKBETAG('a','p','c','o'); // kCMVideoCodecType_AppleProRes422Proxy + case FF_PROFILE_PRORES_LT: + return MKBETAG('a','p','c','s'); // kCMVideoCodecType_AppleProRes422LT + case FF_PROFILE_PRORES_STANDARD: + return MKBETAG('a','p','c','n'); // kCMVideoCodecType_AppleProRes422 + case FF_PROFILE_PRORES_HQ: + return MKBETAG('a','p','c','h'); // kCMVideoCodecType_AppleProRes422HQ + case FF_PROFILE_PRORES_4444: + return MKBETAG('a','p','4','h'); // kCMVideoCodecType_AppleProRes4444 + case FF_PROFILE_PRORES_XQ: + return MKBETAG('a','p','4','x'); // kCMVideoCodecType_AppleProRes4444XQ + + default: + av_log(avctx, AV_LOG_ERROR, "Unknown profile ID: %"PRId64", using auto\n", profile); + case FF_PROFILE_UNKNOWN: + if (desc && + ((desc->flags & AV_PIX_FMT_FLAG_ALPHA) || + desc->log2_chroma_w == 0)) + return MKBETAG('a','p','4','h'); // kCMVideoCodecType_AppleProRes4444 + else + return MKBETAG('a','p','c','n'); // kCMVideoCodecType_AppleProRes422 + } default: return 0; } } @@ -1104,7 +1130,7 @@ static int vtenc_create_encoder(AVCodecContext *avctx, kVTCompressionPropertyKey_Quality, quality_num); CFRelease(quality_num); - } else { + } else if (avctx->codec_id != AV_CODEC_ID_PRORES) { bit_rate_num = CFNumberCreate(kCFAllocatorDefault, kCFNumberSInt32Type, &bit_rate); @@ -1191,7 +1217,7 @@ static int vtenc_create_encoder(AVCodecContext *avctx, } } - if (avctx->gop_size > 0) { + if (avctx->gop_size > 0 && avctx->codec_id != AV_CODEC_ID_PRORES) { CFNumberRef interval = CFNumberCreate(kCFAllocatorDefault, kCFNumberIntType, &avctx->gop_size); @@ -1340,7 +1366,7 @@ static int vtenc_create_encoder(AVCodecContext *avctx, } } - if (!vtctx->has_b_frames) { + if (!vtctx->has_b_frames && avctx->codec_id != AV_CODEC_ID_PRORES) { status = VTSessionSetProperty(vtctx->session, kVTCompressionPropertyKey_AllowFrameReordering, kCFBooleanFalse); @@ -1390,16 +1416,24 @@ static int vtenc_configure_encoder(AVCodecContext *avctx) CFMutableDictionaryRef pixel_buffer_info; CMVideoCodecType codec_type; VTEncContext *vtctx = avctx->priv_data; - CFStringRef profile_level; + CFStringRef profile_level = NULL; CFNumberRef gamma_level = NULL; int status; - codec_type = get_cm_codec_type(avctx, vtctx->alpha_quality); + codec_type = get_cm_codec_type(avctx, vtctx->profile, vtctx->alpha_quality); if (!codec_type) { av_log(avctx, AV_LOG_ERROR, "Error: no mapping for AVCodecID %d\n", avctx->codec_id); return AVERROR(EINVAL); } +#if defined(MAC_OS_X_VERSION_10_9) && !TARGET_OS_IPHONE && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9) + if (avctx->codec_id == AV_CODEC_ID_PRORES) { + if (__builtin_available(macOS 10.9, *)) { + VTRegisterProfessionalVideoWorkflowVideoEncoders(); + } + } +#endif + vtctx->codec_id = avctx->codec_id; if (vtctx->codec_id == AV_CODEC_ID_H264) { @@ -1417,12 +1451,14 @@ static int vtenc_configure_encoder(AVCodecContext *avctx) } if (!get_vt_h264_profile_level(avctx, &profile_level)) return AVERROR(EINVAL); - } else { + } else if (vtctx->codec_id == AV_CODEC_ID_HEVC) { vtctx->get_param_set_func = compat_keys.CMVideoFormatDescriptionGetHEVCParameterSetAtIndex; if (!vtctx->get_param_set_func) return AVERROR(EINVAL); if (!get_vt_hevc_profile_level(avctx, &profile_level)) return AVERROR(EINVAL); // HEVC has b-byramid vtctx->has_b_frames = avctx->max_b_frames > 0 ? 2 : 0; + } else if (vtctx->codec_id == AV_CODEC_ID_PRORES) { + avctx->codec_tag = av_bswap32(codec_type); } enc_info = CFDictionaryCreateMutable( @@ -2600,6 +2636,38 @@ static const enum AVPixelFormat hevc_pix_fmts[] = { AV_PIX_FMT_NONE }; +static const enum AVPixelFormat prores_pix_fmts[] = { + AV_PIX_FMT_YUV420P, +#ifdef kCFCoreFoundationVersionNumber10_7 + AV_PIX_FMT_NV12, + AV_PIX_FMT_AYUV64, +#endif + AV_PIX_FMT_UYVY422, +#if HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE + AV_PIX_FMT_P010, +#endif +#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR8BIPLANARVIDEORANGE + AV_PIX_FMT_NV16, +#endif +#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR10BIPLANARVIDEORANGE + AV_PIX_FMT_P210, +#endif +#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR16BIPLANARVIDEORANGE + AV_PIX_FMT_P216, +#endif +#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR8BIPLANARVIDEORANGE + AV_PIX_FMT_NV24, +#endif +#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR10BIPLANARVIDEORANGE + AV_PIX_FMT_P410, +#endif +#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR16BIPLANARVIDEORANGE + AV_PIX_FMT_P416, +#endif + AV_PIX_FMT_BGRA, + AV_PIX_FMT_NONE +}; + #define VE AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_ENCODING_PARAM #define COMMON_OPTIONS \ { "allow_sw", "Allow software encoding", OFFSET(allow_sw), AV_OPT_TYPE_BOOL, \ @@ -2703,3 +2771,42 @@ const AVCodec ff_hevc_videotoolbox_encoder = { FF_CODEC_CAP_INIT_CLEANUP, .wrapper_name = "videotoolbox", }; + +static const AVOption prores_options[] = { + { "profile", "Profile", OFFSET(profile), AV_OPT_TYPE_INT64, { .i64 = FF_PROFILE_UNKNOWN }, FF_PROFILE_UNKNOWN, FF_PROFILE_PRORES_XQ, VE, "profile" }, + { "auto", "Automatically determine based on input format", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_UNKNOWN }, INT_MIN, INT_MAX, VE, "profile" }, + { "proxy", "ProRes 422 Proxy", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_PROXY }, INT_MIN, INT_MAX, VE, "profile" }, + { "lt", "ProRes 422 LT", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_LT }, INT_MIN, INT_MAX, VE, "profile" }, + { "standard", "ProRes 422", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_STANDARD }, INT_MIN, INT_MAX, VE, "profile" }, + { "hq", "ProRes 422 HQ", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_HQ }, INT_MIN, INT_MAX, VE, "profile" }, + { "4444", "ProRes 4444", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_4444 }, INT_MIN, INT_MAX, VE, "profile" }, + { "xq", "ProRes 4444 XQ", 0, AV_OPT_TYPE_CONST, { .i64 = FF_PROFILE_PRORES_XQ }, INT_MIN, INT_MAX, VE, "profile" }, + + COMMON_OPTIONS + { NULL }, +}; + +static const AVClass prores_videotoolbox_class = { + .class_name = "prores_videotoolbox", + .item_name = av_default_item_name, + .option = prores_options, + .version = LIBAVUTIL_VERSION_INT, +}; + +const AVCodec ff_prores_videotoolbox_encoder = { + .name = "prores_videotoolbox", + .long_name = NULL_IF_CONFIG_SMALL("VideoToolbox ProRes Encoder"), + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_PRORES, + .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_DELAY | + AV_CODEC_CAP_HARDWARE, + .priv_data_size = sizeof(VTEncContext), + .pix_fmts = prores_pix_fmts, + .init = vtenc_init, + .encode2 = vtenc_frame, + .close = vtenc_close, + .priv_class = &prores_videotoolbox_class, + .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE | + FF_CODEC_CAP_INIT_CLEANUP, + .wrapper_name = "videotoolbox", +};