From 274e71ee8b774d6c9c69929a548a83c343202be1 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 12 Sep 2016 15:08:38 +0200 Subject: vo_opengl: add hw overlay support and use it for RPI This overlay support specifically skips the OpenGL rendering chain, and uses GL rendering only for OSD/subtitles. This is for devices which don't have performant GL support. hwdec_rpi.c contains code ported from vo_rpi.c. vo_rpi.c is going to be deprecated. I left in the code for uploading sw surfaces (as it might be slightly more efficient for rendering sw decoded video), although it's dead code for now. --- video/out/opengl/video.c | 31 ++++++++++++++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) (limited to 'video/out/opengl/video.c') diff --git a/video/out/opengl/video.c b/video/out/opengl/video.c index d54858bd7e..c41aeb34cd 100644 --- a/video/out/opengl/video.c +++ b/video/out/opengl/video.c @@ -834,6 +834,10 @@ static void init_video(struct gl_video *p) for (int n = 0; exts && exts[n]; n++) gl_sc_enable_extension(p->sc, (char *)exts[n]); p->hwdec_active = true; + if (p->hwdec->driver->overlay_frame) { + MP_WARN(p, "Using HW-overlay mode. No GL filtering is performed " + "on the video!\n"); + } } else { init_format(p, p->image_params.imgfmt, false); } @@ -2679,6 +2683,7 @@ void gl_video_render_frame(struct gl_video *p, struct vo_frame *frame, int fbo) gl->BindFramebuffer(GL_FRAMEBUFFER, fbo); bool has_frame = !!frame->current; + bool is_new = has_frame && !frame->redraw && !frame->repeat; if (!has_frame || p->dst_rect.x0 > 0 || p->dst_rect.y0 > 0 || p->dst_rect.x1 < p->vp_w || p->dst_rect.y1 < abs(p->vp_h)) @@ -2688,6 +2693,28 @@ void gl_video_render_frame(struct gl_video *p, struct vo_frame *frame, int fbo) gl->Clear(GL_COLOR_BUFFER_BIT); } + if (p->hwdec_active && p->hwdec->driver->overlay_frame) { + if (has_frame) { + float *c = p->hwdec->overlay_colorkey; + gl->Scissor(p->dst_rect.x0, p->dst_rect.y0, + p->dst_rect.x1 - p->dst_rect.x0, + p->dst_rect.y1 - p->dst_rect.y0); + gl->Enable(GL_SCISSOR_TEST); + gl->ClearColor(c[0], c[1], c[2], c[3]); + gl->Clear(GL_COLOR_BUFFER_BIT); + gl->Disable(GL_SCISSOR_TEST); + } + + if (is_new || !frame->current) + p->hwdec->driver->overlay_frame(p->hwdec, frame->current); + + if (frame->current) + p->osd_pts = frame->current->pts; + + // Disable GL rendering + has_frame = false; + } + if (has_frame) { gl_sc_set_vao(p->sc, &p->vao); @@ -2702,7 +2729,6 @@ void gl_video_render_frame(struct gl_video *p, struct vo_frame *frame, int fbo) if (interpolate) { gl_video_interpolate_frame(p, frame, fbo); } else { - bool is_new = !frame->redraw && !frame->repeat; if (is_new || !p->output_fbo_valid) { p->output_fbo_valid = false; @@ -2797,6 +2823,9 @@ void gl_video_resize(struct gl_video *p, int vp_w, int vp_h, if (p->osd) mpgl_osd_resize(p->osd, p->osd_rect, p->image_params.stereo_out); + + if (p->hwdec && p->hwdec->driver->overlay_adjust) + p->hwdec->driver->overlay_adjust(p->hwdec, vp_w, vp_h, src, dst); } static struct voctrl_performance_entry gl_video_perfentry(struct gl_timer *t) -- cgit v1.2.3