summaryrefslogtreecommitdiffstats
path: root/video/decode/lavc.h
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2013-08-11 23:23:12 +0200
committerwm4 <wm4@nowhere>2013-08-11 23:59:18 +0200
commit8fe4790ec8945cae52ea7600312f54e1dbdf8162 (patch)
treeda448807fd64dc944387f548b5c23ec7005c59c2 /video/decode/lavc.h
parentcdf4b7d2ee666a2b4635bd9eacce7e1a414dd7c2 (diff)
downloadmpv-8fe4790ec8945cae52ea7600312f54e1dbdf8162.tar.bz2
mpv-8fe4790ec8945cae52ea7600312f54e1dbdf8162.tar.xz
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.
Diffstat (limited to 'video/decode/lavc.h')
-rw-r--r--video/decode/lavc.h32
1 files changed, 28 insertions, 4 deletions
diff --git a/video/decode/lavc.h b/video/decode/lavc.h
index 3611530400..94973cb2d8 100644
--- a/video/decode/lavc.h
+++ b/video/decode/lavc.h
@@ -10,10 +10,19 @@
#include "demux/stheader.h"
#include "video/mp_image.h"
+// keep in sync with --hwdec option
+enum hwdec_type {
+ HWDEC_AUTO = -1,
+ HWDEC_NONE = 0,
+ HWDEC_VDPAU = 1,
+ HWDEC_VDA = 2,
+ HWDEC_CRYSTALHD = 3,
+};
+
typedef struct lavc_ctx {
AVCodecContext *avctx;
AVFrame *pic;
- struct hwdec *hwdec;
+ struct vd_lavc_hwdec *hwdec;
enum PixelFormat pix_fmt;
int do_hw_dr1;
int vo_initialized;
@@ -35,16 +44,31 @@ typedef struct lavc_ctx {
struct mp_image_pool *non_dr1_pool;
} vd_ffmpeg_ctx;
-struct vd_lavc_hwdec_functions {
- // If not-NULL, a 0 terminated list of IMGFMT_ formats. Only one of these
- // formats is accepted when handling the libavcodec get_format callback.
+struct vd_lavc_hwdec {
+ enum hwdec_type type;
+ // If non-NULL: lists pairs software and hardware decoders. If the current
+ // codec is not one of the listed software decoders, probing fails.
+ // Otherwise, the AVCodecContext is initialized with the associated
+ // hardware decoder.
+ // Useful only if hw decoding requires a special codec, instead of using
+ // the libavcodec hwaccel infrastructure.
+ const char **codec_pairs;
+ // If not-NULL: a 0 terminated list of IMGFMT_ formats, and only one of
+ // these formats is accepted in the libavcodec get_format callback.
const int *image_formats;
+ int (*probe)(struct vd_lavc_hwdec *hwdec, struct mp_hwdec_info *info,
+ const char *decoder);
int (*init)(struct lavc_ctx *ctx);
void (*uninit)(struct lavc_ctx *ctx);
struct mp_image *(*allocate_image)(struct lavc_ctx *ctx, AVFrame *frame);
void (*fix_image)(struct lavc_ctx *ctx, struct mp_image *img);
};
+enum {
+ HWDEC_ERR_NO_CTX = -2,
+ HWDEC_ERR_NO_CODEC = -3,
+};
+
// lavc_dr1.c
int mp_codec_get_buffer(AVCodecContext *s, AVFrame *frame);
void mp_codec_release_buffer(AVCodecContext *s, AVFrame *frame);