summaryrefslogtreecommitdiffstats
path: root/video/out
diff options
context:
space:
mode:
Diffstat (limited to 'video/out')
-rw-r--r--video/out/cocoa_common.m85
-rw-r--r--video/out/gl_common.c4
-rw-r--r--video/out/gl_common.h4
-rw-r--r--video/out/gl_video.c106
-rw-r--r--video/out/gl_video.h2
-rw-r--r--video/out/gl_wayland.c7
-rw-r--r--video/out/vo.c47
-rw-r--r--video/out/vo.h14
-rw-r--r--video/out/vo_corevideo.c (renamed from video/out/vo_corevideo.m)44
-rw-r--r--video/out/vo_corevideo.h28
-rw-r--r--video/out/vo_opengl.c20
-rw-r--r--video/out/vo_vdpau.c374
-rw-r--r--video/out/wayland_common.c23
-rw-r--r--video/out/wayland_common.h1
14 files changed, 311 insertions, 448 deletions
diff --git a/video/out/cocoa_common.m b/video/out/cocoa_common.m
index b280b54a31..f50d8af291 100644
--- a/video/out/cocoa_common.m
+++ b/video/out/cocoa_common.m
@@ -46,8 +46,7 @@
- (void)fullscreen;
- (void)mulSize:(float)multiplier;
- (int)titleHeight;
-- (NSRect)clipFrame:(NSRect)frame withContentAspect:(NSSize) aspect;
-- (void)setContentSize:(NSSize)newSize keepCentered:(BOOL)keepCentered;
+- (void)setCenteredContentSize:(NSSize)newSize;
@property(nonatomic, assign) struct vo *videoOutput;
@end
@@ -96,6 +95,8 @@ struct vo_cocoa_state {
NSLock *lock;
bool enable_resize_redraw;
void (*resize_redraw)(struct vo *vo, int w, int h);
+
+ struct mp_log *log;
};
static struct vo_cocoa_state *vo_cocoa_init_state(struct vo *vo)
@@ -112,6 +113,7 @@ static struct vo_cocoa_state *vo_cocoa_init_state(struct vo *vo)
.accumulated_scroll = 0,
.lock = [[NSLock alloc] init],
.enable_resize_redraw = NO,
+ .log = mp_log_new(s, vo->log, "cocoa"),
};
return s;
}
@@ -198,13 +200,15 @@ void vo_cocoa_register_resize_callback(struct vo *vo,
s->resize_redraw = cb;
}
-static int get_screen_handle(int identifier, NSWindow *window, NSScreen **screen) {
+static int get_screen_handle(struct vo *vo, int identifier, NSWindow *window,
+ NSScreen **screen) {
+ struct vo_cocoa_state *s = vo->cocoa;
NSArray *screens = [NSScreen screens];
int n_of_displays = [screens count];
if (identifier >= n_of_displays) { // check if the identifier is out of bounds
- mp_msg(MSGT_VO, MSGL_INFO, "[cocoa] Screen ID %d does not exist, "
- "falling back to main device\n", identifier);
+ MP_INFO(s, "Screen ID %d does not exist, falling back to main "
+ "device\n", identifier);
identifier = -1;
}
@@ -224,8 +228,8 @@ static void update_screen_info(struct vo *vo)
{
struct vo_cocoa_state *s = vo->cocoa;
struct mp_vo_opts *opts = vo->opts;
- get_screen_handle(opts->screen_id, s->window, &s->current_screen);
- get_screen_handle(opts->fsscreen_id, s->window, &s->fs_screen);
+ get_screen_handle(vo, opts->screen_id, s->window, &s->current_screen);
+ get_screen_handle(vo, opts->fsscreen_id, s->window, &s->fs_screen);
}
static void vo_cocoa_update_screen_info(struct vo *vo)
@@ -284,7 +288,7 @@ static void update_state_sizes(struct vo_cocoa_state *s,
static void resize_window_from_stored_size(struct vo *vo)
{
struct vo_cocoa_state *s = vo->cocoa;
- [s->window setContentSize:s->current_video_size keepCentered:YES];
+ [s->window setCenteredContentSize:s->current_video_size];
[s->window setContentAspectRatio:s->current_video_size];
}
@@ -365,8 +369,7 @@ static int create_gl_context(struct vo *vo, int gl3profile)
[[[NSOpenGLPixelFormat alloc] initWithAttributes:attr] autorelease];
if (!s->pixelFormat) {
- mp_msg(MSGT_VO, MSGL_ERR,
- "[cocoa] Trying to build invalid OpenGL pixel format\n");
+ MP_ERR(s, "Trying to build invalid OpenGL pixel format\n");
return -1;
}
@@ -742,7 +745,7 @@ int vo_cocoa_cgl_color_size(struct vo *vo)
.width = self.videoOutput->cocoa->aspdat.prew * multiplier,
.height = self.videoOutput->cocoa->aspdat.preh * multiplier
};
- [self setContentSize:size keepCentered:YES];
+ [self setCenteredContentSize:size];
}
}
@@ -753,60 +756,26 @@ int vo_cocoa_cgl_color_size(struct vo *vo)
return of.size.height - cb.size.height;
}
-- (NSRect)clipFrame:(NSRect)frame withContentAspect:(NSSize) aspect
-{
- NSRect vf = [[self screen] visibleFrame];
- double ratio = (double)aspect.width / (double)aspect.height;
-
- // clip frame to screens visibile frame
- frame = CGRectIntersection(frame, vf);
-
- NSSize s = frame.size;
- s.height -= [self titleHeight];
-
- if (s.width > s.height) {
- s.width = ((double)s.height * ratio);
- } else {
- s.height = ((double)s.width * 1.0/ratio);
- }
-
- s.height += [self titleHeight];
- frame.size = s;
-
- return frame;
-}
-
- (void)setCenteredContentSize:(NSSize)ns
{
-#define get_center(x) NSMakePoint(CGRectGetMidX((x)), CGRectGetMidY((x)))
- NSRect of = [self frame];
- NSRect vf = [[self screen] visibleFrame];
- NSPoint old_center = get_center(of);
-
- NSRect nf = NSMakeRect(vf.origin.x, vf.origin.y,
- ns.width, ns.height + [self titleHeight]);
-
- nf = [self clipFrame:nf withContentAspect:ns];
-
- NSPoint new_center = get_center(nf);
+ NSRect f = [self frame];
+ CGFloat dx = (f.size.width - ns.width) / 2;
+ CGFloat dy = (f.size.height - ns.height - [self titleHeight]) / 2;
+ NSRect nf = NSRectFromCGRect(CGRectInset(NSRectToCGRect(f), dx, dy));
- int dx0 = old_center.x - new_center.x;
- int dy0 = old_center.y - new_center.y;
-
- nf.origin.x += dx0;
- nf.origin.y += dy0;
+ struct vo *vo = self.videoOutput;
+ if (!(vo && !vo->opts->border)) {
+ NSRect s = [[self screen] visibleFrame];
+ if (nf.origin.y + nf.size.height > s.origin.y + s.size.height)
+ nf.origin.y = s.size.height - nf.size.height;
+ }
- [self setFrame:nf display:YES animate:NO];
-#undef get_center
+ [self setFrame:nf display:NO animate:NO];
}
-- (void)setContentSize:(NSSize)ns keepCentered:(BOOL)keepCentered
+- (NSRect)constrainFrameRect:(NSRect)rect toScreen:(NSScreen *)screen
{
- if (keepCentered) {
- [self setCenteredContentSize:ns];
- } else {
- [self setContentSize:ns];
- }
+ return rect;
}
@end
diff --git a/video/out/gl_common.c b/video/out/gl_common.c
index 497387aa4f..7c4bfd3056 100644
--- a/video/out/gl_common.c
+++ b/video/out/gl_common.c
@@ -984,7 +984,7 @@ bool mpgl_is_thread_safe(MPGLContext *ctx)
return !!ctx->set_current;
}
-void mp_log_source(int mod, int lev, const char *src)
+void mp_log_source(struct mp_log *log, int lev, const char *src)
{
int line = 1;
if (!src)
@@ -994,7 +994,7 @@ void mp_log_source(int mod, int lev, const char *src)
const char *next = end + 1;
if (!end)
next = end = src + strlen(src);
- mp_msg(mod, lev, "[%3d] %.*s\n", line, (int)(end - src), src);
+ mp_msg_log(log, lev, "[%3d] %.*s\n", line, (int)(end - src), src);
line++;
src = next;
}
diff --git a/video/out/gl_common.h b/video/out/gl_common.h
index ed63491c1a..e6ceabff74 100644
--- a/video/out/gl_common.h
+++ b/video/out/gl_common.h
@@ -170,8 +170,8 @@ void mpgl_load_functions(GL *gl, void *(*getProcAddress)(const GLubyte *),
const char *ext2);
// print a multi line string with line numbers (e.g. for shader sources)
-// mod, lev: module and log level, as in mp_msg()
-void mp_log_source(int mod, int lev, const char *src);
+// log, lev: module and log level, as in mp_msg()
+void mp_log_source(struct mp_log *log, int lev, const char *src);
//function pointers loaded from the OpenGL library
struct GL {
diff --git a/video/out/gl_video.c b/video/out/gl_video.c
index fca8167139..273e3ac968 100644
--- a/video/out/gl_video.c
+++ b/video/out/gl_video.c
@@ -138,6 +138,7 @@ struct fbotex {
struct gl_video {
GL *gl;
+ struct mp_log *log;
struct gl_video_opts opts;
bool gl_debug;
@@ -443,7 +444,7 @@ static bool fbotex_init(struct gl_video *p, struct fbotex *fbo, int w, int h,
tex_size(p, w, h, &fbo->tex_w, &fbo->tex_h);
- mp_msg(MSGT_VO, MSGL_V, "[gl] Create FBO: %dx%d\n", fbo->tex_w, fbo->tex_h);
+ MP_VERBOSE(p, "Create FBO: %dx%d\n", fbo->tex_w, fbo->tex_h);
gl->GenFramebuffers(1, &fbo->fbo);
gl->GenTextures(1, &fbo->texture);
@@ -457,8 +458,7 @@ static bool fbotex_init(struct gl_video *p, struct fbotex *fbo, int w, int h,
GL_TEXTURE_2D, fbo->texture, 0);
if (gl->CheckFramebufferStatus(GL_FRAMEBUFFER) != GL_FRAMEBUFFER_COMPLETE) {
- mp_msg(MSGT_VO, MSGL_ERR, "[gl] Error: framebuffer completeness "
- "check failed!\n");
+ MP_ERR(p, "Error: framebuffer completeness check failed!\n");
res = false;
}
@@ -629,9 +629,11 @@ static char *t_concat(void *talloc_ctx, const char *s1, const char *s2)
return talloc_asprintf(talloc_ctx, "%s%s", s1, s2);
}
-static GLuint create_shader(GL *gl, GLenum type, const char *header,
+static GLuint create_shader(struct gl_video *p, GLenum type, const char *header,
const char *source)
{
+ GL *gl = p->gl;
+
void *tmp = talloc_new(NULL);
const char *full_source = t_concat(tmp, header, source);
@@ -645,15 +647,15 @@ static GLuint create_shader(GL *gl, GLenum type, const char *header,
int pri = status ? (log_length > 1 ? MSGL_V : MSGL_DBG2) : MSGL_ERR;
const char *typestr = type == GL_VERTEX_SHADER ? "vertex" : "fragment";
- if (mp_msg_test(MSGT_VO, pri)) {
- mp_msg(MSGT_VO, pri, "[gl] %s shader source:\n", typestr);
- mp_log_source(MSGT_VO, pri, full_source);
+ if (mp_msg_test_log(p->log, pri)) {
+ MP_MSG(p, pri, "%s shader source:\n", typestr);
+ mp_log_source(p->log, pri, full_source);
}
if (log_length > 1) {
- GLchar *log = talloc_zero_size(tmp, log_length + 1);
- gl->GetShaderInfoLog(shader, log_length, NULL, log);
- mp_msg(MSGT_VO, pri, "[gl] %s shader compile log (status=%d):\n%s\n",
- typestr, status, log);
+ GLchar *logstr = talloc_zero_size(tmp, log_length + 1);
+ gl->GetShaderInfoLog(shader, log_length, NULL, logstr);
+ MP_MSG(p, pri, "%s shader compile log (status=%d):\n%s\n",
+ typestr, status, logstr);
}
talloc_free(tmp);
@@ -661,16 +663,18 @@ static GLuint create_shader(GL *gl, GLenum type, const char *header,
return shader;
}
-static void prog_create_shader(GL *gl, GLuint program, GLenum type,
- const char *header, const char *source)
+static void prog_create_shader(struct gl_video *p, GLuint program, GLenum type,
+ const char *header, const char *source)
{
- GLuint shader = create_shader(gl, type, header, source);
+ GL *gl = p->gl;
+ GLuint shader = create_shader(p, type, header, source);
gl->AttachShader(program, shader);
gl->DeleteShader(shader);
}
-static void link_shader(GL *gl, GLuint program)
+static void link_shader(struct gl_video *p, GLuint program)
{
+ GL *gl = p->gl;
gl->LinkProgram(program);
GLint status;
gl->GetProgramiv(program, GL_LINK_STATUS, &status);
@@ -678,12 +682,11 @@ static void link_shader(GL *gl, GLuint program)
gl->GetProgramiv(program, GL_INFO_LOG_LENGTH, &log_length);
int pri = status ? (log_length > 1 ? MSGL_V : MSGL_DBG2) : MSGL_ERR;
- if (mp_msg_test(MSGT_VO, pri)) {
- GLchar *log = talloc_zero_size(NULL, log_length + 1);
- gl->GetProgramInfoLog(program, log_length, NULL, log);
- mp_msg(MSGT_VO, pri, "[gl] shader link log (status=%d): %s\n",
- status, log);
- talloc_free(log);
+ if (mp_msg_test_log(p->log, pri)) {
+ GLchar *logstr = talloc_zero_size(NULL, log_length + 1);
+ gl->GetProgramInfoLog(program, log_length, NULL, logstr);
+ MP_MSG(p, pri, "shader link log (status=%d): %s\n", status, logstr);
+ talloc_free(logstr);
}
}
@@ -696,18 +699,20 @@ static void bind_attrib_locs(GL *gl, GLuint program)
#define PRELUDE_END "// -- prelude end\n"
-static GLuint create_program(GL *gl, const char *name, const char *header,
- const char *vertex, const char *frag)
+static GLuint create_program(struct gl_video *p, const char *name,
+ const char *header, const char *vertex,
+ const char *frag)
{
- mp_msg(MSGT_VO, MSGL_V, "[gl] compiling shader program '%s', header:\n", name);
+ GL *gl = p->gl;
+ MP_VERBOSE(p, "compiling shader program '%s', header:\n", name);
const char *real_header = strstr(header, PRELUDE_END);
real_header = real_header ? real_header + strlen(PRELUDE_END) : header;
- mp_log_source(MSGT_VO, MSGL_V, real_header);
+ mp_log_source(p->log, MSGL_V, real_header);
GLuint prog = gl->CreateProgram();
- prog_create_shader(gl, prog, GL_VERTEX_SHADER, header, vertex);
- prog_create_shader(gl, prog, GL_FRAGMENT_SHADER, header, frag);
+ prog_create_shader(p, prog, GL_VERTEX_SHADER, header, vertex);
+ prog_create_shader(p, prog, GL_FRAGMENT_SHADER, header, frag);
bind_attrib_locs(gl, prog);
- link_shader(gl, prog);
+ link_shader(p, prog);
return prog;
}
@@ -786,7 +791,7 @@ static void compile_shaders(struct gl_video *p)
if (name) {
char *s_osd = get_section(tmp, src, name);
p->osd_programs[n] =
- create_program(gl, name, header_osd, vertex_shader, s_osd);
+ create_program(p, name, header_osd, vertex_shader, s_osd);
}
}
@@ -883,7 +888,7 @@ static void compile_shaders(struct gl_video *p)
shader_def_opt(&header_conv, "FIXED_SCALE", true);
header_conv = t_concat(tmp, header, header_conv);
p->indirect_program =
- create_program(gl, "indirect", header_conv, vertex_shader, s_video);
+ create_program(p, "indirect", header_conv, vertex_shader, s_video);
} else if (header_sep) {
header_sep = t_concat(tmp, header_sep, header_conv);
} else {
@@ -893,12 +898,12 @@ static void compile_shaders(struct gl_video *p)
if (header_sep) {
header_sep = t_concat(tmp, header, header_sep);
p->scale_sep_program =
- create_program(gl, "scale_sep", header_sep, vertex_shader, s_video);
+ create_program(p, "scale_sep", header_sep, vertex_shader, s_video);
}
header_final = t_concat(tmp, header, header_final);
p->final_program =
- create_program(gl, "final", header_final, vertex_shader, s_video);
+ create_program(p, "final", header_final, vertex_shader, s_video);
debug_check_gl(p, "shader compilation");
@@ -1017,7 +1022,7 @@ static void init_dither(struct gl_video *p)
if (p->opts.dither_depth < 0 || p->opts.dither_algo < 0)
return;
- mp_msg(MSGT_VO, MSGL_V, "[gl] Dither to %d.\n", dst_depth);
+ MP_VERBOSE(p, "Dither to %d.\n", dst_depth);
int tex_size;
void *tex_data;
@@ -1098,7 +1103,7 @@ static const char *expected_scaler(struct gl_video *p, int unit)
static void reinit_rendering(struct gl_video *p)
{
- mp_msg(MSGT_VO, MSGL_V, "[gl] Reinit rendering.\n");
+ MP_VERBOSE(p, "Reinit rendering.\n");
debug_check_gl(p, "before scaler initialization");
@@ -1213,8 +1218,8 @@ static void init_video(struct gl_video *p)
tex_size(p, plane->w, plane->h,
&plane->tex_w, &plane->tex_h);
- mp_msg(MSGT_VO, MSGL_V, "[gl] Texture for plane %d: %dx%d\n",
- n, plane->tex_w, plane->tex_h);
+ MP_VERBOSE(p, "Texture for plane %d: %dx%d\n",
+ n, plane->tex_w, plane->tex_h);
gl->ActiveTexture(GL_TEXTURE0 + n);
gl->GenTextures(1, &plane->gl_texture);
@@ -1451,8 +1456,8 @@ static void check_resize(struct gl_video *p)
init_scaler(p, &p->scalers[1]);
}
if (too_small) {
- mp_msg(MSGT_VO, MSGL_WARN, "[gl] Can't downscale that much, window "
- "output may look suboptimal.\n");
+ MP_WARN(p, "Can't downscale that much, window "
+ "output may look suboptimal.\n");
}
update_window_sized_objects(p);
@@ -1534,8 +1539,8 @@ void gl_video_upload_image(struct gl_video *p, struct mp_image *mpi)
if (pbo) {
gl->BindBuffer(GL_PIXEL_UNPACK_BUFFER, plane->gl_buffer);
if (!gl->UnmapBuffer(GL_PIXEL_UNPACK_BUFFER))
- mp_msg(MSGT_VO, MSGL_FATAL, "[gl] Video PBO upload failed. "
- "Remove the 'pbo' suboption.\n");
+ MP_FATAL(p, "Video PBO upload failed. "
+ "Remove the 'pbo' suboption.\n");
plane->buffer_ptr = NULL;
plane_ptr = NULL; // PBO offset 0
}
@@ -1663,7 +1668,7 @@ static bool test_fbo(struct gl_video *p, GLenum format)
gl->ClearColor(val, 0.0f, 0.0f, 1.0f);
gl->Clear(GL_COLOR_BUFFER_BIT);
gl->ReadPixels(0, 0, 1, 1, GL_RED, GL_FLOAT, &pixel);
- mp_msg(MSGT_VO, MSGL_V, " %s: %a\n", val_names[i], val - pixel);
+ MP_VERBOSE(p, " %s: %a\n", val_names[i], val - pixel);
}
gl->BindFramebuffer(GL_FRAMEBUFFER, 0);
glCheckError(gl, "after FBO read");
@@ -1691,7 +1696,7 @@ static void check_gl_features(struct gl_video *p)
int n_disabled = 0;
if (have_fbo) {
- mp_msg(MSGT_VO, MSGL_V, "Testing user-set FBO format\n");
+ MP_VERBOSE(p, "Testing user-set FBO format\n");
have_fbo = test_fbo(p, p->opts.fbo_format);
}
@@ -1700,7 +1705,7 @@ static void check_gl_features(struct gl_video *p)
p->use_lut_3d)
{
// doesn't disalbe anything; it's just for the log
- mp_msg(MSGT_VO, MSGL_V, "Testing GL_R16 FBO (dithering/LUT)\n");
+ MP_VERBOSE(p, "Testing GL_R16 FBO (dithering/LUT)\n");
test_fbo(p, GL_R16);
}
@@ -1739,14 +1744,14 @@ static void check_gl_features(struct gl_video *p)
}
if (n_disabled) {
- mp_msg(MSGT_VO, MSGL_ERR, "[gl] Some OpenGL extensions not detected, "
+ MP_ERR(p, "Some OpenGL extensions not detected, "
"disabling: ");
for (int n = 0; n < n_disabled; n++) {
if (n)
- mp_msg(MSGT_VO, MSGL_ERR, ", ");
- mp_msg(MSGT_VO, MSGL_ERR, "%s", disabled[n]);
+ MP_ERR(p, ", ");
+ MP_ERR(p, "%s", disabled[n]);
}
- mp_msg(MSGT_VO, MSGL_ERR, ".\n");
+ MP_ERR(p, ".\n");
}
}
@@ -1964,15 +1969,16 @@ void gl_video_config(struct gl_video *p, struct mp_image_params *params)
void gl_video_set_output_depth(struct gl_video *p, int r, int g, int b)
{
- mp_msg(MSGT_VO, MSGL_V, "[gl] Display depth: R=%d, G=%d, B=%d\n", r, g, b);
+ MP_VERBOSE(p, "Display depth: R=%d, G=%d, B=%d\n", r, g, b);
p->depth_g = g;
}
-struct gl_video *gl_video_init(GL *gl)
+struct gl_video *gl_video_init(GL *gl, struct mp_log *log)
{
struct gl_video *p = talloc_ptrtype(NULL, p);
*p = (struct gl_video) {
.gl = gl,
+ .log = log,
.opts = gl_video_opts_def,
.gl_debug = true,
.colorspace = MP_CSP_DETAILS_DEFAULTS,
@@ -2046,7 +2052,7 @@ bool gl_video_set_equalizer(struct gl_video *p, const char *name, int val)
{
if (mp_csp_equalizer_set(&p->video_eq, name, val) >= 0) {
if (!p->opts.gamma && p->video_eq.values[MP_CSP_EQ_GAMMA] != 0) {
- mp_msg(MSGT_VO, MSGL_V, "[gl] Auto-enabling gamma.\n");
+ MP_VERBOSE(p, "Auto-enabling gamma.\n");
p->opts.gamma = true;
compile_shaders(p);
}
diff --git a/video/out/gl_video.h b/video/out/gl_video.h
index ca0cb5468a..2ed8507a9c 100644
--- a/video/out/gl_video.h
+++ b/video/out/gl_video.h
@@ -52,7 +52,7 @@ extern const struct m_sub_options gl_video_conf;
struct gl_video;
-struct gl_video *gl_video_init(GL *gl);
+struct gl_video *gl_video_init(GL *gl, struct mp_log *log);
void gl_video_uninit(struct gl_video *p);
void gl_video_set_options(struct gl_video *p, struct gl_video_opts *opts);
void gl_video_config(struct gl_video *p, struct mp_image_params *params);
diff --git a/video/out/gl_wayland.c b/video/out/gl_wayland.c
index 1b5a21ec43..0381177292 100644
--- a/video/out/gl_wayland.c
+++ b/video/out/gl_wayland.c
@@ -27,6 +27,7 @@
#include "gl_common.h"
struct egl_context {
+ struct mp_log *log;
EGLSurface egl_surface;
struct wl_egl_window *egl_window;
@@ -96,6 +97,8 @@ static void egl_resize_func(struct vo_wayland_state *wl,
else
y = 0;
+ MP_VERBOSE(ctx, "resizing %dx%d -> %dx%d\n", wl->window.width,
+ wl->window.height, width, height);
wl_egl_window_resize(ctx->egl_window, width, height, x, y);
wl->window.width = width;
@@ -134,6 +137,8 @@ static bool egl_create_context(struct vo_wayland_state *wl,
if (eglInitialize(egl_ctx->egl.dpy, &major, &minor) != EGL_TRUE)
return false;
+ MP_VERBOSE(egl_ctx, "EGL version %d.%d\n", major, minor);
+
EGLint context_attribs[] = {
EGL_CONTEXT_MAJOR_VERSION_KHR,
MPGL_VER_GET_MAJOR(ctx->requested_gl_version),
@@ -210,6 +215,8 @@ static bool config_window_wayland(struct MPGLContext *ctx,
bool enable_alpha = !!(flags & VOFLAG_ALPHA);
bool ret = false;
+ egl_ctx->log = mp_log_new(egl_ctx, wl->log, "EGL");
+
wl->window.resize_func = egl_resize_func;
wl->window.resize_func_data = (void*) egl_ctx;
diff --git a/video/out/vo.c b/video/out/vo.c
index 2db6afa05a..3a0c1d060d 100644
--- a/video/out/vo.c
+++ b/video/out/vo.c
@@ -39,6 +39,7 @@
#include "core/input/input.h"
#include "core/m_config.h"
#include "core/mp_msg.h"
+#include "core/mpv_global.h"
#include "video/mp_image.h"
#include "video/vfcap.h"
#include "sub/sub.h"
@@ -134,20 +135,24 @@ const struct m_obj_list vo_obj_list = {
.allow_trailer = true,
};
-static struct vo *vo_create(struct mp_vo_opts *opts,
+static struct vo *vo_create(struct mpv_global *global,
struct input_ctx *input_ctx,
struct encode_lavc_context *encode_lavc_ctx,
char *name, char **args)
{
+ struct mp_log *log = mp_log_new(NULL, global->log, "vo");
struct m_obj_desc desc;
if (!m_obj_list_find(&desc, &vo_obj_list, bstr0(name))) {
- mp_tmsg(MSGT_CPLAYER, MSGL_ERR, "Video output %s not found!\n", name);
+ mp_tmsg_log(log, MSGL_ERR, "Video output %s not found!\n", name);
+ talloc_free(log);
return NULL;
};
struct vo *vo = talloc_ptrtype(NULL, vo);
*vo = (struct vo) {
+ .vo_log = { .log = talloc_steal(vo, log) },
+ .log = mp_log_new(vo, log, name),
.driver = desc.p,
- .opts = opts,
+ .opts = &global->opts->vo,
.encode_lavc_ctx = encode_lavc_ctx,
.input_ctx = input_ctx,
.event_fd = -1,
@@ -289,18 +294,18 @@ void vo_destroy(struct vo *vo)
talloc_free(vo);
}
-struct vo *init_best_video_out(struct mp_vo_opts *opts,
+struct vo *init_best_video_out(struct mpv_global *global,
struct input_ctx *input_ctx,
struct encode_lavc_context *encode_lavc_ctx)
{
- struct m_obj_settings *vo_list = opts->video_driver_list;
+ struct m_obj_settings *vo_list = global->opts->vo.video_driver_list;
// first try the preferred drivers, with their optional subdevice param:
if (vo_list && vo_list[0].name) {
for (int n = 0; vo_list[n].name; n++) {
// Something like "-vo name," allows fallback to autoprobing.
if (strlen(vo_list[n].name) == 0)
goto autoprobe;
- struct vo *vo = vo_create(opts, input_ctx, encode_lavc_ctx,
+ struct vo *vo = vo_create(global, input_ctx, encode_lavc_ctx,
vo_list[n].name, vo_list[n].attribs);
if (vo)
return vo;
@@ -310,7 +315,7 @@ struct vo *init_best_video_out(struct mp_vo_opts *opts,
autoprobe:
// now try the rest...
for (int i = 0; video_out_drivers[i]; i++) {
- struct vo *vo = vo_create(opts, input_ctx, encode_lavc_ctx,
+ struct vo *vo = vo_create(global, input_ctx, encode_lavc_ctx,
(char *)video_out_drivers[i]->info->short_name, NULL);
if (vo)
return vo;
@@ -444,24 +449,22 @@ int lookup_keymap_table(const struct mp_keymap *map, int key) {
static void print_video_rect(struct vo *vo, struct mp_rect src,
struct mp_rect dst, struct mp_osd_res osd)
{
- int lv = MSGL_V;
-
int sw = src.x1 - src.x0, sh = src.y1 - src.y0;
int dw = dst.x1 - dst.x0, dh = dst.y1 - dst.y0;
- mp_msg(MSGT_VO, lv, "[vo] Window size: %dx%d\n",
- vo->dwidth, vo->dheight);
- mp_msg(MSGT_VO, lv, "[vo] Video source: %dx%d (%dx%d)\n",
- vo->aspdat.orgw, vo->aspdat.orgh,
- vo->aspdat.prew, vo->aspdat.preh);
- mp_msg(MSGT_VO, lv, "[vo] Video display: (%d, %d) %dx%d -> (%d, %d) %dx%d\n",
- src.x0, src.y0, sw, sh, dst.x0, dst.y0, dw, dh);
- mp_msg(MSGT_VO, lv, "[vo] Video scale: %f/%f\n",
- (double)dw / sw, (double)dh / sh);
- mp_msg(MSGT_VO, lv, "[vo] OSD borders: l=%d t=%d r=%d b=%d\n",
- osd.ml, osd.mt, osd.mr, osd.mb);
- mp_msg(MSGT_VO, lv, "[vo] Video borders: l=%d t=%d r=%d b=%d\n",
- dst.x0, dst.y0, vo->dwidth - dst.x1, vo->dheight - dst.y1);
+ MP_VERBOSE(&vo->vo_log, "Window size: %dx%d\n",
+ vo->dwidth, vo->dheight);
+ MP_VERBOSE(&vo->vo_log, "Video source: %dx%d (%dx%d)\n",
+ vo->aspdat.orgw, vo->aspdat.orgh,
+ vo->aspdat.prew, vo->aspdat.preh);
+ MP_VERBOSE(&vo->vo_log, "Video display: (%d, %d) %dx%d -> (%d, %d) %dx%d\n",
+ src.x0, src.y0, sw, sh, dst.x0, dst.y0, dw, dh);
+ MP_VERBOSE(&vo->vo_log, "Video scale: %f/%f\n",
+ (double)dw / sw, (double)dh / sh);
+ MP_VERBOSE(&vo->vo_log, "OSD borders: l=%d t=%d r=%d b=%d\n",
+ osd.ml, osd.mt, osd.mr, osd.mb);
+ MP_VERBOSE(&vo->vo_log, "Video borders: l=%d t=%d r=%d b=%d\n",
+ dst.x0, dst.y0, vo->dwidth - dst.x1, vo->dheight - dst.y1);
}
// Clamp [start, end) to range [0, size) with various fallbacks.
diff --git a/video/out/vo.h b/video/out/vo.h
index ae84f9d0c9..1a57ad2a25 100644
--- a/video/out/vo.h
+++ b/video/out/vo.h
@@ -51,8 +51,7 @@ enum mp_voctrl {
VOCTRL_GET_EQUALIZER, // struct voctrl_get_equalizer_args*
/* for vdpau hardware decoding */
- VOCTRL_HWDEC_DECODER_RENDER, // pointer to hw state
- VOCTRL_HWDEC_ALLOC_SURFACE, // struct mp_image**
+ VOCTRL_GET_HWDEC_INFO, // struct mp_hwdec_info*
VOCTRL_NEWFRAME,
VOCTRL_SKIPFRAME,
@@ -233,8 +232,12 @@ struct vo_driver {
};
struct vo {
- int config_ok; // Last config call was successful?
- int config_count; // Total number of successful config calls
+ struct {
+ struct mp_log *log; // Using "[vo]" as prefix
+ } vo_log;
+ struct mp_log *log; // Using e.g. "[vo/vdpau]" as prefix
+ int config_ok; // Last config call was successful?
+ int config_count; // Total number of successful config calls
bool untimed; // non-interactive, don't do sleep calls in playloop
@@ -282,7 +285,8 @@ struct vo {
char *window_title;
};
-struct vo *init_best_video_out(struct mp_vo_opts *opts,
+struct mpv_global;
+struct vo *init_best_video_out(struct mpv_global *global,
struct input_ctx *input_ctx,
struct encode_lavc_context *encode_lavc_ctx);
int vo_reconfig(struct vo *vo, struct mp_image_params *p, int flags);
diff --git a/video/out/vo_corevideo.m b/video/out/vo_corevideo.c
index cb60fef95d..77511b2b0b 100644
--- a/video/out/vo_corevideo.m
+++ b/video/out/vo_corevideo.c
@@ -19,23 +19,21 @@
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
+#include <QuartzCore/QuartzCore.h>
#include <assert.h>
-#import "vo_corevideo.h"
+#include "talloc.h"
+#include "video/out/vo.h"
+#include "sub/sub.h"
+#include "core/m_option.h"
-// mplayer includes
-#import "talloc.h"
-#import "vo.h"
-#import "sub/sub.h"
-#import "core/m_option.h"
+#include "video/csputils.h"
+#include "video/vfcap.h"
+#include "video/mp_image.h"
-#import "video/csputils.h"
-#import "video/vfcap.h"
-#import "video/mp_image.h"
-
-#import "gl_common.h"
-#import "gl_osd.h"
-#import "cocoa_common.h"
+#include "gl_common.h"
+#include "gl_osd.h"
+#include "cocoa_common.h"
struct quad {
GLfloat lowerLeft[2];
@@ -83,13 +81,6 @@ static int init_gl(struct vo *vo, uint32_t d_width, uint32_t d_height)
struct priv *p = vo->priv;
GL *gl = p->mpglctx->gl;
- const char *vendor = gl->GetString(GL_VENDOR);
- const char *version = gl->GetString(GL_VERSION);
- const char *renderer = gl->GetString(GL_RENDERER);
-
- mp_msg(MSGT_VO, MSGL_V, "[vo_corevideo] Running on OpenGL '%s' by '%s',"
- " version '%s'\n", renderer, vendor, version);
-
gl->Disable(GL_BLEND);
gl->Disable(GL_DEPTH_TEST);
gl->DepthMask(GL_FALSE);
@@ -148,8 +139,7 @@ static void prepare_texture(struct vo *vo)
error = CVOpenGLTextureCacheCreateTextureFromImage(NULL,
p->textureCache, p->pixelBuffer, 0, &p->texture);
if(error != kCVReturnSuccess)
- mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create OpenGL"
- " texture(%d)\n", error);
+ MP_ERR(vo, "Failed to create OpenGL texture(%d)\n", error);
CVOpenGLTextureGetCleanTexCoords(p->texture, q->lowerLeft, q->lowerRight,
q->upperRight, q->upperLeft);
@@ -215,15 +205,13 @@ static void draw_image(struct vo *vo, mp_image_t *mpi)
error = CVOpenGLTextureCacheCreate(NULL, 0, vo_cocoa_cgl_context(vo),
vo_cocoa_cgl_pixel_format(vo), 0, &p->textureCache);
if(error != kCVReturnSuccess)
- mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create OpenGL"
- " texture Cache(%d)\n", error);
+ MP_ERR(vo, "Failed to create OpenGL texture Cache(%d)\n", error);
error = CVPixelBufferCreateWithBytes(NULL, mpi->w, mpi->h,
p->pixelFormat, mpi->planes[0], mpi->stride[0],
NULL, NULL, NULL, &p->pixelBuffer);
if(error != kCVReturnSuccess)
- mp_msg(MSGT_VO, MSGL_ERR,"[vo_corevideo] Failed to create Pixel"
- "Buffer(%d)\n", error);
+ MP_ERR(vo, "Failed to create PixelBuffer(%d)\n", error);
}
do_render(vo);
@@ -317,8 +305,8 @@ static int get_image_fmt(struct vo *vo)
case k32ARGBPixelFormat: return IMGFMT_ARGB;
case k32BGRAPixelFormat: return IMGFMT_BGRA;
}
- mp_msg(MSGT_VO, MSGL_ERR, "[vo_corevideo] Failed to convert pixel format. "
- "Please contact the developers. PixelFormat: %d\n", p->pixelFormat);
+ MP_ERR(vo, "Failed to convert pixel format. Please contact the "
+ "developers. PixelFormat: %d\n", p->pixelFormat);
return -1;
}
diff --git a/video/out/vo_corevideo.h b/video/out/vo_corevideo.h
deleted file mode 100644
index cfb86621bc..0000000000
--- a/video/out/vo_corevideo.h
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- * CoreVideo video output driver
- *
- * Copyright (c) 2005 Nicolas Plourde <nicolasplourde@gmail.com>
- *
- * This file is part of MPlayer.
- *
- * MPlayer is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2 of the License, or
- * (at your option) any later version.
- *
- * MPlayer is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License along
- * with MPlayer; if not, write to the Free Softw