summaryrefslogtreecommitdiffstats
path: root/libvo
diff options
context:
space:
mode:
Diffstat (limited to 'libvo')
-rw-r--r--libvo/vdpau_template.c43
-rw-r--r--libvo/video_out.c18
-rw-r--r--libvo/video_out.h6
-rw-r--r--libvo/vo_corevideo.m54
-rw-r--r--libvo/vo_gl3.c2
-rw-r--r--libvo/vo_sharedbuffer.m104
-rw-r--r--libvo/vo_vdpau.c101
-rw-r--r--libvo/x11_common.c9
-rw-r--r--libvo/x11_common.h2
9 files changed, 151 insertions, 188 deletions
diff --git a/libvo/vdpau_template.c b/libvo/vdpau_template.c
deleted file mode 100644
index 14e5e7d211..0000000000
--- a/libvo/vdpau_template.c
+++ /dev/null
@@ -1,43 +0,0 @@
-
-/* List the VDPAU functions used by MPlayer.
- * Generated by vdpau_functions.py.
- * First argument on each line is the VDPAU function type name,
- * second macro name needed to get function address,
- * third name MPlayer uses for the function.
- */
-
-VDP_FUNCTION(VdpGetErrorString, VDP_FUNC_ID_GET_ERROR_STRING, get_error_string)
-VDP_FUNCTION(VdpBitmapSurfaceCreate, VDP_FUNC_ID_BITMAP_SURFACE_CREATE, bitmap_surface_create)
-VDP_FUNCTION(VdpBitmapSurfaceDestroy, VDP_FUNC_ID_BITMAP_SURFACE_DESTROY, bitmap_surface_destroy)
-VDP_FUNCTION(VdpBitmapSurfacePutBitsNative, VDP_FUNC_ID_BITMAP_SURFACE_PUT_BITS_NATIVE, bitmap_surface_put_bits_native)
-VDP_FUNCTION(VdpBitmapSurfaceQueryCapabilities, VDP_FUNC_ID_BITMAP_SURFACE_QUERY_CAPABILITIES, bitmap_surface_query_capabilities)
-VDP_FUNCTION(VdpDecoderCreate, VDP_FUNC_ID_DECODER_CREATE, decoder_create)
-VDP_FUNCTION(VdpDecoderDestroy, VDP_FUNC_ID_DECODER_DESTROY, decoder_destroy)
-VDP_FUNCTION(VdpDecoderRender, VDP_FUNC_ID_DECODER_RENDER, decoder_render)
-VDP_FUNCTION(VdpDeviceDestroy, VDP_FUNC_ID_DEVICE_DESTROY, device_destroy)
-VDP_FUNCTION(VdpGenerateCSCMatrix, VDP_FUNC_ID_GENERATE_CSC_MATRIX, generate_csc_matrix)
-VDP_FUNCTION(VdpOutputSurfaceCreate, VDP_FUNC_ID_OUTPUT_SURFACE_CREATE, output_surface_create)
-VDP_FUNCTION(VdpOutputSurfaceDestroy, VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY, output_surface_destroy)
-VDP_FUNCTION(VdpOutputSurfaceGetBitsNative, VDP_FUNC_ID_OUTPUT_SURFACE_GET_BITS_NATIVE, output_surface_get_bits_native)
-VDP_FUNCTION(VdpOutputSurfacePutBitsIndexed, VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED, output_surface_put_bits_indexed)
-VDP_FUNCTION(VdpOutputSurfacePutBitsNative, VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE, output_surface_put_bits_native)
-VDP_FUNCTION(VdpOutputSurfaceRenderBitmapSurface, VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_BITMAP_SURFACE, output_surface_render_bitmap_surface)
-VDP_FUNCTION(VdpOutputSurfaceRenderOutputSurface, VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE, output_surface_render_output_surface)
-VDP_FUNCTION(VdpPreemptionCallbackRegister, VDP_FUNC_ID_PREEMPTION_CALLBACK_REGISTER, preemption_callback_register)
-VDP_FUNCTION(VdpPresentationQueueBlockUntilSurfaceIdle, VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE, presentation_queue_block_until_surface_idle)
-VDP_FUNCTION(VdpPresentationQueueCreate, VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE, presentation_queue_create)
-VDP_FUNCTION(VdpPresentationQueueDestroy, VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY, presentation_queue_destroy)
-VDP_FUNCTION(VdpPresentationQueueDisplay, VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY, presentation_queue_display)
-VDP_FUNCTION(VdpPresentationQueueGetTime, VDP_FUNC_ID_PRESENTATION_QUEUE_GET_TIME, presentation_queue_get_time)
-VDP_FUNCTION(VdpPresentationQueueQuerySurfaceStatus, VDP_FUNC_ID_PRESENTATION_QUEUE_QUERY_SURFACE_STATUS, presentation_queue_query_surface_status)
-VDP_FUNCTION(VdpPresentationQueueTargetCreateX11, VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11, presentation_queue_target_create_x11)
-VDP_FUNCTION(VdpPresentationQueueTargetDestroy, VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY, presentation_queue_target_destroy)
-VDP_FUNCTION(VdpVideoMixerCreate, VDP_FUNC_ID_VIDEO_MIXER_CREATE, video_mixer_create)
-VDP_FUNCTION(VdpVideoMixerDestroy, VDP_FUNC_ID_VIDEO_MIXER_DESTROY, video_mixer_destroy)
-VDP_FUNCTION(VdpVideoMixerQueryFeatureSupport, VDP_FUNC_ID_VIDEO_MIXER_QUERY_FEATURE_SUPPORT, video_mixer_query_feature_support)
-VDP_FUNCTION(VdpVideoMixerRender, VDP_FUNC_ID_VIDEO_MIXER_RENDER, video_mixer_render)
-VDP_FUNCTION(VdpVideoMixerSetAttributeValues, VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES, video_mixer_set_attribute_values)
-VDP_FUNCTION(VdpVideoMixerSetFeatureEnables, VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES, video_mixer_set_feature_enables)
-VDP_FUNCTION(VdpVideoSurfaceCreate, VDP_FUNC_ID_VIDEO_SURFACE_CREATE, video_surface_create)
-VDP_FUNCTION(VdpVideoSurfaceDestroy, VDP_FUNC_ID_VIDEO_SURFACE_DESTROY, video_surface_destroy)
-VDP_FUNCTION(VdpVideoSurfacePutBitsYCbCr, VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR, video_surface_put_bits_y_cb_cr)
diff --git a/libvo/video_out.c b/libvo/video_out.c
index aea62ce0ab..b49e5b095f 100644
--- a/libvo/video_out.c
+++ b/libvo/video_out.c
@@ -36,8 +36,7 @@
#include "old_vo_wrapper.h"
#include "input/input.h"
#include "mp_fifo.h"
-
-
+#include "m_config.h"
#include "mp_msg.h"
#include "osdep/shmem.h"
@@ -258,8 +257,21 @@ const struct vo_driver *video_out_drivers[] =
};
-static int vo_preinit(struct vo *vo, const char *arg)
+static int vo_preinit(struct vo *vo, char *arg)
{
+ if (vo->driver->privsize)
+ vo->priv = talloc_zero_size(vo, vo->driver->privsize);
+ if (vo->driver->options) {
+ struct m_config *cfg = m_config_simple(vo->driver->options);
+ m_config_initialize(cfg, vo->priv);
+ char n[50];
+ int l = snprintf(n, sizeof(n), "vo/%s", vo->driver->info->short_name);
+ assert(l < sizeof(n));
+ int r = m_config_parse_suboptions(cfg, vo->priv, n, arg);
+ talloc_free(cfg);
+ if (r < 0)
+ return r;
+ }
return vo->driver->preinit(vo, arg);
}
diff --git a/libvo/video_out.h b/libvo/video_out.h
index 1fe726def5..df27d373fe 100644
--- a/libvo/video_out.h
+++ b/libvo/video_out.h
@@ -239,6 +239,12 @@ struct vo_driver {
* Closes driver. Should restore the original state of the system.
*/
void (*uninit)(struct vo *vo);
+
+ // Size of private struct for automatic allocation
+ int privsize;
+
+ // List of options to parse into priv struct (requires privsize to be set)
+ const struct m_option *options;
};
struct vo_old_functions {
diff --git a/libvo/vo_corevideo.m b/libvo/vo_corevideo.m
index 57e93a9326..4c69426e4d 100644
--- a/libvo/vo_corevideo.m
+++ b/libvo/vo_corevideo.m
@@ -69,10 +69,9 @@ struct priv {
struct osd_p *osd;
};
-static struct priv *p;
-
static void resize(struct vo *vo, int width, int height)
{
+ struct priv *p = vo->priv;
GL *gl = p->mpglctx->gl;
p->image_width = width;
p->image_height = height;
@@ -110,6 +109,7 @@ static void resize(struct vo *vo, int width, int height)
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);
@@ -136,7 +136,8 @@ static int init_gl(struct vo *vo, uint32_t d_width, uint32_t d_height)
return 1;
}
-static void release_cv_entities(void) {
+static void release_cv_entities(struct vo *vo) {
+ struct priv *p = vo->priv;
CVPixelBufferRelease(p->pixelBuffer);
p->pixelBuffer = NULL;
CVOpenGLTextureRelease(p->texture);
@@ -150,7 +151,8 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
uint32_t d_width, uint32_t d_height, uint32_t flags,
uint32_t format)
{
- release_cv_entities();
+ struct priv *p = vo->priv;
+ release_cv_entities(vo);
p->image_width = width;
p->image_height = height;
@@ -166,6 +168,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
static void check_events(struct vo *vo)
{
+ struct priv *p = vo->priv;
int e = p->mpglctx->check_events(vo);
if (e & VO_EVENT_RESIZE)
resize(vo, vo->dwidth, vo->dheight);
@@ -175,6 +178,7 @@ static void create_osd_texture(void *ctx, int x0, int y0, int w, int h,
unsigned char *src, unsigned char *srca,
int stride)
{
+ struct priv *p = ((struct vo *) ctx)->priv;
struct osd_p *osd = p->osd;
GL *gl = p->mpglctx->gl;
@@ -214,6 +218,7 @@ static void create_osd_texture(void *ctx, int x0, int y0, int w, int h,
static void clearOSD(struct vo *vo)
{
+ struct priv *p = vo->priv;
struct osd_p *osd = p->osd;
GL *gl = p->mpglctx->gl;
@@ -225,6 +230,7 @@ static void clearOSD(struct vo *vo)
static void draw_osd(struct vo *vo, struct osd_state *osd_s)
{
+ struct priv *p = vo->priv;
struct osd_p *osd = p->osd;
GL *gl = p->mpglctx->gl;
@@ -252,10 +258,11 @@ static void draw_osd(struct vo *vo, struct osd_state *osd_s)
}
}
-static void prepare_texture(void)
+static void prepare_texture(struct vo *vo)
{
- CVReturn error;
+ struct priv *p = vo->priv;
struct quad *q = p->quad;
+ CVReturn error;
CVOpenGLTextureRelease(p->texture);
error = CVOpenGLTextureCacheCreateTextureFromImage(NULL,
@@ -270,9 +277,10 @@ static void prepare_texture(void)
static void do_render(struct vo *vo)
{
+ struct priv *p = vo->priv;
struct quad *q = p->quad;
GL *gl = p->mpglctx->gl;
- prepare_texture();
+ prepare_texture(vo);
float x0 = 0;
float y0 = 0;
@@ -303,12 +311,14 @@ static void do_render(struct vo *vo)
static void flip_page(struct vo *vo)
{
+ struct priv *p = vo->priv;
p->mpglctx->swapGlBuffers(p->mpglctx);
p->mpglctx->gl->Clear(GL_COLOR_BUFFER_BIT);
}
static uint32_t draw_image(struct vo *vo, mp_image_t *mpi)
{
+ struct priv *p = vo->priv;
CVReturn error;
if (!p->textureCache || !p->pixelBuffer) {
@@ -330,8 +340,9 @@ static uint32_t draw_image(struct vo *vo, mp_image_t *mpi)
return VO_TRUE;
}
-static int query_format(uint32_t format)
+static int query_format(struct vo *vo, uint32_t format)
{
+ struct priv *p = vo->priv;
const int flags = VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW |
VFCAP_OSD | VFCAP_HWSCALE_UP | VFCAP_HWSCALE_DOWN |
VOCAP_NOSLICES;
@@ -357,27 +368,16 @@ static int query_format(uint32_t format)
static void uninit(struct vo *vo)
{
+ struct priv *p = vo->priv;
uninit_mpglcontext(p->mpglctx);
- release_cv_entities();
- talloc_free(p);
+ release_cv_entities(vo);
}
static int preinit(struct vo *vo, const char *arg)
{
- const opt_t subopts[] = {
- {NULL}
- };
-
- if (subopt_parse(arg, subopts) != 0) {
- mp_msg(MSGT_VO, MSGL_FATAL,
- "\n-vo corevideo command line help:\n"
- "Example: mplayer -vo corevideo\n"
- "\n" );
- return -1;
- }
+ struct priv *p = vo->priv;
- p = talloc_ptrtype(NULL, p);
*p = (struct priv) {
.mpglctx = init_mpglcontext(GLTYPE_COCOA, vo),
.colorspace = MP_CSP_DETAILS_DEFAULTS,
@@ -392,8 +392,9 @@ static int preinit(struct vo *vo, const char *arg)
return 0;
}
-static CFStringRef get_cv_csp_matrix(void)
+static CFStringRef get_cv_csp_matrix(struct vo *vo)
{
+ struct priv *p = vo->priv;
switch (p->colorspace.format) {
case MP_CSP_BT_601:
return kCVImageBufferYCbCrMatrix_ITU_R_601_4;
@@ -407,19 +408,21 @@ static CFStringRef get_cv_csp_matrix(void)
static void set_yuv_colorspace(struct vo *vo)
{
+ struct priv *p = vo->priv;
CVBufferSetAttachment(p->pixelBuffer,
- kCVImageBufferYCbCrMatrixKey, get_cv_csp_matrix(),
+ kCVImageBufferYCbCrMatrixKey, get_cv_csp_matrix(vo),
kCVAttachmentMode_ShouldPropagate);
vo->want_redraw = true;
}
static int control(struct vo *vo, uint32_t request, void *data)
{
+ struct priv *p = vo->priv;
switch (request) {
case VOCTRL_DRAW_IMAGE:
return draw_image(vo, data);
case VOCTRL_QUERY_FORMAT:
- return query_format(*(uint32_t*)data);
+ return query_format(vo, *(uint32_t*)data);
case VOCTRL_ONTOP:
p->mpglctx->ontop(vo);
return VO_TRUE;
@@ -464,4 +467,5 @@ const struct vo_driver video_out_corevideo = {
.flip_page = flip_page,
.check_events = check_events,
.uninit = uninit,
+ .privsize = sizeof(struct priv),
};
diff --git a/libvo/vo_gl3.c b/libvo/vo_gl3.c
index 1947839816..adfe636909 100644
--- a/libvo/vo_gl3.c
+++ b/libvo/vo_gl3.c
@@ -484,7 +484,7 @@ static char *get_section(void *talloc_ctx, struct bstr source,
char *res = talloc_strdup(talloc_ctx, "");
bool copy = false;
while (source.len) {
- struct bstr line = bstr_getline(source, &source);
+ struct bstr line = bstr_strip_linebreaks(bstr_getline(source, &source));
if (bstr_eatstart(&line, bstr(SECTION_HEADER))) {
copy = bstrcmp0(line, section) == 0;
} else if (copy) {
diff --git a/libvo/vo_sharedbuffer.m b/libvo/vo_sharedbuffer.m
index 0b811f1848..40aa170864 100644
--- a/libvo/vo_sharedbuffer.m
+++ b/libvo/vo_sharedbuffer.m
@@ -18,7 +18,7 @@
*/
/*
- * This video output was extracted from mplayer's corevideo. It's purpose it
+ * This video output was extracted from mplayer's corevideo. Its purpose is
* to copy mp_image data to a shared buffer using mmap and to do simple
* coordination with the GUIs using Distributed Objects.
*/
@@ -27,7 +27,7 @@
#include "vo_sharedbuffer.h"
#include "video_out.h"
-#include "subopt-helper.h"
+#include "m_option.h"
#include "talloc.h"
#include "libmpcodecs/vfcap.h"
@@ -53,52 +53,30 @@ struct priv {
id <MPlayerOSXVOProto> mposx_proto;
};
-struct priv *p;
-
// implementation
static void draw_alpha(void *ctx, int x0, int y0, int w, int h,
unsigned char *src, unsigned char *srca,
int stride)
{
+ struct priv *p = ((struct vo *) ctx)->priv;
p->vo_draw_alpha_fnc(w, h, src, srca, stride,
p->image_data + (x0 + y0 * p->image_width) * p->image_bytespp,
p->image_width * p->image_bytespp);
}
-static unsigned int image_bytes()
+static unsigned int image_bytes(struct priv *p)
{
return p->image_width * p->image_height * p->image_bytespp;
}
static int preinit(struct vo *vo, const char *arg)
{
- p = talloc_zero(NULL, struct priv);
-
- const opt_t subopts[] = {
- {"buffer_name", OPT_ARG_MSTRZ, &p->buffer_name, NULL},
- {NULL}
- };
-
- if (subopt_parse(arg, subopts) != 0) {
- mp_msg(MSGT_VO, MSGL_FATAL,
- "\n-vo sharedbuffer command line help:\n"
- "Example: mplayer -vo shared_buffer:buffer_name=mybuff\n"
- "\nOptions:\n"
- " buffer_name=<name>\n"
- " Name of the shared buffer created with shm_open() as well as\n"
- " the name of the NSConnection mplayer2 will try to open.\n"
- "Example: mplayer -vo sharedbuffer\n"
- "\n" );
- return -1;
- }
-
- if (!p->buffer_name) p->buffer_name = "mplayerosx";
-
return 0;
}
static void flip_page(struct vo *vo)
{
+ struct priv *p = vo->priv;
NSAutoreleasePool *pool = [NSAutoreleasePool new];
[p->mposx_proto render];
[pool release];
@@ -108,6 +86,7 @@ static void check_events(struct vo *vo) { }
static uint32_t draw_image(struct vo *vo, mp_image_t *mpi)
{
+ struct priv *p = vo->priv;
memcpy_pic(p->image_data, mpi->planes[0],
(p->image_width) * (p->image_bytespp), p->image_height,
(p->image_width) * (p->image_bytespp), mpi->stride[0]);
@@ -115,10 +94,11 @@ static uint32_t draw_image(struct vo *vo, mp_image_t *mpi)
}
static void draw_osd(struct vo *vo, struct osd_state *osd) {
+ struct priv *p = vo->priv;
osd_draw_text(osd, p->image_width, p->image_height, draw_alpha, vo);
}
-static void free_buffers(void)
+static void free_buffers(struct priv *p)
{
[p->mposx_proto stop];
p->mposx_proto = nil;
@@ -126,7 +106,7 @@ static void free_buffers(void)
p->mposx_proxy = nil;
if (p->image_data) {
- if (munmap(p->image_data, image_bytes()) == -1)
+ if (munmap(p->image_data, image_bytes(p)) == -1)
mp_msg(MSGT_VO, MSGL_FATAL, "[vo_sharedbuffer] uninit: munmap "
"failed. Error: %s\n", strerror(errno));
@@ -140,8 +120,9 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
uint32_t d_width, uint32_t d_height, uint32_t flags,
uint32_t format)
{
+ struct priv *p = vo->priv;
NSAutoreleasePool *pool = [NSAutoreleasePool new];
- free_buffers();
+ free_buffers(p);
p->image_width = width;
p->image_height = height;
@@ -158,7 +139,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
goto err_out;
}
- if (ftruncate(shm_fd, image_bytes()) == -1) {
+ if (ftruncate(shm_fd, image_bytes(p)) == -1) {
mp_msg(MSGT_VO, MSGL_FATAL,
"[vo_sharedbuffer] failed to size shared memory, possibly "
"already in use. Error: %s\n", strerror(errno));
@@ -167,7 +148,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height,
goto err_out;
}
- p->image_data = mmap(NULL, image_bytes(),
+ p->image_data = mmap(NULL, image_bytes(p),
PROT_READ | PROT_WRITE, MAP_SHARED, shm_fd, 0);
close(shm_fd);
@@ -207,28 +188,29 @@ err_out:
return 1;
}
-static int query_format(uint32_t format)
+static int query_format(struct vo *vo, uint32_t format)
{
- unsigned int image_depth = 0;
- switch (format) {
- case IMGFMT_YUY2:
- p->vo_draw_alpha_fnc = vo_draw_alpha_yuy2;
- image_depth = 16;
- goto supported;
- case IMGFMT_RGB24:
- p->vo_draw_alpha_fnc = vo_draw_alpha_rgb24;
- image_depth = 24;
- goto supported;
- case IMGFMT_ARGB:
- p->vo_draw_alpha_fnc = vo_draw_alpha_rgb32;
- image_depth = 32;
- goto supported;
- case IMGFMT_BGRA:
- p->vo_draw_alpha_fnc = vo_draw_alpha_rgb32;
- image_depth = 32;
- goto supported;
- }
- return 0;
+ struct priv *p = vo->priv;
+ unsigned int image_depth = 0;
+ switch (format) {
+ case IMGFMT_YUY2:
+ p->vo_draw_alpha_fnc = vo_draw_alpha_yuy2;
+ image_depth = 16;
+ goto supported;
+ case IMGFMT_RGB24:
+ p->vo_draw_alpha_fnc = vo_draw_alpha_rgb24;
+ image_depth = 24;
+ goto supported;
+ case IMGFMT_ARGB:
+ p->vo_draw_alpha_fnc = vo_draw_alpha_rgb32;
+ image_depth = 32;
+ goto supported;
+ case IMGFMT_BGRA:
+ p->vo_draw_alpha_fnc = vo_draw_alpha_rgb32;
+ image_depth = 32;
+ goto supported;
+ }
+ return 0;
supported:
p->image_bytespp = (image_depth + 7) / 8;
@@ -239,11 +221,13 @@ supported:
static void uninit(struct vo *vo)
{
- free_buffers();
+ struct priv *p = vo->priv;
+ free_buffers(p);
}
static int control(struct vo *vo, uint32_t request, void *data)
{
+ struct priv *p = vo->priv;
switch (request) {
case VOCTRL_DRAW_IMAGE:
return draw_image(vo, data);
@@ -251,7 +235,7 @@ static int control(struct vo *vo, uint32_t request, void *data)
[p->mposx_proto toggleFullscreen];
return VO_TRUE;
case VOCTRL_QUERY_FORMAT:
- return query_format(*(uint32_t*)data);
+ return query_format(vo, *(uint32_t*)data);
case VOCTRL_ONTOP:
[p->mposx_proto ontop];
return VO_TRUE;
@@ -259,6 +243,9 @@ static int control(struct vo *vo, uint32_t request, void *data)
return VO_NOTIMPL;
}
+#undef OPT_BASE_STRUCT
+#define OPT_BASE_STRUCT struct priv
+
const struct vo_driver video_out_sharedbuffer = {
.is_new = true,
.info = &(const vo_info_t) {
@@ -273,5 +260,10 @@ const struct vo_driver video_out_sharedbuffer = {
.flip_page = flip_page,
.check_events = check_events,
.uninit = uninit,
- .draw_osd = draw_osd
+ .draw_osd = draw_osd,
+ .privsize = sizeof(struct priv),
+ .options = (const struct m_option[]) {
+ OPT_STRING("buffer_name", buffer_name, 0, OPTDEF_STR("mplayerosx")),
+ {NULL},
+ },
};
diff --git a/libvo/vo_vdpau.c b/libvo/vo_vdpau.c
index a7a13bc36f..9343dea3e1 100644
--- a/libvo/vo_vdpau.c
+++ b/libvo/vo_vdpau.c
@@ -43,7 +43,7 @@
#include "aspect.h"
#include "csputils.h"
#include "sub/sub.h"
-#include "subopt-helper.h"
+#include "m_option.h"
#include "libmpcodecs/vfcap.h"
#include "libmpcodecs/mp_image.h"
#include "osdep/timer.h"
@@ -152,6 +152,7 @@ struct vdpctx {
int query_surface_num;
VdpTime recent_vsync_time;
float user_fps;
+ int composite_detect;
unsigned int vsync_interval;
uint64_t last_queue_time;
uint64_t queue_time[MAX_OUTPUT_SURFACES];
@@ -438,9 +439,11 @@ static int win_x11_init_vdpau_procs(struct vo *vo)
{
struct vo_x11_state *x11 = vo->x11;
struct vdpctx *vc = vo->priv;
- talloc_free(vc->vdp); // In case this is reinitialization after preemption
- struct vdp_functions *vdp = talloc_zero(vc, struct vdp_functions);
- vc->vdp = vdp;
+ if (vc->vdp) // reinitialization after preemption
+ memset(vc->vdp, 0, sizeof(*vc->vdp));
+ else
+ vc->vdp = talloc_zero(vc, struct vdp_functions);
+ struct vdp_functions *vdp = vc->vdp;
VdpStatus vdp_st;
struct vdp_function {
@@ -525,7 +528,10 @@ static int win_x11_init_vdpau_flip_queue(struct vo *vo)
vc->last_sync_update = GetTimer();
vc->vsync_interval = 1;
- if (vc->user_fps > 0) {
+ if (vc->composite_detect && vo_x11_screen_is_composited(vo)) {
+ mp_msg(MSGT_VO, MSGL_INFO, "[vdpau] Compositing window manager "
+ "detected. Assuming timing info is inaccurate.\n");
+ } else if (vc->user_fps > 0) {
vc->vsync_interval = 1e9 / vc->user_fps;
mp_msg(MSGT_VO, MSGL_INFO, "[vdpau] Assuming user-specified display "
"refresh rate of %.3f Hz.\n", vc->user_fps);
@@ -1164,7 +1170,7 @@ static void flip_page_timed(struct vo *vo, unsigned int pts_us, int duration)
else
duration *= 1000;
- if (vc->user_fps < 0)
+ if (vc->vsync_interval == 1)
duration = -1; // Make sure drop logic is disabled
uint64_t now = sync_vdptime(vo);
@@ -1484,12 +1490,7 @@ static void uninit(struct vo *vo)
static int preinit(struct vo *vo, const char *arg)
{
- int i;
- int user_colorspace = 0;
- int studio_levels = 0;
-
- struct vdpctx *vc = talloc_zero(vo, struct vdpctx);
- vo->priv = vc;
+ struct vdpctx *vc = vo->priv;
vc->eosd_packer = eosd_packer_create(vo);
@@ -1498,54 +1499,9 @@ static int preinit(struct vo *vo, const char *arg)
mark_vdpau_objects_uninitialized(vo);
vc->colorspace = (struct mp_csp_details) MP_CSP_DETAILS_DEFAULTS;
- vc->deint_type = 3;
- vc->chroma_deint = 1;
- vc->flip_offset_window = 50;
- vc->flip_offset_fs = 50;
- vc->num_output_surfaces = 3;
vc->video_eq.capabilities = MP_CSP_EQ_CAPS_COLORMATRIX;
- const opt_t subopts[] = {
- {"deint", OPT_ARG_INT, &vc->deint, NULL},
- {"chroma-deint", OPT_ARG_BOOL, &vc->chroma_deint, NULL},
- {"pullup", OPT_ARG_BOOL, &vc->pullup, NULL},
- {"denoise", OPT_ARG_FLOAT, &vc->denoise, NULL},
- {"sharpen", OPT_ARG_FLOAT, &vc->sharpen, NULL},
- {"colorspace", OPT_ARG_INT, &user_colorspace, NULL},
- {"studio", OPT_ARG_BOOL, &studio_levels, NULL},
- {"hqscaling", OPT_ARG_INT, &vc->hqscaling, NULL},
- {"fps", OPT_ARG_FLOAT, &vc->user_fps, NULL},
- {"queuetime_windowed", OPT_ARG_INT, &vc->flip_offset_window, NULL},
- {"queuetime_fs", OPT_ARG_INT, &vc->flip_offset_fs, NULL},
- {"output_surfaces", OPT_ARG_INT, &vc->num_output_surfaces, NULL},
- {NULL}
- };
- if (subopt_parse(arg, subopts) != 0) {
- mp_msg(MSGT_VO, MSGL_FATAL, "[vdpau] Could not parse suboptions.\n");
- return -1;
- }
- if (vc->hqscaling < 0 || vc->hqscaling > 9) {
- mp_msg(MSGT_VO, MSGL_FATAL, "[vdpau] Invalid value for suboption "
- "hqscaling\n");
- return -1;
- }
- if (vc->num_output_surfaces < 2) {
- mp_msg(MSGT_VO, MSGL_FATAL, "[vdpau] Invalid suboption "
- "output_surfaces: can't use less than 2 surfaces\n");
- return -1;
- }
- if (user_colorspace != 0 || studio_levels != 0) {
- mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] \"colorspace\" and \"studio\""
- " suboptions have been removed. Use options --colormatrix and"
- " --colormatrix-output-range=limited instead.\n");
- return -1;
- }
- if (vc->num_output_surfaces > MAX_OUTPUT_SURFACES) {
- mp_msg(MSGT_VO, MSGL_WARN, "[vdpau] Number of output surfaces "
- "is limited to %d.\n", MAX_OUTPUT_SURFACES);
- vc->num_output_surfaces = MAX_OUTPUT_SURFACES;
- }
- if (vc->deint)
- vc->deint_type = FFABS(vc->deint);
+
+ vc->deint_type = vc->deint ? FFABS(vc->deint) : 3;
if (vc->deint < 0)
vc->deint = 0;
@@ -1562,7 +1518,7 @@ static int preinit(struct vo *vo, const char *arg)
}
// full grayscale palette.
- for (i = 0; i < PALETTE_SIZE; ++i)
+ for (int i = 0; i < PALETTE_SIZE; ++i)
vc->palette[i] = (i << 16) | (i << 8) | i;
return 0;
@@ -1722,6 +1678,9 @@ static int control(struct vo *vo, uint32_t request, void *data)
return VO_NOTIMPL;
}
+#undef OPT_BASE_STRUCT
+#define OPT_BASE_STRUCT struct vdpctx
+
const struct vo_driver video_out_vdpau = {
.is_new = true,
.buffer_frames = true,
@@ -1741,4 +1700,26 @@ const struct vo_driver video_out_vdpau = {
.flip_page_timed = flip_page_timed,
.check_events = check_events,
.uninit = uninit,
+ .privsize = sizeof(struct vdpctx),
+ .options = (const struct m_option []){
+ OPT_INTRANGE("deint", deint, 0, -4, 4),
+ OPT_FLAG_ON("chroma-deint", chroma_deint, 0, OPTDEF_INT(1)),
+ OPT_FLAG_OFF("nochroma-deint", chroma_deint, 0),
+ OPT_MAKE_FLAGS("pullup", pullup, 0),
+ OPT_FLOATRANGE("denoise", denoise, 0, 0, 1),
+ OPT_FLOATRANGE("sharpen", sharpen, 0, -1, 1),
+ OPT_ERRORMESSAGE("colorspace", "vo_vdpau suboption \"colorspace\" has "
+ "been removed. Use --colormatrix instead.\n"),
+ OPT_ERRORMESSAGE("studio", "vo_vdpau suboption \"studio\" has been "
+ "removed. Use --colormatrix-output-range=limited "
+ "instead.\n"),
+ OPT_INTRANGE("hqscaling", hqscaling, 0, 0, 9),
+ OPT_FLOAT("fps", user_fps, 0),
+ OPT_FLAG_ON("composite-detect", composite_detect, 0, OPTDEF_INT(1)),
+ OPT_INT("queuetime_windowed", flip_offset_window, 0, OPTDEF_INT(50)),
+ OPT_INT("queuetime_fs", flip_offset_fs, 0, OPTDEF_INT(50)),
+ OPT_INTRANGE("output_surfaces", num_output_surfaces, 0,
+ 2, MAX_OUTPUT_SURFACES, OPTDEF_INT(3)),
+ {NULL},
+ }
};
diff --git a/libvo/x11_common.c b/libvo/x11_common.c
index 2fae9f480a..074e97bfed 100644
--- a/libvo/x11_common.c
+++ b/libvo/x11_common.c
@@ -337,6 +337,9 @@ static void init_atoms(struct vo_x11_state *x11)
XA_INIT(WM_PROTOCOLS);
XA_INIT(WM_DELETE_WINDOW);
XA_INIT(UTF8_STRING);
+ char buf[50];
+ sprintf(buf, "_NET_WM_CM_S%d", x11->screen);
+ x11->XA_NET_WM_CM = XInternAtom(x11->display, buf, False);
}
void update_xinerama_info(struct vo *vo) {
@@ -1942,6 +1945,12 @@ uint32_t vo_x11_get_equalizer(const char *name, int *value)
return VO_TRUE;
}
+bool vo_x11_screen_is_composited(struct vo *vo)
+{
+ struct vo_x11_state *x11 = vo->x11;
+ return XGetSelectionOwner(x11->display, x11->XA_NET_WM_CM) != None;
+}
+
#ifdef CONFIG_XV
int vo_xv_set_eq(struct vo *vo, uint32_t xv_port, const char *name, int value)
{
diff --git a/libvo/x11_common.h b/libvo/x11_common.h
index 14c7e44549..bd340c822d 100644
--- a/libvo/x11_common.h
+++ b/libvo/x11_common.h
@@ -95,6 +95,7 @@ struct vo_x11_state {
Atom XAWM_PROTOCOLS;
Atom XAWM_DELETE_WINDOW;
Atom XAUTF8_STRING;
+ Atom XA_NET_WM_CM;
};
#if defined(CONFIG_GL) || defined(CONFIG_X11) || defined(CONFIG_XV)
@@ -137,6 +138,7 @@ void vo_x11_uninit(struct vo *vo);
Colormap vo_x11_create_colormap(struct vo *vo, XVisualInfo *vinfo);
uint32_t vo_x11_set_equalizer(struct vo *vo, const char *name, int value);
uint32_t vo_x11_get_equalizer(const char *name, int *value);
+bool vo_x11_screen_is_composited(struct vo *vo);
void fstype_help(void);
void vo_x11_create_vo_window(struct vo *vo, XVisualInfo *vis,
int x, int y, unsigned int width, unsigned int height, int flags,