int vda_init(AVCodecContext *s) { InputStream *ist = s->opaque; int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; VDAContext *vda; int ret; vda = av_mallocz(sizeof(*vda)); if (!vda) return AVERROR(ENOMEM); ist->hwaccel_ctx = vda; ist->hwaccel_uninit = vda_uninit; ist->hwaccel_retrieve_data = vda_retrieve_data; vda->tmp_frame = av_frame_alloc(); if (!vda->tmp_frame) { ret = AVERROR(ENOMEM); goto fail; } ret = av_vda_default_init(s); if (ret < 0) { av_log(NULL, loglevel, "Error creating VDA decoder.\n"); goto fail; } return 0; fail: vda_uninit(s); return ret; }
static int Setup( vlc_va_t *va, AVCodecContext *avctx, vlc_fourcc_t *p_chroma ) { av_vda_default_free(avctx); (void) va; *p_chroma = VLC_CODEC_UYVY; return (av_vda_default_init(avctx) < 0) ? VLC_EGENERIC : VLC_SUCCESS; }
int videotoolbox_init(AVCodecContext *s) { InputStream *ist = s->opaque; int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR; int ret = 0; VTContext *vt; vt = av_mallocz(sizeof(*vt)); if (!vt) return AVERROR(ENOMEM); ist->hwaccel_ctx = vt; ist->hwaccel_uninit = videotoolbox_uninit; ist->hwaccel_retrieve_data = videotoolbox_retrieve_data; vt->tmp_frame = av_frame_alloc(); if (!vt->tmp_frame) { ret = AVERROR(ENOMEM); goto fail; } if (ist->hwaccel_id == HWACCEL_VIDEOTOOLBOX) { #if CONFIG_VIDEOTOOLBOX if (!videotoolbox_pixfmt) { ret = av_videotoolbox_default_init(s); } else { AVVideotoolboxContext *vtctx = av_videotoolbox_alloc_context(); CFStringRef pixfmt_str = CFStringCreateWithCString(kCFAllocatorDefault, videotoolbox_pixfmt, kCFStringEncodingUTF8); vtctx->cv_pix_fmt_type = UTGetOSTypeFromString(pixfmt_str); ret = av_videotoolbox_default_init2(s, vtctx); CFRelease(pixfmt_str); } #endif } else { #if CONFIG_VDA if (!videotoolbox_pixfmt) { ret = av_vda_default_init(s); } else { AVVDAContext *vdactx = av_vda_alloc_context(); CFStringRef pixfmt_str = CFStringCreateWithCString(kCFAllocatorDefault, videotoolbox_pixfmt, kCFStringEncodingUTF8); vdactx->cv_pix_fmt_type = UTGetOSTypeFromString(pixfmt_str); ret = av_vda_default_init2(s, vdactx); CFRelease(pixfmt_str); } #endif } if (ret < 0) { av_log(NULL, loglevel, "Error creating %s decoder.\n", ist->hwaccel_id == HWACCEL_VIDEOTOOLBOX ? "Videotoolbox" : "VDA"); goto fail; } return 0; fail: videotoolbox_uninit(s); return ret; }