From patchwork Mon Nov 22 21:58:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31543 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7665503iob; Mon, 22 Nov 2021 13:58:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJx3DTqLYY4aVI7ONNizI7FSXZUOkSZs9JVv3HmOgBKMUAKeTK6uunsgRI8c/lbrf5JC8vl9 X-Received: by 2002:a17:906:b884:: with SMTP id hb4mr715403ejb.376.1637618321331; Mon, 22 Nov 2021 13:58:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637618321; cv=none; d=google.com; s=arc-20160816; b=q6zWnt1aH51pyNPJpJMEyoCqpv8TT59hFZryCSPH0SVn7p4qJoLVqoU4uDfBg/TLXe ib0PghyW81JcW5/9blLBqAzB4HAFRlmDu2K9UmPmr1u+Cw+HGHtLkNgBElE+t9Ygu7rv fEf7ie500N0v6QKdvNGF17+po5u4adSWLXC+ZQuLTUW6t71M7VcwLfh6n4PFIsuTOdGo IFMchNVTr+kq4nhF26XD8ta8vwAnMOHOI6eOeruTarl3WFMu4jpKf33eke43NWoRpYgK mg/KiPO2PsQyGeuKCvIHoayoqwGLzRgeZTNh84nS0dhI2LPKXvu+m2nBhyZQqEOcWJUk uu8w== 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=FW0VPfZGAq6iBxuUrIkocGxQyb57pDDwPiMvUUpwoka6K6/mWu5XprkN0b4HnLH8XO 3XBsmJfrxT0H7HWiOwJq6F2251mRWuaWeA4wL9rD/i1YAHFaZqjidPZ4AarjEZ/Ii44I dd/V+XbHU/9IjYGmI0p9xHaixCFPfOexpOo2J2gwRKexXCYkcVOhZbSCaXWZ/VkfdoD/ nQlsbqKCqfXkZ2Gfx/Ia4K8ASbcnR+3Y6NYMaC6BeYuvsNtBFTxvbM26WvJjB18axujv AOikHs03dl6d/VW8GePvUscFUh0OC491YlRlI3uBYrsKagkmDxXkHnk8JT4hq09vvf71 sDgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=UpUDWKBN; 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 r6si1747256edv.7.2021.11.22.13.58.39; Mon, 22 Nov 2021 13:58:41 -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=UpUDWKBN; 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 ADF4B688324; Mon, 22 Nov 2021 23:58:35 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id C84B9689B6B for ; Mon, 22 Nov 2021 23:58:29 +0200 (EET) Received: by mail-io1-f51.google.com with SMTP id y16so25297318ioc.8 for ; Mon, 22 Nov 2021 13:58:29 -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=UpUDWKBNFT+eTD+x4TzogTBM/1tSjpZwFn5LAWclZ2xqhpULkgkMpgczSIG32AcyXr GrXlRxFDH6awKp1iLO1XixP+epeibl0cuttjOIhycfYqiutoAzPrWF/M/b5mcgiC6xdi Hto8roAtnCuLbX0gLv1pipsvkPFi1w2Y8sbIPAE+PvwKGsQW6ocLlK36Lez7MN8+ksci MOLPrd6Yzc3rMAaARMLFoEVJxnd1qnnMy9YzosdfAMUJV9/Kr6JElPgVqgsquAYrc+6m Itjn8XTcVUnfnCBG7jACnXdEmfomvWaoFDAK8/26llz4k8ynkYTJ3S0h9K5/n7ohhVbp GA/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:mime-version :content-transfer-encoding; bh=WbJA7/NUFCQfQREc5BExWSRa4f9eL/VySokDsUX1AMg=; b=Ci1k2IdE0dMI6nExigtN1FsZG2mhIZCS/3e+fwNOfipA2bO0gXm6voGZk0Cv1WgTnR MdDtG3s0gOuce7KZm2SgdGuaAA4A4z0spcuZET/aOnt0vR1jtTvwQQLEfxlA05FHPdVL WqLJYesAIdB//noQT9Yg2Tc4ToJEajf9TwHQeNJ3DYYahq0f02Iks96WmG7+hHY2BB3+ sPUq6YTEN4KcG/G6oDaiCL3px9yrWPLviT0HSvGo3xPu2wcxP7KiI7J+lR2jBLABhkH6 wCgG0j/2loLVyQeZT0pAr3eeO+WiZe8c/53t+unDote+8BPFd6R0s+4k7Uqq5yT6yxCb I8Mg== X-Gm-Message-State: AOAM532717iHsJbDGfR/Fqg+nw5CasL8w/NxKiQh6zR5en4VGSdrVISx ibVz8UbNV9s6fFTjSn/yKIrHO9QmQ4+JVzk= X-Received: by 2002:a05:6638:2055:: with SMTP id t21mr343748jaj.90.1637618307962; Mon, 22 Nov 2021 13:58:27 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id o1sm5668802ilj.41.2021.11.22.13.58.26 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 13:58:27 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 15:58:06 -0600 Message-Id: <20211122215821.9849-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: GhWaVbt+gnvV 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 21:58:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31544 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7665710iob; Mon, 22 Nov 2021 13:58:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJwEgLeWgrHMTViLwG/Gn7DmGqGp2Vi+F6kt6tiQsE+Tn2EhDomq40i6hu5XLP/fs2mQOwlJ X-Received: by 2002:a05:6402:b23:: with SMTP id bo3mr608135edb.366.1637618333924; Mon, 22 Nov 2021 13:58:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637618333; cv=none; d=google.com; s=arc-20160816; b=MTyYHwFp+84XjgJl7CKVkTXMpgGZwYg2O8C2k1Onb/ZEx2HnlFc+fY4MFGZ/I1qbwN WcH8RK5E+FsIjfxdH5I16bcYWg8oxwwosLC5Or/bnzQt5W5x8jz12Qw4/nJ6CKap5uqm W/HO4DogZODmVnEbqlO0hkoy5dTYu5FtHBJZk+8K959+KuqhdM7xyh30JTwj/HE+CaGD 45HqA/WcEDyylDKNx7cWFtSDWddv/eHi+T0e8No4hoBRyfMxzU3Iprecjw/4xtFZnKL4 6v7CUDyGaZ8TLTPUgEk32FswgBLTxWzcDYb/+YHuvezIrsUWhFT/vWqR0fuH44SgWF51 fh2Q== 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=G0iqtDtMUaCamLmuXVy4ZEcb5szMCfLYdmvrxDeT83M=; b=JB/r7Ohr/LhI27r4PHbIrVwcgfOqQNnn/h8AyACx9KS4xwlc4hrekLXOarrtr0gfKF JIP79kkiLAA3Et4N6GrJK4L8Ug31O6MQRyruSPtPK1UyKpoOv3h5uKBsNKXSfrkMSTxU YthhV7HKh8O4aDO2JJz7u/Y6rzff9uLK1E4+erpMD6Kgxv3+iSLfzLm+ZtYE+Nsz79xQ rnyW94SFQoDcbh/eLUCtq7iUtNQ5d8QXwyPMEp4b+rAYtjaonHBNzvObwJfG/XQAX8xQ ZJNgnsvRyE1G+Tgh6F3ehgU3i2Eb5mAm+DZkxK1LMfKaEwsQbR3whT9BOenb60l+sB+L M3mQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=YcGjCyCF; 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 he37si29442464ejc.123.2021.11.22.13.58.52; Mon, 22 Nov 2021 13:58: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=YcGjCyCF; 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 C52A768A755; Mon, 22 Nov 2021 23:58:38 +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 BD1D268A940 for ; Mon, 22 Nov 2021 23:58:32 +0200 (EET) Received: by mail-io1-f47.google.com with SMTP id x6so3597089iol.13 for ; Mon, 22 Nov 2021 13:58:32 -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=/aS8o9WfrtiOuJCA8D5r9g4jgcUF+vw+abxBN9ZGang=; b=YcGjCyCFgxu6Fr4S3SEWLibOAHNtxarfjxcmY+7IaA12KQRgTpAS4lgnxLUJ51cMSt ASgGZg7nZ7Ndy85TkrmhJNr71Yo3MgvePfvtwA+ZAUTdwoaWIqEgKvCVyhwyw4TvHxkY PiMU9ezheaPaUDpLbLrZEjx7yd82Ps+jvH4qq211nhKf+two4avaoIF3tN3Z6lOg8YCq UuzAR7G9v3AhCvU+WERU4JqWl8gtyw95a8gImmXxgCfBw9gBSAnTv7HYPp58JYkZJo9n MsS7Q6Q/J6E7B2FMp0/xtVuv7oUWLzg89b8NqOuwdHBtbo9JdzCmQNUDYv8P6+QCzw6m w4+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=/aS8o9WfrtiOuJCA8D5r9g4jgcUF+vw+abxBN9ZGang=; b=vOptqhquuZP2zL0Xht5J8mgFGbB2WWAHZBcqvRn7oi8X8O/Ne8UewJHkQNCjwaOiFO CgPtPViVDYGxGLfWu45d5S7JmODOVT6tfCUjMHizslweX4jt+XBayuGykxjlW85rj9al D6OxMZdH97zeykr9Z2pweIy713/vdyEy6WQyknpsUBiFVlZ2RJW2Ltg3FNJOoUE2sGUo UJhH3i2k1uEx2FRxBLSMBBd/eQIOy+WQI+FUW8fc6uhhLPyF7sihjHXid1NQ+6UgcdFT shE2FOIUk3hUBcUSTyGQ6E41SEQWMZrm8NvwvSyGTRM93oe38LwIon8UNFkSVRKFhea5 ijyw== X-Gm-Message-State: AOAM532zOXks9sHznpZ05AiI/yGf5lQj7VKPP4YSJN6j7DwXZ346d/J9 +Mumen54KxtUrFL7sPxO1q5KMwCrKH87zsM= X-Received: by 2002:a05:6638:2585:: with SMTP id s5mr353077jat.68.1637618310997; Mon, 22 Nov 2021 13:58:30 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id o1sm5668802ilj.41.2021.11.22.13.58.28 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 13:58:30 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 15:58:07 -0600 Message-Id: <20211122215821.9849-2-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122215821.9849-1-rcombs@rcombs.me> References: <20211122215821.9849-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 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: vvg6w1UcDxci These are used by VideoToolbox hardware decoders. --- doc/APIchanges | 3 + libavutil/pixdesc.c | 96 ++++++++++++++++++++++++++++++++ libavutil/pixfmt.h | 18 ++++++ tests/ref/fate/imgutils | 8 +++ tests/ref/fate/sws-pixdesc-query | 44 +++++++++++++++ 5 files changed, 169 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 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 21:58:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31598 Delivered-To: andriy.gelman@gmail.com Received: by 2002:ab0:6957:0:0:0:0:0 with SMTP id c23csp7337403uas; Mon, 22 Nov 2021 13:59:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJz7YsJQmYroJTZFU+FMRuq5WoH6/0mcrPRFm4GeQKVkqbt1ZDtfg5odPpnk8dr+qg10qkZp X-Received: by 2002:a17:906:6547:: with SMTP id u7mr739997ejn.544.1637618343551; Mon, 22 Nov 2021 13:59:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637618343; cv=none; d=google.com; s=arc-20160816; b=K6hzJTl1oISZr/+Og9uFTlUGTfLge9I3VODzf7fCg/QHHX95LFo8AqQXF4joFWcPir xyo9wViVM4FsLPfBdrjLm0l4dH8vXQjyFg/f3l7JGWl8KNss9Wkxq64qyW1GCwmkgcbd 7tKFHTXEBjaVcBHF1Oj4nY4GRdPFqet8MnWZFiDRpuOKioPcdAeAaxIp5nXjwhGi3vov 1ewO/Qv0HjbPwC8vdqgmqTEH/EC18cT97AsQirNtnEFZffEa3Vax6MivhKlRriMPilh1 rDhhXMS8ZBIbojG9uXKxwS8v6hvhd74OtZ+AaLaYEVHI4MSdQXlrWz/kj8Cb67Z0EFXt XGwQ== 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=gwWQIa2DGKzQtwaAqUhzHim6/Bmvg9GNWKtzdWtho8Y=; b=pFIOaPJpd9h8Biv91/XJdWOaLMQG1cihl6zt33oGwC9HwXMN6ibzs0Vd46LIxTJylm uAVHPrYSLGQGk5p5dQRYdpaO7t9V3AuWxE/QfrdU4o+8hRg8ez0OTvTDmuNd9DLlikNF tU4cZxfqlrqsh2kJIHYtwCVp+hmrjoxq/oWS6cVoA/1+Hnpq+mv45tOTsPJxHdlP4CbA rZywEO9VtDSYYq2gp8NmduaMxU3Bwoffq/FqYimAlCBBsTdrbKK85ddjf/cu0fVC6kdi XFnSddHQcqc9QaZGmR7te+C0PHq03ZjozPtQBvmea3q8oax9L5vHfT/LcWK5IAeeiO+S yQAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=LrqgIvk1; 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 du6si32501336ejc.161.2021.11.22.13.59.03; Mon, 22 Nov 2021 13:59:03 -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=LrqgIvk1; 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 247C068AB87; Mon, 22 Nov 2021 23:58:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f41.google.com (mail-io1-f41.google.com [209.85.166.41]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7160268A96A for ; Mon, 22 Nov 2021 23:58:34 +0200 (EET) Received: by mail-io1-f41.google.com with SMTP id v23so25324978iom.12 for ; Mon, 22 Nov 2021 13:58: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:in-reply-to:references:mime-version :content-transfer-encoding; bh=90lpGakv6s+RfvSfFrMk4sxnuyhkXapuucPOPTIOTPc=; b=LrqgIvk1xMETrLHDNg9vxhECqtDU2NIgDVigGBa85+Zt0fZGr7SqS+7vp1SB0Ls9C9 oK+9gU3s8x80276k7jS5yBS+V1CBUcFlafXGxJ25y8FaZNtg/DRXfgoGv2sPuA4SXob9 Sv3RgktWcDgbTBE4y6o3nCwlrUy/FVMkWxrl9+o/pv+xtct4fjYwh0pJINgSw/2AcsiW M8Y1lX0vrOcTjvQawgEcuTN8fl1KwwvNIZvY8goizXbfKTqxaCRH6W4+liXvsRInImOL cRdcLARBtlwt6Ma/cgmmETZ4PBBcNpFGT2KsF7qOZf/w/TjqUze6h9LL6LqzgtU1cPJD q8lg== 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=90lpGakv6s+RfvSfFrMk4sxnuyhkXapuucPOPTIOTPc=; b=APIEsw2tWlsDWy1odTUsOFl94MVfe0grfl7SW/YWuQrM3fnbnkP7+qXZfvy78h1hjF zVA/3uY5IUIYdjySmLylID5bvYnY9Io3PxbJvObCBsmJbKquYKVv7NYSzcgXchMMzFTS BHWqdsualp2jrV829aKQJkejKSyhG9tWrcz/Jxso/XlM4unsGNix9V17rOsUSe3mjxg/ xnJ0ZjNehKase/tBgOfwz7Imi2rvkgb17oXv3LzcM4LblC97Nhk6njEN3wsOw/jX83sX dKvYK0haaQHzeE7xdTuUASi7eLpWYuL4Fwy3nSZyeKmFuDJnP/47lnSZGspbqhlpa+gm +h9w== X-Gm-Message-State: AOAM533IQryg3dvxGX+qWUNMpfWq7wr9JLzq8w1jGZvKEv3U5tcs7ErG 5J3zvXw1EnZ4WJvyP3KMNTfE65bPimtCVIU= X-Received: by 2002:a6b:650a:: with SMTP id z10mr18996iob.169.1637618312506; Mon, 22 Nov 2021 13:58:32 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id o1sm5668802ilj.41.2021.11.22.13.58.31 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 13:58:32 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 15:58:08 -0600 Message-Id: <20211122215821.9849-3-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122215821.9849-1-rcombs@rcombs.me> References: <20211122215821.9849-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 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: glMVwJ4r59AS Content-Length: 3498 --- libswscale/input.c | 16 ++++++++++++++++ libswscale/utils.c | 8 ++++++++ libswscale/version.h | 2 +- 3 files changed, 25 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, \ From patchwork Mon Nov 22 21:58:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31599 Delivered-To: andriy.gelman@gmail.com Received: by 2002:ab0:6957:0:0:0:0:0 with SMTP id c23csp7337547uas; Mon, 22 Nov 2021 13:59:09 -0800 (PST) X-Google-Smtp-Source: ABdhPJwYxCIURkF5tdyoBX+ggG32sYmPYJKJ6bSe9GcB3TVy5xu2KPRdggNMNd9xsmfjp1O9pV8Z X-Received: by 2002:a17:906:f0d4:: with SMTP id dk20mr681596ejb.257.1637618349547; Mon, 22 Nov 2021 13:59:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637618349; cv=none; d=google.com; s=arc-20160816; b=i3XDNhXBB3oFYCuHXbenL6UMeFotdAk7OJoE+Gk5bgEnlsn5kYwAqnuUokDAyDP3Uy 7+okpojamurEmM87qKZAhDUDBRGjkQ7A7oTTsHTvQCbhP2uzHsocaZWZWMFNX88chefh pvOboR8sn0KzY3QMm//6NeaEGQBZpSCP67tafnbA+ugMR03v2VWqV+6lRrG5L8o1JilP 235fnMpiaGOtl89cFXvO54hnLEEfs/Bm1TPvqJOJFySvizLEIklmLKGd6/ex2w94rAd6 42r2UoYnieuIYUy45YUDblsbpUxJJ3W9ha2IbFD0zE8fhmfya383F99+3SwSTmZOzWFu PIGA== 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=bXSpQDebVpmAHfSyElD8cAkW46NVb9Mr3MA1LN1ScRhrdK5hAtlWOphGubg/39wlvu P2QHmUg4Vs72OjMRaiMTyxqx4XEgCu/LiRWugpVB/UIEC5QH9PrO0XQyj7re7XTFnz8o rIU0Zmp8sX1dkign2j3esf5NtyOwGmtT6V3C9S4hEO3SpRekPBCx9WaoZ5KcJld0OQn2 oQKTFVQTMyzKSjGf14E8fWAN4PV+fsdvV07B9XPIsolfWKLYNcqRF9kAFFhx/jntx1qt JMPsqdUKBSD0SrzHzXBGC3XKL1Ln6yAEJtmP+cnQEakFSkQ6j5Cw2bRuEO/+ldCebmoT 3+Vg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b="H/xqoEiO"; 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 eb14si32016107edb.134.2021.11.22.13.59.09; Mon, 22 Nov 2021 13:59: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="H/xqoEiO"; 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 A842A68A897; Mon, 22 Nov 2021 23:58:41 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F0FF168A96A for ; Mon, 22 Nov 2021 23:58:34 +0200 (EET) Received: by mail-io1-f51.google.com with SMTP id x6so3597227iol.13 for ; Mon, 22 Nov 2021 13:58: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:in-reply-to:references:mime-version :content-transfer-encoding; bh=Zxhfn7NPJs8PCgIItTNh/yfcO8YZF7Q3/kQwCPck1y0=; b=H/xqoEiONwuuyVY8xvNKYSQBqQcDs9l86coL7A935gEDlwmFqXkIQanMRnCsfpFUyo kBRmUqtSmEx+ZsLTk0CiItG7ni8hTzlBtbUoJNRlzDxNw5oeV55rcMU3EPMeCKso3UaW GBE1qYMyuK7c6O5MUtg9YnZKKlaxuK8p3iP3ZhKT+hpVt/H0SosXBsHYVDQgViE2qhEF 7nP+tFu+8O5+6I9xJTvINI+DyLwZ5GouRKJ6/s/BOLGk55wEdCALo6waqJWQDj4UtspA dDpNgj0vXC9YMup1Y/Q/hK5AuNjMpTkh0gUOlIMx7d82SA9MwWbqJH7PGPX48PG5pXwx Rd2g== 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=Sk+zWII3Jn0eD4vgrEh3Ja0tOR1bTP/LaeKHvS3ynLWIqAoJoRGfL2+ED1DAYKP8HD iVVbxQ91TO8CjtTtZzT7crtIn9ToMcxDYvsH4aK36+jHQxBJgLPXwh4IKXkRZ8iJTHx1 gnr/EAwOeJpmEoaCjYD0r31IwFY6WxYFe7L1CgBVrukbeMdxslfCVPg62gATejRnf+1q WeJ0t7nURKAdcNr1lgspZYJmluB3I/ycC79pk5fXJlsrlwlKsn5rzWoGCBMdCX0FPY5Y /WZiQ3YlJapbryICSvJWxjZBYVSp42Vz6VhoXfhredxi0LFB7NsHkZMcG8S7tBmtROVX A+kQ== X-Gm-Message-State: AOAM530ZfGmgcu3fnln4JxaxeSexzIJxF7SfGzuE/gSwLx3E07jgBju6 DjuhBDNNBgTUoeSHswB/lzHmcjfVARrJ5u8= X-Received: by 2002:a05:6638:1607:: with SMTP id x7mr302182jas.27.1637618313333; Mon, 22 Nov 2021 13:58:33 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id o1sm5668802ilj.41.2021.11.22.13.58.32 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 13:58:32 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 15:58:09 -0600 Message-Id: <20211122215821.9849-4-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122215821.9849-1-rcombs@rcombs.me> References: <20211122215821.9849-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 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: ExyuMu8k2Y18 Content-Length: 5101 --- 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 21:58:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31600 Delivered-To: andriy.gelman@gmail.com Received: by 2002:ab0:6957:0:0:0:0:0 with SMTP id c23csp7337828uas; Mon, 22 Nov 2021 13:59:23 -0800 (PST) X-Google-Smtp-Source: ABdhPJxoODweSqtHfc6H24950DXp45ua0x3/4y3Jy1noCCvHvwoDM/0XoaG32AvWR+BPpsh1X2Zl X-Received: by 2002:a17:906:1706:: with SMTP id c6mr658157eje.343.1637618363011; Mon, 22 Nov 2021 13:59:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637618363; cv=none; d=google.com; s=arc-20160816; b=dp3cTzH/HB0bf4GPhuKfVz7e5D86DUR1w8gMJFtDHDvaRsfsGq7r/6w/fdYAiCD4LY MBxVCF8DTrWxCHKpf3k+2GLbvfwmcn854xl8I0GF5pz4NZHt/Q6pBl2IjUHwwBvp/fw3 pxS3CTJyCwKYWyQ7XBdpdlQCky5tyY9OdpoESE9RI5rBTbxdh7+/iu6bUO1qfpjxOqVJ dHNB+lVYB89jrqiRktBrxWzms7cPnkJKJdxC3CkxiOv0SB+2Pb2kqKPW/iqBTA5yXF43 5s+1J/7rWTWGgJo9vU6UuKP2mA0RPnV5ds4Mc+D4/CkY1GpYYpxzKiuZIXpeGLNU0OdU J7Wg== 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=m7LJYG5P4GBFMiJ06PKk/aA2qzKAZynGlRcWCWr1OQaX9orYC2+wk4NrPBGyge7syc b0hDZ8x4hPi3VR61nlFrBjmsbYMjzarCZYoxk2uZzGEpsA47HD9IrlXONk5v9JyJlNvx FgIwNY/dmccONY/EYMKfmAUVVbaHh893JY5zVota23G8oZn5Zr2InV1CDHaW2HZGRHp2 EPLPIP42YwBDI/Kpk54bmmOP3AWty7qi5UlHsUMRJKC5+Sf8cgu9jOcKXq2L1SpdbmFM HCjU2mfBPrvRlr3kmydmPdsh6w5/HX8nggC3U+1Wx2wbMGur4IN8Q3cQRj5vvk+4GOcc A9Hw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=RitMWAYa; 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 jg6si3427709ejc.521.2021.11.22.13.59.22; Mon, 22 Nov 2021 13:59:23 -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=RitMWAYa; 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 3F48068AA75; Mon, 22 Nov 2021 23:58:43 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-il1-f173.google.com (mail-il1-f173.google.com [209.85.166.173]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 84E3168A897 for ; Mon, 22 Nov 2021 23:58:36 +0200 (EET) Received: by mail-il1-f173.google.com with SMTP id t8so9736359ilu.8 for ; Mon, 22 Nov 2021 13:58: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=UEW4GZ9JW0/r6cyOGPmq4BBHjwoMynaY9s2/VJGvBxA=; b=RitMWAYaDbeJelFkq1sPb++GN+ItVKRpzSlhyxq2Z/K68FCkTPH7sD97Ecoiqqnahv ztCNehIJeiKedff+Mz/P7FVtB5i3XgsAJWbH+qR0w3tLDJHZVEaIZEA6b/TsFhfxelbf mZpiXx8kqMJdDxU2TquRu1LSo7aXArPgnKNMWi6oVIkH4+RQLvJ4BpEb41mNIyt+FNEC 230fqgx715X3plxk3tRBLRAO9vY+1/xHnIuNJY64w+FNB+rZgc3bo66PP/Ry0R0wFmAw tBasw76iHaDityd0Jp7fDodDLIzCfRIMelyXU24hWvowsKIX2OUYFybpaXFwJ6PXw0FQ N+mw== 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=KpHrxDJ/2xgHV1GbCAjTGd69FgCJkYHOgRjaE6RoItGlbPkX7uxtqwtl93ayvDY8ru tWwRTDNrn38ZY6XgKdVxeKOYAyj/0LFrybG78SnNBDO3WZX9sbhf/d5QoL38sTpg4Pgr tuaPqMCCu0KJENFAX/MmWoLoyS4rpRpRo4PGjfAwfchRC+86jDMFKUwouym5Jlj3GUMQ SHYDIkwbq4NzmpIJZXfWtnBgan4vsgeMtTLV9moGnev6YznczCYK0bNAAi5SUnrgf2j7 1UlRSeFM9jfN2DTYpY4Odbz7q2/9EFaDJ3/vvEjjMRa1knQyUpN/LLR5+HLm3Sg1BCOC ugPw== X-Gm-Message-State: AOAM531A8KV2hnfeahXt/qJn43o21PV0SWj4wfQ1+gx3i3ElbsFhs1SG //1d2oBgTjX4TuRsZlp8H9OLksXf2QHPbV0= X-Received: by 2002:a92:d74a:: with SMTP id e10mr166855ilq.315.1637618314819; Mon, 22 Nov 2021 13:58:34 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id o1sm5668802ilj.41.2021.11.22.13.58.33 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 13:58:34 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 15:58:10 -0600 Message-Id: <20211122215821.9849-5-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122215821.9849-1-rcombs@rcombs.me> References: <20211122215821.9849-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 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: uRezBgHPcAOo Content-Length: 3075 --- 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 21:58:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31586 Delivered-To: andriy.gelman@gmail.com Received: by 2002:ab0:6957:0:0:0:0:0 with SMTP id c23csp7338109uas; Mon, 22 Nov 2021 13:59:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJxe3gqQB3UPVl/riS/Abi/UtAi1S5A9FtRbgH6MOlZ0PF9WFMs21oY04eX+QU254vgmnn3q X-Received: by 2002:a17:907:90c3:: with SMTP id gk3mr765766ejb.282.1637618374197; Mon, 22 Nov 2021 13:59:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637618374; cv=none; d=google.com; s=arc-20160816; b=Ib77Kha6+cVfQ5dddz7pHWnMETiOAMEDpBeaIVDbSW8Dqdf2MzsTd6513Iw6EhuSpz M9UJSXFl22vjEtJcAX+xbXTebpzqUChm5PbS9kdJAOUJJk7IU1xt2jafKsULWkmjvFgF AlmCIbSnczFUrwHZkxf2UW1YCN4Amg8h0zMpLIehLYoQwkhwIEDi74iwRvIRs30LGmK5 oWUqh6WoHUd+70InGBRWgZIPS4A0Bv48NmEJT9HGwZm4IFF7tNaHEbumHW8EWdvXaISU xjDStOyfmBVxTn2DqlAkQlrEvfH1kwLBpScje5Y6Y478lkXp1vPkOX01OAawJWydsmjb XuGw== 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=RZeFowRrnhGFXCJg1bXcI51iOFU4xbWvU0qDxieXwJ4wQIwv8anVk7Mry+Wldc0A33 ptKMyNYAVmUgKdtM2SuMo6QARWVxJR+VbfJWPYfx+G4q1QwmVq4yTS5keVU/NnWrXm1s cha442ITGx20684UlyDl32vvZigh+G4DQjWU0EsdxQyTV4++DOESGjOz547pvYYd8xQS MtPNE95uCAD+bxbJv0CEcvR7Wy0c0ROcCJaJdCe0IeCLAZekx8fFdpwOAIyxO0/7cMLq G80QzXs/rF0f6TXnZffLUMah5RcJOEoiuQV7x+ATfOAVVMkd2cPohcRpHeWj7cf422ic Z0Jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=asIlmE1l; 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 gq2si19499819ejb.516.2021.11.22.13.59.33; Mon, 22 Nov 2021 13:59:34 -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=asIlmE1l; 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 67F0868AE12; Mon, 22 Nov 2021 23:58:44 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-il1-f181.google.com (mail-il1-f181.google.com [209.85.166.181]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id ABF9168AD86 for ; Mon, 22 Nov 2021 23:58:37 +0200 (EET) Received: by mail-il1-f181.google.com with SMTP id k1so19633061ilo.7 for ; Mon, 22 Nov 2021 13:58: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=WvQEEhkrtvyP/10de+H1WF6OnE/jl72H/QufzAqlh6A=; b=asIlmE1lcVXRcupEq5Ti8M0vnZTImjR7bMyj7uAjF+lFAOKx6Hih6Enw49PUPapJFm 06F3c5D6pBkwKilewQ7U/SQby6zqf4XGEheU8gW0FyQmdeXB77vYtepBV3oaGcsYc4pP YQDVjeXIKvcmX7eyJU5nx4bY9s4yiftmz2KO5u0DczvX4x18DosP5D800yQkQPKK89Bs VxCsK/lCmeLVX1Qy7G0Qp1oXip7PwSfUCVt8OvmV+AvoEcqn2udgactqEIiFqBQgpyph d0C0KPE+tl+Ir8vAUn5lO2APPkWmr6LchB6Jk3HQB/M0Mm6RzoT3hCTXNO3h4yqqCdT0 e9mQ== 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=muIWWnQYndZBxzRrmlQ6VJWsaJQoS4FJsFDzxlMZz40gq8LGUpuPS+wHvNMoPf3zVc Cdpd1aTp8lljjcUF51EqNHYCannp63r+scPQORQ7horfhXHpr77KkN2deXHJa9ifscok jJDzJh9/MwZH48u2Knrdk4jfXHbZ0UBoevzHWRU1GAG/n7qmmzCjbVzPqmGL+hHcNQtr ITJeRov2b17LNB3iJs50EYtiJ49tdlDr2uHvtr+FSm2lfb6QB3TFwDdPAodGbxz9a8le Kjz38CFd4iVhpwjitSIdv5rtKPeO0Pnoaf8SSiUNE96AF5CDJxgMo6YDCyRPJSWr034n tN6A== X-Gm-Message-State: AOAM532GHEPdP4qL6vZman48BZMuefDWBHavKDavX7d1nIzfVBoPw9V7 zgQLy147bNBecwECof+gI9ZvkIZgsNbhmk0= X-Received: by 2002:a92:da0f:: with SMTP id z15mr198099ilm.151.1637618316096; Mon, 22 Nov 2021 13:58:36 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id o1sm5668802ilj.41.2021.11.22.13.58.34 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 13:58:35 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 15:58:11 -0600 Message-Id: <20211122215821.9849-6-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122215821.9849-1-rcombs@rcombs.me> References: <20211122215821.9849-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 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: Zwd0vsch3VvV Content-Length: 1012 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 21:58:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31589 Delivered-To: andriy.gelman@gmail.com Received: by 2002:ab0:6957:0:0:0:0:0 with SMTP id c23csp7338583uas; Mon, 22 Nov 2021 13:59:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJykTq+elzPi+eUwBbGIWYDcUyUgZ098BLptNjmCTHbryfpJhicIu/n99JEKooRaGSk4XUSo X-Received: by 2002:a05:6402:26d4:: with SMTP id x20mr578624edd.119.1637618396693; Mon, 22 Nov 2021 13:59:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637618396; cv=none; d=google.com; s=arc-20160816; b=oUYkBNusoWd0Y5CDjperuAIzsqsg1QU4py6vB2hqx+BcHC9P6xzoPg5J8EIGMko8dO ks+d2/faxAdNbvWFWl9zRYl4s7UfnwwOhfrsMM5zWqP1mz41GUCrp8Gf2JI2buEQa3z9 QVT/2kBUT7jdLGVwEUZPVBBkm4veWb+iDXaDnyicfAxoShH7M/jm9tUEN2SOsibwB1/4 vag1lqHEQOBL424l3eK4D3AXCfAsYXye8NhIJda01MkulvSChal1Bi7Imuhdi+JmIMUI YTiUKznUvZJU9HP/lAbM6bjaa9fUftAHFj8dzNfpiwRBlZM+EXXLTlA/KzpBLMJr6GZV PVvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:reply-to:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:subject:mime-version:references:in-reply-to:message-id :date:to:from:dkim-signature:delivered-to; bh=td8/WBf/+aJX+fJWTY+47chij11JhuaO26DL/CIj/K0=; b=LJxfDysbL/vc2NwA7oa1BBNqvN6yGETaVKisMsaMQEso9Gcfb7YM3jpsmKDXRtRNvp yp1nb8Vd/DbJFwePoHv+5CHOhxR0Ql7aBQaUuzres+fBW81yLB77mt9qcrwrJMjtHgbJ SfcHf3MB0GQkUmGrw9ETK9R23tKVjk5caLGvc1FSkwJak8paCeeVv1PgWe0fPCCk43op c/H550PQEOJwQXtiQfxCW557afzGmZ0ofkM9QHbFYVeoqWVh4/KgmWrQKdFwTm0yw0lF ZwlXwOLwb6PS6xryuLlTpoSlib9yIp5/SnK3PER1J6VBBPFYMJf7oPNTaNwu2vWlJ7vr 5GAg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=IAE7h13k; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=rcombs.me Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id x10si20584816ejv.557.2021.11.22.13.59.56; Mon, 22 Nov 2021 13:59:56 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=IAE7h13k; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=rcombs.me Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id D9DDF68AE8C; Mon, 22 Nov 2021 23:58:46 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f53.google.com (mail-io1-f53.google.com [209.85.166.53]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 7285B68AC4D for ; Mon, 22 Nov 2021 23:58:38 +0200 (EET) Received: by mail-io1-f53.google.com with SMTP id c3so25390919iob.6 for ; Mon, 22 Nov 2021 13:58:38 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=rcombs.me; s=google; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=upUIvvpvRy/e5dsIWKyQ97yjTuI/f7NAfK8jw8wrof8=; b=IAE7h13k7i9kX7uVFGEy3G+qbfH5diHHyuLh+MRBbpBpWMduYXAx0VI+GtKLOI1oaN 8NmKPT2C0nuyOwAL4AWhokWdhCt3MqVzcMHr/Ma8G/ogU9wKbZ7cF1eJdJWf9sfE4CgP dxbBjIWPzvtLXPjPi6pSeWLqM3lQMD74C0jY4W0oEC4R74kz2A15ABzZVl7AjHjqiOWL bySXo1PyjJFC0VE6lICzFkR7jz7+EfFSaS3UABY/4lRUfazYl21RiFETBLu5T8g6HsRn 2nl5RKRJYP7/XYQ62aJfdxnuC2pjRj45vEdnqneimHGvrNCQSmXR/KeDQ8TR6NpB6Xwu fEtw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=upUIvvpvRy/e5dsIWKyQ97yjTuI/f7NAfK8jw8wrof8=; b=ExMYPCaLY5b9xKc0TlVq54Hl8L99mYOg1KLYdD52DhTzyDe+XElM71JxqKq4fq4xgZ 0gaW+LyNURXwo/icxbSJ/+z7wo9bHII3Z9/2evA6wo6MWXaJBGxtSNZucqafVTj11Ry+ j7rWvvedqj3LhWzipgi7daJyGwAbmmycblLSs7zHqGW3dyo7TWQsT0nG9wES3x2ClhUG 2heDBfH9i2pTPsJmtgJbaZn911PAJRp46Om7NJ7rhdMk6tsmlGoRWF0MyJTvFS9HlH9m 4xEbATCQ/1Gd5UrTsWT5O2JLi+25YCf+F9Ti9zUBAkscGr2UJ2PCNIG4EgKYvks2NZok qa2Q== X-Gm-Message-State: AOAM531yrw4+5ayepg/E1LmSajvbhLdlQV8TL3DN/HPabmhuN6lHZqQy 29VvTepfLx9n0DC+jin0IGQTFOJ2a/V1wrM= X-Received: by 2002:a05:6602:2b83:: with SMTP id r3mr127130iov.8.1637618316820; Mon, 22 Nov 2021 13:58:36 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id o1sm5668802ilj.41.2021.11.22.13.58.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 13:58:36 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 15:58:12 -0600 Message-Id: <20211122215821.9849-7-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122215821.9849-1-rcombs@rcombs.me> References: <20211122215821.9849-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 07/16] lavc/videotoolbox: select 4:2:2 and 4:4:4 formats when applicable X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 1sIyPl4OsPeJ Content-Length: 1648 --- libavcodec/videotoolbox.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index 010f553e57..57b37bf3bf 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -1064,9 +1064,35 @@ static enum AVPixelFormat videotoolbox_best_pixel_format(AVCodecContext *avctx) return AV_PIX_FMT_NV12; // same as av_videotoolbox_alloc_context() int depth = descriptor->comp[0].depth; + +#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR16BIPLANARVIDEORANGE + if (depth > 10) + return descriptor->log2_chroma_w == 0 ? AV_PIX_FMT_P416 : AV_PIX_FMT_P216; +#endif + +#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR10BIPLANARVIDEORANGE + if (descriptor->log2_chroma_w == 0) { +#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR8BIPLANARVIDEORANGE + if (depth <= 8) + return AV_PIX_FMT_NV24; +#endif + return AV_PIX_FMT_P410; + } +#endif +#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR10BIPLANARVIDEORANGE + if (descriptor->log2_chroma_h == 0) { +#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR8BIPLANARVIDEORANGE + if (depth <= 8) + return AV_PIX_FMT_NV16; +#endif + return AV_PIX_FMT_P210; + } +#endif +#if HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE if (depth > 8) { return AV_PIX_FMT_P010; } +#endif return AV_PIX_FMT_NV12; } From patchwork Mon Nov 22 21:58:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31547 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7667376iob; Mon, 22 Nov 2021 14:00:21 -0800 (PST) X-Google-Smtp-Source: ABdhPJxp819yAZyLSry2VhQlb8y4KZmfPnPI6AaCMQ2HiFxQ229UpDYkqmjRLzxjBHUfcSTpSSvE X-Received: by 2002:a05:6402:190c:: with SMTP id e12mr626219edz.396.1637618421415; Mon, 22 Nov 2021 14:00:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637618421; cv=none; d=google.com; s=arc-20160816; b=c0wbIcXW9ZDiP7u6jhyCs9DHgNpM1sTRL5ZFAb2ZbyGYCofto+sI/b+P9XjXDUeA4h sWN6w9dYdgkhJw1ZP5CSWtyf8vE2qn7M5gmaVul6v6JfhsSeZGgTufqzVfDXegXOIayx FHn94BtGeoPlfR0BoRflCK7lBRZe1W2D9qehdp3jZJmmA2qBncy6CCACL40L0FJfyoz7 WkN4Fxcr1bBfay/hOaIzrOPRrUFzG0H70nOr3M8WK+MXm6Zr3V9bbY4zD+73OMtQLKTF tyGW2ANck73DmV9mc6mDlmjxGIImcoEbNj4jB7faad6R3MLmJ2NDB/PVOVvfO4Kp3LSa ldOA== 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=Wwqe+lYcYVcsZX717DnV6KFggupn3ciqlTycHOrz4sw=; b=WNzYSF5k0F1RQK/c7cXrqap5MLlYQ7vQdKfeZawFWX2ucUcaCmd9Whznqxq2etkxCP f9r/Dh9gywlj8u1ku87ihWlq9OxiUmlCuk27gnj4wyQF/BDhld+gpg5z0aeq+zgoeQet vBpf5ZOSLR+kkT2V0NzFXzBU7WHpID8GnPv9X5QMdYos5ZcQtZeEeKmehqrtlf5jrClQ 9pqEjS37oydUhGp9Ymd/LdH1Ix2XYGDjkXgdzghAkxw4MJK9ibJeWwGxJtFUpxx22NSq CfzDdULVKMnt1y2RKOQOcwzpRCooMqkh4MsExCOb53lGlF20/Ok382qfnd99wYsvUUR0 +Log== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=Vd+qM4W0; 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 hb42si25525830ejc.325.2021.11.22.14.00.20; Mon, 22 Nov 2021 14:00:21 -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=Vd+qM4W0; 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 733C768AE36; Mon, 22 Nov 2021 23:58:48 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f51.google.com (mail-io1-f51.google.com [209.85.166.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 1C63B68AE12 for ; Mon, 22 Nov 2021 23:58:39 +0200 (EET) Received: by mail-io1-f51.google.com with SMTP id f9so25151591ioo.11 for ; Mon, 22 Nov 2021 13:58: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=33vpX6jqERpP645J+oDXCxTqvfxozRmd2HN+ScmQJeU=; b=Vd+qM4W0uEkgFF84fQxktVeauPVhH07OzIQcCXzYRFtYvbU4pxAvNrSXpi4keBsUwE RZC86Tnb+TjDSZYLNzyOx+/MqqXmcTh0nYtb/1djxdOvkiGcuXmdndM3eV8X3c+md3pL CmVae1DcrCZmdfSnfCJnILQT7e4VtBdAeeclMqwV/CDUHWHDA8KgOP44DFSGaMCDeJlO 73I4mA75IMk7m+l43fL1BnxFe38eJ6CagSPTRoIgyVpD3+g9fOrYy7zxUctNECfGBOji S5FlJ49O7ip4nY6gtO4MJ1w7ATelgrscLx7pOkKTjPPVpzn8iRvuUhn960bQxcYgB8LG cwoQ== 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=33vpX6jqERpP645J+oDXCxTqvfxozRmd2HN+ScmQJeU=; b=SYobRB6aUI8SseRabFU+MV92DsdAfG9XOTw4WEjlNxS5sPcQ1rXGwj6BmrvFDNyEWP Ce2zBKdL0CrvsyUr2OjllHM5iOxZU8Vx3nrnanQeY4xbX9csEP1FKKINFSoNfKH4fCmz pzzcukVCfFrV4IS8AEaQ6awbmunqHpqR9D31eycemI3hwzCLL9ILIsbLk3nnUVVCwrbq DRmx+cwwTZpkFvwVg+PZln3YgA6USKheDzFDa0J3IsFrlXj0sfqY3/iWPUExkeDtLLvu svj8FjszpdLvwgvMc1g8zimWdbwHHd4DqaCC+jPt1TiMdF8gVn+c95JSXZAECywDXUoZ Tx3A== X-Gm-Message-State: AOAM5309cQ/bBoCTyRuXXCOCT83bjStn+9QOnVcVuZ5TjMnhrdooyoyO Og9HSpfI22JkUVDB+XHNXCps+6LJ0jH8NBg= X-Received: by 2002:a05:6638:3899:: with SMTP id b25mr311858jav.39.1637618317594; Mon, 22 Nov 2021 13:58:37 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id o1sm5668802ilj.41.2021.11.22.13.58.36 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 13:58:37 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 15:58:13 -0600 Message-Id: <20211122215821.9849-8-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122215821.9849-1-rcombs@rcombs.me> References: <20211122215821.9849-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 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: EUWhwi/lNUu0 --- libavcodec/h264_slice.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c index 89ea16a57f..4467882775 100644 --- a/libavcodec/h264_slice.c +++ b/libavcodec/h264_slice.c @@ -811,6 +811,10 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) *fmt++ = AV_PIX_FMT_YUV420P9; break; case 10: +#if CONFIG_H264_VIDEOTOOLBOX_HWACCEL + if (h->avctx->colorspace != AVCOL_SPC_RGB) + *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX; +#endif if (CHROMA444(h)) { if (h->avctx->colorspace == AVCOL_SPC_RGB) { *fmt++ = AV_PIX_FMT_GBRP10; @@ -849,6 +853,10 @@ static enum AVPixelFormat get_pixel_format(H264Context *h, int force_callback) #endif #if CONFIG_H264_NVDEC_HWACCEL *fmt++ = AV_PIX_FMT_CUDA; +#endif +#if CONFIG_H264_VIDEOTOOLBOX_HWACCEL + if (h->avctx->colorspace != AVCOL_SPC_RGB) + *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX; #endif if (CHROMA444(h)) { if (h->avctx->colorspace == AVCOL_SPC_RGB) @@ -872,9 +880,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 21:58:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ridley Combs X-Patchwork-Id: 31552 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7667824iob; Mon, 22 Nov 2021 14:00:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwHKPbA5AElzmMlf98El2r/yCRiAgrUsFqU7KGOfCs55+Vnu6oAlThiFsclpPeMBUEfg4iR X-Received: by 2002:a05:6402:1a4d:: with SMTP id bf13mr608259edb.101.1637618440922; Mon, 22 Nov 2021 14:00:40 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637618440; cv=none; d=google.com; s=arc-20160816; b=pw7f2PchY38IQ24nb6AC1njtauGgU6G+wMlbn95Mwyi5lwmurkKbjQMQ27oCScO07l Hlg8+5jqlxIRoKOGjjbqd/afgqzF8qk6wyjVuj5a8Y4TAeNTMNem4qTl48d1kSmYzpby kpVArv3o+zLfcjRVcLHSWpG2WIhXzcQxbCmDG0zeSRsyvf2qEqc/zluAqsA1+arkoNdl ZFd5IJVlFuOCOkfvpOVOKe25vYBTabY5HMaBCfZAEXeAMTSjAWn0A48M2Bc7Qbg0Lsix TdlmE5PYzEHN6xwC8Wuo6kPo8sppKhLjeL9a8HDnJXAc0WQ7jRJlBzliXI/wKdaCAVlU mOrA== 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=IZUWJZzBTGvSseXEcvIbUrLv7gyB3hZK/NauMz32CDM=; b=slTT3Azfatehu9dLnn3Mh9+/tD4qWuQql/W2rIDI0HwIVGE21xtgpThUi4Rh2A0eoW l7lL8IG44XN2anVpLoptSDcYRCmnmSTnCfFo1ba6ncIVrlekXCydSgMuRIQA837EGgOT eHQbbVvG0WfdkxWz3xsbH384/nP8VeMdCVKbHiicsO95dUGhkt+JzazwPoDE3DLHJQiA jALpAW/1ZV7Wf7i4VFdqrqwg3fCOKH9IdRkU56tnt5V4Lyi+cK9gDAUdFY07uleGFz9Q zlP++7alOLZxBWrPypHjJWdMxRn9UDnmBou9+k9x+xPREBs9tEpmiGUX7Bf7XcxJ8Spb +8iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=oh56h0pl; 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 yd24si19751531ejb.658.2021.11.22.14.00.39; Mon, 22 Nov 2021 14:00:40 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=oh56h0pl; 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 932F468AEA4; Mon, 22 Nov 2021 23:58:50 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f44.google.com (mail-io1-f44.google.com [209.85.166.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id EB92E68A96A for ; Mon, 22 Nov 2021 23:58:39 +0200 (EET) Received: by mail-io1-f44.google.com with SMTP id m9so25425585iop.0 for ; Mon, 22 Nov 2021 13:58: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=7WjyuEncBhM/olWa5t2p7bXN2kDvnMF1fnTrMBx1oGA=; b=oh56h0plxx7elU5UKv3CVdULWURTHndleZIaNSnJAhVLZWqUzOtZPTpAiB+Oct2jC2 0GMYJRI4lbPooYtRFGtvvy3gaF8TiSfXWpewMNpe5/WyPWdOGhxbHWuWgEOmwOtzRLoa HvpRpilLuF0SogWfMWXiIjc0dOUjCxz9AJcoJsWgW4o1y0pndPME0KFQ27vXuUsQuQoM EEEoqR4zVPK7LZw6IXtQwF0sYyL+t9XS2EgieXVUCo15L32qGB4gZ229Qdr/tFOKNKvb 88NNrRNuI5yJuL9e/5dGqYvIgkMFainrLVyrJpcThQ7fyiVJ03PqlK43NsOrzN7Kedcz E2Ng== 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=7WjyuEncBhM/olWa5t2p7bXN2kDvnMF1fnTrMBx1oGA=; b=51FJfpr98oJEIoSmMV1tGX+XsJOgTKbgT82uiBJpzSlClds1fLVIK5VhHFsRIN5sa9 e6dsfxuJAF8CrRkCdVV20I5kFFUX4J9WL/vBgwulwLyYA4eGtBgdMe+fL4YX54kBIrfX B+pUe0U4BLvncs2ct/4u316ZE6zxByM9iLWWP8RQLIP3c1QXWh4K8I4Vxq5IzLjY8ASe ZQ5p6TFXtCsY9xhOgaI6JGxjDa/XJqJnQ9U6uXYBYaut3FCdFUcRulxVXfzdwIPJ1Uvi Rbp1iI6kj6/6JVyA2QRm48D/KWERZKUegx9nT2MagQowyPwM1tlx17aD1Rb4eRlyvMAS 6nxA== X-Gm-Message-State: AOAM531b0eXBHDsUXwPgWuFimo1c5U50iIkR2yVYuNnXZIwARsoMhak7 Riij1l+e+wXvfUZS0GcmKqgqUBwVr1r4nQ0= X-Received: by 2002:a02:a489:: with SMTP id d9mr273198jam.47.1637618318348; Mon, 22 Nov 2021 13:58:38 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id o1sm5668802ilj.41.2021.11.22.13.58.37 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 13:58:37 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 15:58:14 -0600 Message-Id: <20211122215821.9849-9-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122215821.9849-1-rcombs@rcombs.me> References: <20211122215821.9849-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 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: k/7jjl4HiBK8 --- libavcodec/hevcdec.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/libavcodec/hevcdec.c b/libavcodec/hevcdec.c index 3e19f4ebed..f99cd7094e 100644 --- a/libavcodec/hevcdec.c +++ b/libavcodec/hevcdec.c @@ -420,7 +420,7 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) #if CONFIG_HEVC_NVDEC_HWACCEL *fmt++ = AV_PIX_FMT_CUDA; #endif -#if CONFIG_HEVC_VIDEOTOOLBOX_HWACCEL +#if CONFIG_H264_VIDEOTOOLBOX_HWACCEL *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX; #endif break; @@ -435,7 +435,7 @@ 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 +#if CONFIG_H264_VIDEOTOOLBOX_HWACCEL *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX; #endif #if CONFIG_HEVC_VDPAU_HWACCEL @@ -451,16 +451,25 @@ static enum AVPixelFormat get_format(HEVCContext *s, const HEVCSPS *sps) #endif #if CONFIG_HEVC_NVDEC_HWACCEL *fmt++ = AV_PIX_FMT_CUDA; +#endif +#if CONFIG_H264_VIDEOTOOLBOX_HWACCEL + *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX; #endif break; case AV_PIX_FMT_YUV422P: case AV_PIX_FMT_YUV422P10LE: #if CONFIG_HEVC_VAAPI_HWACCEL *fmt++ = AV_PIX_FMT_VAAPI; +#endif +#if CONFIG_H264_VIDEOTOOLBOX_HWACCEL + *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX; #endif break; - case AV_PIX_FMT_YUV420P12: case AV_PIX_FMT_YUV444P10: +#if CONFIG_H264_VIDEOTOOLBOX_HWACCEL + *fmt++ = AV_PIX_FMT_VIDEOTOOLBOX; +#endif + case AV_PIX_FMT_YUV420P12: case AV_PIX_FMT_YUV444P12: #if CONFIG_HEVC_VDPAU_HWACCEL *fmt++ = AV_PIX_FMT_VDPAU; From patchwork Mon Nov 22 21:58: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: 31545 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7668260iob; Mon, 22 Nov 2021 14:01:00 -0800 (PST) X-Google-Smtp-Source: ABdhPJxC6aaYCF2m7scp6GXWL4X9W3kjTfAmc8sUw4QpwVdvb3FHDtGtfrJgKmm3sXLNo/CqW00d X-Received: by 2002:a17:906:35d7:: with SMTP id p23mr819237ejb.32.1637618459843; Mon, 22 Nov 2021 14:00:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637618459; cv=none; d=google.com; s=arc-20160816; b=QesUSrezPlT11Dm/+s5HsEbGXHeRRbIHJlqmT+StdTPtqmFMptAGAWnPcrD43W62QM zcsnwlsvQ3JRGRRRdFMvzrQX+txAlKoCtB90pFKShAczGbgJZaREr3ICfKt1ujhPXxDd T1BEyfSXDXboIGCU1sLji7wBuE62B8auq3GqhwIzAVErsd3YWpMb5z5+2IeVr0owKo0w bnvDDucRffIufLsgdqLMdOOZdTE41OIhuqTGlJpQ8CaujwnHPzjfyOjxZWY1akP28ic2 dT5x086XW4AW7cC7kuhEXHLE+d+z0GhQmqfp93XT/ljBjyiRDp7t37V2bMgbL/HGz0xg zAog== 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=EU2giFNMdOcNKGiHIHJ9ONn802TnZv0tEErH5xOtY6Rte/kVcft6HMW5pfxG/xeX8U 0cxf7kaGHsCosweWbFwErGm38iIUrb95ial6zdqZTLT02TqIK5mV2xV51cOO2VLvd5L5 E8PA1jIfWcNl9LrTRixAG/zClh9SKYU4VZcOIkRg/9H6rpb9BNihfXsec9mcYRnpa9HV cp+k6cmm1GKUmm4NXMcbbA4gYnyidKo8bZQewS8G+DX++vhEF7Z8OV5AJlfWRkXjS0/t b7S1zK7WTIG6rPJjeEI+cab5q7XcZOzH4O+cJTtwLyIDYhC1kF6LZCgk5eVLIv14klqM YfaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=qgs1QcPE; 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 gl1si34324805ejc.433.2021.11.22.14.00.59; Mon, 22 Nov 2021 14:00:59 -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=qgs1QcPE; 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 6246B68AEB2; Mon, 22 Nov 2021 23:58:52 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f44.google.com (mail-io1-f44.google.com [209.85.166.44]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id A393368A96A for ; Mon, 22 Nov 2021 23:58:40 +0200 (EET) Received: by mail-io1-f44.google.com with SMTP id k21so25349812ioh.4 for ; Mon, 22 Nov 2021 13:58: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=1bvVu72bxky2xP7jkMzKU3R+qBcyA6ikIATVLj1l064=; b=qgs1QcPEhdBaqRWJUZqzIQ6AC9KSj/NG/qnkhwfeIoGJD3c10jaQlL16Qbg4qrPM7X kJaaTHypI36pDQuUm69VB2u23kCM4R1TJbP52OtIVbDdCWYw32ge6Y4zJrE5/fqHL0Mj JXB/fUF9oawHrdRv/6XpOU4ylgMPJrDIihDgvdrbvksN7PMtBmzrgTyEJ10IqbsH0E+3 7KMgQ2vCET4rYHcW8v8u/5f5jhBAudcFQdGYI1h8iCwUzOPAurfA7GT2bJguKVhqvK9G K8+eTCH3rizfCEQhofuX+2epcofbEvTkLK6ul56nO0V74olaMf2eDJyhzpnlNHpncUMq P7IA== 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=ozoduuU3lQPnHZkyMjqkWdXqIyAbGhhhgtYqKr0AFUSrLRn4oIqSVJDB1MIRmpODmM 834/b3ufnyf7jTr5CRgHKW4PkHHTIaBseZeke30ZAHJWl/u+j1moYJ8JdoRaPduax0Ye PIAbC8uRBbhmP9EoTtqySZcSmB+bbor6xTzB99cXyL8eqVtfTzldIQAczk0JKawIkMzG 0WhqNVIo/gvbNwu8YxvbQAYlsPHzdv1Y4r6QBzUtvNEmuDwr5u8lpFOD4b5iBX4v1IHG RyoyrzDpi6N6XWo3j+FhzxZDLK70zQ75U6ARsyYh+7OLGgV5DYUa+eU34L6qhOBjCjG+ cMFA== X-Gm-Message-State: AOAM533VgGbY6CykudKih//lv1tSll45dQGj3zzA+X9/fAljcQTocnL/ xURjyA68k/ZBo7jaaaZT0Guz04Lipc6w5yk= X-Received: by 2002:a05:6602:2e81:: with SMTP id m1mr41148iow.55.1637618319043; Mon, 22 Nov 2021 13:58:39 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id o1sm5668802ilj.41.2021.11.22.13.58.38 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 13:58:38 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 15:58:15 -0600 Message-Id: <20211122215821.9849-10-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122215821.9849-1-rcombs@rcombs.me> References: <20211122215821.9849-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 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: 8kMnr/AOt9zZ --- 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 21:58: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: 31550 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7668786iob; Mon, 22 Nov 2021 14:01:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJwvSluAnUh7hykNUKH3NxbswFDaZiC6spIjUy5YtwwRAO1jXAXXTr9cw3b/3mKXuRwovNpS X-Received: by 2002:a17:907:7f25:: with SMTP id qf37mr710633ejc.147.1637618481926; Mon, 22 Nov 2021 14:01:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637618481; cv=none; d=google.com; s=arc-20160816; b=rqMPEZB6Of6eXlKm1oD+DfqLmwFqvASNlrTzUVK/Ksgljtaifzjx2tAQViON/qh6Tr ymKWPNd723CZ1TOSUaU33XgX1s09LvDHimFHf7360kusdxBb056hwDaNG8tm/hzoYU1W qMBObp7y0eZnvmnJzaEzL5Tmccj01+LxdMKcJc+Wwh657BVC9Dkfa1wTr8Yp67G3vAD/ zMKhuDCH0uqgobnC0CV1KtWRug3A2q1BZXIges7lPPAEWakJrsD3H7InnR3gzwGwMExH +uBIXLcUnW8hw85dvAlISZdBMS82K0cTaf6cS+4GWoGKgGlY0FDXyU4rks/7wKMHkGoy ArFQ== 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=DLQDpWJdK/zr+bTe9Ucsp+7i+vh3zQ6/ZMAnCZqUksGsnoENGGAh+8RM4yvnfjQbrB x0iAkDLeOlrKzy28sJYG40Lu7ua1TtfN2fJQGBq/g1bPLux1oOxSstU737F+yFl6cMfp yh/C+09O18Y/3HPGoiX4rwN9YDLwrah9VUiaReciJSkjLrvUg8+oI2i8ARxTdLIHu2d8 5vNp3oaCfrWPqX2QX5hcCi8wnDyNUnoSToZ0DUANAOq54Iky3IzzTqgTsfzPKWrbN78p 4kUYXKgtQvnYo9iKauLHkg5urh+fjqsCizhaZ2eefmu2q0oGcXXPIsJXpaDFbxQgk0vY YzSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=mSUP+td6; 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 j19si28196912edj.137.2021.11.22.14.01.21; Mon, 22 Nov 2021 14:01:21 -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=mSUP+td6; 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 99FB468AEC4; Mon, 22 Nov 2021 23:58:54 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f43.google.com (mail-io1-f43.google.com [209.85.166.43]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 6C3CE68ADE7 for ; Mon, 22 Nov 2021 23:58:41 +0200 (EET) Received: by mail-io1-f43.google.com with SMTP id v23so25325433iom.12 for ; Mon, 22 Nov 2021 13:58: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=xN60GqDTodIomXLEr+wKZl0AiCIavHsu5iL1Gt5PXSM=; b=mSUP+td6rp91BTtWRQrVoHR8C/0KhqM1ESP2bo76Hi5t/HNF18zXY49y6rQuFYZrld XAnmOa4SA1jpmygnjsyH3VNqVXvsqlNwTDBiMPUBmSUC/YQ33RQF1i8LYWBF9wNh3fNa rrR+VLO7VK46XtKr5Qpmo7YS+Egi17p2erFI7iEKVMg9fw8G4TzzUiHt1OOpV6+fUztL zrO36bQ+OJ9+6XnlgcfhTi69TcmpM7dFxrH3IxZM26PKfk7QIPgEPdqZsA4yMwTQV1qZ DUCxKwdKolfr3ZmDzH6d960nv3rLQpkN9o0+v5nGbQWfmHs/OPiukyT6jrh4LI08S8Xa 45VA== 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=7OIgzpSlGx1Zg8xU8zidGVt9k+C/zMN0/3iBLzriev1JPHKkz66Rv5XiBiaUHcPBXT rLZWozCEaKO6Ulw1SBCOZuH/NneFUdDeoWkIaagBEbwmTEqCnIXH6Q5OGOXgw7N8oKTg lrVowhYxDWibclExbsQEYeJd5L+Bsm3bZC0QzrTVr3ZG6S1A3rO1QRg0JZsObc/Q9gfW gYFNg8TJ2mZlPMdiBgNIKGjfAstPaSm8lNa6VPsqTTynhjFXb9BsWJqq/1dQ67zBW6vm +59Y+FV1YqfvOeIiyecwZosSt8eMpJ4IISauEY+NWoeYGhjWZfQVjXJOf81enJR2Gp1K /vPQ== X-Gm-Message-State: AOAM530oMNKIv5Z5dKDtSOFrJr5SC/co/x4MOrnntKG2S0QOS20YDTas nCy122EfOB5MyHUeYtAx0l91sov4zCEyuIU= X-Received: by 2002:a05:6638:2689:: with SMTP id o9mr259239jat.83.1637618319887; Mon, 22 Nov 2021 13:58:39 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id o1sm5668802ilj.41.2021.11.22.13.58.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 13:58:39 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 15:58:16 -0600 Message-Id: <20211122215821.9849-11-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122215821.9849-1-rcombs@rcombs.me> References: <20211122215821.9849-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 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: XYBjaDqa5XFr 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 21:58: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: 31583 Delivered-To: andriy.gelman@gmail.com Received: by 2002:ab0:6957:0:0:0:0:0 with SMTP id c23csp7338264uas; Mon, 22 Nov 2021 13:59:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJy+YfNzK6uBi5EXps0HPLvlcyjxGU6tkLLl9528brCCUGhyvfoEL8atooZ1qs9GPPEXa06P X-Received: by 2002:a05:6402:11d2:: with SMTP id j18mr619142edw.318.1637618381297; Mon, 22 Nov 2021 13:59:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637618381; cv=none; d=google.com; s=arc-20160816; b=qsCs1QPZUXHRNfEGA8A9Uh+55LVb79mOECr5/ZUNJm67jF9HMtk5xckyCC85ilyzKV 60D+v1vQtPMGOrAnm7WmN97EVYC8v9TSUQoyvup2H23ziapkGh+7KVgKlEL2gxFnjOah KzTNKFmersg2DgRZqKo+Sb43hWLUw8NP0j3YE8t90IchyRlhDJOQ5yUosH0rvKSu0oKA fLxtygOZwpoYXUYFig3LAC1b24Y2UCpj8gGxTvq8zbYQ9jmpNvxGirQbk5XST1dXqxHy uW1W/5O3Px25FYpJfkKsMvH+k4GijyyvqSXqCxzVkLbbIzE54QOfG2e9x6piXBZthAFD LGWw== 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=pOYMbc7U7QbZ0Zm5HatYOYPeM3LoYQ6s9h3SEhgRZuNVcopGzH/y0NxRU16+FgiWiT jQZO5eJ3FZ0yg1K5HypE8soVaKEsyKFuW7yLJoMQGt2ypBmzLDrIirZ+Z8QhmDx0mHCz dXXKk4gjCsF/hcZAyoEYTE663PvW74JiSNcFAKd+iJ3kGci8+7ZkNTPADeYuhv+WXXX3 sTcq1pVP6GPW2S04AcV77uzzyWZHApRslufotjBmzJNBxfAqimaLzGLzRFoAAW5wHtNE DlOkbBv4QRe5Vgh+pdYFmqa2s/DmEtaiJgydGyqTQBgTu+2sw13u/XatJYfH6k65GGKZ AiXg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=Nse8EM9u; 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 hs10si28354907ejc.712.2021.11.22.13.59.40; Mon, 22 Nov 2021 13:59:41 -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=Nse8EM9u; 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 1424468AC75; Mon, 22 Nov 2021 23:58:45 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f49.google.com (mail-io1-f49.google.com [209.85.166.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 16A5168AA75 for ; Mon, 22 Nov 2021 23:58:42 +0200 (EET) Received: by mail-io1-f49.google.com with SMTP id e144so25292610iof.3 for ; Mon, 22 Nov 2021 13:58: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=S4tY74O1rWCxl5cTsOhSoStbjporJFcND2PPBXSAWto=; b=Nse8EM9uqwXykIZYWx4oM4VgEgYDd3+nyriyp8SQctkrkaozbfPTLEueuHT99wAcxb 0q7qKKiaCePFGPIRM/JlhifI7UrtOs1uK7joLEFFInS5mmkFVUger8gJPNCsJimDQqJQ 2dd9GvnfbFPwiOa7RgvnZqyknSgCqhUNlQDhtW9VaMP53O+PS+ia22CK+UrWaRHLNCxd EakfAhffJSGpxJxUz+pv50mHhltG/N3nyFtTfmg8oXWnNTO8FuINPIhn9eWcfsO0kydl Pr2t6v3++m6ezw6W+R95w9aR+H7OkVwjvjmOqQKLT02snvJtX6jKMfq5xR1HANd0HViY dRhA== 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=H2fMmsR07aQCCosphMym/oT1dR+3j7mbA51LfME2nX3wSRbtdwufwTGCICpJ1ZorVR jQUvZ5x89/757pmlp4RHSqMIEQVAjBGhWo0SwY3y4SGnuDnpbiZaZHIHs6LvUXVRwk80 RafTlwuOZ9Zo+wbp/9qh4dyXEvjIQGLLO2AinN9GJ5lKMlqp/LmhpZ+HnTWCxnsZYCHq meYGpLjSAwxWW4SNmx4hdrIYQ1gPp9NEw544wAbPwUj/W3gsJu3Z6EUbxgJ1VCCJjMCN nEz8QWzPEqjL0614mgTeUf1ws27HiMug+Zf3yJn7uGq+LKZ+Z74H0kKOYsdBzH3M5sa7 /wAA== X-Gm-Message-State: AOAM530ALG/pOoXyU8T5n7lB6xLVCZRDv/A37uQHrSzAWETG0i97P6OA ZdFccwisp8//b9Dr4XPXkQwtHl9vjhFESuY= X-Received: by 2002:a02:a314:: with SMTP id q20mr341082jai.104.1637618321013; Mon, 22 Nov 2021 13:58:41 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id o1sm5668802ilj.41.2021.11.22.13.58.39 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 13:58:40 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 15:58:17 -0600 Message-Id: <20211122215821.9849-12-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122215821.9849-1-rcombs@rcombs.me> References: <20211122215821.9849-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 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: A4rwS6KqGKRv Content-Length: 12276 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 21:58: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: 31549 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7667091iob; Mon, 22 Nov 2021 14:00:07 -0800 (PST) X-Google-Smtp-Source: ABdhPJwIZEmseGST+9inI6HZRPdcBt8dIJ080I1jL4Nxh+KtHGcR934oXno8sicwTkxtgLIqirFj X-Received: by 2002:a17:907:8a13:: with SMTP id sc19mr790569ejc.130.1637618407120; Mon, 22 Nov 2021 14:00:07 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637618407; cv=none; d=google.com; s=arc-20160816; b=mG4HFobvlxkD7yRghWgh1lE8pFSzuOV07U0SOlDriAhpZRKcN3w+0NW+WCjBt7waAH JoNGkiRLp2OrC3jKffiUoSu154Mr7ZbV1jy2bkXAGWSSBpLqJmucoay9R6V0I8rUa+fV 1nX0wI5PMlEOcZibRb4J3dzQ5aZwbZWnkniLYPv0wsB7be23YR9ZkJyh1zeaBEWpd/3O qRUi+L0sbu0+XdEsq8r3xwdtyzPSYMvoJOJi2Lm8e44S/FfbDYVlRLIa2UhLXXafXF7s x6Co2PvVPmKTvE2tO3mxsVTx/S/3nwkF0zL99jx+wX6XErN8SlyzmEpzqSu261CO3Ced zZRQ== 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=QR9sCIIe4pEFXiAIyi0kjUEUXIwaq07jxWmpPiQ9kL8xF30mqp24KrNwJJwSIVyx4t dwNbQDYg8HW1ktnwj7FAD7u9j1fM5WDrDL0Nhfy4AY/BoHw8p00zQVQR9Q6Ys03KgB6z 5J39h4qHKbDbUQ6Ts39Vg4zZ2OulDOj1pNayXcpesJlGqd6UoIqfwiZdTeDdcqoVUrnm fIyQ0PPmPf9Q890thN3mDFEawyoAP2tFjSX/stv+DHPHHaUJcRh48rxxjIDi9NyWtS6l XItZjunJKyz1vNGzLOPq2+WuDXyttxf1QLELxz64ZhsVCttbhLTxdnH+EI1Iq4Old4Ja Aggw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=BjOFRkZS; 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 z6si34515413edd.85.2021.11.22.14.00.06; Mon, 22 Nov 2021 14:00:07 -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=BjOFRkZS; 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 97C1068AA83; Mon, 22 Nov 2021 23:58:47 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-il1-f169.google.com (mail-il1-f169.google.com [209.85.166.169]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id F15FE68ADEE for ; Mon, 22 Nov 2021 23:58:43 +0200 (EET) Received: by mail-il1-f169.google.com with SMTP id w15so19645630ill.2 for ; Mon, 22 Nov 2021 13:58: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=E25XfZk/aICizzjL0V5qNgzhaRSzJjV1KMphiW2eKVE=; b=BjOFRkZSs2NQ7TZgEWN8IHN96BmEz1uUS5dR94yoOPZJHPeFeTr25uosJG5ozbvMfN Zsq7EJqcf1KLD8ae1p8dRPWvW4QULtSNaaIgP5ZJXqeZPxQ0fcfnOiM8VSd/ub+oSSwV 7hNteCNbk9ZAkh7UB3Q84qkP8jmZFHqnOy5eNWozlmJ7k3upVk5WHc6Upvk7ndYp1wmv UFLUXJLGIadQeSDN2lITu57mRRUmCrxmdPqTj3o0jbrt9gyxYymS/0iUtcGhgcvbTlYD FrRMRL8DST2ZvyIaUDfmLdH9tQWupxz5/N+YqPC3GcGAf4y/oCf8PjOuYKJeHeW26m/0 +xNQ== 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=k2v0gWn+R2B9HH8eVPqndlffYfTM/vWnJJWge932p6J/SxewLH8DhxhFKW/Kkv+9oh FwGUL47ScyE/L72yKgyj38xr74LojSk7TSqwKAp81XCxmvuA2L4UnJdfnsodj1y+OJaX MRI4VvDsy0JR32R5iUD/DBkZQGaRfxtIuiJGYHmfTOQ1ghfOMwi1ZwAOEcgRqrJH4Bk8 nuJuVl9WWQxmaxiFg3ZfJ/ZgV0m3EvAI+tMEmJwM329T1bB+TP63DC8AzAorqV6Vwqp7 7iIjHVhWVRQ+AGj4OErkQeIDmSEypj9/TAE8b3a0Al9MoTvEH4FVbvCAZVbqOZqMR+SB b6ew== X-Gm-Message-State: AOAM533jIUPa0mA8Le4m9koh4yWHtEF/ZjqySi98n/JVmUD5wB5k7JCB HbTSMpd3kLNXFcAZ4Amx9KoqK3hiPsacehM= X-Received: by 2002:a05:6e02:1bc3:: with SMTP id x3mr193149ilv.39.1637618322090; Mon, 22 Nov 2021 13:58:42 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id o1sm5668802ilj.41.2021.11.22.13.58.41 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 13:58:41 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 15:58:18 -0600 Message-Id: <20211122215821.9849-13-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122215821.9849-1-rcombs@rcombs.me> References: <20211122215821.9849-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 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: B3ikB/HOeCbB --- 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 21:58: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: 31551 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7667547iob; Mon, 22 Nov 2021 14:00:30 -0800 (PST) X-Google-Smtp-Source: ABdhPJxILLgrPi+jfElrTdZr5Xn5Xurwr9T1SlmRy7WugNAn9Gxjo2SCluiMv4e3qZmnPce4VSwV X-Received: by 2002:a05:6402:2806:: with SMTP id h6mr666354ede.120.1637618430571; Mon, 22 Nov 2021 14:00:30 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637618430; cv=none; d=google.com; s=arc-20160816; b=OYor6flGmESI4MKihXTvAWQX6t4O+npMotlrmMLHF3rOuhbDj7pYa25te2x2CpChY/ hqVUshwmr2jKXu5CqWpa9z0SNvOTSeIYKZjzPYh+KDzdHfGygH5ikBGjqCkSt6EfBGTe RlZRDuoh+QKBt+nydejxcpoGcGIvjRsqWZ3TA1bfg9GmGT4xDjggwOheeZqJkruCtwAG Uqzkgm0j1WwPJHiXxK/szofhyGYv6fdsONejP+oGrUX9irE+3jQnpczA8lZpVVEDhA/O JR7f/sJf92PUWxL6D2d5NnyWuLPRsoT4x/3Znpc3FOeNX9imB0an6fpON3md57aKOH/v OLfg== 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=JrpInMxIMGGSzuUMqVVwMOgoJbcDFvXhzc67+OEePa7d/P7amnkGWQHckombDI6kpQ R5+R0Ek6pW7/c+VzML42+ErWfI1W59jAWm6nSdPX8Hyfc5Xllxc1bNXtTtRk75JMGNpq pmHLGgWPRyFiQjEZxBR03xTvS7O/VKuE718B6GAd2BNpKmgECAi3M/ufYhtvCqOXSjt3 tLc57DuDVH1agGRpdFtSPxQ3303jvE8w8hESCn5HtCdTinGAPDSgLNK9plRfBmPwDYUT xpKoKnGRvL5UT5bBwLGCK03ODBx11/x57ZXudvX66yMiyVEzao22obz/qIrrSaZoTx0W hmPQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=Nj0Zdc0K; 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 s24si24548904ejd.339.2021.11.22.14.00.30; Mon, 22 Nov 2021 14:00: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=Nj0Zdc0K; 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 8883168AE59; Mon, 22 Nov 2021 23:58:49 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f50.google.com (mail-io1-f50.google.com [209.85.166.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id BD8D268AE59 for ; Mon, 22 Nov 2021 23:58:44 +0200 (EET) Received: by mail-io1-f50.google.com with SMTP id x10so25337017ioj.9 for ; Mon, 22 Nov 2021 13:58: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=zz+HQHPSZK+EjF/L2hCcqBg66cCuZTNzMLSYw+djs8Y=; b=Nj0Zdc0KY5TCLf/K4fia3FEHij8gfrbDmntTNSjTTs7g/jPVfGSp5a3j/wTA7aBb83 Wbb0A1QJhGlCTPujdFBIwIFqu4NkZiKMMnyfhD98hqJj6+dAOlHh9ehL2Mm5Cv5CgGSN 9QVP/TdvwiYNT5AEOGTkVUb1gC5o0AgWO+9A83BKjd+NTobYox1t3QOwWzU2zuDUR/2g VqrDeU885vCsJPuA2w6ET5knlHSQ/YcnMMI1mIQS9mC1I/TJQZfKdHDVurXpaCS771ck 9iszznAdAnxBIIP8g+xxsWcb8bNCsocXXZBMZjmj6pde4RAZRFi/jREUlVkRm30S70mI +u+g== 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=tnfVceyMJ/K/2rb96VErrcEQSjfIPjAL07BilWZrxfrotXVO4ooBm8VJlAx8jqX/eL aIJjrmYrb2e7cKBX4KX4R6C3v+zO/ZxyoWyJo7aTm3GBUCJgI1Ye1O7TdHY/qRA5QZC1 IcJWKbGqT9Aydr/LSZeNPR2JGgiXB0Ph8/uJiuYf+x22LkuJ1DslNXjEChT3Ob2LTp72 hKokJDslwOdfOiX6OkPOAow8S4IZwgPdqHHFHcYnliH4qs9dAx8fUlHSqgg/I8ATSiJr XHDqr9cuVaD2ICVxbgxTM8OjcQHSpIXwkQJ0M1Cf7sA1bWTKHbcMHa7GDV4W3TiQz/5j R9yg== X-Gm-Message-State: AOAM531VNXwTTJ2XLGH6yjuB6grUPel/uS6F24eZQPdEB37narE+Bf/R cdHZtHIwMYu0V49DhGeQ4QajN+lniHpPbfQ= X-Received: by 2002:a05:6602:1604:: with SMTP id x4mr107813iow.84.1637618322766; Mon, 22 Nov 2021 13:58:42 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id o1sm5668802ilj.41.2021.11.22.13.58.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 13:58:42 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 15:58:19 -0600 Message-Id: <20211122215821.9849-14-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122215821.9849-1-rcombs@rcombs.me> References: <20211122215821.9849-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 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: cgj0+Ol/OJaS --- 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 21:58: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: 31546 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7668066iob; Mon, 22 Nov 2021 14:00:50 -0800 (PST) X-Google-Smtp-Source: ABdhPJw4ySd4LbMIOAD4jlCeVd4V6g8jXc54qhyF88HWS0nyN/vxuQkCoz/yo1GioAmM5C8Lt77K X-Received: by 2002:a17:907:dab:: with SMTP id go43mr645411ejc.537.1637618450815; Mon, 22 Nov 2021 14:00:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637618450; cv=none; d=google.com; s=arc-20160816; b=inRZU0yTR1tsrh6MPSiSW5YYSNcAgIuJ8w4rjGQmPT29URdcYO8V/firNbV/noiX1d qQcP4OGo+TaVArWrugOBn/OLuvXbUjDe8eKYU0kHsQ5+0sGFGCsVAl0aoO+jn39SWzoK y+zKg6t1XGbLQ5FK95bfoy2N/1E5YxLkGJvZyD9O+jhcZGHHHPKPoABrmDy0kuCHEtnM zaEXAc/MaLHNXbYYsSy6EddpoXIP0nGtayzYg9hTPeZc869JbEKd/HlZ77uOcqaXvKhu n+MrRjxeQH9tSwcPrZAUW1HaTPzuVe1P1KwmZQwDxci8qwi71tcnn2bf13Vwd7efRS6y r0xw== 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=EZevc3kaluS0/oUrE8HROQZq+p746ReJ4cyzQlugeBRp5A0LL2XBWS1McVafvnZGJX mI1MHbDezQ7cIt/KDORY2MYzKRxj6icLKrAXXqXJnbvuZ38B4A7uEYrCHlKVorV1/9Zm pk1fDsFieKx/+h9teIRtAtv5Nj+jTU4vLwLdOqQtaxvc0o1xJkm7vwXYqwhg5OlViFjv Bc/lA1AY4xCj0gnuJrKgRqsLJZqUoU+rdI4yIA68BGyKhUJJQqtDwSHjyYtoqx1GfjEW 3KLcc3o+NruVOX8GDy30RON9xyFG/HL8mZGEfIpO8HPzeOe3K514fjNCteJbAevoxKa1 HY1Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=T+EYoSVg; 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 q23si21926658edw.289.2021.11.22.14.00.48; Mon, 22 Nov 2021 14:00:50 -0800 (PST) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b=T+EYoSVg; 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 7BF4C68AC4D; Mon, 22 Nov 2021 23:58:51 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f49.google.com (mail-io1-f49.google.com [209.85.166.49]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 3A0E368AE68 for ; Mon, 22 Nov 2021 23:58:45 +0200 (EET) Received: by mail-io1-f49.google.com with SMTP id c3so25391349iob.6 for ; Mon, 22 Nov 2021 13:58: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=fu55E76kt4YRwjp34oQVtylB7Mnd5wNBLpEZClGcfpU=; b=T+EYoSVgXrPqbTeqMWxepAgJdJBnoHQTDEM69r/ZXSsfeDWbv9fv28Iyoh3Nle8KrI Jm4OtUIKnRHxV7vl2e0EcV7mH2HFchHf0cPj5gD7g38/VbqV5cOEfcjNVsB33FpSfj3W Yy9dyM8Ol4aokt4BXmHJUL5Wr03oCA3RzI1iQWHff7XnQYVlTznQdf8POosWRHJvnbIW AwC+PowH9by+o0FeffP94C4uN+jcz6PDYMK5g8OuTeOivQCX3oYsJbznGiVHjBgqKCIn W2x+E74MFzfusds8dwRWl1JSXw/xKHbpGW0i9Tgr84apcKsUQK33z2/WJZT6tcRj4JCb bCaw== 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=zhogp6Cu3/rZkzl3cC82D10H5UHbM7cB7r6kuZN8TUoBv9lAUxn7O+d+ez0jKTWmyM b4M/sFtKgr8RqdgwTGGb8rg1Lg/MZsG6cN2z/bRl62B1AuFg/hikIb3Hnejn/njlX5ar NDF/MRZcjtWJRBf3h8WIM4cmU3lP0U6yZqJPsN6VoM+jo0h/gdIDT7/2T9nmZI0HCQjk CvD/RbV2ry9riUgpT4caO4xFaGEupLU02ChcXeXHPc7lFq6vgG56A1l0dUSJfY6+1eb+ 0XkUoH11Zj56sH7qH54skrHe5zo1531BYWBV3L2M/EAni5YF74Va20D6F406uBqLzKLS 6LuA== X-Gm-Message-State: AOAM532Mphtm0G1URjuPrqGtsgZRYAStvoT+MzmXdkIPulQth7EJRcJW DefxvUuLtbi36I+Qme5yr6sYpELZnS9vh/c= X-Received: by 2002:a02:ab8f:: with SMTP id t15mr251437jan.147.1637618323586; Mon, 22 Nov 2021 13:58:43 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id o1sm5668802ilj.41.2021.11.22.13.58.42 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 13:58:43 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 15:58:20 -0600 Message-Id: <20211122215821.9849-15-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122215821.9849-1-rcombs@rcombs.me> References: <20211122215821.9849-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 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: 7MPJZdmURGah --- 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 21:58: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: 31548 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:d206:0:0:0:0:0 with SMTP id q6csp7668563iob; Mon, 22 Nov 2021 14:01:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJya2hSmJWPFdJNUOWu5YcQYrrgiKTzaZLtsaRNJFAiy4Yl6c6DSjVreydgpaXl8DZSKcvGv X-Received: by 2002:a17:907:6e91:: with SMTP id sh17mr827343ejc.86.1637618471966; Mon, 22 Nov 2021 14:01:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1637618471; cv=none; d=google.com; s=arc-20160816; b=R1r7mQLUYCFvpwOrQlqan9PL+xkQ9ZN4fEJ8K4+cZyySRX7xvpgJ/TNryqr2wJCAbS ocs+a3iIrYGhUpZt5/yEuX2wA5D5sFaA3/YRUs0yJSd601i10WJGMpplIkL1wT96XLUU yFz9NQBEggXhfhDsRx1iBHPHyvHmEhl4CoyII4HQiyFUwL5UVUe5N/r2RKw8oiPEGw8w vbxbD67wnrDQSVCWv/LBMcEv7nFn6b/4lWq/biLVvzRxw8NFib16maNwX9q2WqikmPRb l9xKRq8RXowXOFCbyrMQDsQhDECx7oDoaZ+JKb+KKxytOPaPagvzxI4biVbN7zt8aBSC RAkA== 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=Pv5GlZPBXRAmzGV10S7yQoOSlTD0RG5v187P9XYU5aLVuru9VHdFkTjoNbjnkqndjo l74XoBiNAUU1V52OVaCcbdE7yuvZ821ELh0VXZ3rknwrwaLGdxONXM8U0PkxrQBwcDAQ ZfZbMyj0GCNpyk14R+ACajpAUjRrMTCb1oObZ8Ezx7zT/xET8PqQXo3x1rfTaNZPm6ek ajGm/YF+Ht1iax5XR64k/5bPJIOvRwpX3DcEeuFUEhOPybL+ETVTuGU5y3gGGuez1A14 +GOkG8YxLoHKb6d65cKm3J9rivzhmI1qclJRSVV3aCzp/SB4c1pBniXBJVs8xXrmK1Zs W5hg== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@rcombs.me header.s=google header.b="BVVn6d/+"; 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 nc26si32613149ejc.455.2021.11.22.14.01.10; Mon, 22 Nov 2021 14:01:11 -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="BVVn6d/+"; 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 73DFC68AEBD; Mon, 22 Nov 2021 23:58:53 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io1-f48.google.com (mail-io1-f48.google.com [209.85.166.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 50B2D68AA83 for ; Mon, 22 Nov 2021 23:58:46 +0200 (EET) Received: by mail-io1-f48.google.com with SMTP id x6so3597860iol.13 for ; Mon, 22 Nov 2021 13:58: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=NAxq2hPqc9TaWGwvUQRFri1BLWwUNluwDg77I8VDTjs=; b=BVVn6d/+1sao3tqXGeJ3dKM95mNNECPRMZIP1xgJ+N7cjx8wn4tqkeJSBTa7KAnaFW j7TyswLXROGGfqcijFX/hH+0XUnkW8URs2U0HoSQicMUj8yTb5oqFLuhZ4bCTWYetol/ sGq9CG+biaKzBOv8PpkX6wCtabBHmxugVP3aXiV+q4ll51+WW0gAeR843MyfGgHBkZB0 XU71HOlhrS7KXYRcHJE+8U2CvhVQ+huWUeoAiuo1YWXOKjZtCPDZbXWiALry6pXauMB2 hpmuW81u7U3J68W79OyqdASK5Q/21J5CaNPZLtNY2bXLOX/ZywfyEghAJJESe/oMHsKv j5qA== 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=d6Y8btlBA5vMnJDpEsPScuw0kxvcXika8sK19dZ+/HKzB+7Ka+XvULJJppuoFG8AQP hM/IbmIRKf3wyn02LfUffA+tgwdtQuqyaFLClcqBptBADP6O5ikyQ+5VLPv63DLMavsA Q1faNWcoj090OUhltggEe3aeImyYJWTPGdDDTiGHEZhOhX/Spv+D5/wsUvlGzKkm/BZz PfUJx2ZjlUR2em5GLOP7k9oWIda7O7eAG5EB8pJjFS4ThaHLZc6Xg2NoqXhZ4HAwLV3a 4r0oXbD1//ZO96r8glqYIx4QkLLLJ8I0uZUHuZtNJVRhjAA942QHUsN3eVGN5Yg09W6J MyWA== X-Gm-Message-State: AOAM532vMVaLrdChDPbwwb+FT+fYgJG3GjyYiTw9aZoXKM92AlW6tQji o3nM8/TjEDIUfKXnTVRu9F1nVBy9MxQmf7g= X-Received: by 2002:a05:6638:13d5:: with SMTP id i21mr281220jaj.79.1637618324327; Mon, 22 Nov 2021 13:58:44 -0800 (PST) Received: from rcombs-mbp.localdomain ([2601:243:2000:5ac:edf5:499:2479:42a8]) by smtp.gmail.com with ESMTPSA id o1sm5668802ilj.41.2021.11.22.13.58.43 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Mon, 22 Nov 2021 13:58:43 -0800 (PST) From: rcombs To: ffmpeg-devel@ffmpeg.org Date: Mon, 22 Nov 2021 15:58:21 -0600 Message-Id: <20211122215821.9849-16-rcombs@rcombs.me> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20211122215821.9849-1-rcombs@rcombs.me> References: <20211122215821.9849-1-rcombs@rcombs.me> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 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: 2dMJbFOpGUG1 --- 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, \