From patchwork Mon Nov 22 20:53: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: 31542 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7582108iob; Mon, 22 Nov 2021 12:53:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJx3QJmdfDlmqcC1MZikXCHiogmPsV/95L63VE95zyIgyyR4u1ElsbexfNPDiRxCmp+zFzyw X-Received: by 2002:a50:eb98:: with SMTP id y24mr68689315edr.339.1637614426583; Mon, 22 Nov 2021 12:53:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637614426; cv=none; d=google.com; s=arc-20160816; b=D1hPCQVY2xq1MYGl+LKgMn/2qWNkGdM3UbHlg+C5qXDEWVP1NR3G9d5fKz0TFKpPmL a1SpkreMKFUCYp8zlbbh9L0BRZPXlEVKyhOogLmy9MU5nXRDIfSqudOSVptI55dLPCtz WzRufVOrLpyHiBxE+RAqOz2/fu0u2TAeb3GXtMA8F3Y4qGoO1hR7OIvxuDebvxhN0ZXf UEvAtTlOOHi2M36wkz0KjvaRbnN5+QOvrubIe3b439TB4zQHwqhwwL3Z/9A8cJ5+8EHB RKSYw62llcnUpCZIlzCmhlHxF4mRYj3G/X34BzAYUPdxKN/JycYmD0DmCvQMEEgwuNH1 FG6A== 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:message-id:date:to:from :dkim-signature:delivered-to; bh=63t6TLW7th4TPt6dkSBUPz2PkfLc3yLMGaDR++Ceenk=; b=qCCgI9SkfTbgmfP5lfsQl1AgbrVYMg69t8PMtG8yHW7rz6uubZ3MTEHmbgPQf4pukg ftzwZxaBuhS0qP7LiIi4Jex7FNg77ZNe+f+YwS2eQhGHwmEDUuqbOz3Ovj2OE6qtrR2p GhwvaPD7l+8lAfcYf8TCs7GiER8zr3IL4VYo+PEdDp1CEMIqPpin70D88zzrc3Je/WTg PQ0Ic0vyepcwYFP18LXQ1Yqarng8NDmRfwnlkv1lBIW8oSblDnRzS121SCRsoFZCJYFT ofi8qCcwcE9tKXS44ml6YX7NVoL0DjeOFQT4MRDkog1Zxd54JbDku8rGxQVd/PWbtF/V Kciw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b="TFMAXPo/"; 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 d9si27337462edm.271.2021.11.22.12.53.45; Mon, 22 Nov 2021 12:53:46 -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="TFMAXPo/"; 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 7615F68A51F; Mon, 22 Nov 2021 22:53:41 +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 128576808E6 for ; Mon, 22 Nov 2021 22:53:35 +0200 (EET) Received: by mail-io1-f47.google.com with SMTP id p23so25153745iod.7 for ; Mon, 22 Nov 2021 12:53:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rcombs.me; s=google; h=from:to:subject:date:message-id:mime-version :content-transfer-encoding; bh=WbJA7/NUFCQfQREc5BExWSRa4f9eL/VySokDsUX1AMg=; b=TFMAXPo/okk6EaMtoVjnSvQJJ6vTG0SUx3vWqmmNuh5zTqaDW9QWiTlW4fOR2pa5gN DsoB+taHt49kbb/4hCRV7JYWzor6wHm8tmDuMX98GO1xY4KZmVaADdMtDhLoy50kRYA5 SeMT/jNtCUitU29y9bNRds5dtuBInU/g6SWSovqNd/gBwIUabaicGZXhH7g/Yg2GOlKS wMbSbnzjp/ANT15p3d2XHw83k8ostNYHZhma4ikG4X+fzfopwnt8OfcYPWxTAE7oObge PcQscc2P/sPoMpKVDn6FIrWy4aFjZn+l8e19mlYZ3UgXBEUeinY7eJTw53Ln3l4izuYu jsfw== 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:mime-version :content-transfer-encoding; bh=WbJA7/NUFCQfQREc5BExWSRa4f9eL/VySokDsUX1AMg=; b=3D1RtVOgjWKW6T7Mm1HREmuy4A0aBy/7jS26HiOQ9UQQIXs7zKpkBI4nabnQfncF3I 808x/Kp6qyKgesNjiYFB8Wu91gAOcgTVqdnxbBwo6vembNvvBiqPkCR55YiON10agNcZ OhxSl5mKfL7afksGwg3m7u+7Zv539uSm+KNxI/JAdixfbEKcJbGRt7Cz/qZbZ3n6FpkT Fq2M30yvjYE0OJcdTQz7HA+kareonyKdU0GcwfVON6w9yqO8G9ZL0QqD39gcs907jU95 SBAaousQzsBYnoLrOdzUjyEDzl3zptFJX8PKS7G7LUNssw1gXteuCsxcjHGvkO1mnn7P jvYw== X-Gm-Message-State: AOAM531nHzMECwwlec4zCFothLAb8UDtRTzutn8w+R09sGxLs96NxHch P8GHHXN1eERIV8nKXvvQhx0cqoPhRL24zZo= X-Received: by 2002:a5d:8451:: with SMTP id w17mr26272017ior.139.1637614412912; Mon, 22 Nov 2021 12:53:32 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id b3sm3571580ile.26.2021.11.22.12.53.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 12:53:32 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 14:53:15 -0600 Message-Id: <20211122205330.43546-1-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 01/16] ffmpeg: remove ffmpeg_videotoolbox 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: swlL5ikUQjtj This was almost completely redundant. The only functionality that's no longer available after this removal is the videotoolbox_pixfmt arg, which has been obsolete for several years. --- fftools/Makefile | 4 - fftools/ffmpeg.c | 37 +------ fftools/ffmpeg.h | 10 -- fftools/ffmpeg_opt.c | 28 +----- fftools/ffmpeg_videotoolbox.c | 177 ---------------------------------- 5 files changed, 7 insertions(+), 249 deletions(-) delete mode 100644 fftools/ffmpeg_videotoolbox.c diff --git a/fftools/Makefile b/fftools/Makefile index 5234932ab0..da420786eb 100644 --- a/fftools/Makefile +++ b/fftools/Makefile @@ -10,10 +10,6 @@ ALLAVPROGS = $(AVBASENAMES:%=%$(PROGSSUF)$(EXESUF)) ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF)) OBJS-ffmpeg += fftools/ffmpeg_opt.o fftools/ffmpeg_filter.o fftools/ffmpeg_hw.o -ifndef CONFIG_VIDEOTOOLBOX -OBJS-ffmpeg-$(CONFIG_VDA) += fftools/ffmpeg_videotoolbox.o -endif -OBJS-ffmpeg-$(CONFIG_VIDEOTOOLBOX) += fftools/ffmpeg_videotoolbox.o define DOFFTOOL OBJS-$(1) += fftools/cmdutils.o fftools/$(1).o $(OBJS-$(1)-yes) diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c index c9a9cdfcd6..589d2efed3 100644 --- a/fftools/ffmpeg.c +++ b/fftools/ffmpeg.c @@ -2859,12 +2859,7 @@ static enum AVPixelFormat get_format(AVCodecContext *s, const enum AVPixelFormat break; } } - if (config) { - if (config->device_type != ist->hwaccel_device_type) { - // Different hwaccel offered, ignore. - continue; - } - + if (config && config->device_type == ist->hwaccel_device_type) { ret = hwaccel_decode_init(s); if (ret < 0) { if (ist->hwaccel_id == HWACCEL_GENERIC) { @@ -2877,36 +2872,10 @@ static enum AVPixelFormat get_format(AVCodecContext *s, const enum AVPixelFormat } continue; } - } else { - const HWAccel *hwaccel = NULL; - int i; - for (i = 0; hwaccels[i].name; i++) { - if (hwaccels[i].pix_fmt == *p) { - hwaccel = &hwaccels[i]; - break; - } - } - if (!hwaccel) { - // No hwaccel supporting this pixfmt. - continue; - } - if (hwaccel->id != ist->hwaccel_id) { - // Does not match requested hwaccel. - continue; - } - ret = hwaccel->init(s); - if (ret < 0) { - av_log(NULL, AV_LOG_FATAL, - "%s hwaccel requested for input stream #%d:%d, " - "but cannot be initialized.\n", hwaccel->name, - ist->file_index, ist->st->index); - return AV_PIX_FMT_NONE; - } + ist->hwaccel_pix_fmt = *p; + break; } - - ist->hwaccel_pix_fmt = *p; - break; } return *p; diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h index 1728010f56..21c63415d6 100644 --- a/fftools/ffmpeg.h +++ b/fftools/ffmpeg.h @@ -60,16 +60,8 @@ enum HWAccelID { HWACCEL_NONE = 0, HWACCEL_AUTO, HWACCEL_GENERIC, - HWACCEL_VIDEOTOOLBOX, }; -typedef struct HWAccel { - const char *name; - int (*init)(AVCodecContext *s); - enum HWAccelID id; - enum AVPixelFormat pix_fmt; -} HWAccel; - typedef struct HWDevice { const char *name; enum AVHWDeviceType type; @@ -626,7 +618,6 @@ extern int stdin_interaction; extern int frame_bits_per_raw_sample; extern AVIOContext *progress_avio; extern float max_error_rate; -extern char *videotoolbox_pixfmt; extern char *filter_nbthreads; extern int filter_complex_nbthreads; @@ -636,7 +627,6 @@ extern int auto_conversion_filters; extern const AVIOInterruptCB int_cb; extern const OptionDef options[]; -extern const HWAccel hwaccels[]; #if CONFIG_QSV extern char *qsv_device; #endif diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c index 6732a29625..f59986a648 100644 --- a/fftools/ffmpeg_opt.c +++ b/fftools/ffmpeg_opt.c @@ -134,12 +134,6 @@ static const char *const opt_name_enc_time_bases[] = {"enc_time_base" }\ } -const HWAccel hwaccels[] = { -#if CONFIG_VIDEOTOOLBOX - { "videotoolbox", videotoolbox_init, HWACCEL_VIDEOTOOLBOX, AV_PIX_FMT_VIDEOTOOLBOX }, -#endif - { 0 }, -}; HWDevice *filter_hw_device; char *vstats_filename; @@ -955,21 +949,10 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) else if (!strcmp(hwaccel, "auto")) ist->hwaccel_id = HWACCEL_AUTO; else { - enum AVHWDeviceType type; - int i; - for (i = 0; hwaccels[i].name; i++) { - if (!strcmp(hwaccels[i].name, hwaccel)) { - ist->hwaccel_id = hwaccels[i].id; - break; - } - } - - if (!ist->hwaccel_id) { - type = av_hwdevice_find_type_by_name(hwaccel); - if (type != AV_HWDEVICE_TYPE_NONE) { - ist->hwaccel_id = HWACCEL_GENERIC; - ist->hwaccel_device_type = type; - } + enum AVHWDeviceType type = av_hwdevice_find_type_by_name(hwaccel); + if (type != AV_HWDEVICE_TYPE_NONE) { + ist->hwaccel_id = HWACCEL_GENERIC; + ist->hwaccel_device_type = type; } if (!ist->hwaccel_id) { @@ -3844,9 +3827,6 @@ const OptionDef options[] = { { "hwaccel_output_format", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT | OPT_SPEC | OPT_INPUT, { .off = OFFSET(hwaccel_output_formats) }, "select output format used with HW accelerated decoding", "format" }, -#if CONFIG_VIDEOTOOLBOX - { "videotoolbox_pixfmt", HAS_ARG | OPT_STRING | OPT_EXPERT, { &videotoolbox_pixfmt}, "" }, -#endif { "hwaccels", OPT_EXIT, { .func_arg = show_hwaccels }, "show available HW acceleration methods" }, { "autorotate", HAS_ARG | OPT_BOOL | OPT_SPEC | diff --git a/fftools/ffmpeg_videotoolbox.c b/fftools/ffmpeg_videotoolbox.c deleted file mode 100644 index 4ba8618539..0000000000 --- a/fftools/ffmpeg_videotoolbox.c +++ /dev/null @@ -1,177 +0,0 @@ -/* - * This file is part of FFmpeg. - * - * FFmpeg is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * FFmpeg is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with FFmpeg; if not, write to the Free Software - * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - */ - -#include "config.h" - -#if HAVE_UTGETOSTYPEFROMSTRING -#include -#endif - -#include "libavcodec/avcodec.h" -#include "libavcodec/videotoolbox.h" -#include "libavutil/imgutils.h" -#include "ffmpeg.h" - -typedef struct VTContext { - AVFrame *tmp_frame; - int log_once; -} VTContext; - -char *videotoolbox_pixfmt; - -static int videotoolbox_retrieve_data(AVCodecContext *s, AVFrame *frame) -{ - InputStream *ist = s->opaque; - VTContext *vt = ist->hwaccel_ctx; - CVPixelBufferRef pixbuf = (CVPixelBufferRef)frame->data[3]; - OSType pixel_format = CVPixelBufferGetPixelFormatType(pixbuf); - CVReturn err; - uint8_t *data[4] = { 0 }; - int linesize[4] = { 0 }; - int planes, ret, i; - - if (frame->format == ist->hwaccel_output_format) { - av_log_once(s, AV_LOG_INFO, AV_LOG_TRACE, &vt->log_once, - "There is no video filter for videotoolbox pix_fmt now, remove the " - "-hwaccel_output_format option if video filter doesn't work\n"); - return 0; - } - - av_frame_unref(vt->tmp_frame); - - switch (pixel_format) { - case kCVPixelFormatType_420YpCbCr8Planar: vt->tmp_frame->format = AV_PIX_FMT_YUV420P; break; - case kCVPixelFormatType_422YpCbCr8: vt->tmp_frame->format = AV_PIX_FMT_UYVY422; break; - case kCVPixelFormatType_32BGRA: vt->tmp_frame->format = AV_PIX_FMT_BGRA; break; -#ifdef kCFCoreFoundationVersionNumber10_7 - case kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange: - case kCVPixelFormatType_420YpCbCr8BiPlanarFullRange: vt->tmp_frame->format = AV_PIX_FMT_NV12; break; -#endif -#if HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE - case kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange: - case kCVPixelFormatType_420YpCbCr10BiPlanarFullRange: vt->tmp_frame->format = AV_PIX_FMT_P010; break; -#endif - default: - av_log(NULL, AV_LOG_ERROR, - "%s: Unsupported pixel format: %s\n", - av_fourcc2str(s->codec_tag), videotoolbox_pixfmt); - return AVERROR(ENOSYS); - } - - vt->tmp_frame->width = frame->width; - vt->tmp_frame->height = frame->height; - ret = av_frame_get_buffer(vt->tmp_frame, 0); - if (ret < 0) - return ret; - - err = CVPixelBufferLockBaseAddress(pixbuf, kCVPixelBufferLock_ReadOnly); - if (err != kCVReturnSuccess) { - av_log(NULL, AV_LOG_ERROR, "Error locking the pixel buffer.\n"); - return AVERROR_UNKNOWN; - } - - if (CVPixelBufferIsPlanar(pixbuf)) { - - planes = CVPixelBufferGetPlaneCount(pixbuf); - for (i = 0; i < planes; i++) { - data[i] = CVPixelBufferGetBaseAddressOfPlane(pixbuf, i); - linesize[i] = CVPixelBufferGetBytesPerRowOfPlane(pixbuf, i); - } - } else { - data[0] = CVPixelBufferGetBaseAddress(pixbuf); - linesize[0] = CVPixelBufferGetBytesPerRow(pixbuf); - } - - av_image_copy(vt->tmp_frame->data, vt->tmp_frame->linesize, - (const uint8_t **)data, linesize, vt->tmp_frame->format, - frame->width, frame->height); - - ret = av_frame_copy_props(vt->tmp_frame, frame); - CVPixelBufferUnlockBaseAddress(pixbuf, kCVPixelBufferLock_ReadOnly); - if (ret < 0) - return ret; - - av_frame_unref(frame); - av_frame_move_ref(frame, vt->tmp_frame); - - return 0; -} - -static void videotoolbox_uninit(AVCodecContext *s) -{ - InputStream *ist = s->opaque; - VTContext *vt = ist->hwaccel_ctx; - - ist->hwaccel_uninit = NULL; - ist->hwaccel_retrieve_data = NULL; - - av_frame_free(&vt->tmp_frame); - - av_videotoolbox_default_free(s); - av_freep(&ist->hwaccel_ctx); -} - -int videotoolbox_init(AVCodecContext *s) -{ - InputStream *ist = s->opaque; - int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; - int ret = 0; - VTContext *vt; - - vt = av_mallocz(sizeof(*vt)); - if (!vt) - return AVERROR(ENOMEM); - - ist->hwaccel_ctx = vt; - ist->hwaccel_uninit = videotoolbox_uninit; - ist->hwaccel_retrieve_data = videotoolbox_retrieve_data; - - vt->tmp_frame = av_frame_alloc(); - if (!vt->tmp_frame) { - ret = AVERROR(ENOMEM); - goto fail; - } - - // TODO: reindent - if (!videotoolbox_pixfmt) { - ret = av_videotoolbox_default_init(s); - } else { - AVVideotoolboxContext *vtctx = av_videotoolbox_alloc_context(); - CFStringRef pixfmt_str = CFStringCreateWithCString(kCFAllocatorDefault, - videotoolbox_pixfmt, - kCFStringEncodingUTF8); -#if HAVE_UTGETOSTYPEFROMSTRING - vtctx->cv_pix_fmt_type = UTGetOSTypeFromString(pixfmt_str); -#else - av_log(s, loglevel, "UTGetOSTypeFromString() is not available " - "on this platform, %s pixel format can not be honored from " - "the command line\n", videotoolbox_pixfmt); -#endif - ret = av_videotoolbox_default_init2(s, vtctx); - CFRelease(pixfmt_str); - } - if (ret < 0) { - av_log(NULL, loglevel, "Error creating Videotoolbox decoder.\n"); - goto fail; - } - - return 0; -fail: - videotoolbox_uninit(s); - return ret; -} From patchwork Mon Nov 22 20:53:16 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31530 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7582369iob; Mon, 22 Nov 2021 12:53:58 -0800 (PST) X-Google-Smtp-Source: ABdhPJzl+wqBJeDrFtiZRU9eO2zYPufG9yJL7iTjIQD2Si5vOjmOWUjNdTFyMWzp4sj1YCctdw/T X-Received: by 2002:a17:906:4793:: with SMTP id cw19mr47359ejc.387.1637614438692; Mon, 22 Nov 2021 12:53:58 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637614438; cv=none; d=google.com; s=arc-20160816; b=uxjIyYTEfr/ODiFAKC5OfLzDvbpsCYE/R5opmtx0qP/7iOYl9lK4Je3G3sU/dCLucm A9xegH7hEWUwFtPU8C5gsf9CqOSP/Refqy+iCuSv3gYLKNOy4IprbHLtu9qg/PZSURNy SPQcrso/m9m2nefJK3qkMx+SaC6fZ6ZlWXHnAzEt8ClL+mq8fYl3LOolAdW/7lSpsoLE Dfj9q3NvECFaZsjjLLMYW7Ed+VduJdgCvY5JRH8BRcaUtSSAN6FsXy48aS5MWISIMAd1 +O927JANWfxO680n/80ieCnAEsPogYwQUzD0E5xdYHqbRY/sLn4nxNJMIPsT8Eb0M77j 6/xg== 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=Iriw+tYfqfR/KK6hRTbMTGrBfhwHWuqvnyIR8A/zngc=; b=q1PQ9uM+C9+qyLfy5yWMBXjXf0QzEIr7F3ZyzM8VsENvm/AupwwKW305LKfR5c8HTU jXN1cJPHvW6QTItzzAECK8HN8Tp5+mq7NuBdN+tQg2sMFQ1FKGjGpHDE9nW8gvQ0Z4hN ZDrI+JG/A1Dj5X/aXU6SHLgyDjdPuKuuqDzqKDTnyfJv+9oAlGDqWKiHs7mARIJCadXK /AzGkK5IF0lDUeBpCZThE8vks7PRa5bqiQ113VXeAwbGTnTbumHCuOyNNDoBvpK6+r64 iw1ZN54ry5aPtZsupDzsCTMTsPypNtqzoNAXtrcseVv1GpziuMGqYWKva2dXotsNDb0Y 7KlQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b="IY/NRefM"; 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 a5si22511145edy.585.2021.11.22.12.53.58; Mon, 22 Nov 2021 12:53:58 -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="IY/NRefM"; 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 A396868A703; Mon, 22 Nov 2021 22:53:43 +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 E523E689F02 for ; Mon, 22 Nov 2021 22:53:35 +0200 (EET) Received: by mail-il1-f179.google.com with SMTP id l8so19514282ilv.3 for ; Mon, 22 Nov 2021 12:53:35 -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=RVUWk4Ol0h4K51/PMeE0+Dk7xLqLqS5A98FzWnwNK5U=; b=IY/NRefMxpdbFOJb3WpcUEbgKizuo5YivTsdU7ry8fImEO4NDEHU5ce62K9bK6snPi w6XDOmbR7Ts05YKlTbxN59N/4xK3octjxQlgLBeWlgrU5wKgdy0T8QtcKCWLYxZHtFvs SqooSZ7u/fwOxepCE8XLxOGt8R5u43zp/wn5lGrf8vs6/dw4eY3vQWCut0VtyDr6Z4si 967j39IwSjutYKtseEIDtBq1BpFJCUBM8WYcPX9TsS7hjrr1DzO+CwwzdJ9plCq2crOt O/kt33gV7VtG9R55Hm5qrahSnHN5qhXfh80h2E1S00wdJwzHFMU7fG5v8HNdQ9uHlUWr 4M+Q== 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=RVUWk4Ol0h4K51/PMeE0+Dk7xLqLqS5A98FzWnwNK5U=; b=3PSML5b5mba9EZhLseUiadDZ2A9GdZON2shuxcKle0L+/xBZFe2hb9gToaGtL8cuGP PvS9qNI1aVaqmP0xCRzAv021Ri5od7gBkMF/ER04dYL5hka9XZVjYAFaLGgkn++DG7ot dg53C4FZY1i85Jl2a1ynUVK6VTQkI7o4zt+SwBuax3YpazzET4YGi5jRaIevNqo76R3X JN/WFJPHp5pefnBsoUU5+qCulJuI3H4wX9WGOped5hzMESx4GQD0isUDvktH0WETzifc kdpiv0HmC2wCw63AxjvvvtN0GYzesiGXoYOTp9y4dq6EuLxS7w6zCyeb+T9A110O3zYP pXzA== X-Gm-Message-State: AOAM532VJnrICMimnie7qkmMWpAudf0uoel6jeNDYaQdGxNSrSenf5Qt uf7aJWp4l90mh1ULD+1pCbdyLknbgWPrmJg= X-Received: by 2002:a92:c90d:: with SMTP id t13mr22874737ilp.26.1637614413919; Mon, 22 Nov 2021 12:53:33 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id b3sm3571580ile.26.2021.11.22.12.53.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 12:53:33 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 14:53:16 -0600 Message-Id: <20211122205330.43546-2-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122205330.43546-1-rcombs@rcombs.me> References: <20211122205330.43546-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 02/16] lavu/pixfmt: add high-bit-depth semi-planar 4:2:2/4:4:4 formats 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: 6Ex8CZgwdC39 These are used by VideoToolbox hardware decoders. --- doc/APIchanges | 3 ++ libavutil/pixdesc.c | 96 +++++++++++++++++++++++++++++++++++++++++ libavutil/pixfmt.h | 18 ++++++++ tests/ref/fate/imgutils | 8 ++++ 4 files changed, 125 insertions(+) diff --git a/doc/APIchanges b/doc/APIchanges index 565f7e091e..bc9f4e38da 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -14,6 +14,9 @@ libavutil: 2021-04-27 API changes, most recent first: +2021-11-22 - xxxxxxxxxx - lavu 57.9.100 - pixfmt.h + Add AV_PIX_FMT_P210, AV_PIX_FMT_P410, AV_PIX_FMT_P216, and AV_PIX_FMT_P416. + 2021-11-17 - xxxxxxxxxx - lavf 57.9.100 - frame.h Add AV_FRAME_DATA_DOVI_RPU_BUFFER. diff --git a/libavutil/pixdesc.c b/libavutil/pixdesc.c index 69cb198646..727d7540b3 100644 --- a/libavutil/pixdesc.c +++ b/libavutil/pixdesc.c @@ -2393,6 +2393,102 @@ static const AVPixFmtDescriptor av_pix_fmt_descriptors[AV_PIX_FMT_NB] = { .name = "vulkan", .flags = AV_PIX_FMT_FLAG_HWACCEL, }, + [AV_PIX_FMT_P210BE] = { + .name = "p210be", + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, + .comp = { + { 0, 2, 0, 6, 10 }, /* Y */ + { 1, 4, 0, 6, 10 }, /* U */ + { 1, 4, 2, 6, 10 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE, + }, + [AV_PIX_FMT_P210LE] = { + .name = "p210le", + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, + .comp = { + { 0, 2, 0, 6, 10 }, /* Y */ + { 1, 4, 0, 6, 10 }, /* U */ + { 1, 4, 2, 6, 10 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_PLANAR, + }, + [AV_PIX_FMT_P410BE] = { + .name = "p410be", + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 2, 0, 6, 10 }, /* Y */ + { 1, 4, 0, 6, 10 }, /* U */ + { 1, 4, 2, 6, 10 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE, + }, + [AV_PIX_FMT_P410LE] = { + .name = "p410le", + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 2, 0, 6, 10 }, /* Y */ + { 1, 4, 0, 6, 10 }, /* U */ + { 1, 4, 2, 6, 10 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_PLANAR, + }, + [AV_PIX_FMT_P216BE] = { + .name = "p216be", + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, + .comp = { + { 0, 2, 0, 0, 16 }, /* Y */ + { 1, 4, 0, 0, 16 }, /* U */ + { 1, 4, 2, 0, 16 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE, + }, + [AV_PIX_FMT_P216LE] = { + .name = "p216le", + .nb_components = 3, + .log2_chroma_w = 1, + .log2_chroma_h = 0, + .comp = { + { 0, 2, 0, 0, 16 }, /* Y */ + { 1, 4, 0, 0, 16 }, /* U */ + { 1, 4, 2, 0, 16 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_PLANAR, + }, + [AV_PIX_FMT_P416BE] = { + .name = "p416be", + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 2, 0, 0, 16 }, /* Y */ + { 1, 4, 0, 0, 16 }, /* U */ + { 1, 4, 2, 0, 16 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_PLANAR | AV_PIX_FMT_FLAG_BE, + }, + [AV_PIX_FMT_P416LE] = { + .name = "p416le", + .nb_components = 3, + .log2_chroma_w = 0, + .log2_chroma_h = 0, + .comp = { + { 0, 2, 0, 0, 16 }, /* Y */ + { 1, 4, 0, 0, 16 }, /* U */ + { 1, 4, 2, 0, 16 }, /* V */ + }, + .flags = AV_PIX_FMT_FLAG_PLANAR, + }, }; static const char * const color_range_names[] = { diff --git a/libavutil/pixfmt.h b/libavutil/pixfmt.h index 53bdecfcb7..02e355eb4d 100644 --- a/libavutil/pixfmt.h +++ b/libavutil/pixfmt.h @@ -352,6 +352,19 @@ enum AVPixelFormat { AV_PIX_FMT_X2RGB10BE, ///< packed RGB 10:10:10, 30bpp, (msb)2X 10R 10G 10B(lsb), big-endian, X=unused/undefined AV_PIX_FMT_X2BGR10LE, ///< packed BGR 10:10:10, 30bpp, (msb)2X 10B 10G 10R(lsb), little-endian, X=unused/undefined AV_PIX_FMT_X2BGR10BE, ///< packed BGR 10:10:10, 30bpp, (msb)2X 10B 10G 10R(lsb), big-endian, X=unused/undefined + + AV_PIX_FMT_P210BE, ///< interleaved chroma YUV 4:2:2, 20bpp, data in the high bits, big-endian + AV_PIX_FMT_P210LE, ///< interleaved chroma YUV 4:2:2, 20bpp, data in the high bits, little-endian + + AV_PIX_FMT_P410BE, ///< interleaved chroma YUV 4:4:4, 30bpp, data in the high bits, big-endian + AV_PIX_FMT_P410LE, ///< interleaved chroma YUV 4:4:4, 30bpp, data in the high bits, little-endian + + AV_PIX_FMT_P216BE, ///< interleaved chroma YUV 4:2:2, 32bpp, big-endian + AV_PIX_FMT_P216LE, ///< interleaved chroma YUV 4:2:2, 32bpp, liddle-endian + + AV_PIX_FMT_P416BE, ///< interleaved chroma YUV 4:4:4, 48bpp, big-endian + AV_PIX_FMT_P416LE, ///< interleaved chroma YUV 4:4:4, 48bpp, little-endian + AV_PIX_FMT_NB ///< number of pixel formats, DO NOT USE THIS if you want to link with shared libav* because the number of formats might differ between versions }; @@ -444,6 +457,11 @@ enum AVPixelFormat { #define AV_PIX_FMT_X2RGB10 AV_PIX_FMT_NE(X2RGB10BE, X2RGB10LE) #define AV_PIX_FMT_X2BGR10 AV_PIX_FMT_NE(X2BGR10BE, X2BGR10LE) +#define AV_PIX_FMT_P210 AV_PIX_FMT_NE(P210BE, P210LE) +#define AV_PIX_FMT_P410 AV_PIX_FMT_NE(P410BE, P410LE) +#define AV_PIX_FMT_P216 AV_PIX_FMT_NE(P216BE, P216LE) +#define AV_PIX_FMT_P416 AV_PIX_FMT_NE(P416BE, P416LE) + /** * Chromaticity coordinates of the source primaries. * These values match the ones defined by ISO/IEC 23091-2_2019 subclause 8.1 and ITU-T H.273. diff --git a/tests/ref/fate/imgutils b/tests/ref/fate/imgutils index 495bbd46f0..b23d1b4c39 100644 --- a/tests/ref/fate/imgutils +++ b/tests/ref/fate/imgutils @@ -238,3 +238,11 @@ x2rgb10le planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 x2rgb10be planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 x2bgr10le planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 x2bgr10be planes: 1, linesizes: 256 0 0 0, plane_sizes: 12288 0 0 0, plane_offsets: 0 0 0, total_size: 12288 +p210be planes: 2, linesizes: 128 128 0 0, plane_sizes: 6144 6144 0 0, plane_offsets: 6144 0 0, total_size: 12288 +p210le planes: 2, linesizes: 128 128 0 0, plane_sizes: 6144 6144 0 0, plane_offsets: 6144 0 0, total_size: 12288 +p410be planes: 2, linesizes: 128 256 0 0, plane_sizes: 6144 12288 0 0, plane_offsets: 6144 0 0, total_size: 18432 +p410le planes: 2, linesizes: 128 256 0 0, plane_sizes: 6144 12288 0 0, plane_offsets: 6144 0 0, total_size: 18432 +p216be planes: 2, linesizes: 128 128 0 0, plane_sizes: 6144 6144 0 0, plane_offsets: 6144 0 0, total_size: 12288 +p216le planes: 2, linesizes: 128 128 0 0, plane_sizes: 6144 6144 0 0, plane_offsets: 6144 0 0, total_size: 12288 +p416be planes: 2, linesizes: 128 256 0 0, plane_sizes: 6144 12288 0 0, plane_offsets: 6144 0 0, total_size: 18432 +p416le planes: 2, linesizes: 128 256 0 0, plane_sizes: 6144 12288 0 0, plane_offsets: 6144 0 0, total_size: 18432 From patchwork Mon Nov 22 20:53:17 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31534 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7582608iob; Mon, 22 Nov 2021 12:54:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJxL/FhalWD/sCUSfny23109j62tBOYuJBB4RrcKzQmVv0H8DErjjpMFoWe2HrxenjQdFY2e X-Received: by 2002:a17:907:d08:: with SMTP id gn8mr46815ejc.395.1637614449402; Mon, 22 Nov 2021 12:54:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637614449; cv=none; d=google.com; s=arc-20160816; b=Y3b9wbtS4UQZTc0UgZaJlbdd84fGt4NIy+yMc0Kgh4daXAkjjPQWdelwd+7ww+h5Q6 gBwHZ4fvUNTGspg+CCNc2KVBDWPY//6qnWJcJzWNj+qKyJ8qRT56coitUUQgEgjl4Qtv b4A/pW8HjtGEhs4RKuWdlvNljHdxALF7cl/Qd2fMmHxmTN+AElVDAv2QO6T8O3SCcWOR 6oSVwVOGoIfmeA/jGfMXNslDoCNcD0qyavN9vHa34HAOHgHVIq3Xj4lQWuKjxIlT11vm hjdoHG9TLw+Ty3z/xbbpJfas8jEsztUbNTQs8DR+JaTKaLxmWstxuiumAmBHe5kASEhb x3HA== 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=nNtzfJRkEdkFY38sQcadh3h8TvGRr5ZF3vpoIp8G8+E=; b=gXV8ouwJsKmC5uShiU0W7iQ33VucDvY++6cPS/a4W/NZPVSvK4q5M9oo7wXe8PTEa5 JwAe0Ve4t2lnJo2K9bpWu9zwWQkn7cb6uqccrBNhGMTglGnDYCLhTESAPdEYvN72k3gd h1dFjGp4NJtUm7hrATc8gHHEd6+P22VU6IVfDV83cnwKWIa1E4/XsmClY5UhOmkDNC9G Ka97qARta4gtCXg+fMdqAHImTLuH2picoiuIjzw/jVUOWMzrezUSBT4/CK2sXZxB3k6g FNYX6yZHP0bt2zXzfpb4aUO/dttd2eYdij9idJFJrNW6Nrf24NOBHUG+fBQGR4ZxkQ+g V6tA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=bysjxkYJ; 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 f21si36525530edf.172.2021.11.22.12.54.09; Mon, 22 Nov 2021 12:54:09 -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=bysjxkYJ; 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 CAB35689FB5; Mon, 22 Nov 2021 22:53:44 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f46.google.com (mail-io1-f46.google.com [209.85.166.46]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ECDE46808E6 for ; Mon, 22 Nov 2021 22:53:36 +0200 (EET) Received: by mail-io1-f46.google.com with SMTP id v23so25124265iom.12 for ; Mon, 22 Nov 2021 12:53:36 -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=3NHh9bfvCdA+YyzzG5seJP/EBMQbqQh6uUJfMfy3mh0=; b=bysjxkYJhc7am9M2CIjIw9nzjky4TIURHssnRF5Hd/T4+HX86/7Mhd1uOKJC82CsUX naxMG3NF+OlKPwgHrLS+ZZAt9UN7b0o1tJbnIUrvm63s4ajfEBd2fiWpYdI35/KAUt+S 4bpUYEX94tky27wN3CuIbHu7y3Y6oKnSv4qIkHnfS1mbpIrhpXZtJgnBnwFQfIvT1kyE 1pLYVeLtb5hBFnERdfOJClY5py4a7YpX6vmQANFE8xi8FDME2eUcj1plGihgqbVsy5+z 1TyX+sLN0Vk51yK2Pr1buhaykLbf8bNNRGyaCuYIUFi4brcWblI4uUJEYQ7NSrAUx/M8 WHQg== 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=3NHh9bfvCdA+YyzzG5seJP/EBMQbqQh6uUJfMfy3mh0=; b=kvZjPxPOUKWNvXJecRgr5wOWLNEzFDUvYr6ofDduSUVeI13rFFaTLDnOmRiJbvp+mi knJBen901U2dJGLgUa+ddUimmk/csPupMqPB/e9F7z3nPXI2gys8jbaLfaOn4TO24XYX XLFeEJJeynPqpiI9vx+osPPbDuJjmssExv5KjIEyOH1OkaYMzkTtTPF+PFKbaeqbt2MR S9Q/04sscJ92V1p4CMPhVZqRC3K7aX8vixljiBqLMV3o4CduY6xuwmGeMeeS9FYz9ssO lCRlua0+58bw2KoNKxbMnco9A61N0gKv1xtX6wuiTFKISE4aJkHIkqmGT8v0Ikh8FUIi KZyA== X-Gm-Message-State: AOAM5310a83+TvYvhL6X9A+jvbI2Gs/gz/8EV56dc9VOsq895Aky7Pwj yweykB4W9kQz+yO4VVOe/YwbZSFF6rXWICo= X-Received: by 2002:a5d:848a:: with SMTP id t10mr8371792iom.207.1637614415054; Mon, 22 Nov 2021 12:53:35 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id b3sm3571580ile.26.2021.11.22.12.53.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 12:53:34 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 14:53:17 -0600 Message-Id: <20211122205330.43546-3-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122205330.43546-1-rcombs@rcombs.me> References: <20211122205330.43546-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 03/16] swscale: add P210/P410/P216/P416 input 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: aCMUWC1D3hU9 --- libswscale/input.c | 16 ++++++++++++ libswscale/utils.c | 8 ++++++ libswscale/version.h | 2 +- tests/ref/fate/sws-pixdesc-query | 44 ++++++++++++++++++++++++++++++++ 4 files changed, 69 insertions(+), 1 deletion(-) diff --git a/libswscale/input.c b/libswscale/input.c index 1351ea5bd4..6acc39f89f 100644 --- a/libswscale/input.c +++ b/libswscale/input.c @@ -1238,15 +1238,23 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) c->chrToYV12 = read_ayuv64le_UV_c; break; case AV_PIX_FMT_P010LE: + case AV_PIX_FMT_P210LE: + case AV_PIX_FMT_P410LE: c->chrToYV12 = p010LEToUV_c; break; case AV_PIX_FMT_P010BE: + case AV_PIX_FMT_P210BE: + case AV_PIX_FMT_P410BE: c->chrToYV12 = p010BEToUV_c; break; case AV_PIX_FMT_P016LE: + case AV_PIX_FMT_P216LE: + case AV_PIX_FMT_P416LE: c->chrToYV12 = p016LEToUV_c; break; case AV_PIX_FMT_P016BE: + case AV_PIX_FMT_P216BE: + case AV_PIX_FMT_P416BE: c->chrToYV12 = p016BEToUV_c; break; case AV_PIX_FMT_Y210LE: @@ -1519,6 +1527,8 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) case AV_PIX_FMT_GRAY16LE: case AV_PIX_FMT_P016LE: + case AV_PIX_FMT_P216LE: + case AV_PIX_FMT_P416LE: c->lumToYV12 = bswap16Y_c; break; case AV_PIX_FMT_YUVA420P9LE: @@ -1561,6 +1571,8 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) case AV_PIX_FMT_GRAY16BE: case AV_PIX_FMT_P016BE: + case AV_PIX_FMT_P216BE: + case AV_PIX_FMT_P416BE: c->lumToYV12 = bswap16Y_c; break; case AV_PIX_FMT_YUVA420P9BE: @@ -1687,9 +1699,13 @@ av_cold void ff_sws_init_input_funcs(SwsContext *c) c->lumToYV12 = bgr64LEToY_c; break; case AV_PIX_FMT_P010LE: + case AV_PIX_FMT_P210LE: + case AV_PIX_FMT_P410LE: c->lumToYV12 = p010LEToY_c; break; case AV_PIX_FMT_P010BE: + case AV_PIX_FMT_P210BE: + case AV_PIX_FMT_P410BE: c->lumToYV12 = p010BEToY_c; break; case AV_PIX_FMT_GRAYF32LE: diff --git a/libswscale/utils.c b/libswscale/utils.c index c726922527..ae92ac9fbc 100644 --- a/libswscale/utils.c +++ b/libswscale/utils.c @@ -268,6 +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 }, }; int sws_isSupportedInput(enum AVPixelFormat pix_fmt) diff --git a/libswscale/version.h b/libswscale/version.h index 0d3b7cf363..15ad54319c 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 100 +#define LIBSWSCALE_VERSION_MICRO 101 #define LIBSWSCALE_VERSION_INT AV_VERSION_INT(LIBSWSCALE_VERSION_MAJOR, \ LIBSWSCALE_VERSION_MINOR, \ diff --git a/tests/ref/fate/sws-pixdesc-query b/tests/ref/fate/sws-pixdesc-query index a74109c3d7..553c039061 100644 --- a/tests/ref/fate/sws-pixdesc-query +++ b/tests/ref/fate/sws-pixdesc-query @@ -13,6 +13,10 @@ is16BPS: gray16le p016be p016le + p216be + p216le + p416be + p416le rgb48be rgb48le rgba64be @@ -57,6 +61,10 @@ isNBPS: nv20le p010be p010le + p210be + p210le + p410be + p410le x2bgr10be x2bgr10le x2rgb10be @@ -140,6 +148,10 @@ isBE: nv20be p010be p016be + p210be + p216be + p410be + p416be rgb444be rgb48be rgb555be @@ -193,6 +205,14 @@ isYUV: p010le p016be p016le + p210be + p210le + p216be + p216le + p410be + p410le + p416be + p416le uyvy422 uyyvyy411 xyz12be @@ -287,6 +307,14 @@ isPlanarYUV: p010le p016be p016le + p210be + p210le + p216be + p216le + p410be + p410le + p416be + p416le yuv410p yuv411p yuv420p @@ -370,6 +398,14 @@ isSemiPlanarYUV: p010le p016be p016le + p210be + p210le + p216be + p216le + p410be + p410le + p416be + p416le isRGB: 0bgr @@ -751,6 +787,14 @@ Planar: p010le p016be p016le + p210be + p210le + p216be + p216le + p410be + p410le + p416be + p416le yuv410p yuv411p yuv420p From patchwork Mon Nov 22 20:53:18 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31528 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7582843iob; Mon, 22 Nov 2021 12:54:20 -0800 (PST) X-Google-Smtp-Source: ABdhPJylQ1ZPNuL+fhjUjwwKzi6BNg2vmDb2RdNkj+Zwo9QhNMZ4PeicfLaCo5yT4L6S/VOssATf X-Received: by 2002:a17:906:f0d4:: with SMTP id dk20mr70495ejb.257.1637614460541; Mon, 22 Nov 2021 12:54:20 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637614460; cv=none; d=google.com; s=arc-20160816; b=nA91ZTCe0O8EPIS9RxskdUYXNW05QgWTwErsdUp7K/p34JLaZpEDwEp0HmRrQjbz5J BfF6S8ag/ypzp1yjtyp3nJ0R5lb5RRqeRmPzc3WB3aOrU5YLVpIkkUrky7OXc02gxoMg lSyue5uQoYK8bk0l7dWERIzPX8aShqlHqyuRWHAV7fVDfUsus0dLuqjgffaxlWqpEM9i eYjX0WQZ2EnWlalTji77Ni4Nus+pH3E9XJBkypV2xH/q+IIK777IjkwmWtZA/nVHrJnm PjVfAtUV8IzwwVVoV0wq0SCR2GjewwGpGYi+0L9oD9bIEo+CZRll9cKwGoNv+3u1ciDO HJ5w== 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=srTRvVH+hebzDZTHFSVMmTStOO76PkGg5px9ANmvyRI=; b=qTcdR6glx7h7PawJ6S7x2Uwi6sa8sE70YlI9HPhVyrSM6Wtgzlh+h870v/g0kKg6iW Y9LfrbzmYK6vGc6cOGM/Q0rMK80FQItUGhfIqqXK2ABDtsDKl+aghJ0byg05dlZnLxTB P69Feqt/CUiADZRrnj3reexg/yJ69pDb7CGR5FxUdMZf90231BFIfyyGo7VM7y2lal8a R1mnwrdpKGjJLtJAVqVhbNL4DZk/gykYPjdsqSG9XRGca/RRKWcIJcVTf/3uIwuIwBbl kctvERYeUbl7DopAogc7GQm/rew+RveYbrVU1ry93QGOcdQfdxdYOKzGUYBPvQJpsL2q CXpw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=A9wQuDUs; 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 g19si26230865edu.311.2021.11.22.12.54.20; Mon, 22 Nov 2021 12:54:20 -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=A9wQuDUs; 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 DCD9368A940; Mon, 22 Nov 2021 22:53:46 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f45.google.com (mail-io1-f45.google.com [209.85.166.45]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C41C6689F59 for ; Mon, 22 Nov 2021 22:53:37 +0200 (EET) Received: by mail-io1-f45.google.com with SMTP id e144so25093831iof.3 for ; Mon, 22 Nov 2021 12:53:37 -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=Zxhfn7NPJs8PCgIItTNh/yfcO8YZF7Q3/kQwCPck1y0=; b=A9wQuDUs5elA9M4GoIx0x/dSuXq1w2ofZuoxY6wR8fbxBTDOkp75Y7mJfjU6tU1wmF 6pARAtfyp+ZyOTE5HiEQuEo/ICZW7UDCYBU4W3ngCyyZZBdLKrolyz2w0exH0D9t4gZu 9fT99mWMZ7/ikmXbprvpdFvp8DHiRCKuPN5C6e1oM0NDBv4SrN1aKS/GQ4Qvt+EPbU8e KI1WoytNWUqPvVb/A3xXIzP6F0mpWHGMGxUb/2TajPzKoeNXC9lMm50mrm6YGxW9X52x 6rfRdYyCsNjo4slY1E0VA5VAhtQplJCc+EjgtTkpjm5Gs5l/25cMZ1hvUhqBk/MILJA5 8Y1g== 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=Zxhfn7NPJs8PCgIItTNh/yfcO8YZF7Q3/kQwCPck1y0=; b=SrdIIkMFDaauI7umhUigTDy4/2h2pedekFCBDGftV020JfrxvGGjr4S669GTVtuqeL UjuBrgsXEeqUox+3hNEIpzX8+bib6CorKfG60lAXKEvGR/W5tpq1pzNqMtMVRqR+O3jB hb+XZcly4wgjvSLzf8HFIDifVFo9yziXnINGnMYigfi2rRPHVY4K/TPH8PRr2RuY4tWr 1rWKaEV3l3+RpS8xcAI9VWe7fF2oJg3jPNlbzKtYfIQYF+//0F5ljYVfS4vIk0YBARQ3 k8Yft/YVIvqAT/70HiafZ3Mc5VZJDr2z2qFkSpy9sa4fXrz2pgzgigzmDqplcCyxoMEz kbIQ== X-Gm-Message-State: AOAM532XAVCRCGKh3OSUwLgm1VtAYwqzB0R3av7oiVdgl/VVyk3Il6/P gN9vZAv4MxpYnsO1y5xr2oS7btoVKb8efTY= X-Received: by 2002:a05:6602:2ac5:: with SMTP id m5mr23020895iov.156.1637614416085; Mon, 22 Nov 2021 12:53:36 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id b3sm3571580ile.26.2021.11.22.12.53.35 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 12:53:35 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 14:53:18 -0600 Message-Id: <20211122205330.43546-4-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122205330.43546-1-rcombs@rcombs.me> References: <20211122205330.43546-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 04/16] lavu/videotoolbox: add 422 and 444 pixel format mappings 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: pn8sx8Dja0fd --- configure | 12 ++++++++ libavutil/hwcontext_videotoolbox.c | 44 ++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/configure b/configure index d068b11073..cc79b5b793 100755 --- a/configure +++ b/configure @@ -2329,6 +2329,12 @@ TYPES_LIST=" kCMVideoCodecType_HEVC kCMVideoCodecType_HEVCWithAlpha kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange + kCVPixelFormatType_422YpCbCr8BiPlanarVideoRange + kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange + kCVPixelFormatType_422YpCbCr16BiPlanarVideoRange + kCVPixelFormatType_444YpCbCr8BiPlanarVideoRange + kCVPixelFormatType_444YpCbCr10BiPlanarVideoRange + kCVPixelFormatType_444YpCbCr16BiPlanarVideoRange kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ kCVImageBufferTransferFunction_ITU_R_2100_HLG kCVImageBufferTransferFunction_Linear @@ -6282,6 +6288,12 @@ enabled videotoolbox && { check_func_headers CoreMedia/CMFormatDescription.h kCMVideoCodecType_HEVC "-framework CoreMedia" check_func_headers CoreMedia/CMFormatDescription.h kCMVideoCodecType_HEVCWithAlpha "-framework CoreMedia" check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange "-framework CoreVideo" + check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_422YpCbCr8BiPlanarVideoRange "-framework CoreVideo" + check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange "-framework CoreVideo" + check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_422YpCbCr16BiPlanarVideoRange "-framework CoreVideo" + check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_444YpCbCr8BiPlanarVideoRange "-framework CoreVideo" + check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_444YpCbCr10BiPlanarVideoRange "-framework CoreVideo" + check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_444YpCbCr16BiPlanarVideoRange "-framework CoreVideo" check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferTransferFunction_SMPTE_ST_2084_PQ "-framework CoreVideo" check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferTransferFunction_ITU_R_2100_HLG "-framework CoreVideo" check_func_headers CoreVideo/CVImageBuffer.h kCVImageBufferTransferFunction_Linear "-framework CoreVideo" diff --git a/libavutil/hwcontext_videotoolbox.c b/libavutil/hwcontext_videotoolbox.c index 25f4e17715..f7a1299cc3 100644 --- a/libavutil/hwcontext_videotoolbox.c +++ b/libavutil/hwcontext_videotoolbox.c @@ -53,13 +53,57 @@ static const struct { { kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange, false, AV_PIX_FMT_P010 }, { kCVPixelFormatType_420YpCbCr10BiPlanarFullRange, true, AV_PIX_FMT_P010 }, #endif +#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR8BIPLANARVIDEORANGE + { kCVPixelFormatType_422YpCbCr8BiPlanarVideoRange, false, AV_PIX_FMT_NV16 }, + { kCVPixelFormatType_422YpCbCr8BiPlanarFullRange, true, AV_PIX_FMT_NV16 }, +#endif +#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR10BIPLANARVIDEORANGE + { kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange, false, AV_PIX_FMT_P210 }, + { kCVPixelFormatType_422YpCbCr10BiPlanarFullRange, true, AV_PIX_FMT_P210 }, +#endif +#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR16BIPLANARVIDEORANGE + { kCVPixelFormatType_422YpCbCr16BiPlanarVideoRange, false, AV_PIX_FMT_P216 }, +#endif +#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR8BIPLANARVIDEORANGE + { kCVPixelFormatType_444YpCbCr8BiPlanarVideoRange, false, AV_PIX_FMT_NV24 }, + { kCVPixelFormatType_444YpCbCr8BiPlanarFullRange, true, AV_PIX_FMT_NV24 }, +#endif +#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR10BIPLANARVIDEORANGE + { kCVPixelFormatType_444YpCbCr10BiPlanarVideoRange, false, AV_PIX_FMT_P410 }, + { kCVPixelFormatType_444YpCbCr10BiPlanarFullRange, true, AV_PIX_FMT_P410 }, +#endif +#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR16BIPLANARVIDEORANGE + { kCVPixelFormatType_444YpCbCr16BiPlanarVideoRange, false, AV_PIX_FMT_P416 }, +#endif }; static const enum AVPixelFormat supported_formats[] = { +#ifdef kCFCoreFoundationVersionNumber10_7 AV_PIX_FMT_NV12, +#endif AV_PIX_FMT_YUV420P, 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, }; From patchwork Mon Nov 22 20:53:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31540 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7583065iob; Mon, 22 Nov 2021 12:54:32 -0800 (PST) X-Google-Smtp-Source: ABdhPJzHM2Y3EE5gsUdL80heAaJy5xdZC8hl+FwV5XEg8ov+LR6AK4HQRh54xbS/cSkTbngueCtu X-Received: by 2002:a05:6402:2930:: with SMTP id ee48mr71715319edb.295.1637614472061; Mon, 22 Nov 2021 12:54:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637614472; cv=none; d=google.com; s=arc-20160816; b=LmFCK08XkloCzdeJeqGWPJefEDlwkhrePpxqhxNGNPQvup7EBKC9KGfOBT5+VFx4GF Xsyvd429iGtG4QPgfrPSmnxmzjSlW890ZCwUugiGUp0k7kiXAKqi192JxePxF/vtOwco rI8PbfmIr065Pp3h1vQclRmu9AzSD/jmHhOTVuyzaJn20yQ9pfmS78/Ed8s83f3CWbcV HW3ONjgazlw3CaYTtTH677jkZO1MMUasWIPQ6SZDeFLoU1ADgvGHme4G7OBEQkOtfxuY hOPlT1qf0J6UbMPPdYn/b5NggefSf2yyZXAXIWMRPFQjgiyNHaORxGhSfdg02eU4yg/y rCXg== 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=9USmkLa3WgykokEfk6l0toq9dAyEZaqAvQ0ZmulxTHo=; b=CgiMXYbleb0dEE2Ml1Cn8hN9BWqW/uN00zdYEGZzO28ZRdpXkrciEUl3WEvuqi1+Vk kKNTmQwJH8UxreAxN87m+uXqeHY8vb1KdYbXY69gg6rIZJRyvDLuSaWi/k3/FAREEC10 DE1nTAcO/BI0DKjFhWgXgj0NifkHICSwZWzVSchtREk+NTu/RMdS7e2b3z4WtgYAZ/Qr hPhe0IRzkoHI1ZOjhNGfmkrDIenAnRXFqg+wyusziIdI9OK9+5rg8ELmuH07eU9Gir9d myclhi78rgWUV11p9MAc8GLyWwJqasLgIzSUMvSDmvcpIM2DjXTrcUY4grzd6g/O37fJ ZgzQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=nDwapgFr; 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 5si20957596eji.566.2021.11.22.12.54.31; Mon, 22 Nov 2021 12:54: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=nDwapgFr; 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 C6BE668A93D; Mon, 22 Nov 2021 22:53:47 +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 8FC0068A701 for ; Mon, 22 Nov 2021 22:53:38 +0200 (EET) Received: by mail-io1-f52.google.com with SMTP id e144so25093867iof.3 for ; Mon, 22 Nov 2021 12:53: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=UEW4GZ9JW0/r6cyOGPmq4BBHjwoMynaY9s2/VJGvBxA=; b=nDwapgFr6Y2NvjEL9L9m2rKRH9rCvK+P8XGqRj2vVMhKpzUVPZm2duaq6j7hm7m2GW a0BBTx8dudmmByeerqL1OGLA+doNNxnVZap6fFHTHr1R6X1mmPWBfyLHjQnwUFo+KmkZ S0rOWtx/ItjjvkjEn5FJJrCmITuK4Bwh9BJruhG5sBs+QleMCtbct18r4wWpUkHRc1YR ddppCqTHw8TLUgcb/BUIgXCM21kVS3jYhyK4WCS84Wv+etTyFkNqtAzxOmn5UkbxQJ3z Ag1cgh6xgDzxMemf/OW50BlEoutmYt5QlXXsIKTZ1+RfuBQ6SlUUaBIytwuoYidkOsX9 /ddw== 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=UEW4GZ9JW0/r6cyOGPmq4BBHjwoMynaY9s2/VJGvBxA=; b=InyXYyK3+IqFm2MsS0RpefxxRMvqqHU97BIQhP8W2+TiGm7nIvft73Uv8mKJyHaGWR X9VdOZESvreowV7KWkGdwwXLPLh8X1bF5mnoDolm3DPG5n2zDx3exGTOhGVWIYf5aukz X9BvZpty7XlXs1GN52a1gLR2RGNzXCLeCIG2FxS+ZGaXkyGRPL0z3ZadABeWlPnLd1o6 vaa0SUNSHOweUBl7rVlbrfgs2ggu/j50l2J7Hjp7OCwR9IwfoZbKD12/clKY5XvPufjo LZKVP6TUNfeWJV81DNorXAX4hnstsQ5vHVEe1Oj1IWyG/FpCYOxYwYMTIN8lAJb/qmNw ZCog== X-Gm-Message-State: AOAM531KwI5bwlQyf4cmtKVbwrm0N2/Kf46aey8ovRvEQ/GpnJdqVySS ibYLHGlNiHM1QPt/bED5nu+yN142pY1vJ2k= X-Received: by 2002:a5e:da09:: with SMTP id x9mr26399434ioj.171.1637614417007; Mon, 22 Nov 2021 12:53:37 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id b3sm3571580ile.26.2021.11.22.12.53.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 12:53:36 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 14:53:19 -0600 Message-Id: <20211122205330.43546-5-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122205330.43546-1-rcombs@rcombs.me> References: <20211122205330.43546-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 05/16] lavc/videotoolbox: escape 0x00000[0-3]s in avcC PSs 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: 1J/WYeN1HHJw --- libavcodec/videotoolbox.c | 53 +++++++++++++++++++++++++++++++++------ 1 file changed, 45 insertions(+), 8 deletions(-) diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index 49e726a75f..bd6e769207 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -140,14 +140,51 @@ int ff_videotoolbox_alloc_frame(AVCodecContext *avctx, AVFrame *frame) #define AV_W8(p, v) *(p) = (v) +static int escape_ps(uint8_t* dst, const uint8_t* src, int src_size) +{ + int i; + int size = src_size; + uint8_t* p = dst; + + for (i = 0; i < src_size; i++) { + if (i + 2 < src_size && + src[i] == 0x00 && + src[i + 1] == 0x00 && + src[i + 2] <= 0x03) { + if (dst) { + *p++ = src[i++]; + *p++ = src[i++]; + *p++ = 0x03; + } else { + i += 2; + } + size++; + } + if (dst) + *p++ = src[i]; + } + + if (dst) + av_assert0((p - dst) == size); + + return size; +} + CFDataRef ff_videotoolbox_avcc_extradata_create(AVCodecContext *avctx) { VTContext *vtctx = avctx->internal->hwaccel_priv_data; H264Context *h = avctx->priv_data; CFDataRef data = NULL; uint8_t *p; - int vt_extradata_size = 6 + 2 + h->ps.sps->data_size + 3 + h->ps.pps->data_size; - uint8_t *vt_extradata = av_malloc(vt_extradata_size); + int sps_size = escape_ps(NULL, h->ps.sps->data, h->ps.sps->data_size); + int pps_size = escape_ps(NULL, h->ps.pps->data, h->ps.pps->data_size); + int vt_extradata_size; + uint8_t *vt_extradata; + int i; + + vt_extradata_size = 6 + 2 + sps_size + 3 + pps_size; + vt_extradata = av_malloc(vt_extradata_size); + if (!vt_extradata) return NULL; @@ -159,14 +196,14 @@ CFDataRef ff_videotoolbox_avcc_extradata_create(AVCodecContext *avctx) AV_W8(p + 3, h->ps.sps->data[3]); /* level */ AV_W8(p + 4, 0xff); /* 6 bits reserved (111111) + 2 bits nal size length - 3 (11) */ AV_W8(p + 5, 0xe1); /* 3 bits reserved (111) + 5 bits number of sps (00001) */ - AV_WB16(p + 6, h->ps.sps->data_size); - memcpy(p + 8, h->ps.sps->data, h->ps.sps->data_size); - p += 8 + h->ps.sps->data_size; + AV_WB16(p + 6, sps_size); + p += 8; + p += escape_ps(p, h->ps.sps->data, h->ps.sps->data_size); AV_W8(p + 0, 1); /* number of pps */ - AV_WB16(p + 1, h->ps.pps->data_size); - memcpy(p + 3, h->ps.pps->data, h->ps.pps->data_size); + AV_WB16(p + 1, pps_size); + p += 3; + p += escape_ps(p, h->ps.pps->data, h->ps.pps->data_size); - p += 3 + h->ps.pps->data_size; av_assert0(p - vt_extradata == vt_extradata_size); // save sps header (profile/level) used to create decoder session, From patchwork Mon Nov 22 20:53:20 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31529 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7583549iob; Mon, 22 Nov 2021 12:54:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJwQE7I0hXwLnWWSG+V9b885qVD5IR2kALjBRQjzZQ2fTyPzgJ2zTRosWWP923j+j1aUegzK X-Received: by 2002:a05:6402:50c6:: with SMTP id h6mr68830193edb.228.1637614494529; Mon, 22 Nov 2021 12:54:54 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637614494; cv=none; d=google.com; s=arc-20160816; b=l2xzvXGu////IpI+4QtZpeeBjvmZ8Apg/ezcRVjcdSrL7NI6jJIWh8odOZDaXU5u6A 0fB0aGPGCvHud1VyMcGLQ9L6FVbrF4Wf4eF7D9V1GoIsUgQQthOwJHhGOxd3qSTxPZNU +AssVy5N5N+8Fw2/ZmPNkCfAbCFl2R4AF9yJRjKfI8oo8BMZXQC88LC3DCDWkqRGJ1wm 2WbYYX7ovcHH+qVomr2lSec727UMLdZik7ymd5Y2A+XWimzTHQdeTnNNzltLZbU5O9Xi 8UGUR7wm6wcpv2R80RQ7vb9rZSZPy/sgjruxAtWKvZeItPAZZKUHmN+dP9xVsSpEu/XZ baGw== 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=dsEL+SK0n+DD7XGaqlhWP+AfjLTVjJ2xdgQOdrLv50k=; b=bDE9S+bKN7uv+oV643hcE6rQO4mP9yn524n84gasVWzGSJ3Z7p3o1eg17WhzPeIM/n 3LjhkdDFwgTb7x4s9zAwzvL1q+8oLvdVbo8Uz24wFLkO+8EbJ0+8T0hf0+8pSeE8wqql AoINTqTu46gv4MolZC3/mMuVYDGEdvlaxdE9ExKR4zi9ARvv9CxuSYUiWDqCgXKZhlpZ Tca1xS8RpjnZAD4i689/6Yx41NFwCoNCo1SO31BNM7lmd/E4VDwJ6b13RhxNaPnzpjhM vkxLR65ADXDyftjygdsbmfroX7yWfkHrboDnh/GaSgC3HrFnjElKvn5a1WleHUiAVLcj MaHw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=CNCm4yl8; 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 ar8si20490276ejc.259.2021.11.22.12.54.54; Mon, 22 Nov 2021 12:54:54 -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=CNCm4yl8; 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 0FBEF68ABD1; Mon, 22 Nov 2021 22:53:50 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-il1-f171.google.com (mail-il1-f171.google.com [209.85.166.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7FA0268A778 for ; Mon, 22 Nov 2021 22:53:39 +0200 (EET) Received: by mail-il1-f171.google.com with SMTP id i6so100008ila.0 for ; Mon, 22 Nov 2021 12:53:39 -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=WvQEEhkrtvyP/10de+H1WF6OnE/jl72H/QufzAqlh6A=; b=CNCm4yl8Tokaq6RZHe7EVuY4dNqXSFWIlMVdfxpJoW7Cc/FGmAWKQom+Fr4flYRu8A oRTUanv0EvFovPmXKae/hd7GnmWh/Utw3KZWLYUuvCqz4puEmFo75t4Mjwb5jRRPYpdc JGa3mYlU+n4k3D7HFqMYMTqEjOc+dODc5el0M/K0oo/UfdTiHDvdLNUkO+QsTCZYSD9a fJGDiElGCAaVhbFR+Ig/RWu6uto0XN70DqKksp9u2jPrDpXBQfR5wnVRpJSH9/MWL7Cx 9YI9oYLZ2v21g/NuXe3sBuv4h/XUuvWw8ML5Me5/O8jbY5oC7oB5dgV8hyuUg2bnb2Cs wZoQ== 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=WvQEEhkrtvyP/10de+H1WF6OnE/jl72H/QufzAqlh6A=; b=yvKAmrMoOmKRvzvRjbB98iLApNOGZRxmrDyd25X0fPGPoNkbjQGVKZo/osViZmJrqH h6CwpPmlLPUkFJcFee7GA9hDQTP1vHCraNXaErLYlDVh4Dm/3CSx4m/2prW+fZjNcZdB ObMbRVQe2w1inU1tte0l2fsYQNl0sKB+JdlHpf7soVmE9NH6x6/zIjDnzIEpJebSLjMX WBJ5Gzopw5PYawbAKneut0NaKwQHf5I/NJKXGGSE3Ag7Zs61hx/dojq1vdHcOht3vDCe Alro9mHf5f4pigIT+/kkHAqpwW3OeCLrJcev3l7AwNxqDP6fqfEOI84SwVVpWQZRSHgU mdqw== X-Gm-Message-State: AOAM530MGyQu3pjCQZLx+SLvwKBI2XNUG+lenprzavvnV0+fY+M+gsUA FjsOlbhPdKckcyhWDzUHLKVEcQH6H+VWMxw= X-Received: by 2002:a05:6e02:690:: with SMTP id o16mr21784615ils.102.1637614417855; Mon, 22 Nov 2021 12:53:37 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id b3sm3571580ile.26.2021.11.22.12.53.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 12:53:37 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 14:53:20 -0600 Message-Id: <20211122205330.43546-6-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122205330.43546-1-rcombs@rcombs.me> References: <20211122205330.43546-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 06/16] lavc/videotoolbox: fix format computation 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: U6+m2VQMx4dB Use sw_pix_fmt instead of pix_fmt (consistent with other hwaccels) --- libavcodec/videotoolbox.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index bd6e769207..010f553e57 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -1059,7 +1059,7 @@ static int videotoolbox_uninit(AVCodecContext *avctx) } static enum AVPixelFormat videotoolbox_best_pixel_format(AVCodecContext *avctx) { - const AVPixFmtDescriptor *descriptor = av_pix_fmt_desc_get(avctx->pix_fmt); + const AVPixFmtDescriptor *descriptor = av_pix_fmt_desc_get(avctx->sw_pix_fmt); if (!descriptor) return AV_PIX_FMT_NV12; // same as av_videotoolbox_alloc_context() From patchwork Mon Nov 22 20:53:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31535 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7583995iob; Mon, 22 Nov 2021 12:55:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJygDhpe2EPMrgH+3b3XCspPxVFRDEma+nQHzQ2VYTw8Ur3sjBsQUwaIefj5K8HTu3xaXzHV X-Received: by 2002:a17:907:3fa3:: with SMTP id hr35mr59741ejc.397.1637614517533; Mon, 22 Nov 2021 12:55:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637614517; cv=none; d=google.com; s=arc-20160816; b=C/ddF571meCkFTnl/Z102LSHBL9l+ZYFkAMmDc6Ufqfdnq/Wd9UKCE0AasVEqOXsfg rdfSEyfE6wP2WecNUV3ez4UxnbbxySJEnoPxcLr+B4e+UkEX6x4Izt2RpffvVh4b6wWA pBPAwmJ8lTcNzcOaDzDBmR+Rf8019HafUJ3hNlEjM0+Ukoumuvx4KMqIubu/IK8gEdiG DHhT9tv7TXDG8lktv3tTxbV7VQmAA44TBzPMAZUlE3InQRvpKk9kJZfYiispe10JcL0o c8AxY7NMM795V2OuxZBHEWET8Li33mRp6D7XtifVN5g4M8QS1WunmK6DTJ29XEkPSvvo fpGQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=td8/WBf/+aJX+fJWTY+47chij11JhuaO26DL/CIj/K0=; b=I0RxQbo6A5QolpV0HOIzhCai0qGzo8qoPKNIewuWNLrNMNmHqAFLkZUtgsL081+eoq pkRFCsR0eriPDN0QDkTxKrB5NZ9YN8ezlfXcWY3jd+3QAQGn0SKj1s7mgOl8MZaV2mDR B4mGiOv27uhyrySvHiAcdAk1ZPt5vF3c6S8Opc8yc9LMJqMPGvCtBGK0VGusO0CN/WVk vwZvFjjhUYgi5s3fgZh13W3P6AYSax3fdQOYr+Nxh9SIzjyEMO8pULcsmseyGF0zi8LR 7teufxJAyIIhCmAKNr72V708sMqIiS9EY8fBGpymwwgoMFT4oOWO2sJyRBDgFngg1tgY 1fWQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=Uh9gFuVI; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=rcombs.me Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id m21si22442837edb.268.2021.11.22.12.55.17; Mon, 22 Nov 2021 12:55:17 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=Uh9gFuVI; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=rcombs.me Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 3EDD268A9A5; Mon, 22 Nov 2021 22:53:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-il1-f174.google.com (mail-il1-f174.google.com [209.85.166.174]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A125468A8A5 for ; Mon, 22 Nov 2021 22:53:40 +0200 (EET) Received: by mail-il1-f174.google.com with SMTP id j7so12167481ilk.13 for ; Mon, 22 Nov 2021 12:53:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rcombs.me; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=upUIvvpvRy/e5dsIWKyQ97yjTuI/f7NAfK8jw8wrof8=; b=Uh9gFuVICylkSUBRqpaWxSJmld3Exgz4SxYlkdiEUGGyYdrSjOcMfZ9RTqpTcwQwmC ZwTQiyg05TKNpZ8UFdPh8vX/3TWvLy9ugIXX3JqIZhzd6c6/vpb5jWE6qFFzBdyTk74+ BqQ0kNLg3jrnt6TJAaC/15GmSrQYC0fjAnc7ss0nRaSwmy8zln9/YrzNcvEULPzvBLHF RhmjKpzH7mr5UT+whZIEqI0T9L4akHzH/CVWr6IB8zCj2Kco7UQPUPLWYLXso7ipp67o Rx35WvDrnBMaDmn0G0kJSilcXJlfL0CMbErZcYHQaIpD/kyu7mYNa3Zw2LaKcl2/ocQR kzRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=upUIvvpvRy/e5dsIWKyQ97yjTuI/f7NAfK8jw8wrof8=; b=JxsGTpALfYmeSStAy8agdYOFN0bACzfTB8dNGpkIjpndFztgTNZ1zxz6bZ+JzuLLGn wLLGmgBu78elWrRbmqDJn7Hk/hKTrTyBNOo7DBEhJrPP4Y5GEJmWspDm5ZEs+ZSYqyaH Egs3oWxfwtnsDCDd3XYO1gUbaMhiOObRMxHVfaROmyogudegHS7WBDTW4WZMn4I6ONqe VVehSGWEzSnp6M5UUebnh5b4+VpL5HtFXqFPsqtz41/ze7/FZto/lSj2HutcjHYw7ybK aMJbNPWCka9xPOlnURMVHkpdgyaW/u6zS9coOqu4PRHrL+TDxamnYi/xf5NQsKeuxWE8 /YPQ== X-Gm-Message-State: AOAM532rJPieARv5i4Z/T+qmWrpiV2kGc/u1sgDBJ9Y14A7cxCxZXzaG IFCJqMZNEwpDR3vSA/SqlkurRcfQXHSwGkA= X-Received: by 2002:a05:6e02:214b:: with SMTP id d11mr12623202ilv.241.1637614419005; Mon, 22 Nov 2021 12:53:39 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id b3sm3571580ile.26.2021.11.22.12.53.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 12:53:38 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 14:53:21 -0600 Message-Id: <20211122205330.43546-7-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122205330.43546-1-rcombs@rcombs.me> References: <20211122205330.43546-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/16] lavc/videotoolbox: select 4:2:2 and 4:4:4 formats when applicable X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: ofzcxaY/Qgtu --- libavcodec/videotoolbox.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index 010f553e57..57b37bf3bf 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -1064,9 +1064,35 @@ static enum AVPixelFormat videotoolbox_best_pixel_format(AVCodecContext *avctx) return AV_PIX_FMT_NV12; // same as av_videotoolbox_alloc_context() int depth = descriptor->comp[0].depth; + +#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR16BIPLANARVIDEORANGE + if (depth > 10) + return descriptor->log2_chroma_w == 0 ? AV_PIX_FMT_P416 : AV_PIX_FMT_P216; +#endif + +#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR10BIPLANARVIDEORANGE + if (descriptor->log2_chroma_w == 0) { +#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR8BIPLANARVIDEORANGE + if (depth <= 8) + return AV_PIX_FMT_NV24; +#endif + return AV_PIX_FMT_P410; + } +#endif +#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR10BIPLANARVIDEORANGE + if (descriptor->log2_chroma_h == 0) { +#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR8BIPLANARVIDEORANGE + if (depth <= 8) + return AV_PIX_FMT_NV16; +#endif + return AV_PIX_FMT_P210; + } +#endif +#if HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE if (depth > 8) { return AV_PIX_FMT_P010; } +#endif return AV_PIX_FMT_NV12; } From patchwork Mon Nov 22 20:53:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31527 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7584206iob; Mon, 22 Nov 2021 12:55:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJw+fHVYjZgqwj4e5sJjlZPf5yiRylfBzURUW6QEO4pkg5nfZ/xt8ZACEFuaiH9+7xAkIVm0 X-Received: by 2002:a17:906:6bc4:: with SMTP id t4mr79301ejs.259.1637614530147; Mon, 22 Nov 2021 12:55:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637614530; cv=none; d=google.com; s=arc-20160816; b=MEtlhvAS6j5ZcHogkDUz25UH4tRXJtKBZK/pnaxkEZtn9eqXUAfiumTBQ3OGM06zkI tAZdJN20iV7jiOYv1b2Bm4YZAdEmQeAdShi3yRPaMyjC4weR0GbFrGtWZfvECbkVhjYY cgFysYcEald5/Woy39eTWirxEc8JxaW/urV0IkeIPpAPcso6VPzjVVe7UcGyIfY0ggqn RjgU6HZ8dhjAXRrchEvEWeNYT36eHv2dsXGQLNGnPMgrsWSd7Wj0XyKZTgaA0PQxQcj4 45jnRHxpHcy4azUY+irp62qdedpUSt9VGGcVBP91jTphE/QguMlnhCRmhcie1V3OKpbK QCzQ== 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=6lVIrkMm6KPrqXeTn+IiiYDr4flZ0ORA+A5kcjYrrGo=; b=rZ0xnsPV90GQ4obuvyfsL+5QLDnrW30/nxh9CQOQH0PxutPXhdHvs7gKpMiCNSkh76 R11c0s/vywNsPLYbuIL5ny0n/ZDTExj71qcmh033LZn3FIfG7rIQz8Fqot3x4PfZ7kzC xtQBmZPSGrt48MWnU8XDfUovn36hKYK6FHXUk+ySbaIiDDk2yhlqxqcuU2Cw6SLaE9fn B80/ULxfHFAO4+7ylbtR+E9i0r74/2PtNlwVq/iTNMODNAs4m1o2sE6ZpboQR9opc8Gl mNVDiiMj2dK4NeSj6cOru61+KN5MrtkH3dQhdbRCbKWTNQ12LZd0Z8qz4onirTi2WVIU XHAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=MkXJz5sA; 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 b13si33887610edz.495.2021.11.22.12.55.29; Mon, 22 Nov 2021 12:55:30 -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=MkXJz5sA; 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 37E3E68AC4D; Mon, 22 Nov 2021 22:53:53 +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 5805E68A44C for ; Mon, 22 Nov 2021 22:53:41 +0200 (EET) Received: by mail-il1-f176.google.com with SMTP id t8so9583715ilu.8 for ; Mon, 22 Nov 2021 12:53:41 -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=fII5PjthrjHamJsAyrtOHkH7y2pej7OdhiTi3QeFUd4=; b=MkXJz5sAzFhuD88Efo6FS2dtsJQKxGPZFvq+LRXp6BXpU/TZyaczeAlfCZF46Dkf6a yoBFM0r02XoxfhtrtjR0ti0R1RqxsMn98ageMTWc26eEoGi3cY4NWCBJDLFAHIqWODXG 95RBSxnxQeoun1gOOdTa0q80UcAriV/vUy3lCGSYwNpXffYY+PcYrcNs22cGi8Dt7gal dWHvCIN3ZJH7lL6Fdthc/KXS7b4awOUNABmuebWVrfh/Z/fvkXRsAGvqjzGpSnaxaS1S J+JHSnL0bHFXv7MuydLFCj3ov+cj+S8ykxWtgBb/kME6PRlaLO22A49QkFbBEOCO2+S4 9oNQ== 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=fII5PjthrjHamJsAyrtOHkH7y2pej7OdhiTi3QeFUd4=; b=bVLWqEFGqfKkUZ9kPDIfyHwVjAiDqXLaL78fYYtS/KlSjO8xby76WhUw1j6uhetRAu g8gHfU/X5JFNx7RUIgKfO0fCr2KXDxMD04msq1Eo/ls+NVY3tgteooIr2KraOZxuIybl WR3kMm/6FJeRzr57Zn6EPoXTeQG18b4NmEAJ3UWU2EOUf25TkDrBkgTXIwzUVGpPhs7L /317RU6P86KAsJQ9Yl21HstyGaL4lr57BiGQIQPrsCjFQvHhQq1osw9Hllztk42RDXog AMwSllSNB1Hu/m4iEpxm+TKV0K2QTsRd7i4V4bDSSZGNnKsS0s+z9X4UEEw60dhoaiMX OCIw== X-Gm-Message-State: AOAM533s95ue9P7bP0rFVosMj1KznfClOhperhd2TPzKHRMlY47KOf31 g/GzizNnn+CCDxys3apuyKdnw0hBfgy1280= X-Received: by 2002:a05:6e02:1541:: with SMTP id j1mr21493057ilu.177.1637614419768; Mon, 22 Nov 2021 12:53:39 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id b3sm3571580ile.26.2021.11.22.12.53.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 12:53:39 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 14:53:22 -0600 Message-Id: <20211122205330.43546-8-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122205330.43546-1-rcombs@rcombs.me> References: <20211122205330.43546-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 08/16] lavc/h264dec: support all color formats in videotoolbox hwaccel 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: RXlJNRX0V0zH --- libavcodec/h264_slice.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 89ea16a57f..476a14d485 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -798,6 +798,10 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) const enum AVPixelFormat *choices = pix_fmts; int i; +#if CONFIG_H264_VIDEOTOOLBOX_HWACCEL + *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX; +#endif + switch (h->ps.sps->bit_depth_luma) { case 9: if (CHROMA444(h)) { @@ -872,9 +876,6 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) #endif #if CONFIG_H264_VAAPI_HWACCEL *fmt++ = AV_PIX_FMT_VAAPI; -#endif -#if CONFIG_H264_VIDEOTOOLBOX_HWACCEL - *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX; #endif if (h->avctx->codec->pix_fmts) choices = h->avctx->codec->pix_fmts; From patchwork Mon Nov 22 20:53:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31533 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7584685iob; Mon, 22 Nov 2021 12:55:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJy1cZwHGr4PCkCKh+FnWNmUf2DHICE1+Enp21oVvNU3BmjYxyTwP4nusoVdJFhHSXJX070U X-Received: by 2002:a17:907:96a9:: with SMTP id hd41mr65201ejc.413.1637614553847; Mon, 22 Nov 2021 12:55:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637614553; cv=none; d=google.com; s=arc-20160816; b=ABbVAalQ/DuoRIfEpL9aGXL71uaFvOsuDlz5hEn2nAczpWDNM/prK5ghHOpMSnrur3 kzzsKmCbFiCw/glPGsE0pbuGZw6wQ4hOqRLlHqRzB3KoU5MSbbG8vxKfTEOdPEAydNTB s9k6l4dosFzJAQ8sIcFUOC3LZOhNO3/A2caScEVLHkc0ly1kcQskr/L9brN/WCwExkAt ZmP0+/Cr/ZI99oOHM41RtuRj6TPZc5bYzlb4nEPnC80auDNM7gZdQAnfhGj+/c/Bv1Ln YjoYtq59hZzATOWQj4lNzlnOnHmnIbxNnLOpfESx0f0hGTlyfzVL9LQl0owHlknzpjYQ yJYA== 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=pHj6+0cXNR7QKWO5kzAtHLBypsL5hpyNYv3kixZSVbg=; b=ae7tUg0okH0g9ly6m52hCwS3a6PHAY2yN0KQ/zJZV8ry0eVpOLwR0S1vaXkJrpPYhd Vc6XxcESQn2MYlLxzbfV++x9jNVWpXGc6nBMyoxwnAlrB3ASLFnFgLpciobrBzaTJtYS r/8ez5WVSrBpTmCepsLFZkQyeTScPpdF5lCBnnmbiFZycjG4UfKqHVmkLPsZNQg53N/d FKpMV4t2t5QF8LbPT/jSc9cgTbtR5ecmTumlZ9ACN4tz8aq7W0r3Nk6VC83JVke2IVYJ dxfIcrRlbC1u1cgHxRwhuAdphmsywPbzWE1+IOU54ZL93KTkWMfRZly3NblFHj5kYAPj weVQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=X84Ok0lj; 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 y11si30921742edc.377.2021.11.22.12.55.53; Mon, 22 Nov 2021 12:55:53 -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=X84Ok0lj; 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 17ECD68A8E7; Mon, 22 Nov 2021 22:53:55 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-il1-f172.google.com (mail-il1-f172.google.com [209.85.166.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4E4A3689F59 for ; Mon, 22 Nov 2021 22:53:42 +0200 (EET) Received: by mail-il1-f172.google.com with SMTP id t8so9583763ilu.8 for ; Mon, 22 Nov 2021 12:53:42 -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=5BkYfYLit1/tWm0Ip0avOh412R4H0ZmbSSS6/YcUY+U=; b=X84Ok0ljNORpgzphvMC4qN8ky2Zb4tStMjMqCz/JQWR64xXSrNIAmd5qF1Cq3JlwPC cN33+6db7btDjkj1rWf8XPRLg0XDWH1WG4UI0bpz/dNheV+/rWeqwlKUpX1pzvtsCpe+ 85VScx68mSF2K9x0dtRXmR3hQSpOdPlXJOlt7UjiRVjK3yDtiWB3VNaR1XmtWarnMxwI hXO+eVFyKo1WT90MAtD7cQn36pj0upj42LrIPZ4tMzjghQuEAmVkHyXHbI9qebfQt5vj QuI26VdTaKckpbISBuPcrDlszf4Nio70d4Ld4N4wv+tmKp1xRR0SvWe2Ssxujo8g44Cl 5xUw== 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=5BkYfYLit1/tWm0Ip0avOh412R4H0ZmbSSS6/YcUY+U=; b=cwC9urjH9rXMIZqjYIcMoYsKBKPkWLlK3OPims59cP48+IIEA+Y2bVuCX/ldV4CEKW sPdlxAlWbXT7n08nfc6gFy3FuMfNN3V7LMVUpSqiI3hy6jGuSuzI/WGRjNJbLFxsA5hh dmPCqByvVYwxIoFMSHhljNcRMneJvaCVwtOhiwpMjqzT6T4n1wAc/6S6bRcAmx1zdKzf LpJOoBKn63dT2kUE5sge2h93Mf5rFHikw4drhBWmEXpstgCSgs/mjP7wX9hE5+tr9Tz/ aeUr8idNaXd43XUVKk6mOWt/tyfz6V+aMaW8fNCR5BPr3S+4FzLde9R/f69hP1DVBrV2 e/7A== X-Gm-Message-State: AOAM5307atZgZ1nSwt6GBxU2dSI7bQN7yPDTXm+5XAvPAJcWP7+xf680 7bO57j3V/5ZA3lphaII2yYRosQiN7NfTD+o= X-Received: by 2002:a05:6e02:219a:: with SMTP id j26mr16851436ila.323.1637614420646; Mon, 22 Nov 2021 12:53:40 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id b3sm3571580ile.26.2021.11.22.12.53.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 12:53:40 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 14:53:23 -0600 Message-Id: <20211122205330.43546-9-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122205330.43546-1-rcombs@rcombs.me> References: <20211122205330.43546-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 09/16] lavc/hevcdec: support all color formats in videotoolbox hwaccel 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: OQTEyLo1pbGo --- libavcodec/hevcdec.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 3e19f4ebed..47c551237f 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -401,6 +401,10 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) CONFIG_HEVC_VDPAU_HWACCEL) enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmt = pix_fmts; +#if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL + *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX; +#endif + switch (sps->pix_fmt) { case AV_PIX_FMT_YUV420P: case AV_PIX_FMT_YUVJ420P: @@ -419,9 +423,6 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) #endif #if CONFIG_HEVC_NVDEC_HWACCEL *fmt++ = AV_PIX_FMT_CUDA; -#endif -#if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL - *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX; #endif break; case AV_PIX_FMT_YUV420P10: @@ -435,9 +436,6 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) #if CONFIG_HEVC_VAAPI_HWACCEL *fmt++ = AV_PIX_FMT_VAAPI; #endif -#if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL - *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX; -#endif #if CONFIG_HEVC_VDPAU_HWACCEL *fmt++ = AV_PIX_FMT_VDPAU; #endif From patchwork Mon Nov 22 20:53:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31532 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7585142iob; Mon, 22 Nov 2021 12:56:17 -0800 (PST) X-Google-Smtp-Source: ABdhPJwB45tZoIeNNY4e+l+9qPUQgPBFMffpDUuKd/9pnvbAo50fwBEgkJk3+SlDfg0yDXQZb3PR X-Received: by 2002:a17:907:1b06:: with SMTP id mp6mr85205ejc.275.1637614577648; Mon, 22 Nov 2021 12:56:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637614577; cv=none; d=google.com; s=arc-20160816; b=eU+4/juydqHeFeDxPcwDb6+jcPHI7z+jB3nmRl8IN+Y3Jm1/HukA51Z449ZZa7A5cr xCbDTaw9PYg9jVQf/6+EuyctZYIFlU+u6CKPKjaEZwJAWq+ZcTRQ8BhPqyhPJ5xK+Mci DKdTUUmQaj4YeIYRtLC+JRZmjvu3r9tjIIPwOTs0q31/Bz6HEX5dc3MQF+fu9IxWgCXP rvkvzwRcFurp0gv0SYIG3BvXyIPV9tUQUoFG5izwcPUuWicaZDsOqZnWAgU2SDo6KrwJ l/vH3Il7S7E9Y8VGmhx3lX/qzn2/9g0EZLjqcL7WLH6KSbeNac8dUHDQrFxa7xGEEHdW IOeQ== 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=rZ7m6e4Eqw4ZHCJ/vY1nF9Kr2/nkWpjxiTkg+PXwvg0=; b=LVAGXTqWw6v8GDBIFXEWn278h35JwvL24APf1cDiHNHlOE0Bxo2J6zTevA73Ee1qt5 A/7CIINbBrNby7H5fMKwhBVx/PCvJ0J7oM69+09L0jM+JplND1hjYG4OjrNdCTKFKbUv jmaEEo9bIEN70PNBDoN/eCIJVWgCWQjcu8jDdsgB/bTSDOnbhkyARKFTHGLeOg7eWt56 j8Td8G5RMQWlOdId7s601jYyzUaW3bkzsDsKQggr6WtCASXZ4857EbVeEvwIs8iHVhS6 iNcMowwZVnxP4eSBtZ2sLORLTBD28erIT5mZM2b6LUNHDtFGVgzyd4p6M4J6CNrTJsLW 9YGA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=GJqYMYMg; 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 u1si22715444edx.234.2021.11.22.12.56.17; Mon, 22 Nov 2021 12:56:17 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=GJqYMYMg; 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 15AD368A8A5; Mon, 22 Nov 2021 22:53:57 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-il1-f172.google.com (mail-il1-f172.google.com [209.85.166.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5E68D68A980 for ; Mon, 22 Nov 2021 22:53:43 +0200 (EET) Received: by mail-il1-f172.google.com with SMTP id i6so100171ila.0 for ; Mon, 22 Nov 2021 12:53:43 -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=1bvVu72bxky2xP7jkMzKU3R+qBcyA6ikIATVLj1l064=; b=GJqYMYMgxXNflwGIXm0SEoy4Yd2HPh624bwpLhshO8Zz8PJQ6iVNDb+CHC666BmdNc cW3SiAq4YzkS38850Uo/KDK/twK6PCgNtjrHDXaO34epdrI6gaMFSxz8PJJ1sv3BlHQb xpAduFsKQVja6kHPwQrO8J5ZWEw2J6DPV/OL7gAoBhkfFDd6wZOuBvsSbtogRFnwhTVl Rl433COK0Ej5etMvu9g3KXMEanbqFIB38BX5ajGRQCj6M2EpBuZturVfW6DrQgDy+ib8 aHdJNnPBQyCeMt1hgq8+pREGhgf0TnsoiTmPhuFG+o+E8s9iWVyBsjIQVS1JybLovjgD ZgxA== 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=1bvVu72bxky2xP7jkMzKU3R+qBcyA6ikIATVLj1l064=; b=Keifn1mUN29tiUV39ORFIarE+fQA7CRLDUJrojQohtXLxrRL6gAEBWR2TZPEPendkY 90yt/JavGbWdrt1ZfuFt9l/iWFysdkB8DsNwqdQx7CmagVyac5A4Fwu13HVpLGWyrITU wGxpVItzpDvqFk55Ya0ziIyKLUkaurY6+ACEdjMNDub1nOzPNqf/KzlXpwG2z80OvrGM Ba4nktgeMH4/S3BEoXQ6CyqDo13I3pPo7Nky5RstBccPY114FIglHvn6FWxUYJ9jqfXd AIPo8Ph04Zt9gObWMZdXHqxUWnlBIuv4zYZKjXA1oOByYI4qLvyZNKZsaU2gcV38F+on dqWQ== X-Gm-Message-State: AOAM530XFK/Y8m3Pu3uT/sRrlRH9+lJPe0yCpV4wWP0AKIQaRqWA7oYE 2EtLYy26pwiR0IHGKA76FVNxprQnr8TYgvc= X-Received: by 2002:a05:6e02:148d:: with SMTP id n13mr22496121ilk.100.1637614421545; Mon, 22 Nov 2021 12:53:41 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id b3sm3571580ile.26.2021.11.22.12.53.40 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 12:53:41 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 14:53:24 -0600 Message-Id: <20211122205330.43546-10-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122205330.43546-1-rcombs@rcombs.me> References: <20211122205330.43546-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 10/16] lavc/videotoolbox: expose some functions as lavc-internal 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: QUeEJ17O40cN --- libavcodec/videotoolbox.c | 146 ++++++++++++++++++-------------------- libavcodec/vt_internal.h | 10 +++ 2 files changed, 78 insertions(+), 78 deletions(-) diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index 57b37bf3bf..3022cd1cbf 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -61,9 +61,9 @@ static void videotoolbox_buffer_release(void *opaque, uint8_t *data) av_free(data); } -static int videotoolbox_buffer_copy(VTContext *vtctx, - const uint8_t *buffer, - uint32_t size) +int ff_videotoolbox_buffer_copy(VTContext *vtctx, + const uint8_t *buffer, + uint32_t size) { void *tmp; @@ -376,7 +376,7 @@ int ff_videotoolbox_h264_start_frame(AVCodecContext *avctx, H264Context *h = avctx->priv_data; if (h->is_avc == 1) { - return videotoolbox_buffer_copy(vtctx, buffer, size); + return ff_videotoolbox_buffer_copy(vtctx, buffer, size); } return 0; @@ -440,18 +440,6 @@ int ff_videotoolbox_h264_decode_slice(AVCodecContext *avctx, return videotoolbox_common_decode_slice(avctx, buffer, size); } -int ff_videotoolbox_uninit(AVCodecContext *avctx) -{ - VTContext *vtctx = avctx->internal->hwaccel_priv_data; - if (vtctx) { - av_freep(&vtctx->bitstream); - if (vtctx->frame) - CVPixelBufferRelease(vtctx->frame); - } - - return 0; -} - #if CONFIG_VIDEOTOOLBOX // Return the AVVideotoolboxContext that matters currently. Where it comes from // depends on the API used. @@ -467,6 +455,43 @@ static AVVideotoolboxContext *videotoolbox_get_context(AVCodecContext *avctx) return avctx->hwaccel_context; } +static void videotoolbox_stop(AVCodecContext *avctx) +{ + AVVideotoolboxContext *videotoolbox = videotoolbox_get_context(avctx); + if (!videotoolbox) + return; + + if (videotoolbox->cm_fmt_desc) { + CFRelease(videotoolbox->cm_fmt_desc); + videotoolbox->cm_fmt_desc = NULL; + } + + if (videotoolbox->session) { + VTDecompressionSessionInvalidate(videotoolbox->session); + CFRelease(videotoolbox->session); + videotoolbox->session = NULL; + } +} + +int ff_videotoolbox_uninit(AVCodecContext *avctx) +{ + VTContext *vtctx = avctx->internal->hwaccel_priv_data; + if (!vtctx) + return 0; + + av_freep(&vtctx->bitstream); + if (vtctx->frame) + CVPixelBufferRelease(vtctx->frame); + + if (vtctx->vt_ctx) + videotoolbox_stop(avctx); + + av_buffer_unref(&vtctx->cached_hw_frames_ctx); + av_freep(&vtctx->vt_ctx); + + return 0; +} + static int videotoolbox_buffer_create(AVCodecContext *avctx, AVFrame *frame) { VTContext *vtctx = avctx->internal->hwaccel_priv_data; @@ -903,24 +928,6 @@ static int videotoolbox_start(AVCodecContext *avctx) } } -static void videotoolbox_stop(AVCodecContext *avctx) -{ - AVVideotoolboxContext *videotoolbox = videotoolbox_get_context(avctx); - if (!videotoolbox) - return; - - if (videotoolbox->cm_fmt_desc) { - CFRelease(videotoolbox->cm_fmt_desc); - videotoolbox->cm_fmt_desc = NULL; - } - - if (videotoolbox->session) { - VTDecompressionSessionInvalidate(videotoolbox->session); - CFRelease(videotoolbox->session); - videotoolbox->session = NULL; - } -} - static const char *videotoolbox_error_string(OSStatus status) { switch (status) { @@ -934,7 +941,7 @@ static const char *videotoolbox_error_string(OSStatus status) return "unknown"; } -static int videotoolbox_common_end_frame(AVCodecContext *avctx, AVFrame *frame) +int ff_videotoolbox_common_end_frame(AVCodecContext *avctx, AVFrame *frame) { OSStatus status; AVVideotoolboxContext *videotoolbox = videotoolbox_get_context(avctx); @@ -973,7 +980,7 @@ static int videotoolbox_h264_end_frame(AVCodecContext *avctx) H264Context *h = avctx->priv_data; AVFrame *frame = h->cur_pic_ptr->f; VTContext *vtctx = avctx->internal->hwaccel_priv_data; - int ret = videotoolbox_common_end_frame(avctx, frame); + int ret = ff_videotoolbox_common_end_frame(avctx, frame); vtctx->bitstream_size = 0; return ret; } @@ -1012,7 +1019,7 @@ static int videotoolbox_hevc_end_frame(AVCodecContext *avctx) h->output_frame->crop_top = 0; h->output_frame->crop_bottom = 0; - int ret = videotoolbox_common_end_frame(avctx, frame); + int ret = ff_videotoolbox_common_end_frame(avctx, frame); vtctx->bitstream_size = 0; return ret; } @@ -1023,7 +1030,7 @@ static int videotoolbox_mpeg_start_frame(AVCodecContext *avctx, { VTContext *vtctx = avctx->internal->hwaccel_priv_data; - return videotoolbox_buffer_copy(vtctx, buffer, size); + return ff_videotoolbox_buffer_copy(vtctx, buffer, size); } static int videotoolbox_mpeg_decode_slice(AVCodecContext *avctx, @@ -1038,24 +1045,7 @@ static int videotoolbox_mpeg_end_frame(AVCodecContext *avctx) MpegEncContext *s = avctx->priv_data; AVFrame *frame = s->current_picture_ptr->f; - return videotoolbox_common_end_frame(avctx, frame); -} - -static int videotoolbox_uninit(AVCodecContext *avctx) -{ - VTContext *vtctx = avctx->internal->hwaccel_priv_data; - if (!vtctx) - return 0; - - ff_videotoolbox_uninit(avctx); - - if (vtctx->vt_ctx) - videotoolbox_stop(avctx); - - av_buffer_unref(&vtctx->cached_hw_frames_ctx); - av_freep(&vtctx->vt_ctx); - - return 0; + return ff_videotoolbox_common_end_frame(avctx, frame); } static enum AVPixelFormat videotoolbox_best_pixel_format(AVCodecContext *avctx) { @@ -1097,7 +1087,7 @@ static enum AVPixelFormat videotoolbox_best_pixel_format(AVCodecContext *avctx) return AV_PIX_FMT_NV12; } -static int videotoolbox_common_init(AVCodecContext *avctx) +int ff_videotoolbox_common_init(AVCodecContext *avctx) { VTContext *vtctx = avctx->internal->hwaccel_priv_data; AVHWFramesContext *hw_frames; @@ -1169,12 +1159,12 @@ static int videotoolbox_common_init(AVCodecContext *avctx) return 0; fail: - videotoolbox_uninit(avctx); + ff_videotoolbox_uninit(avctx); return err; } -static int videotoolbox_frame_params(AVCodecContext *avctx, - AVBufferRef *hw_frames_ctx) +int ff_videotoolbox_frame_params(AVCodecContext *avctx, + AVBufferRef *hw_frames_ctx) { AVHWFramesContext *frames_ctx = (AVHWFramesContext*)hw_frames_ctx->data; @@ -1195,9 +1185,9 @@ const AVHWAccel ff_h263_videotoolbox_hwaccel = { .start_frame = videotoolbox_mpeg_start_frame, .decode_slice = videotoolbox_mpeg_decode_slice, .end_frame = videotoolbox_mpeg_end_frame, - .frame_params = videotoolbox_frame_params, - .init = videotoolbox_common_init, - .uninit = videotoolbox_uninit, + .frame_params = ff_videotoolbox_frame_params, + .init = ff_videotoolbox_common_init, + .uninit = ff_videotoolbox_uninit, .priv_data_size = sizeof(VTContext), }; @@ -1211,9 +1201,9 @@ const AVHWAccel ff_hevc_videotoolbox_hwaccel = { .decode_slice = videotoolbox_hevc_decode_slice, .decode_params = videotoolbox_hevc_decode_params, .end_frame = videotoolbox_hevc_end_frame, - .frame_params = videotoolbox_frame_params, - .init = videotoolbox_common_init, - .uninit = videotoolbox_uninit, + .frame_params = ff_videotoolbox_frame_params, + .init = ff_videotoolbox_common_init, + .uninit = ff_videotoolbox_uninit, .priv_data_size = sizeof(VTContext), }; @@ -1227,9 +1217,9 @@ const AVHWAccel ff_h264_videotoolbox_hwaccel = { .decode_slice = ff_videotoolbox_h264_decode_slice, .decode_params = videotoolbox_h264_decode_params, .end_frame = videotoolbox_h264_end_frame, - .frame_params = videotoolbox_frame_params, - .init = videotoolbox_common_init, - .uninit = videotoolbox_uninit, + .frame_params = ff_videotoolbox_frame_params, + .init = ff_videotoolbox_common_init, + .uninit = ff_videotoolbox_uninit, .priv_data_size = sizeof(VTContext), }; @@ -1242,9 +1232,9 @@ const AVHWAccel ff_mpeg1_videotoolbox_hwaccel = { .start_frame = videotoolbox_mpeg_start_frame, .decode_slice = videotoolbox_mpeg_decode_slice, .end_frame = videotoolbox_mpeg_end_frame, - .frame_params = videotoolbox_frame_params, - .init = videotoolbox_common_init, - .uninit = videotoolbox_uninit, + .frame_params = ff_videotoolbox_frame_params, + .init = ff_videotoolbox_common_init, + .uninit = ff_videotoolbox_uninit, .priv_data_size = sizeof(VTContext), }; @@ -1257,9 +1247,9 @@ const AVHWAccel ff_mpeg2_videotoolbox_hwaccel = { .start_frame = videotoolbox_mpeg_start_frame, .decode_slice = videotoolbox_mpeg_decode_slice, .end_frame = videotoolbox_mpeg_end_frame, - .frame_params = videotoolbox_frame_params, - .init = videotoolbox_common_init, - .uninit = videotoolbox_uninit, + .frame_params = ff_videotoolbox_frame_params, + .init = ff_videotoolbox_common_init, + .uninit = ff_videotoolbox_uninit, .priv_data_size = sizeof(VTContext), }; @@ -1272,9 +1262,9 @@ const AVHWAccel ff_mpeg4_videotoolbox_hwaccel = { .start_frame = videotoolbox_mpeg_start_frame, .decode_slice = videotoolbox_mpeg_decode_slice, .end_frame = videotoolbox_mpeg_end_frame, - .frame_params = videotoolbox_frame_params, - .init = videotoolbox_common_init, - .uninit = videotoolbox_uninit, + .frame_params = ff_videotoolbox_frame_params, + .init = ff_videotoolbox_common_init, + .uninit = ff_videotoolbox_uninit, .priv_data_size = sizeof(VTContext), }; diff --git a/libavcodec/vt_internal.h b/libavcodec/vt_internal.h index fb64735b8c..e2f279d0fc 100644 --- a/libavcodec/vt_internal.h +++ b/libavcodec/vt_internal.h @@ -19,6 +19,9 @@ #ifndef AVCODEC_VT_INTERNAL_H #define AVCODEC_VT_INTERNAL_H +#include "avcodec.h" +#include "videotoolbox.h" + typedef struct VTContext { // The current bitstream buffer. uint8_t *bitstream; @@ -45,6 +48,12 @@ typedef struct VTContext { } VTContext; int ff_videotoolbox_alloc_frame(AVCodecContext *avctx, AVFrame *frame); +int ff_videotoolbox_common_init(AVCodecContext *avctx); +int ff_videotoolbox_frame_params(AVCodecContext *avctx, + AVBufferRef *hw_frames_ctx); +int ff_videotoolbox_buffer_copy(VTContext *vtctx, + const uint8_t *buffer, + uint32_t size); int ff_videotoolbox_uninit(AVCodecContext *avctx); int ff_videotoolbox_h264_start_frame(AVCodecContext *avctx, const uint8_t *buffer, @@ -52,6 +61,7 @@ int ff_videotoolbox_h264_start_frame(AVCodecContext *avctx, int ff_videotoolbox_h264_decode_slice(AVCodecContext *avctx, const uint8_t *buffer, uint32_t size); +int ff_videotoolbox_common_end_frame(AVCodecContext *avctx, AVFrame *frame); CFDataRef ff_videotoolbox_avcc_extradata_create(AVCodecContext *avctx); CFDataRef ff_videotoolbox_hvcc_extradata_create(AVCodecContext *avctx); From patchwork Mon Nov 22 20:53:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31538 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7583310iob; Mon, 22 Nov 2021 12:54:44 -0800 (PST) X-Google-Smtp-Source: ABdhPJwpV0MejYKkPKZL+XcVdkl98Nuft/HeVR2I4wPF+lr8Tpk9gyDMGuI+8jxbActyw0x1eaUu X-Received: by 2002:a17:907:1b06:: with SMTP id mp6mr71064ejc.275.1637614484196; Mon, 22 Nov 2021 12:54:44 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637614484; cv=none; d=google.com; s=arc-20160816; b=STma/VD4jkfI/IA4TCnkKkfPaLpeyiL0YaIcn65bzhqzluuMbBAynm+s1+Vfn8q8W7 mCitgu4EvaRuOLRXPjVInIqwHLdcS7d0M/jfnrN5wyQW800e1tW49HeRxqgmQ+ABHO+p /4kavydLUTBqidVGisRzzFgXjk4COmPvRO0S5WiLG18ZZSPRAeVslFt6jIXawXSjTYNN o4TRBdIuIgXqDotFreOeJwBl+qM82lcx3NUwBBY06X6XMuEkqGsbmgkwAnMjmuUADu50 ExE3deb+g/zzAMU7ZtL4iKwQ7AUoTyS/2BE+7UnVLqX9L8raIyd5iSGRdff73SIzgJKt LEvg== 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=BGQKr/eljpoQyRrxiE3KpxKqEb0CbqtTYVWsx9bM6xQ=; b=hjoWvPeRYIN9YDYiSUv1q5emKXjv/n5/AhBIBwiZMPi/XKVlPhh90NunPFwtAMEl0Q Z2DCiQJn3bWhV14KEBBtLgBhc/P9MmBs5JAzoVsTNVfvMDya7qs3x9NjzkMBEJ0HTivR BmJmsNYQ2m/VtHz8VI/FEG82fNNn8dYQUkhxt97wqXjX2ALMpOsQz05B80so4xGxdvrQ VYjLJEiMPMVUjbpSZ+eYAxm5IvIhN5g/TG9gShl2AYfjFbdJ7GCwwoMsl3eW81Tws32X c8KoAA5J7JQ/hDxKnpATMAbFDDLNaLp9lGXAo08yrGunK/sGebCQpgxqwKoCouCMxoCd vMLw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=FDqZpDQU; 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 c30si29357522ejj.396.2021.11.22.12.54.43; Mon, 22 Nov 2021 12:54:44 -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=FDqZpDQU; 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 0BB4568A44C; Mon, 22 Nov 2021 22:53:49 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-il1-f171.google.com (mail-il1-f171.google.com [209.85.166.171]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4BAE568A619 for ; Mon, 22 Nov 2021 22:53:44 +0200 (EET) Received: by mail-il1-f171.google.com with SMTP id k1so19479623ilo.7 for ; Mon, 22 Nov 2021 12:53:44 -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=xN60GqDTodIomXLEr+wKZl0AiCIavHsu5iL1Gt5PXSM=; b=FDqZpDQUnHwIHocNBQNlF0XOETYX17E/nG7ate32E/V2hENlQsvM4qDcpjcyc0PLSr FlnUvhBjFoBYGLSMyTeFbDiB6MfUfF+Mxr/i8WF4fqQJpfdWyBNECD5c3iv1H9WOlJ3S TLKUA5YDmgSh+ql7HKV+AvKUXCyclrLJHhQ9tIwz50TBnxVGw4eJlc4sbOD4qSq4sABv KMRsMms5G3830XBT0n+Je02JfsnIVinw3UPuDlT9BcTvpXmajhZAyhYPnYn97Ciuccbj RiXmOia/UoxnPZ69k7sf9xqhUiSae30HCNzcFU/InVaR+Fi8JwHFgcJ7dQPyAABJZV8z jdAg== 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=xN60GqDTodIomXLEr+wKZl0AiCIavHsu5iL1Gt5PXSM=; b=I3nmSKkyNBrlajBSdre/6CtB9lNHW01BsZpCv8HzC8TxoQ/BU/0LzDWFb0zpeb9KXc k4JOAfwMzSCfHg65SsBpaU0CrTrn2cCMIDql9tXTzHnxXJ295Hb45WPycMlmBUuqYagq METAKviGOcRbYbvQsgTvI6iFM5rt2uQjOgCwkJfhNxqY3X8fSb1TWynleqICctRW9tvp gLF1Wwl1Q/Fh2/AvnX1qKKNVjWI+OR9Ce9SrkFX1qyICn0JPJgdt0bxDGjhK/wsflUNk 12kYSq5Ms5N4Lijtlwnw5knR5ArbZeZz51qqqm46Xv5NBDoQ6j+kF6yPUl8kM/8bvNJ+ eeXA== X-Gm-Message-State: AOAM533XgxS172d3J61LhPkggqlOMsshgf1vj1PxwKWdmM+sQha6S7Ac j3+RnQQ/DyHL2q6lm1aAVQLI29OjF70rBGo= X-Received: by 2002:a05:6e02:12ed:: with SMTP id l13mr13235840iln.165.1637614422709; Mon, 22 Nov 2021 12:53:42 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id b3sm3571580ile.26.2021.11.22.12.53.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 12:53:41 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 14:53:25 -0600 Message-Id: <20211122205330.43546-11-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122205330.43546-1-rcombs@rcombs.me> References: <20211122205330.43546-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 11/16] lavc/videotoolbox: call VTRegisterSupplementalVideoDecoderIfAvailable 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: mxxGAdivzPrb This is required for VP9 to work. --- libavcodec/videotoolbox.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index 3022cd1cbf..a11d494915 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -32,6 +32,7 @@ #include "h264dec.h" #include "hevcdec.h" #include "mpegvideo.h" +#include #include #ifndef kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder @@ -866,6 +867,12 @@ static int videotoolbox_start(AVCodecContext *avctx) break; } +#ifdef __MAC_10_11 + if (__builtin_available(macOS 10.11, *)) { + VTRegisterSupplementalVideoDecoderIfAvailable(videotoolbox->cm_codec_type); + } +#endif + decoder_spec = videotoolbox_decoder_config_create(videotoolbox->cm_codec_type, avctx); if (!decoder_spec) { From patchwork Mon Nov 22 20:53:26 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31539 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7583772iob; Mon, 22 Nov 2021 12:55:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJzhsNB48kqH+TdtT9v3ae76Fv8hYkGjFXE/VAtU7VaA7Dd7zRhh5oU/Wm1qw7sjLcC3jx4P X-Received: by 2002:a17:907:720b:: with SMTP id dr11mr105032ejc.93.1637614505696; Mon, 22 Nov 2021 12:55:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637614505; cv=none; d=google.com; s=arc-20160816; b=vJlmqU2kP0BLx9FZqFxakBT7kuH22N5bSOLFVpIOroa9dPb7HvXU8Cyto2VR5KMJHK Gvymh6Ok9su3ssNI0HYXVJ8vh4XNqDXEjkxW4lHeBowm4pN9IAJgdJ+cCbHhr0KSi96X phg+Yx6vsQx2Ly+jphVqbbrVOmbdh4tcR/STcuXlw74s4WNwIQFAoyQZEj3XGudH6yEl ZF7tdsgWNC4Iby3vreHwf8vKGkERsS/bUWqnXigO9wa8iebXQX3gW8mJJGnzml94VYvY DXO+34B24+8QZN7nOOENq8b35Onypkgu7hraXsQ1mdih299nzDV/ASM1qODaTxeK6CV0 z8pQ== 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=eZ0qzurqRe37Owxk4Ow8IVlTgPWA+WCJXGZp+DhF6+w=; b=xeIM0Z/3KLNrjjxlwQ3LagWQ1fs4290+nWnNXLbEP3wBnO6LeJca68Z0UaoUumJpMI cIbWhy5Rh0i//k8QYegusqDlSRIP9KVeOp0SmfadktVLn7blHTWv/kqyfIh82lqzDk/T 91qvvJbwpqsAoHQY9uffkE1JOqnoV4P5PlZe+lF4HC9S1of1Ysc6Os3Hwet2ErN8R9Ow 22GLszyuOSH8Vj8xyno/+iaw+L6/fXRJQNETpXhVGexJ5JKCPKBfuKCH8ULAlepp68R/ 3W+4YCiN3EW5I/0HOuu26KWJAoJjTGbp55rBNhDuiwL2/nheQj/IEurD7mBwQfdWDC34 oZSQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=Xp0YSySb; 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 j8si21364206edr.47.2021.11.22.12.55.05; Mon, 22 Nov 2021 12:55:05 -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=Xp0YSySb; 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 296C168AA67; Mon, 22 Nov 2021 22:53:51 +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 917E768A44C for ; Mon, 22 Nov 2021 22:53:45 +0200 (EET) Received: by mail-il1-f176.google.com with SMTP id x9so19458788ilu.6 for ; Mon, 22 Nov 2021 12:53:45 -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=S4tY74O1rWCxl5cTsOhSoStbjporJFcND2PPBXSAWto=; b=Xp0YSySbkSUxLV/HZ4VkLkp7K53NmSNQW1F5FyVVh33Rh/QKcOGmVux9z/P4H1mdlL YesV0BkjSKVxh6CTDVDlPpzHWlPQGRD/1uV7OPCidrM8lpnaqQTZSR6m6tgrIXUIergY IqmU2OXc5QZPNbQo4wye/lEo6j7Zr/rzey90FE6Zo2E5RrvnYyRi6wZeZbK5rGdmrBBR c3hR5qgu6RQH/3DmEnbjDIDh92uAVCG1XegGIKun7ut1/losDs6f73+Bv2INqHMqTGI8 X0tQXQk4GYKogtgbrefnSXbtQjwEt0cWVET8JDVQpDDCz7uGpC9ZB9wYt6AWzUzliHVp S/VA== 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=S4tY74O1rWCxl5cTsOhSoStbjporJFcND2PPBXSAWto=; b=iNbLUKUp/7iqaQz9Em0+hYSVw3oeMQUx4plSIqeO329KQWq+Iz6U+iqLayyVDutb62 ONmG2/mXOiZ7j4gOrIJYRTks6vKjOSnoSuntu/P1h68WnbpKDoUdr2kFmcsw/AC9uM9B p4S87PM3r+o159fFwkqFSdzryUX8sSl5B7p5DZs5oOOiy7a1+Z+haMCNefc6ErGtsh22 1yK4QgrFS8HMhhthWNhUMFnlDq71UTUCJESx7hegTzXpsQwuTAKEUf2WsnnSYlJx99Fn Mitlc/f9QunmlmEw6+u/k5G++N94MVwASVq22xnlN3JGaeCe8047aOK/RYD6dmBmiJKX MGNg== X-Gm-Message-State: AOAM531xe/w2Tczk0LQ939sZlq3Afo1P2t6BrBoY+BgR5n8cKukkqbck C9tA6MohjUmqrU5ORDRDRgxSJ0eRpubMan0= X-Received: by 2002:a05:6e02:1c2b:: with SMTP id m11mr24258090ilh.303.1637614423802; Mon, 22 Nov 2021 12:53:43 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id b3sm3571580ile.26.2021.11.22.12.53.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 12:53:43 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 14:53:26 -0600 Message-Id: <20211122205330.43546-12-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122205330.43546-1-rcombs@rcombs.me> References: <20211122205330.43546-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 12/16] lavc/videotoolbox: add VP9 hardware acceleration 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: eGQX0NZg2BDC On M1 Max, this supports profiles 0 and 2, but not 1 and 3. --- Changelog | 1 + configure | 4 + libavcodec/Makefile | 1 + libavcodec/hwaccels.h | 1 + libavcodec/videotoolbox.c | 17 ++++- libavcodec/videotoolbox_vp9.c | 140 ++++++++++++++++++++++++++++++++++ libavcodec/vp9.c | 9 ++- libavcodec/vt_internal.h | 1 + 8 files changed, 171 insertions(+), 3 deletions(-) create mode 100644 libavcodec/videotoolbox_vp9.c diff --git a/Changelog b/Changelog index 31a0d5ef5d..d6be6bbe4f 100644 --- a/Changelog +++ b/Changelog @@ -31,6 +31,7 @@ version : - varblur video filter - huesaturation video filter - colorspectrum source video filter +- VideoToolbox VP9 hwaccel version 4.4: diff --git a/configure b/configure index cc79b5b793..262261b544 100755 --- a/configure +++ b/configure @@ -2328,6 +2328,7 @@ TOOLCHAIN_FEATURES=" TYPES_LIST=" kCMVideoCodecType_HEVC kCMVideoCodecType_HEVCWithAlpha + kCMVideoCodecType_VP9 kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange kCVPixelFormatType_422YpCbCr8BiPlanarVideoRange kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange @@ -3083,6 +3084,8 @@ vp9_vaapi_hwaccel_deps="vaapi VADecPictureParameterBufferVP9_bit_depth" vp9_vaapi_hwaccel_select="vp9_decoder" vp9_vdpau_hwaccel_deps="vdpau VdpPictureInfoVP9" vp9_vdpau_hwaccel_select="vp9_decoder" +vp9_videotoolbox_hwaccel_deps="videotoolbox" +vp9_videotoolbox_hwaccel_select="vp9_decoder" wmv3_d3d11va_hwaccel_select="vc1_d3d11va_hwaccel" wmv3_d3d11va2_hwaccel_select="vc1_d3d11va2_hwaccel" wmv3_dxva2_hwaccel_select="vc1_dxva2_hwaccel" @@ -6287,6 +6290,7 @@ enabled videotoolbox && { check_lib coreservices CoreServices/CoreServices.h UTGetOSTypeFromString "-framework CoreServices" check_func_headers CoreMedia/CMFormatDescription.h kCMVideoCodecType_HEVC "-framework CoreMedia" check_func_headers CoreMedia/CMFormatDescription.h kCMVideoCodecType_HEVCWithAlpha "-framework CoreMedia" + check_func_headers CoreMedia/CMFormatDescription.h kCMVideoCodecType_VP9 "-framework CoreMedia" check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange "-framework CoreVideo" check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_422YpCbCr8BiPlanarVideoRange "-framework CoreVideo" check_func_headers CoreVideo/CVPixelBuffer.h kCVPixelFormatType_422YpCbCr10BiPlanarVideoRange "-framework CoreVideo" diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 14fbd2ecbc..32b35ebe75 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -975,6 +975,7 @@ OBJS-$(CONFIG_VP9_DXVA2_HWACCEL) += dxva2_vp9.o OBJS-$(CONFIG_VP9_NVDEC_HWACCEL) += nvdec_vp9.o OBJS-$(CONFIG_VP9_VAAPI_HWACCEL) += vaapi_vp9.o OBJS-$(CONFIG_VP9_VDPAU_HWACCEL) += vdpau_vp9.o +OBJS-$(CONFIG_VP9_VIDEOTOOLBOX_HWACCEL) += videotoolbox_vp9.o OBJS-$(CONFIG_VP8_QSV_HWACCEL) += qsvdec.o # libavformat dependencies diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h index 8e54cf73f9..65e778f3e4 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h @@ -74,6 +74,7 @@ extern const AVHWAccel ff_vp9_dxva2_hwaccel; extern const AVHWAccel ff_vp9_nvdec_hwaccel; extern const AVHWAccel ff_vp9_vaapi_hwaccel; extern const AVHWAccel ff_vp9_vdpau_hwaccel; +extern const AVHWAccel ff_vp9_videotoolbox_hwaccel; extern const AVHWAccel ff_wmv3_d3d11va_hwaccel; extern const AVHWAccel ff_wmv3_d3d11va2_hwaccel; extern const AVHWAccel ff_wmv3_dxva2_hwaccel; diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index a11d494915..5f08488a6b 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -33,6 +33,7 @@ #include "hevcdec.h" #include "mpegvideo.h" #include +#include #include #ifndef kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder @@ -46,6 +47,10 @@ enum { kCMVideoCodecType_HEVC = 'hvc1' }; #endif +#if !HAVE_KCMVIDEOCODECTYPE_VP9 +enum { kCMVideoCodecType_VP9 = 'vp09' }; +#endif + #define VIDEOTOOLBOX_ESDS_EXTRADATA_PADDING 12 typedef struct VTHWFrame { @@ -816,6 +821,11 @@ static CFDictionaryRef videotoolbox_decoder_config_create(CMVideoCodecType codec if (data) CFDictionarySetValue(avc_info, CFSTR("hvcC"), data); break; + case kCMVideoCodecType_VP9 : + data = ff_videotoolbox_vpcc_extradata_create(avctx); + if (data) + CFDictionarySetValue(avc_info, CFSTR("vpcC"), data); + break; default: break; } @@ -863,12 +873,15 @@ static int videotoolbox_start(AVCodecContext *avctx) case AV_CODEC_ID_MPEG4 : videotoolbox->cm_codec_type = kCMVideoCodecType_MPEG4Video; break; + case AV_CODEC_ID_VP9 : + videotoolbox->cm_codec_type = kCMVideoCodecType_VP9; + break; default : break; } -#ifdef __MAC_10_11 - if (__builtin_available(macOS 10.11, *)) { +#if defined(MAC_OS_VERSION_11_0) && !TARGET_OS_IPHONE && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0) + if (__builtin_available(macOS 11.0, *)) { VTRegisterSupplementalVideoDecoderIfAvailable(videotoolbox->cm_codec_type); } #endif diff --git a/libavcodec/videotoolbox_vp9.c b/libavcodec/videotoolbox_vp9.c new file mode 100644 index 0000000000..1b6d08f00b --- /dev/null +++ b/libavcodec/videotoolbox_vp9.c @@ -0,0 +1,140 @@ +/* + * Videotoolbox hardware acceleration for VP9 + * + * copyright (c) 2021 rcombs + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "config.h" +#include "videotoolbox.h" +#include "libavutil/hwcontext_videotoolbox.h" +#include "vt_internal.h" +#include "libavutil/avutil.h" +#include "libavutil/frame.h" +#include "libavutil/hwcontext.h" +#include "libavutil/intreadwrite.h" +#include "libavutil/pixdesc.h" +#include "decode.h" +#include "internal.h" +#include "vp9shared.h" + +enum VPX_CHROMA_SUBSAMPLING +{ + VPX_SUBSAMPLING_420_VERTICAL = 0, + VPX_SUBSAMPLING_420_COLLOCATED_WITH_LUMA = 1, + VPX_SUBSAMPLING_422 = 2, + VPX_SUBSAMPLING_444 = 3, +}; + +static int get_vpx_chroma_subsampling(enum AVPixelFormat pixel_format, + enum AVChromaLocation chroma_location) +{ + int chroma_w, chroma_h; + if (av_pix_fmt_get_chroma_sub_sample(pixel_format, &chroma_w, &chroma_h) == 0) { + if (chroma_w == 1 && chroma_h == 1) { + return (chroma_location == AVCHROMA_LOC_LEFT) + ? VPX_SUBSAMPLING_420_VERTICAL + : VPX_SUBSAMPLING_420_COLLOCATED_WITH_LUMA; + } else if (chroma_w == 1 && chroma_h == 0) { + return VPX_SUBSAMPLING_422; + } else if (chroma_w == 0 && chroma_h == 0) { + return VPX_SUBSAMPLING_444; + } + } + return -1; +} + +CFDataRef ff_videotoolbox_vpcc_extradata_create(AVCodecContext *avctx) +{ + const VP9SharedContext *h = avctx->priv_data; + CFDataRef data = NULL; + uint8_t *p; + int vt_extradata_size; + uint8_t *vt_extradata; + int subsampling = get_vpx_chroma_subsampling(avctx->sw_pix_fmt, avctx->chroma_sample_location); + + vt_extradata_size = 1 + 3 + 6 + 2; + vt_extradata = av_malloc(vt_extradata_size); + + if (subsampling < 0) + return NULL; + + if (!vt_extradata) + return NULL; + + p = vt_extradata; + + *p++ = 1; /* version */ + AV_WB24(p + 1, 0); /* flags */ + p += 3; + + *p++ = h->h.profile; + *p++ = avctx->level; + *p++ = (h->h.bpp << 4) | (subsampling << 1) | (avctx->color_range == AVCOL_RANGE_JPEG); + *p++ = avctx->color_primaries; + *p++ = avctx->color_trc; + *p++ = avctx->colorspace; + + AV_WB16(p + 0, 0); + p += 2; + + av_assert0(p - vt_extradata == vt_extradata_size); + + data = CFDataCreate(kCFAllocatorDefault, vt_extradata, vt_extradata_size); + av_free(vt_extradata); + return data; +} + +static int videotoolbox_vp9_start_frame(AVCodecContext *avctx, + const uint8_t *buffer, + uint32_t size) +{ + return 0; +} + +static int videotoolbox_vp9_decode_slice(AVCodecContext *avctx, + const uint8_t *buffer, + uint32_t size) +{ + VTContext *vtctx = avctx->internal->hwaccel_priv_data; + + return ff_videotoolbox_buffer_copy(vtctx, buffer, size); +} + +static int videotoolbox_vp9_end_frame(AVCodecContext *avctx) +{ + const VP9SharedContext *h = avctx->priv_data; + AVFrame *frame = h->frames[CUR_FRAME].tf.f; + + return ff_videotoolbox_common_end_frame(avctx, frame); +} + +const AVHWAccel ff_vp9_videotoolbox_hwaccel = { + .name = "vp9_videotoolbox", + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_VP9, + .pix_fmt = AV_PIX_FMT_VIDEOTOOLBOX, + .alloc_frame = ff_videotoolbox_alloc_frame, + .start_frame = videotoolbox_vp9_start_frame, + .decode_slice = videotoolbox_vp9_decode_slice, + .end_frame = videotoolbox_vp9_end_frame, + .frame_params = ff_videotoolbox_frame_params, + .init = ff_videotoolbox_common_init, + .uninit = ff_videotoolbox_uninit, + .priv_data_size = sizeof(VTContext), +}; diff --git a/libavcodec/vp9.c b/libavcodec/vp9.c index 8317ac6bd8..24841c5b9f 100644 --- a/libavcodec/vp9.c +++ b/libavcodec/vp9.c @@ -181,7 +181,8 @@ static int update_size(AVCodecContext *avctx, int w, int h) CONFIG_VP9_D3D11VA_HWACCEL * 2 + \ CONFIG_VP9_NVDEC_HWACCEL + \ CONFIG_VP9_VAAPI_HWACCEL + \ - CONFIG_VP9_VDPAU_HWACCEL) + CONFIG_VP9_VDPAU_HWACCEL + \ + CONFIG_VP9_VIDEOTOOLBOX_HWACCEL) enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmtp = pix_fmts; VP9Context *s = avctx->priv_data; uint8_t *p; @@ -212,6 +213,9 @@ static int update_size(AVCodecContext *avctx, int w, int h) #endif #if CONFIG_VP9_VDPAU_HWACCEL *fmtp++ = AV_PIX_FMT_VDPAU; +#endif +#if CONFIG_VP9_VIDEOTOOLBOX_HWACCEL + *fmtp++ = AV_PIX_FMT_VIDEOTOOLBOX; #endif break; case AV_PIX_FMT_YUV420P12: @@ -1893,6 +1897,9 @@ const AVCodec ff_vp9_decoder = { #endif #if CONFIG_VP9_VDPAU_HWACCEL HWACCEL_VDPAU(vp9), +#endif +#if CONFIG_VP9_VIDEOTOOLBOX_HWACCEL + HWACCEL_VIDEOTOOLBOX(vp9), #endif NULL }, diff --git a/libavcodec/vt_internal.h b/libavcodec/vt_internal.h index e2f279d0fc..54a11fd1b5 100644 --- a/libavcodec/vt_internal.h +++ b/libavcodec/vt_internal.h @@ -64,5 +64,6 @@ int ff_videotoolbox_h264_decode_slice(AVCodecContext *avctx, int ff_videotoolbox_common_end_frame(AVCodecContext *avctx, AVFrame *frame); CFDataRef ff_videotoolbox_avcc_extradata_create(AVCodecContext *avctx); CFDataRef ff_videotoolbox_hvcc_extradata_create(AVCodecContext *avctx); +CFDataRef ff_videotoolbox_vpcc_extradata_create(AVCodecContext *avctx); #endif /* AVCODEC_VT_INTERNAL_H */ From patchwork Mon Nov 22 20:53:27 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31536 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7584432iob; Mon, 22 Nov 2021 12:55:42 -0800 (PST) X-Google-Smtp-Source: ABdhPJwl9r3sgj5Zl7inVNo/x8//N/InFfqjgjpotl71HoAt24+g528vANdYReIO8FyfaU/LayKp X-Received: by 2002:a17:906:974a:: with SMTP id o10mr177299ejy.226.1637614542179; Mon, 22 Nov 2021 12:55:42 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637614542; cv=none; d=google.com; s=arc-20160816; b=LB01Di5HWMGNG3ETEGw5iFigAAo5/IcC/SXxp0RpO1LkZWYK6moJde1Pd9aCESA8if rwM+do7v68+UFQiURMx7Ek3Ua3K55o7ABz3pCyN6I0wiALOqhDbEQW8HcsfimO+fwxBV gLtSHBiBDsS0Epg8QlJiCQBUV5zGcnvz7slwQnBfQFkfJL5y/CcC9ELvXJpJUldkGvg2 FMneRGnZNCs8BCkrGiS+OuNbmI6LlxAr7MdLzDzJmdIIdr9naOIihSr3QrShbY7/MFMY nhP8kJENVZ+UeXVDvGiHYvgm39kcTNwmUMm/eAk/PhLplraphxRnJYbt7Rpp16PX1Pfh JIrg== 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=2+twiCVMWYgcSbbAmDEG8r+j7vJXBzCfhxn8BLkWxqY=; b=y6IpYZ6tm34BvZc5WPUsQO1f2b72s99UN6Y2ULuKtSvwVRUWMqUNX0nsbMI3p4p7qw wHl+56JZQruvjSEyZr0N+AYnHCnIz+bWWiXarmHZ3LfVhkiX09Pvs7wrIbrAt7xjyGGs g89AqECOeUpfEfMgHOKSvRWmyUk1wwMn2OOslgxq0mi5eTcf9MGhweMvGuKB6rm02qNI KVdT/6CKEodLGy8w8rbapt26g2QI8YPV+qVtJKAqe/2hTGJTWDK3fDpTyuw0aGqVUG1E 0nUgWPmYpLpPETdBhdLeiEhwzCCRqzuy9Bk80T+F4kF7h8vzs68sRkrwyBn7hQMGQ+3J usAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=Ejrc1aW2; 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 gs42si29122137ejc.704.2021.11.22.12.55.41; Mon, 22 Nov 2021 12:55:42 -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=Ejrc1aW2; 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 1A08768ADBD; Mon, 22 Nov 2021 22:53:54 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-il1-f177.google.com (mail-il1-f177.google.com [209.85.166.177]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EEB5D68A958 for ; Mon, 22 Nov 2021 22:53:46 +0200 (EET) Received: by mail-il1-f177.google.com with SMTP id h23so19469374ila.4 for ; Mon, 22 Nov 2021 12:53:46 -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=E25XfZk/aICizzjL0V5qNgzhaRSzJjV1KMphiW2eKVE=; b=Ejrc1aW2pmeTYC07hzMohaX9lHDvcHqPtj80MZmywjgNl9YxmiEPKxDvbR1oaEo4pm H+4u+DNs7nc6I1ShSPoSW3rpbhinubcy6ddFmQn4RNK6/CMmKZg2f3dFuloTknSUIkDH wmEQRpvVgLd/DCsn/gAjzn6Dj4RZTJijz+mEF0rBW87AfddA8VmffIP6thyqNmKb3173 EgUDylJTB0tO92BlBRWgGPgPXvtbtfHEDg9ZakySq40aLtUuzuoskWs2HyDnhRQp3eCw rZpsvIXNPYNeBpsIcr2/91C12f/l8StwxDRDtJL8ff70M+k6POXQ9hqR6+m2+Mssupwp K+Qg== 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=E25XfZk/aICizzjL0V5qNgzhaRSzJjV1KMphiW2eKVE=; b=nII6RcdC0pyMY/IvWxk+AUeO6gNN0Sv+ErBIlfMNTOhjive+BgoIQEjhLoMCrw6Bfq 9FR1iv00NuWh7Nq0CzFK4oKUvAszL+nBct2SsntbVAOPcZevDvbsPApbaCzx04PMnTXI wOKTCIK7zmxPuESxXHHS6ai1rBkEICsx+jTcC61ZTgNKPOlr+TIvvvQv6IMhnP/apN8H KW3Wq+lWK51VxpnmJa1Lx0tEZhDsIo/F5M/KEXTUb4s1MaLxzvyKp59prMHpH8KMMFcn Fv9vpBYPz/mwK0w9CZ/nqCr9c9i3JENoaARqB6DiNoal4skFVcdXKmrr/xvaxevifH6o nEHQ== X-Gm-Message-State: AOAM530K3RQdGwzixTrIVgdm5d75A0DVcscqYO86y/1ca5dFI5UFMuHg qrzQkUtlgtfKUs6vOj/fKt0Oql/llhWK10I= X-Received: by 2002:a05:6e02:1a2c:: with SMTP id g12mr14801962ile.22.1637614424861; Mon, 22 Nov 2021 12:53:44 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id b3sm3571580ile.26.2021.11.22.12.53.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 12:53:44 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 14:53:27 -0600 Message-Id: <20211122205330.43546-13-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122205330.43546-1-rcombs@rcombs.me> References: <20211122205330.43546-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 13/16] videotoolbox: add alpha 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: 9mpmMnzDf0QG --- libavcodec/videotoolbox.c | 3 +++ libavutil/hwcontext_videotoolbox.c | 2 ++ 2 files changed, 5 insertions(+) diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index 5f08488a6b..542fe9316a 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -1075,6 +1075,9 @@ static enum AVPixelFormat videotoolbox_best_pixel_format(AVCodecContext *avctx) int depth = descriptor->comp[0].depth; + if (descriptor->flags & AV_PIX_FMT_FLAG_ALPHA) + return AV_PIX_FMT_AYUV64; + #if HAVE_KCVPIXELFORMATTYPE_444YPCBCR16BIPLANARVIDEORANGE if (depth > 10) return descriptor->log2_chroma_w == 0 ? AV_PIX_FMT_P416 : AV_PIX_FMT_P216; diff --git a/libavutil/hwcontext_videotoolbox.c b/libavutil/hwcontext_videotoolbox.c index f7a1299cc3..e9567bbf44 100644 --- a/libavutil/hwcontext_videotoolbox.c +++ b/libavutil/hwcontext_videotoolbox.c @@ -48,6 +48,7 @@ static const struct { #ifdef kCFCoreFoundationVersionNumber10_7 { kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange, false, AV_PIX_FMT_NV12 }, { kCVPixelFormatType_420YpCbCr8BiPlanarFullRange, true, AV_PIX_FMT_NV12 }, + { kCVPixelFormatType_4444AYpCbCr16, false, AV_PIX_FMT_AYUV64 }, #endif #if HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE { kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange, false, AV_PIX_FMT_P010 }, @@ -80,6 +81,7 @@ static const struct { static const enum AVPixelFormat supported_formats[] = { #ifdef kCFCoreFoundationVersionNumber10_7 AV_PIX_FMT_NV12, + AV_PIX_FMT_AYUV64, #endif AV_PIX_FMT_YUV420P, AV_PIX_FMT_UYVY422, From patchwork Mon Nov 22 20:53:28 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31541 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7584924iob; Mon, 22 Nov 2021 12:56:06 -0800 (PST) X-Google-Smtp-Source: ABdhPJwnqol4XRlUUFPJCouSM7qY4LySaUfHRIL0+VgH3ytUPCclK5EbfXshW+iwxERKMNL/dYFH X-Received: by 2002:a17:906:fcba:: with SMTP id qw26mr146589ejb.448.1637614566250; Mon, 22 Nov 2021 12:56:06 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637614566; cv=none; d=google.com; s=arc-20160816; b=AwkmUKXS8R/R4e2MzxzRVzDe0CKWeO+ziuHFi1VlPdSmnZdPtCDtB1XQn82U1n+NBs Ukh3C6UAaC2jaYdP6OcNI3y4g5o/lir2AQ/aPzqzxXYS0eoJzHkP26ReLcOIrPYshp6A WxW/LF7M+CbeLgWjgTwQYvIFVhe2vDYaIorVUxFXtxq2slhfY0ltxBWoFUZrlGG789VC 2UiMendBopt/TYl9xK3q/B06uKBwErq05Sdi3IlvUcN/+uJT4PZYVuQdbLrRxOEf/xU0 WaR3oEJqntNPMTasEA57GkvemNwHMIY6ckX/l0OYY0IdG28ju12DuB00B4z8jEcZPf/Z 32Og== 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=pEgnrnkKFRlF1NlpJGDuKRViWF0rIzbrbZElJrPDbWk=; b=KIKC4iBBfvvd14X8eDTrYYGdL6e+NsLg/BCUhDFlxuFUeNjX0dTN26xT6aP1pckws/ KkmkClzgbfLFVxghbdYKHeaMafEwsUwl3oPveHg8AvWbUtNudY5mcadmdFKfeBFoeTvU oUYBJme11qxFeq7eqH+SzNCb4RpxBira8/d76AUX1Oi6V/16I33eAwVp21I39gFNX2T0 JKBtneajGB+nEhK2vIwhQV0uE+4NexhU7Irs3n7bdO8YHPpn1PLEtFy4IrF6Mm+DPhB6 HeANcm4Iik7O6HfLYIZM7QkGSSYXuH/oGx7eUi9sx/zhmy6wtvRFvwwRQzCWseEL4LWH yv2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=EWu+tJKg; 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 l10si29910101ejo.308.2021.11.22.12.56.05; Mon, 22 Nov 2021 12:56:06 -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=EWu+tJKg; 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 18FE968A8EE; Mon, 22 Nov 2021 22:53:56 +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 8FF3068AA67 for ; Mon, 22 Nov 2021 22:53:47 +0200 (EET) Received: by mail-io1-f52.google.com with SMTP id f9so24953403ioo.11 for ; Mon, 22 Nov 2021 12:53:47 -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=zz+HQHPSZK+EjF/L2hCcqBg66cCuZTNzMLSYw+djs8Y=; b=EWu+tJKgwS8YM4E2GzZVQO7VrmHiOY6gzAfxyVM1QhWBWVih1n1pZ8FJuAvTJ5nssI 1lQceMd3+1qLkT+1URmUt4ezLxWR3fOdelHlUnuKVztt53az23x9QaKLVb4eA+K1bVmb ZmqoGjun4HN5n5N9MdG3ADupSpJTIdkhhm5BXHU29o1Rya8VroCl5xSF/HfqPFI21bZW WK7FLcmdMldOuf45JSIr9kiEfJrc8nyL+h+RHUXnoy3ppMFFTei5nJqJqse2JYBcgMHl wb0mYQTAZhVKW45PmEeQ7fNsq2/Pl4iW/5E96NYUqU6r2QCD66HorWWeTgqNnsK1XCXM j/fQ== 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=zz+HQHPSZK+EjF/L2hCcqBg66cCuZTNzMLSYw+djs8Y=; b=Ugkt1LB4KcCishru6rTedq/UC0GxcApPyOl4VsCU3WGrDetkVd2gUGgt52Z8AARUp4 NbRbg4pBRra4wNCrB2ZYyGg/JW8fsUL58hn+R+Gtsj4Y/YJ09J3Mahps037zocQpOViI xKMLPlitsvxzjUBRnDIMC/j3nhot456EdKDBm9ORnmOn/oh/109aC0qn4BxQqWrWug5E 0hhlsPLvLMlie4Q8+0P4vi0G/usuXcE1jZIKc+jkkWdE3KbipXBcDsjnPwvhAE7P1H9v hFOUVvmUdbnpiuIdZlrr+HuKh2wK0+0DMe7+w7oe10PkWmn/sBJ15yCG+zhULkqpBLUb s/EA== X-Gm-Message-State: AOAM532LygK6AVIq9yIYC9O1F7DBJ+Hob4Vrc/IiP1PmYT1PanIthIlM +RiW2NsAKvjTO3AwwMe1hco58sueRa60hxE= X-Received: by 2002:a05:6602:2c07:: with SMTP id w7mr25595898iov.122.1637614425903; Mon, 22 Nov 2021 12:53:45 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id b3sm3571580ile.26.2021.11.22.12.53.44 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 12:53:45 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 14:53:28 -0600 Message-Id: <20211122205330.43546-14-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122205330.43546-1-rcombs@rcombs.me> References: <20211122205330.43546-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 14/16] lavc/proresdec: add scaffolding for hwdec 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: tC0lEUoXTBY/ --- libavcodec/proresdec.h | 1 + libavcodec/proresdec2.c | 48 ++++++++++++++++++++++++++++++++++------- 2 files changed, 41 insertions(+), 8 deletions(-) diff --git a/libavcodec/proresdec.h b/libavcodec/proresdec.h index 06e41dd09a..1e48752e6f 100644 --- a/libavcodec/proresdec.h +++ b/libavcodec/proresdec.h @@ -52,6 +52,7 @@ typedef struct { int first_field; int alpha_info; void (*unpack_alpha)(GetBitContext *gb, uint16_t *dst, int num_coeffs, const int num_bits); + enum AVPixelFormat pix_fmt; } ProresContext; #endif /* AVCODEC_PRORESDEC_H */ diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c index 7750620b22..5b1d7da693 100644 --- a/libavcodec/proresdec2.c +++ b/libavcodec/proresdec2.c @@ -187,6 +187,8 @@ static av_cold int decode_init(AVCodecContext *avctx) permute(ctx->progressive_scan, ff_prores_progressive_scan, idct_permutation); permute(ctx->interlaced_scan, ff_prores_interlaced_scan, idct_permutation); + ctx->pix_fmt = AV_PIX_FMT_NONE; + if (avctx->bits_per_raw_sample == 10){ ctx->unpack_alpha = unpack_alpha_10; } else if (avctx->bits_per_raw_sample == 12){ @@ -204,6 +206,7 @@ static int decode_frame_header(ProresContext *ctx, const uint8_t *buf, int hdr_size, width, height, flags; int version; const uint8_t *ptr; + enum AVPixelFormat pix_fmt; hdr_size = AV_RB16(buf); ff_dlog(avctx, "header size %d\n", hdr_size); @@ -252,18 +255,34 @@ static int decode_frame_header(ProresContext *ctx, const uint8_t *buf, if (ctx->alpha_info) { if (avctx->bits_per_raw_sample == 10) { - avctx->pix_fmt = (buf[12] & 0xC0) == 0xC0 ? AV_PIX_FMT_YUVA444P10 : AV_PIX_FMT_YUVA422P10; + pix_fmt = (buf[12] & 0xC0) == 0xC0 ? AV_PIX_FMT_YUVA444P10 : AV_PIX_FMT_YUVA422P10; } else { /* 12b */ - avctx->pix_fmt = (buf[12] & 0xC0) == 0xC0 ? AV_PIX_FMT_YUVA444P12 : AV_PIX_FMT_YUVA422P12; + pix_fmt = (buf[12] & 0xC0) == 0xC0 ? AV_PIX_FMT_YUVA444P12 : AV_PIX_FMT_YUVA422P12; } } else { if (avctx->bits_per_raw_sample == 10) { - avctx->pix_fmt = (buf[12] & 0xC0) == 0xC0 ? AV_PIX_FMT_YUV444P10 : AV_PIX_FMT_YUV422P10; + pix_fmt = (buf[12] & 0xC0) == 0xC0 ? AV_PIX_FMT_YUV444P10 : AV_PIX_FMT_YUV422P10; } else { /* 12b */ - avctx->pix_fmt = (buf[12] & 0xC0) == 0xC0 ? AV_PIX_FMT_YUV444P12 : AV_PIX_FMT_YUV422P12; + pix_fmt = (buf[12] & 0xC0) == 0xC0 ? AV_PIX_FMT_YUV444P12 : AV_PIX_FMT_YUV422P12; } } + if (pix_fmt != ctx->pix_fmt) { +#define HWACCEL_MAX 0 + enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmtp = pix_fmts; + int ret; + + ctx->pix_fmt = pix_fmt; + + *fmtp++ = ctx->pix_fmt; + *fmtp = AV_PIX_FMT_NONE; + + if ((ret = ff_thread_get_format(avctx, pix_fmts)) < 0) + return ret; + + avctx->pix_fmt = ret; + } + avctx->color_primaries = buf[14]; avctx->color_trc = buf[15]; avctx->colorspace = buf[16]; @@ -782,6 +801,22 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, buf += frame_hdr_size; buf_size -= frame_hdr_size; + if ((ret = ff_thread_get_buffer(avctx, &tframe, 0)) < 0) + return ret; + + if (avctx->hwaccel) { + ret = avctx->hwaccel->start_frame(avctx, NULL, 0); + if (ret < 0) + return ret; + ret = avctx->hwaccel->decode_slice(avctx, avpkt->data, avpkt->size); + if (ret < 0) + return ret; + ret = avctx->hwaccel->end_frame(avctx); + if (ret < 0) + return ret; + goto finish; + } + decode_picture: pic_size = decode_picture_header(avctx, buf, buf_size); if (pic_size < 0) { @@ -789,10 +824,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, return pic_size; } - if (ctx->first_field) - if ((ret = ff_thread_get_buffer(avctx, &tframe, 0)) < 0) - return ret; - if ((ret = decode_picture(avctx)) < 0) { av_log(avctx, AV_LOG_ERROR, "error decoding picture\n"); return ret; @@ -806,6 +837,7 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *got_frame, goto decode_picture; } +finish: *got_frame = 1; return avpkt->size; From patchwork Mon Nov 22 20:53:29 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31531 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7585319iob; Mon, 22 Nov 2021 12:56:28 -0800 (PST) X-Google-Smtp-Source: ABdhPJx8h1SxChZ6uzSFB/BPUOptoINfmQjQ5Tg1fsrvNrIANl9DzKSLWiqi5Zm9anwpTWYtABR3 X-Received: by 2002:a17:906:4e42:: with SMTP id g2mr182298ejw.230.1637614588024; Mon, 22 Nov 2021 12:56:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637614588; cv=none; d=google.com; s=arc-20160816; b=FyV/jQM9LEsMC/rLVm1CJDQKKOMSbU8Y5PzFWz+C7edq0Dhtu08RGnxP5h5m6ijhAC rE03VFMNGrrQDAYaK6iaUZEoz+wN6paiHlkurAQCk0D9qh5wCKwCED/ZUpq7rkmBRt9J K5OMSdoU8783o+zqNjCYzenRDCUIdurMRFSB5UXIQw++KJrPep79L3T+3W+llrxVXwBk 5wGC1778fu1pi9tD7wD4apP+KLTmnxdgfd96V22vwl4BZeoMSUjYL4zk+Af03naxuaOg HMmzUrkO8CNTUzigPasgZsP+zK2UtwdJfdht+kOJ/cvJQYluSkxuTYGfZ6t8fsZmjRxi aBwQ== 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=ovQWuGDSrk3bZIlBe0GvCfYgY03bZmq8V+NbuWomrhQ=; b=oQUeH9AHhzYKPUslnsM/1xFJcgNHL/UbYnhP9BiGCuBrvYWDGB0K2BUdhcFpG1bwW0 CJj4tvcrqvjMs2/6yOdBxzwyDbs5wHpmuv49Q30ul1k58P0LIT19FyKoJ/ZuKmBhaTFi nEcQF77LT5iuXb9K8ewcFyTExgwAFHBoAjTdpveKerYqlMLNsHFM5cqQa4X4euL8QynV Ju5mrPSoSmAm4LcaHwJzxp9k071nD9b4OcZnmSGrEWLTaCjpynS/eIJugAesG1G9HEZ2 sOKWO1Kk9KWnclKvYjFwyWP56xxZogu+i9ZcfugFcLPWFMNh4WMu5nOMtKSEg2m8o7Qd NqHA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=gnSRxcGK; 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 p14si23519344edi.622.2021.11.22.12.56.27; Mon, 22 Nov 2021 12:56:28 -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=gnSRxcGK; 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 1AA7868AE42; Mon, 22 Nov 2021 22:53:58 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-il1-f172.google.com (mail-il1-f172.google.com [209.85.166.172]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 771E568A755 for ; Mon, 22 Nov 2021 22:53:48 +0200 (EET) Received: by mail-il1-f172.google.com with SMTP id t8so9584056ilu.8 for ; Mon, 22 Nov 2021 12:53:48 -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=fu55E76kt4YRwjp34oQVtylB7Mnd5wNBLpEZClGcfpU=; b=gnSRxcGKF52/il0t9R+QXq/ly9TPcXDieEoOAJAzTI+QOam9PjbIVnJK+aypiX43aL k6jdBkOZWAznrnZxBQxa0pstL9rCSmLrN/Vi2UqqRQ5IzwQMtkaB8wV2iJGJ6CEqiebf f7v0G9+G8SPQiD0DiLQViH6QeIu/S7O0Gf7tEpgsq/WcZDAPav5GG0SKwjWKJRcJyedw 4hNsj8ZHc0UnD/CfZFTSuGJ2oHvv7B7z7h8jrC5zeH8uH4ZDS9rx92nuVqc+rpAPBi+4 7SbfNQeYj9FtTl9vBr93OsV2udydQKjZkR8mVUcCy82WgxmIpfovvtDjM+fT2+TYXz3s IaWw== 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=fu55E76kt4YRwjp34oQVtylB7Mnd5wNBLpEZClGcfpU=; b=hs2o+YZ5qD3kOFQD4nOxRbRH8cgqt4NUD+iHBKMeqRAVECVvI6J+Z97dtw39nr04TE OLTjgOtr/8DwaQuhHor5pLZzHJD7L+ijBnLzUvPBphqOzGwCfknW7hspvO7E1v/hB91e jL4/+KclrSAaFNn4WZv+3P68NTqh93LLL+qRniv/d3RdbxCZGONl6Hb0NToFsxgFkQo8 ESrKfdEZ9VNoejxrUQECaZBRrrVnPx2rvB+fjpUmxzKROZsP6Sbl243KOC+k7BQ+iJut 7FCwWS+KWmy6gg79m9Zgww1piiu8+Iyvgcjzm/gQ3JGKLnECf8bkeFCVld3yyX/+rly6 ZOgg== X-Gm-Message-State: AOAM533USr1vnNtk0rAmn/n6Tr9pem5yi1LKm/Cr1z0I2d8xzySXFSDQ QaBl0yiLkLfRUbWwIjn4hlh9YWh5kt+Og0w= X-Received: by 2002:a05:6e02:1e02:: with SMTP id g2mr22782534ila.290.1637614426733; Mon, 22 Nov 2021 12:53:46 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id b3sm3571580ile.26.2021.11.22.12.53.45 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 12:53:46 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 14:53:29 -0600 Message-Id: <20211122205330.43546-15-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122205330.43546-1-rcombs@rcombs.me> References: <20211122205330.43546-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 15/16] lavc/proresdec: add videotoolbox hwaccel 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: WtS+mOAE9qoQ --- Changelog | 1 + configure | 2 ++ libavcodec/hwaccels.h | 1 + libavcodec/proresdec2.c | 12 ++++++- libavcodec/videotoolbox.c | 74 ++++++++++++++++++++++++++++++++++++++- 5 files changed, 88 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index d6be6bbe4f..e80b3fd82d 100644 --- a/Changelog +++ b/Changelog @@ -32,6 +32,7 @@ version : - huesaturation video filter - colorspectrum source video filter - VideoToolbox VP9 hwaccel +- VideoToolbox ProRes hwaccel version 4.4: diff --git a/configure b/configure index 262261b544..599ced3df6 100755 --- a/configure +++ b/configure @@ -3056,6 +3056,8 @@ mpeg4_vdpau_hwaccel_deps="vdpau" mpeg4_vdpau_hwaccel_select="mpeg4_decoder" mpeg4_videotoolbox_hwaccel_deps="videotoolbox" mpeg4_videotoolbox_hwaccel_select="mpeg4_decoder" +prores_videotoolbox_hwaccel_deps="videotoolbox" +prores_videotoolbox_hwaccel_select="prores_decoder" vc1_d3d11va_hwaccel_deps="d3d11va" vc1_d3d11va_hwaccel_select="vc1_decoder" vc1_d3d11va2_hwaccel_deps="d3d11va" diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h index 65e778f3e4..1e7b464950 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h @@ -60,6 +60,7 @@ extern const AVHWAccel ff_mpeg4_nvdec_hwaccel; extern const AVHWAccel ff_mpeg4_vaapi_hwaccel; extern const AVHWAccel ff_mpeg4_vdpau_hwaccel; extern const AVHWAccel ff_mpeg4_videotoolbox_hwaccel; +extern const AVHWAccel ff_prores_videotoolbox_hwaccel; extern const AVHWAccel ff_vc1_d3d11va_hwaccel; extern const AVHWAccel ff_vc1_d3d11va2_hwaccel; extern const AVHWAccel ff_vc1_dxva2_hwaccel; diff --git a/libavcodec/proresdec2.c b/libavcodec/proresdec2.c index 5b1d7da693..719194f21e 100644 --- a/libavcodec/proresdec2.c +++ b/libavcodec/proresdec2.c @@ -33,6 +33,7 @@ #include "avcodec.h" #include "get_bits.h" +#include "hwconfig.h" #include "idctdsp.h" #include "internal.h" #include "profiles.h" @@ -268,12 +269,15 @@ static int decode_frame_header(ProresContext *ctx, const uint8_t *buf, } if (pix_fmt != ctx->pix_fmt) { -#define HWACCEL_MAX 0 +#define HWACCEL_MAX (CONFIG_PRORES_VIDEOTOOLBOX_HWACCEL) enum AVPixelFormat pix_fmts[HWACCEL_MAX + 2], *fmtp = pix_fmts; int ret; ctx->pix_fmt = pix_fmt; +#if CONFIG_PRORES_VIDEOTOOLBOX_HWACCEL + *fmtp++ = AV_PIX_FMT_VIDEOTOOLBOX; +#endif *fmtp++ = ctx->pix_fmt; *fmtp = AV_PIX_FMT_NONE; @@ -864,4 +868,10 @@ const AVCodec ff_prores_decoder = { .capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_SLICE_THREADS | AV_CODEC_CAP_FRAME_THREADS, .profiles = NULL_IF_CONFIG_SMALL(ff_prores_profiles), .caps_internal = FF_CODEC_CAP_INIT_THREADSAFE, + .hw_configs = (const AVCodecHWConfigInternal *const []) { +#if CONFIG_PRORES_VIDEOTOOLBOX_HWACCEL + HWACCEL_VIDEOTOOLBOX(prores), +#endif + NULL + }, }; diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index 542fe9316a..40d231acc1 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -32,6 +32,7 @@ #include "h264dec.h" #include "hevcdec.h" #include "mpegvideo.h" +#include "proresdec.h" #include #include #include @@ -186,7 +187,6 @@ CFDataRef ff_videotoolbox_avcc_extradata_create(AVCodecContext *avctx) int pps_size = escape_ps(NULL, h->ps.pps->data, h->ps.pps->data_size); int vt_extradata_size; uint8_t *vt_extradata; - int i; vt_extradata_size = 6 + 2 + sps_size + 3 + pps_size; vt_extradata = av_malloc(vt_extradata_size); @@ -873,6 +873,31 @@ static int videotoolbox_start(AVCodecContext *avctx) case AV_CODEC_ID_MPEG4 : videotoolbox->cm_codec_type = kCMVideoCodecType_MPEG4Video; break; + case AV_CODEC_ID_PRORES : + switch (avctx->codec_tag) { + case MKTAG('a','p','c','o'): + videotoolbox->cm_codec_type = kCMVideoCodecType_AppleProRes422Proxy; + break; + case MKTAG('a','p','c','s'): + videotoolbox->cm_codec_type = kCMVideoCodecType_AppleProRes422LT; + break; + case MKTAG('a','p','c','n'): + videotoolbox->cm_codec_type = kCMVideoCodecType_AppleProRes422; + break; + case MKTAG('a','p','c','h'): + videotoolbox->cm_codec_type = kCMVideoCodecType_AppleProRes422HQ; + break; + case MKTAG('a','p','4','h'): + videotoolbox->cm_codec_type = kCMVideoCodecType_AppleProRes4444; + break; + case MKTAG('a','p','4','x'): + videotoolbox->cm_codec_type = kCMVideoCodecType_AppleProRes4444XQ; + break; + default: + videotoolbox->cm_codec_type = avctx->codec_tag; + av_log(avctx, AV_LOG_WARNING, "Unknown prores profile %d\n", avctx->codec_tag); + } + break; case AV_CODEC_ID_VP9 : videotoolbox->cm_codec_type = kCMVideoCodecType_VP9; break; @@ -880,6 +905,14 @@ static int videotoolbox_start(AVCodecContext *avctx) break; } +#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, *)) { + VTRegisterProfessionalVideoWorkflowVideoDecoders(); + } + } +#endif + #if defined(MAC_OS_VERSION_11_0) && !TARGET_OS_IPHONE && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_VERSION_11_0) if (__builtin_available(macOS 11.0, *)) { VTRegisterSupplementalVideoDecoderIfAvailable(videotoolbox->cm_codec_type); @@ -1068,6 +1101,30 @@ static int videotoolbox_mpeg_end_frame(AVCodecContext *avctx) return ff_videotoolbox_common_end_frame(avctx, frame); } +static int videotoolbox_prores_start_frame(AVCodecContext *avctx, + const uint8_t *buffer, + uint32_t size) +{ + return 0; +} + +static int videotoolbox_prores_decode_slice(AVCodecContext *avctx, + const uint8_t *buffer, + uint32_t size) +{ + VTContext *vtctx = avctx->internal->hwaccel_priv_data; + + return ff_videotoolbox_buffer_copy(vtctx, buffer, size); +} + +static int videotoolbox_prores_end_frame(AVCodecContext *avctx) +{ + ProresContext *ctx = avctx->priv_data; + AVFrame *frame = ctx->frame; + + return ff_videotoolbox_common_end_frame(avctx, frame); +} + static enum AVPixelFormat videotoolbox_best_pixel_format(AVCodecContext *avctx) { const AVPixFmtDescriptor *descriptor = av_pix_fmt_desc_get(avctx->sw_pix_fmt); if (!descriptor) @@ -1291,6 +1348,21 @@ const AVHWAccel ff_mpeg4_videotoolbox_hwaccel = { .priv_data_size = sizeof(VTContext), }; +const AVHWAccel ff_prores_videotoolbox_hwaccel = { + .name = "prores_videotoolbox", + .type = AVMEDIA_TYPE_VIDEO, + .id = AV_CODEC_ID_PRORES, + .pix_fmt = AV_PIX_FMT_VIDEOTOOLBOX, + .alloc_frame = ff_videotoolbox_alloc_frame, + .start_frame = videotoolbox_prores_start_frame, + .decode_slice = videotoolbox_prores_decode_slice, + .end_frame = videotoolbox_prores_end_frame, + .frame_params = ff_videotoolbox_frame_params, + .init = ff_videotoolbox_common_init, + .uninit = ff_videotoolbox_uninit, + .priv_data_size = sizeof(VTContext), +}; + static AVVideotoolboxContext *av_videotoolbox_alloc_context_with_pix_fmt(enum AVPixelFormat pix_fmt, bool full_range) { From patchwork Mon Nov 22 20:53:30 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31537 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7585487iob; Mon, 22 Nov 2021 12:56:38 -0800 (PST) X-Google-Smtp-Source: ABdhPJzWMYM07oswMIobHLdBaCovoRcMsYpUQ+ouphPnTMby0RHtz3RL4+kq/QjffwiN1vqMUaQI X-Received: by 2002:a17:906:dbef:: with SMTP id yd15mr158196ejb.354.1637614598434; Mon, 22 Nov 2021 12:56:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637614598; cv=none; d=google.com; s=arc-20160816; b=H6dJ/+9N8FZUQ8UNIwICwI0ByDRCYH7EQvFrT8tfl02zZmXs2wY5DJV/fZMtUVZmnL +mjMVz76BJxia3ZIVoWJBk/tN5zgHy0rDloyXReH+dETEcSHUZzxLzQZCRnQz5NzqMnM AzgellVhkny37C5AD6+pe6Fzi4el1fA3y9LShOOlap4hDcl8c4Evkm3bOI5j3uKTqao7 IFofEA1U+IEz/bFVqNgJLY019lqy7OR0MfrViQlywqAo18t+8ybGrh5l5hMO1zmPUvX9 nW2A2dg6SsRTysaeSyNa1XcxO5h+FAQhMpbu50NAWmmOcSKaRDeFGb1Fmvo17E1IJB3p j12g== 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=YqvvewSgKy54J+1pCeWfeiehg5Oo0wFVUEEI8Pd6iCo=; b=p7GP53eWZIQhwZMbdPgh20hYV3JisPDn51JvUceNLN9N29oZKVpaZ+BxqtnM/CUFZr nkDtX85m9RtOl4roR7THSS3LpSsnWzfqKqcVbobEQm2c/bXlaDxk4QGG0lrEV+cO/Ctw Zed6K14SNweaZECPYYAFZGwcCDMZ3vm5PfBdr5sCLpl5U5Ppb5U2mMcsGyfVbmX6ctAA 7Wb0ybBo7QWv8pmhKesXTmxnmr/Q4zYHq2TJLhk7H19E1tK4x3UABeqzB0h81NuMSmb+ nS6tTkV4suMIijrDJ6cKBOLr3K5HOXb0qrSCZ/5gKvPCLQT/xUBrjyG2MzknmuZKmia2 YqWA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=PU09RAZD; 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 dn4si29522176ejc.641.2021.11.22.12.56.38; Mon, 22 Nov 2021 12:56:38 -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=PU09RAZD; 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 3308868AB50; Mon, 22 Nov 2021 22:53:59 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-il1-f170.google.com (mail-il1-f170.google.com [209.85.166.170]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4099768AC14 for ; Mon, 22 Nov 2021 22:53:49 +0200 (EET) Received: by mail-il1-f170.google.com with SMTP id e8so19491383ilu.9 for ; Mon, 22 Nov 2021 12:53:49 -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=NAxq2hPqc9TaWGwvUQRFri1BLWwUNluwDg77I8VDTjs=; b=PU09RAZDzbfLFuw2tlqSXP05hS5835Eo8EtrnEuQMn8alN4z9D8PTViGdtdRehZldL 03JvpIJeMwVh7yXfirv/zJ/w4EuDQHSuJYTLqH+mtopmS0PuD3Tq4L0Y8Ql0/vo+9oZS Xqq0x4T26p8vZP68sHbKTXwkstSWF3wNLH8HqZv0yBofmxq7SDz5l2Yhq5o4TTxmcmCg QIQ+HUQYTcxvCPiCxhzqbmwcrUmHDC0R85aqXiNZ4MB7hK5+KI+RYEq63QIMmxCR3y9G L2H5qVmdsp3ArnojHQUdPWvJ4/E2Z+/Ziq6j9YgSC84xFnr1lFZCEFN5G1Jz3HpJdOjs mvCg== 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=NAxq2hPqc9TaWGwvUQRFri1BLWwUNluwDg77I8VDTjs=; b=3oeJ+hidCpftEWKzsKhPZnQMr+3ipptjMVb0wW8ccjEoRX30d6T/5GaVLPsPpvI0LY n+QASZJWGRbch+WwOC+odsz+nT91Il/o50L+OvN3VRaQRJVbycOXKeLpGdh2nu/ue5WQ ybq4/RF6IJWl6487dsVVyv1kGwUo4NhBAKsjsGwDGJqihH3ZlHwjJ513XjDMbsb01C++ dzqeQd/+SIO9ayFgnDebRgGn4AoQfrb7qsolhwebiLIBYo2wpQyti+J3mAvS/gtNs5Wn 6kb0f5FgT1LZ6UH+C4PWSYeFoNiHAfN8yKZXHhT/3hZaAb8kTL8nIrfzbJCuzErG34+X v72w== X-Gm-Message-State: AOAM5338aL2Hr7y+rMd1jS8D3s6we2Vv1MKyzWlTH449Oa3uEjnatjF8 +NzjDAAvLJ7zDNy1XDoo2odhQPqwFJ09RsA= X-Received: by 2002:a05:6e02:1c4a:: with SMTP id d10mr22273227ilg.157.1637614428229; Mon, 22 Nov 2021 12:53:48 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id b3sm3571580ile.26.2021.11.22.12.53.46 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 12:53:47 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 14:53:30 -0600 Message-Id: <20211122205330.43546-16-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122205330.43546-1-rcombs@rcombs.me> References: <20211122205330.43546-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 16/16] lavc: bump minor version for new VT hwaccels 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: SGGYfzPYnlfQ --- libavcodec/version.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavcodec/version.h b/libavcodec/version.h index 4d3000364a..8a0b94f5aa 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 13 +#define LIBAVCODEC_VERSION_MINOR 14 #define LIBAVCODEC_VERSION_MICRO 100 #define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \