2014-12-03 20:54:04 +00:00
|
|
|
#ifndef MPGL_HWDEC_H_
|
|
|
|
#define MPGL_HWDEC_H_
|
|
|
|
|
|
|
|
#include "gl_common.h"
|
|
|
|
#include "video/hwdec.h"
|
|
|
|
|
|
|
|
struct mp_hwdec_info;
|
|
|
|
|
|
|
|
struct gl_hwdec {
|
|
|
|
const struct gl_hwdec_driver *driver;
|
|
|
|
struct mp_log *log;
|
|
|
|
GL *gl;
|
2015-01-22 14:32:23 +00:00
|
|
|
struct mp_hwdec_ctx *hwctx;
|
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.
|
|
|
|
bool reject_emulated;
|
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-01-26 01:06:18 +00:00
|
|
|
// GL_TEXTURE_RECTANGLE. This is needed because VDA is shit.
|
2014-12-03 20:54:04 +00:00
|
|
|
GLenum gl_texture_target;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct gl_hwdec_driver {
|
|
|
|
// Same name as used by mp_hwdec_info->load_api()
|
|
|
|
const char *api_name;
|
|
|
|
// The hardware surface IMGFMT_ that must be passed to map_image later.
|
|
|
|
int imgfmt;
|
|
|
|
// Create the hwdec device. It must fill in hw->info, if applicable.
|
|
|
|
// 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.
|
|
|
|
int (*reinit)(struct gl_hwdec *hw, struct mp_image_params *params);
|
2014-12-03 20:54:04 +00:00
|
|
|
// Return textures that contain the given hw_image.
|
|
|
|
// Note that the caller keeps a reference to hw_image until unmap_image
|
|
|
|
// is called, so the hwdec driver doesn't need to do that.
|
|
|
|
int (*map_image)(struct gl_hwdec *hw, struct mp_image *hw_image,
|
|
|
|
GLuint *out_textures);
|
|
|
|
// Undo map_image(). The user of map_image() calls this when the textures
|
|
|
|
// are not needed anymore.
|
|
|
|
void (*unmap_image)(struct gl_hwdec *hw);
|
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,
|
2015-01-22 14:32:23 +00:00
|
|
|
const char *api_name);
|
2014-12-03 20:54:04 +00:00
|
|
|
|
|
|
|
void gl_hwdec_uninit(struct gl_hwdec *hwdec);
|
|
|
|
|
|
|
|
#endif
|