summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/hwdec_rpi.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2017-08-10 17:48:33 +0200
committerwm4 <wm4@nowhere>2017-08-10 21:24:31 +0200
commitc6fafbffaca16959dfa2b4bf1eb97861ad66b5ef (patch)
treedecef889171128c27f3a8cb2fcfb552f1b7297be /video/out/opengl/hwdec_rpi.c
parentb2fb3f1340ed7ceb9b3fc8ba4ddec107e3a41a13 (diff)
downloadmpv-c6fafbffaca16959dfa2b4bf1eb97861ad66b5ef.tar.bz2
mpv-c6fafbffaca16959dfa2b4bf1eb97861ad66b5ef.tar.xz
vo_opengl: separate hwdec context and mapping, port it to use ra
This does two separate rather intrusive things: 1. Make the hwdec context (which does initialization, provides the device to the decoder, and other basic state) and frame mapping (getting textures from a mp_image) separate. This is more flexible, and you could map multiple images at once. It will help removing some hwdec special-casing from video.c. 2. Switch all hwdec API use to ra. Of course all code is still GL specific, but in theory it would be possible to support other backends. The most important change is that the hwdec interop returns ra objects, instead of anything GL specific. This removes the last dependency on GL-specific header files from video.c. I'm mixing these separate changes because both requires essentially rewriting all the glue code, so better do them at once. For the same reason, this change isn't done incrementally. hwdec_ios.m is untested, since I can't test it. Apart from superficial mistakes, this also requires dealing with Apple's texture format fuckups: they force you to use GL_LUMINANCE[_ALPHA] instead of GL_RED and GL_RG. We also need to report the correct format via ra_tex to the renderer, which is done by find_la_variant(). It's unknown whether this works correctly. hwdec_rpi.c as well as vo_rpi.c are still broken. (I need to pull my RPI out of a dusty pile of devices and cables, so, later.)
Diffstat (limited to 'video/out/opengl/hwdec_rpi.c')
-rw-r--r--video/out/opengl/hwdec_rpi.c58
1 files changed, 23 insertions, 35 deletions
diff --git a/video/out/opengl/hwdec_rpi.c b/video/out/opengl/hwdec_rpi.c
index daa1a9a54c..72270b5787 100644
--- a/video/out/opengl/hwdec_rpi.c
+++ b/video/out/opengl/hwdec_rpi.c
@@ -103,7 +103,7 @@ static void input_port_cb(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer)
talloc_free(mpi);
}
-static void disable_renderer(struct gl_hwdec *hw)
+static void disable_renderer(struct ra_hwdec *hw)
{
struct priv *p = hw->priv;
@@ -122,7 +122,7 @@ static void disable_renderer(struct gl_hwdec *hw)
}
// check_window_only: assume params and dst/src rc are unchanged
-static void update_overlay(struct gl_hwdec *hw, bool check_window_only)
+static void update_overlay(struct ra_hwdec *hw, bool check_window_only)
{
struct priv *p = hw->priv;
GL *gl = hw->gl;
@@ -183,7 +183,7 @@ static void update_overlay(struct gl_hwdec *hw, bool check_window_only)
MP_WARN(p, "could not set video rectangle\n");
}
-static int enable_renderer(struct gl_hwdec *hw)
+static int enable_renderer(struct ra_hwdec *hw)
{
struct priv *p = hw->priv;
MMAL_PORT_T *input = p->renderer->input[0];
@@ -244,29 +244,13 @@ static int enable_renderer(struct gl_hwdec *hw)
return 0;
}
-static int reinit(struct gl_hwdec *hw, struct mp_image_params *params)
-{
- struct priv *p = hw->priv;
-
- p->params = *params;
-
- *params = (struct mp_image_params){0};
-
- disable_renderer(hw);
-
- if (enable_renderer(hw) < 0)
- return -1;
-
- return 0;
-}
-
static void free_mmal_buffer(void *arg)
{
MMAL_BUFFER_HEADER_T *buffer = arg;
mmal_buffer_header_release(buffer);
}
-static struct mp_image *upload(struct gl_hwdec *hw, struct mp_image *hw_image)
+static struct mp_image *upload(struct ra_hwdec *hw, struct mp_image *hw_image)
{
struct priv *p = hw->priv;
@@ -295,11 +279,21 @@ static struct mp_image *upload(struct gl_hwdec *hw, struct mp_image *hw_image)
return new_ref;
}
-static int overlay_frame(struct gl_hwdec *hw, struct mp_image *hw_image,
+static int overlay_frame(struct ra_hwdec *hw, struct mp_image *hw_image,
struct mp_rect *src, struct mp_rect *dst, bool newframe)
{
struct priv *p = hw->priv;
+ if (hw_image && !mp_image_params_equal(&p->params, &hw_image->params)) {
+ p->params = *params;
+
+ disable_renderer(hw);
+ mp_image_unrefp(&p->current_frame);
+
+ if (enable_renderer(hw) < 0)
+ return -1;
+ }
+
if (hw_image && p->current_frame && !newframe) {
if (!mp_rect_equals(&p->src, src) ||mp_rect_equals(&p->dst, dst)) {
p->src = *src;
@@ -347,7 +341,7 @@ static int overlay_frame(struct gl_hwdec *hw, struct mp_image *hw_image,
return 0;
}
-static void destroy(struct gl_hwdec *hw)
+static void destroy(struct ra_hwdec *hw)
{
struct priv *p = hw->priv;
@@ -359,10 +353,9 @@ static void destroy(struct gl_hwdec *hw)
mmal_vc_deinit();
}
-static int create(struct gl_hwdec *hw)
+static int create(struct ra_hwdec *hw)
{
- struct priv *p = talloc_zero(hw, struct priv);
- hw->priv = p;
+ struct priv *p = hw->priv;
p->log = hw->log;
bcm_host_init();
@@ -382,18 +375,13 @@ static int create(struct gl_hwdec *hw)
return 0;
}
-static bool test_format(struct gl_hwdec *hw, int imgfmt)
-{
- return imgfmt == IMGFMT_MMAL || imgfmt == IMGFMT_420P;
-}
-
-const struct gl_hwdec_driver gl_hwdec_rpi_overlay = {
+const struct ra_hwdec_driver ra_hwdec_rpi_overlay = {
.name = "rpi-overlay",
.api = HWDEC_RPI,
- .test_format = test_format,
- .create = create,
- .reinit = reinit,
+ .priv_size = sizeof(struct priv),
+ .imgfmts = {IMGFMT_MMAL, IMGFMT_420P, 0},
+ .init = create,
.overlay_frame = overlay_frame,
.overlay_adjust = overlay_adjust,
- .destroy = destroy,
+ .uninit = destroy,
};