From 8fe4790ec8945cae52ea7600312f54e1dbdf8162 Mon Sep 17 00:00:00 2001 From: wm4 Date: Sun, 11 Aug 2013 23:23:12 +0200 Subject: video: redo hw decoding initialization, add --hwdec=auto Change how the HW decoding stuff is organized, the way it's initialized in particular. Instead of duplicating the list of supported codecs for hwaccel decoders, add a probe function which allows each decoder to report whether it supports a given codec. Add an "auto" choice to the --hwdec option, which automatically enables hardware decoding if libavcodec and/or the VO supports it. What mpv prints on the terminal changes a bit. Now it will just print a single line whether hw decoding is used or not (and nothing at all if no hw decoding at all was requested). The pretty violent fallback from hw decoding to software decoding is still quite verbose and evil-looking though. --- video/decode/vdpau_old.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) (limited to 'video/decode/vdpau_old.c') diff --git a/video/decode/vdpau_old.c b/video/decode/vdpau_old.c index e9c88b69ea..4abdafa9c0 100644 --- a/video/decode/vdpau_old.c +++ b/video/decode/vdpau_old.c @@ -223,9 +223,6 @@ static void uninit(struct lavc_ctx *ctx) static int init(struct lavc_ctx *ctx) { - if (!ctx->hwdec_info || !ctx->hwdec_info->vdpau_ctx) - return -1; - struct priv *p = talloc_ptrtype(NULL, p); *p = (struct priv) { .mpvdp = ctx->hwdec_info->vdpau_ctx, @@ -246,6 +243,14 @@ static int init(struct lavc_ctx *ctx) return 0; } +static int probe(struct vd_lavc_hwdec *hwdec, struct mp_hwdec_info *info, + const char *decoder) +{ + if (!info || !info->vdpau_ctx) + return HWDEC_ERR_NO_CTX; + return 0; +} + static void fix_image(struct lavc_ctx *ctx, struct mp_image *img) { // Make it follow the convention of the "new" vdpau decoder @@ -254,12 +259,23 @@ static void fix_image(struct lavc_ctx *ctx, struct mp_image *img) img->planes[3] = (void *)(intptr_t)rndr->surface; } -const struct vd_lavc_hwdec_functions mp_vd_lavc_vdpau_old = { +const struct vd_lavc_hwdec mp_vd_lavc_vdpau_old = { .image_formats = (const int[]) { IMGFMT_VDPAU_MPEG1, IMGFMT_VDPAU_MPEG2, IMGFMT_VDPAU_H264, IMGFMT_VDPAU_WMV3, IMGFMT_VDPAU_VC1, IMGFMT_VDPAU_MPEG4, 0 }, + .codec_pairs = (const char *[]) { + "h264", "h264_vdpau", + "wmv3", "wmv3_vdpau", + "vc1", "vc1_vdpau", + "mpegvideo", "mpegvideo_vdpau", + "mpeg1video", "mpeg1video_vdpau", + "mpeg2video", "mpegvideo_vdpau", + "mpeg2", "mpeg2_vdpau", + "mpeg4", "mpeg4_vdpau", + NULL + }, .init = init, .uninit = uninit, .allocate_image = allocate_image, -- cgit v1.2.3