From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.ffmpeg.org (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTPS id E3C124AF21 for ; Thu, 21 Aug 2025 03:10:52 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTP id 21A7868D6BC; Thu, 21 Aug 2025 06:10:48 +0300 (EEST) Received: from c1ad6a1ecdc3 (code.ffmpeg.org [188.245.149.3]) by ffbox0-bg.ffmpeg.org (Postfix) with ESMTPS id 6F1AE68D654 for ; Thu, 21 Aug 2025 06:10:47 +0300 (EEST) MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] =?utf-8?q?=5BPATCH=5D_lavc=3A_add_ProRes_RAW_vide?= =?utf-8?q?otoolbox_hwaccel_=28PR_=2320298=29?= 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: , From: wangbin via ffmpeg-devel Reply-To: FFmpeg development discussions and patches Cc: wangbin Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Message-Id: <20250821031048.21A7868D6BC@ffbox0-bg.ffmpeg.org> Date: Thu, 21 Aug 2025 06:10:48 +0300 (EEST) Archived-At: List-Archive: List-Post: PR #20298 opened by wangbin URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20298 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20298.patch >From 6f824aec76c409efd1da50dd97f947c7a19c86f1 Mon Sep 17 00:00:00 2001 From: wangbin Date: Thu, 21 Aug 2025 10:45:16 +0800 Subject: [PATCH] lavc: add ProRes RAW videotoolbox hwaccel --- Changelog | 1 + configure | 2 ++ libavcodec/hwaccels.h | 1 + libavcodec/prores_raw.c | 6 +++++ libavcodec/videotoolbox.c | 52 +++++++++++++++++++++++++++++++++++++++ 5 files changed, 62 insertions(+) diff --git a/Changelog b/Changelog index 838114934c..86a984245e 100644 --- a/Changelog +++ b/Changelog @@ -39,6 +39,7 @@ version 8.0: - ProRes RAW Vulkan hwaccel - ffprobe -codec option - EXIF Metadata Parsing +- ProRes RAW VideoToolbox hwaccel version 7.1: diff --git a/configure b/configure index e1809a3e58..c0eab1d9c5 100755 --- a/configure +++ b/configure @@ -3297,6 +3297,8 @@ mpeg4_videotoolbox_hwaccel_deps="videotoolbox" mpeg4_videotoolbox_hwaccel_select="mpeg4_decoder" prores_videotoolbox_hwaccel_deps="videotoolbox" prores_videotoolbox_hwaccel_select="prores_decoder" +prores_raw_videotoolbox_hwaccel_deps="videotoolbox" +prores_raw_videotoolbox_hwaccel_select="prores_raw_decoder" prores_raw_vulkan_hwaccel_deps="vulkan spirv_compiler" prores_raw_vulkan_hwaccel_select="prores_raw_decoder" vc1_d3d11va_hwaccel_deps="d3d11va" diff --git a/libavcodec/hwaccels.h b/libavcodec/hwaccels.h index 4b205d386e..40fdf60d37 100644 --- a/libavcodec/hwaccels.h +++ b/libavcodec/hwaccels.h @@ -67,6 +67,7 @@ extern const struct FFHWAccel ff_mpeg4_vaapi_hwaccel; extern const struct FFHWAccel ff_mpeg4_vdpau_hwaccel; extern const struct FFHWAccel ff_mpeg4_videotoolbox_hwaccel; extern const struct FFHWAccel ff_prores_videotoolbox_hwaccel; +extern const struct FFHWAccel ff_prores_raw_videotoolbox_hwaccel; extern const struct FFHWAccel ff_prores_raw_vulkan_hwaccel; extern const struct FFHWAccel ff_vc1_d3d11va_hwaccel; extern const struct FFHWAccel ff_vc1_d3d11va2_hwaccel; diff --git a/libavcodec/prores_raw.c b/libavcodec/prores_raw.c index b2aa97ddda..c150d3e915 100644 --- a/libavcodec/prores_raw.c +++ b/libavcodec/prores_raw.c @@ -317,6 +317,9 @@ static enum AVPixelFormat get_pixel_format(AVCodecContext *avctx, enum AVPixelFormat pix_fmts[] = { #if CONFIG_PRORES_RAW_VULKAN_HWACCEL AV_PIX_FMT_VULKAN, +#endif +#if CONFIG_PRORES_RAW_VIDEOTOOLBOX_HWACCEL + AV_PIX_FMT_VIDEOTOOLBOX, #endif pix_fmt, AV_PIX_FMT_NONE, @@ -531,6 +534,9 @@ const FFCodec ff_prores_raw_decoder = { .hw_configs = (const AVCodecHWConfigInternal *const []) { #if CONFIG_PRORES_RAW_VULKAN_HWACCEL HWACCEL_VULKAN(prores_raw), +#endif +#if CONFIG_PRORES_RAW_VIDEOTOOLBOX_HWACCEL + HWACCEL_VIDEOTOOLBOX(prores_raw), #endif NULL }, diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c index ccba249140..e0a93d349e 100644 --- a/libavcodec/videotoolbox.c +++ b/libavcodec/videotoolbox.c @@ -37,6 +37,7 @@ #include "hwaccel_internal.h" #include "mpegvideo.h" #include "proresdec.h" +#include "prores_raw.h" #include #include #include @@ -946,6 +947,14 @@ static int videotoolbox_start(AVCodecContext *avctx) break; } break; + case AV_CODEC_ID_PRORES_RAW : + switch (avctx->profile) { + case AV_PROFILE_PRORES_RAW: // kCMVideoCodecType_AppleProResRAW + case AV_PROFILE_PRORES_RAW_HQ: // kCMVideoCodecType_AppleProResRAWHQ + videotoolbox->cm_codec_type = av_bswap32(avctx->codec_tag); + break; + } + break; case AV_CODEC_ID_VP9 : videotoolbox->cm_codec_type = kCMVideoCodecType_VP9; break; @@ -1181,6 +1190,31 @@ static int videotoolbox_prores_end_frame(AVCodecContext *avctx) return ff_videotoolbox_common_end_frame(avctx, frame); } +static int videotoolbox_prores_raw_start_frame(AVCodecContext *avctx, + const AVBufferRef *buffer_ref, + 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_raw_decode_slice(AVCodecContext *avctx, + const uint8_t *buffer, + uint32_t size) +{ + return 0; +} + +static int videotoolbox_prores_raw_end_frame(AVCodecContext *avctx) +{ + ProResRAWContext *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) { int depth; const AVPixFmtDescriptor *descriptor = av_pix_fmt_desc_get(avctx->sw_pix_fmt); @@ -1192,6 +1226,9 @@ static enum AVPixelFormat videotoolbox_best_pixel_format(AVCodecContext *avctx) if (descriptor->flags & AV_PIX_FMT_FLAG_ALPHA) return (depth > 8) ? AV_PIX_FMT_AYUV64 : AV_PIX_FMT_AYUV; + if (descriptor->flags & AV_PIX_FMT_FLAG_BAYER) + return AV_PIX_FMT_P416; + #if HAVE_KCVPIXELFORMATTYPE_444YPCBCR16BIPLANARVIDEORANGE if (depth > 10) return descriptor->log2_chroma_w == 0 ? AV_PIX_FMT_P416 : AV_PIX_FMT_P216; @@ -1442,4 +1479,19 @@ const FFHWAccel ff_prores_videotoolbox_hwaccel = { .priv_data_size = sizeof(VTContext), }; +const FFHWAccel ff_prores_raw_videotoolbox_hwaccel = { + .p.name = "prores_raw_videotoolbox", + .p.type = AVMEDIA_TYPE_VIDEO, + .p.id = AV_CODEC_ID_PRORES_RAW, + .p.pix_fmt = AV_PIX_FMT_VIDEOTOOLBOX, + .alloc_frame = ff_videotoolbox_alloc_frame, + .start_frame = videotoolbox_prores_raw_start_frame, + .decode_slice = videotoolbox_prores_raw_decode_slice, + .end_frame = videotoolbox_prores_raw_end_frame, + .frame_params = ff_videotoolbox_frame_params, + .init = ff_videotoolbox_common_init, + .uninit = ff_videotoolbox_uninit, + .priv_data_size = sizeof(VTContext), +}; + #endif /* CONFIG_VIDEOTOOLBOX */ -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org https://ffmpeg.org/mailman/listinfo/ffmpeg-devel To unsubscribe, visit link above, or email ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".