From: Zhao Zhili <quinkblack@foxmail.com> To: ffmpeg-devel@ffmpeg.org Cc: Zhao Zhili <zhilizhao@tencent.com> Subject: [FFmpeg-devel] [PATCH 3/5] avcodec/videotoolbox: deprecate creating AVVideotoolboxContext by user Date: Mon, 9 Jan 2023 20:50:06 +0800 Message-ID: <tencent_D1327FAEAEF63945C32DB68C691201F5680A@qq.com> (raw) In-Reply-To: <20230109125008.13336-1-quinkblack@foxmail.com> From: Zhao Zhili <zhilizhao@tencent.com> --- libavcodec/version_major.h | 1 + libavcodec/videotoolbox.c | 35 ++++++++++++++++++++--------------- libavcodec/videotoolbox.h | 12 ++++++++++++ 3 files changed, 33 insertions(+), 15 deletions(-) diff --git a/libavcodec/version_major.h b/libavcodec/version_major.h index 12f863deb7..2c0443c4c8 100644 --- a/libavcodec/version_major.h +++ b/libavcodec/version_major.h @@ -52,6 +52,7 @@ #define FF_API_SVTAV1_OPTS (LIBAVCODEC_VERSION_MAJOR < 60) #define FF_API_AYUV_CODECID (LIBAVCODEC_VERSION_MAJOR < 60) #define FF_API_VT_OUTPUT_CALLBACK (LIBAVCODEC_VERSION_MAJOR < 60) +#define FF_API_VT_HWACCEL_CONTEXT (LIBAVCODEC_VERSION_MAJOR < 60) #define FF_API_AVCODEC_CHROMA_POS (LIBAVCODEC_VERSION_MAJOR < 60) #endif /* AVCODEC_VERSION_MAJOR_H */ 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 */ diff --git a/libavcodec/videotoolbox.h b/libavcodec/videotoolbox.h index 25a747a49f..3cd1d254ff 100644 --- a/libavcodec/videotoolbox.h +++ b/libavcodec/videotoolbox.h @@ -90,6 +90,8 @@ typedef struct AVVideotoolboxContext { int cm_codec_type; } AVVideotoolboxContext; +#if FF_API_VT_HWACCEL_CONTEXT + /** * Allocate and initialize a Videotoolbox context. * @@ -102,7 +104,9 @@ typedef struct AVVideotoolboxContext { * object and free the Videotoolbox context using av_free(). * * @return the newly allocated context or NULL on failure + * @deprecated Use AVCodecContext.hw_frames_ctx or hw_device_ctx instead. */ +attribute_deprecated AVVideotoolboxContext *av_videotoolbox_alloc_context(void); /** @@ -112,7 +116,9 @@ AVVideotoolboxContext *av_videotoolbox_alloc_context(void); * @param avctx the corresponding codec context * * @return >= 0 on success, a negative AVERROR code on failure + * @deprecated Use AVCodecContext.hw_frames_ctx or hw_device_ctx instead. */ +attribute_deprecated int av_videotoolbox_default_init(AVCodecContext *avctx); /** @@ -123,7 +129,9 @@ int av_videotoolbox_default_init(AVCodecContext *avctx); * @param vtctx the Videotoolbox context to use * * @return >= 0 on success, a negative AVERROR code on failure + * @deprecated Use AVCodecContext.hw_frames_ctx or hw_device_ctx instead. */ +attribute_deprecated int av_videotoolbox_default_init2(AVCodecContext *avctx, AVVideotoolboxContext *vtctx); /** @@ -131,9 +139,13 @@ int av_videotoolbox_default_init2(AVCodecContext *avctx, AVVideotoolboxContext * * av_videotoolbox_default_init(). * * @param avctx the corresponding codec context + * @deprecated Use AVCodecContext.hw_frames_ctx or hw_device_ctx instead. */ +attribute_deprecated void av_videotoolbox_default_free(AVCodecContext *avctx); +#endif /* FF_API_VT_HWACCEL_CONTEXT */ + /** * @} */ -- 2.35.3 _______________________________________________ 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".
next prev parent reply other threads:[~2023-01-09 12:50 UTC|newest] Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top [not found] <20230109125008.13336-1-quinkblack@foxmail.com> 2023-01-09 12:50 ` [FFmpeg-devel] [PATCH 2/5] avcodec/videotoolbox: prefer hw_frames_ctx/hw_device_ctx over hwaccel_context Zhao Zhili 2023-01-09 12:50 ` [FFmpeg-devel] [PATCH 3/5] avcodec/videotoolbox: deprecate create AVVideotoolboxContext by user Zhao Zhili 2023-01-09 12:50 ` Zhao Zhili [this message] 2023-01-09 12:50 ` [FFmpeg-devel] [PATCH 4/5] avcodec/videotoolbox: fix documents of AVVideotoolboxContext Zhao Zhili 2023-01-09 12:50 ` [FFmpeg-devel] [PATCH 5/5] avcodec/videotoolbox: don't use av_ prefix for local function Zhao Zhili
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=tencent_D1327FAEAEF63945C32DB68C691201F5680A@qq.com \ --to=quinkblack@foxmail.com \ --cc=ffmpeg-devel@ffmpeg.org \ --cc=zhilizhao@tencent.com \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: link
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