static AVPixelFormat getVTBFormat(AVCodecContext *ctx, const AVPixelFormat *fmt) { Q_UNUSED(fmt) av_videotoolbox_default_free(ctx); const int ret = av_videotoolbox_default_init(ctx); if (ret < 0) return AV_PIX_FMT_NONE; return AV_PIX_FMT_VIDEOTOOLBOX; };
static int init_decoder(struct lavc_ctx *ctx, int fmt, int w, int h) { av_videotoolbox_default_free(ctx->avctx); AVVideotoolboxContext *vtctx = av_videotoolbox_alloc_context(); vtctx->cv_pix_fmt_type = kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange; int err = av_videotoolbox_default_init2(ctx->avctx, vtctx); if (err < 0) { print_videotoolbox_error(ctx->log, MSGL_ERR, "failed to init videotoolbox decoder", err); return -1; } return 0; }
static void videotoolbox_uninit(AVCodecContext *s) { InputStream *ist = s->opaque; VTContext *vt = ist->hwaccel_ctx; ist->hwaccel_uninit = NULL; ist->hwaccel_retrieve_data = NULL; av_frame_free(&vt->tmp_frame); if (ist->hwaccel_id == HWACCEL_VIDEOTOOLBOX) { #if CONFIG_VIDEOTOOLBOX av_videotoolbox_default_free(s); #endif } else { #if CONFIG_VDA av_vda_default_free(s); #endif } av_freep(&ist->hwaccel_ctx); }
static void uninit(struct lavc_ctx *ctx) { if (ctx->avctx) av_videotoolbox_default_free(ctx->avctx); }