2013-11-23 20:26:31 +00:00
|
|
|
#ifndef MP_HWDEC_H_
|
|
|
|
#define MP_HWDEC_H_
|
|
|
|
|
2015-07-07 12:25:37 +00:00
|
|
|
#include "options/m_option.h"
|
|
|
|
|
2015-01-22 14:32:23 +00:00
|
|
|
struct mp_image_pool;
|
|
|
|
|
2015-07-07 12:25:37 +00:00
|
|
|
// keep in sync with --hwdec option (see mp_hwdec_names)
|
2015-02-02 21:43:05 +00:00
|
|
|
enum hwdec_type {
|
|
|
|
HWDEC_AUTO = -1,
|
|
|
|
HWDEC_NONE = 0,
|
|
|
|
HWDEC_VDPAU = 1,
|
2015-07-11 15:21:39 +00:00
|
|
|
HWDEC_VIDEOTOOLBOX = 3,
|
2015-02-02 21:43:05 +00:00
|
|
|
HWDEC_VAAPI = 4,
|
|
|
|
HWDEC_VAAPI_COPY = 5,
|
2016-01-30 09:04:34 +00:00
|
|
|
HWDEC_DXVA2 = 6,
|
|
|
|
HWDEC_DXVA2_COPY = 7,
|
2016-03-18 06:28:29 +00:00
|
|
|
HWDEC_D3D11VA_COPY = 8,
|
|
|
|
HWDEC_RPI = 9,
|
|
|
|
HWDEC_MEDIACODEC = 10,
|
2015-02-02 21:43:05 +00:00
|
|
|
};
|
|
|
|
|
2015-07-07 12:25:37 +00:00
|
|
|
// hwdec_type names (options.c)
|
|
|
|
extern const struct m_opt_choice_alternatives mp_hwdec_names[];
|
|
|
|
|
2015-01-22 14:32:23 +00:00
|
|
|
struct mp_hwdec_ctx {
|
2015-02-02 21:43:05 +00:00
|
|
|
enum hwdec_type type;
|
|
|
|
|
2015-01-22 14:32:23 +00:00
|
|
|
void *priv; // for free use by hwdec implementation
|
|
|
|
|
|
|
|
// API-specific, not needed by all backends.
|
|
|
|
struct mp_vdpau_ctx *vdpau_ctx;
|
|
|
|
struct mp_vaapi_ctx *vaapi_ctx;
|
2015-07-03 13:58:19 +00:00
|
|
|
struct mp_d3d_ctx *d3d_ctx;
|
2015-01-22 16:47:14 +00:00
|
|
|
|
|
|
|
// Optional.
|
|
|
|
// Allocates a software image from the pool, downloads the hw image from
|
|
|
|
// mpi, and returns it.
|
|
|
|
// pool can be NULL (then just use straight allocation).
|
|
|
|
// Return NULL on error or if mpi has the wrong format.
|
|
|
|
struct mp_image *(*download_image)(struct mp_hwdec_ctx *ctx,
|
|
|
|
struct mp_image *mpi,
|
|
|
|
struct mp_image_pool *swpool);
|
2015-01-22 14:32:23 +00:00
|
|
|
};
|
|
|
|
|
2013-11-23 20:26:31 +00:00
|
|
|
// Used to communicate hardware decoder API handles from VO to video decoder.
|
|
|
|
// The VO can set the context pointer for supported APIs.
|
|
|
|
struct mp_hwdec_info {
|
2015-01-22 14:32:23 +00:00
|
|
|
// (Since currently only 1 hwdec API is loaded at a time, this pointer
|
|
|
|
// simply maps to the loaded one.)
|
|
|
|
struct mp_hwdec_ctx *hwctx;
|
|
|
|
|
2013-11-23 20:26:31 +00:00
|
|
|
// Can be used to lazily load a requested API.
|
|
|
|
// api_name is e.g. "vdpau" (like the fields above, without "_ctx")
|
2015-01-22 14:32:23 +00:00
|
|
|
// Can be NULL, is idempotent, caller checks hwctx fields for success/access.
|
video: move display and timing to a separate thread
The VO is run inside its own thread. It also does most of video timing.
The playloop hands the image data and a realtime timestamp to the VO,
and the VO does the rest.
In particular, this allows the playloop to do other things, instead of
blocking for video redraw. But if anything accesses the VO during video
timing, it will block.
This also fixes vo_sdl.c event handling; but that is only a side-effect,
since reimplementing the broken way would require more effort.
Also drop --softsleep. In theory, this option helps if the kernel's
sleeping mechanism is too inaccurate for video timing. In practice, I
haven't ever encountered a situation where it helps, and it just burns
CPU cycles. On the other hand it's probably actively harmful, because
it prevents the libavcodec decoder threads from doing real work.
Side note:
Originally, I intended that multiple frames can be queued to the VO. But
this is not done, due to problems with OSD and other certain features.
OSD in particular is simply designed in a way that it can be neither
timed nor copied, so you do have to render it into the video frame
before you can draw the next frame. (Subtitles have no such restriction.
sd_lavc was even updated to fix this.) It seems the right solution to
queuing multiple VO frames is rendering on VO-backed framebuffers, like
vo_vdpau.c does. This requires VO driver support, and is out of scope
of this commit.
As consequence, the VO has a queue size of 1. The existing video queue
is just needed to compute frame duration, and will be moved out in the
next commit.
2014-08-12 21:02:08 +00:00
|
|
|
// Due to threading, the callback is the only code that is allowed to
|
|
|
|
// change fields in this struct after initialization.
|
2013-11-23 20:26:31 +00:00
|
|
|
void (*load_api)(struct mp_hwdec_info *info, const char *api_name);
|
|
|
|
void *load_api_ctx;
|
|
|
|
};
|
|
|
|
|
|
|
|
// Trivial helper to call info->load_api().
|
|
|
|
// Implemented in vd_lavc.c.
|
|
|
|
void hwdec_request_api(struct mp_hwdec_info *info, const char *api_name);
|
|
|
|
|
|
|
|
#endif
|