aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/videotoolbox.c
diff options
context:
space:
mode:
authorZhao Zhili <zhilizhao@tencent.com>2023-01-09 20:50:06 +0800
committerZhao Zhili <zhilizhao@tencent.com>2023-01-26 23:48:16 +0800
commitd6bd980da658453e54af40387633f158e0b125af (patch)
treeaec80aa4f1ea98c66cab6ac6a11b36e8621dd03a /libavcodec/videotoolbox.c
parentade89bc6defb0c8996088d59ab0c8eb437156da5 (diff)
downloadffmpeg-d6bd980da658453e54af40387633f158e0b125af.tar.gz
avcodec/videotoolbox: deprecate creating AVVideotoolboxContext by user
Signed-off-by: Zhao Zhili <zhilizhao@tencent.com>
Diffstat (limited to 'libavcodec/videotoolbox.c')
-rw-r--r--libavcodec/videotoolbox.c35
1 files changed, 20 insertions, 15 deletions
diff --git a/libavcodec/videotoolbox.c b/libavcodec/videotoolbox.c
index acf0c79822..a3d19c4c63 100644
--- a/libavcodec/videotoolbox.c
+++ b/libavcodec/videotoolbox.c
@@ -1173,6 +1173,22 @@ static enum AVPixelFormat videotoolbox_best_pixel_format(AVCodecContext *avctx)
return AV_PIX_FMT_NV12;
}
+static AVVideotoolboxContext *av_videotoolbox_alloc_context_with_pix_fmt(enum AVPixelFormat pix_fmt,
+ bool full_range)
+{
+ AVVideotoolboxContext *ret = av_mallocz(sizeof(*ret));
+
+ if (ret) {
+ OSType cv_pix_fmt_type = av_map_videotoolbox_format_from_pixfmt2(pix_fmt, full_range);
+ if (cv_pix_fmt_type == 0) {
+ cv_pix_fmt_type = kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange;
+ }
+ ret->cv_pix_fmt_type = cv_pix_fmt_type;
+ }
+
+ return ret;
+}
+
int ff_videotoolbox_common_init(AVCodecContext *avctx)
{
VTContext *vtctx = avctx->internal->hwaccel_priv_data;
@@ -1191,7 +1207,7 @@ int ff_videotoolbox_common_init(AVCodecContext *avctx)
return AVERROR(EINVAL);
}
- vtctx->vt_ctx = av_videotoolbox_alloc_context();
+ vtctx->vt_ctx = av_videotoolbox_alloc_context_with_pix_fmt(AV_PIX_FMT_NONE, false);
if (!vtctx->vt_ctx) {
err = AVERROR(ENOMEM);
goto fail;
@@ -1371,22 +1387,9 @@ const AVHWAccel ff_prores_videotoolbox_hwaccel = {
.priv_data_size = sizeof(VTContext),
};
-static AVVideotoolboxContext *av_videotoolbox_alloc_context_with_pix_fmt(enum AVPixelFormat pix_fmt,
- bool full_range)
-{
- AVVideotoolboxContext *ret = av_mallocz(sizeof(*ret));
- if (ret) {
- OSType cv_pix_fmt_type = av_map_videotoolbox_format_from_pixfmt2(pix_fmt, full_range);
- if (cv_pix_fmt_type == 0) {
- cv_pix_fmt_type = kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange;
- }
- ret->cv_pix_fmt_type = cv_pix_fmt_type;
- }
-
- return ret;
-}
+#if FF_API_VT_HWACCEL_CONTEXT
AVVideotoolboxContext *av_videotoolbox_alloc_context(void)
{
return av_videotoolbox_alloc_context_with_pix_fmt(AV_PIX_FMT_NONE, false);
@@ -1413,4 +1416,6 @@ void av_videotoolbox_default_free(AVCodecContext *avctx)
videotoolbox_stop(avctx);
av_freep(&avctx->hwaccel_context);
}
+#endif /* FF_API_VT_HWACCEL_CONTEXT */
+
#endif /* CONFIG_VIDEOTOOLBOX */