2014-12-03 20:54:04 +00:00
|
|
|
#ifndef MPGL_HWDEC_H_
|
|
|
|
#define MPGL_HWDEC_H_
|
|
|
|
|
2015-08-29 02:12:56 +00:00
|
|
|
#include "common.h"
|
2014-12-03 20:54:04 +00:00
|
|
|
#include "video/hwdec.h"
|
|
|
|
|
|
|
|
struct gl_hwdec {
|
|
|
|
const struct gl_hwdec_driver *driver;
|
|
|
|
struct mp_log *log;
|
2015-11-17 20:07:41 +00:00
|
|
|
struct mpv_global *global;
|
2014-12-03 20:54:04 +00:00
|
|
|
GL *gl;
|
2016-05-09 17:42:03 +00:00
|
|
|
struct mp_hwdec_devices *devs;
|
2014-12-03 20:54:04 +00:00
|
|
|
// For free use by hwdec driver
|
|
|
|
void *priv;
|
2014-12-09 16:47:02 +00:00
|
|
|
// For working around the vdpau vs. vaapi mess.
|
2015-11-09 10:58:38 +00:00
|
|
|
bool probing;
|
2014-12-03 20:54:04 +00:00
|
|
|
// hwdec backends must set this to an IMGFMT_ that has an equivalent
|
|
|
|
// internal representation in gl_video.c as the hardware texture.
|
2015-01-26 01:06:18 +00:00
|
|
|
// It's used to build the rendering chain. For example, setting it to
|
|
|
|
// IMGFMT_RGB0 indicates that the video texture is RGB.
|
2014-12-03 20:54:04 +00:00
|
|
|
int converted_imgfmt;
|
|
|
|
// Normally this is GL_TEXTURE_2D, but the hwdec driver can set it to
|
2015-09-28 19:55:23 +00:00
|
|
|
// GL_TEXTURE_RECTANGLE. This is needed because VideoToolbox is shit.
|
2014-12-03 20:54:04 +00:00
|
|
|
GLenum gl_texture_target;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct gl_hwdec_driver {
|
2016-05-04 14:55:26 +00:00
|
|
|
// Name of the interop backend. This is used for informational purposes only.
|
2016-02-01 19:02:52 +00:00
|
|
|
const char *name;
|
|
|
|
// Used to explicitly request a specific API.
|
|
|
|
enum hwdec_type api;
|
2014-12-03 20:54:04 +00:00
|
|
|
// The hardware surface IMGFMT_ that must be passed to map_image later.
|
|
|
|
int imgfmt;
|
2016-05-09 17:42:03 +00:00
|
|
|
// Create the hwdec device. It must add it to hw->devs, if applicable.
|
2014-12-03 20:54:04 +00:00
|
|
|
// This also must set hw->converted_imgfmt.
|
|
|
|
int (*create)(struct gl_hwdec *hw);
|
|
|
|
// Prepare for rendering video. (E.g. create textures.)
|
|
|
|
// Called on initialization, and every time the video size changes.
|
2015-01-29 18:53:49 +00:00
|
|
|
// *params must be set to the format the hw textures return.
|
2016-04-07 16:47:03 +00:00
|
|
|
// This also can update hw->converted_imgfmt.
|
2015-01-29 18:53:49 +00:00
|
|
|
int (*reinit)(struct gl_hwdec *hw, struct mp_image_params *params);
|
2015-03-14 21:39:22 +00:00
|
|
|
// Return textures that contain a copy or reference of the given hw_image.
|
2014-12-03 20:54:04 +00:00
|
|
|
int (*map_image)(struct gl_hwdec *hw, struct mp_image *hw_image,
|
|
|
|
GLuint *out_textures);
|
2015-01-22 16:47:14 +00:00
|
|
|
|
2014-12-03 20:54:04 +00:00
|
|
|
void (*destroy)(struct gl_hwdec *hw);
|
|
|
|
};
|
|
|
|
|
|
|
|
struct gl_hwdec *gl_hwdec_load_api(struct mp_log *log, GL *gl,
|
2016-05-09 17:42:03 +00:00
|
|
|
struct mpv_global *g,
|
|
|
|
struct mp_hwdec_devices *devs,
|
|
|
|
enum hwdec_type api);
|
2014-12-03 20:54:04 +00:00
|
|
|
|
|
|
|
void gl_hwdec_uninit(struct gl_hwdec *hwdec);
|
|
|
|
|
|
|
|
#endif
|