mirror of
https://git.ffmpeg.org/ffmpeg.git
synced 2026-06-11 08:13:06 +00:00
lavc: add ProRes RAW videotoolbox hwaccel
This commit is contained in:
committed by
Lynne
co-authored by
Lynne
parent
3b9ab7f119
commit
239c679c54
@@ -10,6 +10,7 @@ version <next>:
|
||||
- transpose_cuda filter
|
||||
- Add AMF Frame Rate Converter (vf_frc_amf) filter
|
||||
- SMPTE 2094-50 metadata support and passthrough
|
||||
- ProRes RAW VideoToolbox hwaccel
|
||||
|
||||
|
||||
version 8.1:
|
||||
|
||||
@@ -3501,6 +3501,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"
|
||||
prores_vulkan_hwaccel_deps="vulkan spirv_compiler"
|
||||
|
||||
@@ -69,6 +69,7 @@ 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_vulkan_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;
|
||||
|
||||
@@ -314,6 +314,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,
|
||||
@@ -573,6 +576,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
|
||||
},
|
||||
|
||||
@@ -38,6 +38,7 @@
|
||||
#include "hwaccel_internal.h"
|
||||
#include "mpegvideo.h"
|
||||
#include "proresdec.h"
|
||||
#include "prores_raw.h"
|
||||
#include <Availability.h>
|
||||
#include <AvailabilityMacros.h>
|
||||
#include <TargetConditionals.h>
|
||||
@@ -844,7 +845,10 @@ static CFDictionaryRef videotoolbox_decoder_config_create(CMVideoCodecType codec
|
||||
&kCFTypeDictionaryValueCallBacks);
|
||||
|
||||
CFDictionarySetValue(config_info,
|
||||
codec_type == kCMVideoCodecType_HEVC ?
|
||||
avctx->codec_id == AV_CODEC_ID_HEVC
|
||||
|| avctx->codec_id == AV_CODEC_ID_PRORES
|
||||
|| avctx->codec_id == AV_CODEC_ID_PRORES_RAW
|
||||
?
|
||||
kVTVideoDecoderSpecification_EnableHardwareAcceleratedVideoDecoder :
|
||||
kVTVideoDecoderSpecification_RequireHardwareAcceleratedVideoDecoder,
|
||||
kCFBooleanTrue);
|
||||
@@ -947,6 +951,9 @@ static int videotoolbox_start(AVCodecContext *avctx)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case AV_CODEC_ID_PRORES_RAW :
|
||||
videotoolbox->cm_codec_type = av_bswap32(avctx->codec_tag);
|
||||
break;
|
||||
case AV_CODEC_ID_VP9 :
|
||||
videotoolbox->cm_codec_type = kCMVideoCodecType_VP9;
|
||||
break;
|
||||
@@ -958,7 +965,7 @@ static int videotoolbox_start(AVCodecContext *avctx)
|
||||
}
|
||||
|
||||
#if defined(MAC_OS_X_VERSION_10_9) && !TARGET_OS_IPHONE && (MAC_OS_X_VERSION_MAX_ALLOWED >= MAC_OS_X_VERSION_10_9) && AV_HAS_BUILTIN(__builtin_available)
|
||||
if (avctx->codec_id == AV_CODEC_ID_PRORES) {
|
||||
if (avctx->codec_id == AV_CODEC_ID_PRORES || avctx->codec_id == AV_CODEC_ID_PRORES_RAW) {
|
||||
if (__builtin_available(macOS 10.9, *)) {
|
||||
VTRegisterProfessionalVideoWorkflowVideoDecoders();
|
||||
}
|
||||
@@ -1190,6 +1197,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);
|
||||
@@ -1201,6 +1233,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_BAYER_RGGB16;
|
||||
|
||||
#if HAVE_KCVPIXELFORMATTYPE_444YPCBCR16BIPLANARVIDEORANGE
|
||||
if (depth > 10)
|
||||
return descriptor->log2_chroma_w == 0 ? AV_PIX_FMT_P416 : AV_PIX_FMT_P216;
|
||||
@@ -1451,4 +1486,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 */
|
||||
|
||||
@@ -86,6 +86,7 @@ static const struct {
|
||||
#if HAVE_KCVPIXELFORMATTYPE_422YPCBCR8_YUVS
|
||||
{ kCVPixelFormatType_422YpCbCr8_yuvs, false, AV_PIX_FMT_YUYV422 },
|
||||
#endif
|
||||
{ 'bp16'/*kCVPixelFormatType_16VersatileBayer*/, false, AV_PIX_FMT_BAYER_RGGB16},
|
||||
};
|
||||
|
||||
static const enum AVPixelFormat supported_formats[] = {
|
||||
@@ -121,6 +122,7 @@ static const enum AVPixelFormat supported_formats[] = {
|
||||
AV_PIX_FMT_YUYV422,
|
||||
#endif
|
||||
AV_PIX_FMT_BGRA,
|
||||
AV_PIX_FMT_BAYER_RGGB16,
|
||||
};
|
||||
|
||||
static int vt_frames_get_constraints(AVHWDeviceContext *ctx,
|
||||
|
||||
Reference in New Issue
Block a user