summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/hwdec_rpi.c
diff options
context:
space:
mode:
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,
};