summaryrefslogtreecommitdiffstats
path: root/video/out/opengl/video.c
diff options
context:
space:
mode:
authorwm4 <wm4@nowhere>2016-09-12 15:08:38 +0200
committerwm4 <wm4@nowhere>2016-09-12 19:58:58 +0200
commit274e71ee8b774d6c9c69929a548a83c343202be1 (patch)
tree1176b9933fb04d730e0eeec4bcb3bc024725d618 /video/out/opengl/video.c
parent343f5ca24beeddc69f49d43448acc05b982176ad (diff)
downloadmpv-274e71ee8b774d6c9c69929a548a83c343202be1.tar.bz2
mpv-274e71ee8b774d6c9c69929a548a83c343202be1.tar.xz
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.
Diffstat (limited to 'video/out/opengl/video.c')
-rw-r--r--video/out/opengl/video.c31
1 files changed, 30 insertions, 1 deletions
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)