* [FFmpeg-devel] [PATCH] lavc: add ProRes RAW videotoolbox hwaccel (PR #20298)
@ 2025-08-21 3:10 wangbin via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: wangbin via ffmpeg-devel @ 2025-08-21 3:10 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: wangbin
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 <wbsecg1@gmail.com>
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 <Availability.h>
#include <AvailabilityMacros.h>
#include <TargetConditionals.h>
@@ -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".
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-08-21 3:10 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-08-21 3:10 [FFmpeg-devel] [PATCH] lavc: add ProRes RAW videotoolbox hwaccel (PR #20298) wangbin via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git