From 7ef7333e5990e5714719d89fa5fdf890beb76e16 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Mon, 4 May 2009 03:01:51 +0300 Subject: vo_vdpau: Delete GUI stuff, include font_load.h for force_load_font font_load.h was previously included through gui/interface.h --- libvo/vo_vdpau.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) (limited to 'libvo') diff --git a/libvo/vo_vdpau.c b/libvo/vo_vdpau.c index e0a2c40de0..532ba67795 100644 --- a/libvo/vo_vdpau.c +++ b/libvo/vo_vdpau.c @@ -46,7 +46,7 @@ #include "libavcodec/vdpau.h" -#include "gui/interface.h" +#include "font_load.h" #include "libavutil/common.h" #include "libavutil/mathematics.h" @@ -555,11 +555,6 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, visible_buf = 0; -#ifdef CONFIG_GUI - if (use_gui) - guiGetEvent(guiSetShVideo, 0); // the GUI will set up / resize our window - else -#endif { #ifdef CONFIG_XF86VM if (vm) @@ -1196,8 +1191,6 @@ static int control(uint32_t request, void *data) return get_image(data); case VOCTRL_DRAW_IMAGE: return draw_image(data); - case VOCTRL_GUISUPPORT: - return VO_TRUE; case VOCTRL_BORDER: vo_x11_border(); resize(); -- cgit v1.2.3 From 09943048cbe71cb15742608400c595cf5d4d1c45 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Mon, 4 May 2009 03:09:50 +0300 Subject: vo_vdpau: Make compile as new-style VO --- libvo/vo_vdpau.c | 175 ++++++++++++++++++++++++++++++------------------------- 1 file changed, 97 insertions(+), 78 deletions(-) (limited to 'libvo') diff --git a/libvo/vo_vdpau.c b/libvo/vo_vdpau.c index 532ba67795..dee5c8adc4 100644 --- a/libvo/vo_vdpau.c +++ b/libvo/vo_vdpau.c @@ -37,12 +37,14 @@ #include "config.h" #include "mp_msg.h" +#include "options.h" #include "video_out.h" -#include "video_out_internal.h" #include "x11_common.h" #include "aspect.h" #include "sub.h" #include "subopt-helper.h" +#include "libmpcodecs/vfcap.h" +#include "libmpcodecs/mp_image.h" #include "libavcodec/vdpau.h" @@ -54,15 +56,6 @@ #include "libass/ass.h" #include "libass/ass_mp.h" -static vo_info_t info = { - "VDPAU with X11", - "vdpau", - "Rajib Mahapatra and others", - "" -}; - -LIBVO_EXTERN(vdpau) - #define CHECK_ST_ERROR(message) \ if (vdp_st != VDP_STATUS_OK) { \ mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] %s: %s\n", \ @@ -220,7 +213,9 @@ static void push_deint_surface(VdpVideoSurface surface) deint_surfaces[0] = surface; } -static void video_to_output_surface(void) +static void flip_page(struct vo *vo); +static void draw_osd(struct vo *vo, struct osd_state *osd); +static void video_to_output_surface(struct vo *vo) { VdpTime dummy; VdpStatus vdp_st; @@ -236,8 +231,8 @@ static void video_to_output_surface(void) VdpOutputSurface output_surface; if (i) { draw_eosd(); - draw_osd(); - flip_page(); + //draw_osd(vo, NULL); + flip_page(vo); } if (deint) field = (top_field_first == i) ^ (deint > 1) ? @@ -261,14 +256,15 @@ static void video_to_output_surface(void) } } -static void resize(void) +static void resize(struct vo *vo) { VdpStatus vdp_st; int i; struct vo_rect src_rect; struct vo_rect dst_rect; struct vo_rect borders; - calc_src_dst_rects(vid_width, vid_height, &src_rect, &dst_rect, &borders, NULL); + calc_src_dst_rects(vo, vid_width, vid_height, &src_rect, &dst_rect, + &borders, NULL); out_rect_vid.x0 = dst_rect.left; out_rect_vid.x1 = dst_rect.right; out_rect_vid.y0 = dst_rect.top; @@ -285,14 +281,14 @@ static void resize(void) #endif vo_osd_changed(OSDTYPE_OSD); - if (output_surface_width < vo_dwidth || output_surface_height < vo_dheight) { - if (output_surface_width < vo_dwidth) { + if (output_surface_width < vo->dwidth || output_surface_height < vo->dheight) { + if (output_surface_width < vo->dwidth) { output_surface_width += output_surface_width >> 1; - output_surface_width = FFMAX(output_surface_width, vo_dwidth); + output_surface_width = FFMAX(output_surface_width, vo->dwidth); } - if (output_surface_height < vo_dheight) { + if (output_surface_height < vo->dheight) { output_surface_height += output_surface_height >> 1; - output_surface_height = FFMAX(output_surface_height, vo_dheight); + output_surface_height = FFMAX(output_surface_height, vo->dheight); } // Creation of output_surfaces for (i = 0; i <= NUM_OUTPUT_SURFACES; i++) { @@ -305,14 +301,15 @@ static void resize(void) mp_msg(MSGT_VO, MSGL_DBG2, "OUT CREATE: %u\n", output_surfaces[i]); } } - video_to_output_surface(); + video_to_output_surface(vo); if (visible_buf) - flip_page(); + flip_page(vo); } /* Initialize vdp_get_proc_address, called from preinit() */ -static int win_x11_init_vdpau_procs(void) +static int win_x11_init_vdpau_procs(struct vo *vo) { + struct vo_x11_state *x11 = vo->x11; VdpStatus vdp_st; struct vdp_function { @@ -368,7 +365,7 @@ static int win_x11_init_vdpau_procs(void) {0, NULL} }; - vdp_st = vdp_device_create(mDisplay, mScreen, + vdp_st = vdp_device_create(x11->display, x11->screen, &vdp_device, &vdp_get_proc_address); if (vdp_st != VDP_STATUS_OK) { mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] Error when calling vdp_device_create_x11: %i\n", vdp_st); @@ -387,11 +384,12 @@ static int win_x11_init_vdpau_procs(void) } /* Initialize vdpau_flip_queue, called from config() */ -static int win_x11_init_vdpau_flip_queue(void) +static int win_x11_init_vdpau_flip_queue(struct vo *vo) { + struct vo_x11_state *x11 = vo->x11; VdpStatus vdp_st; - vdp_st = vdp_presentation_queue_target_create_x11(vdp_device, vo_window, + vdp_st = vdp_presentation_queue_target_create_x11(vdp_device, x11->window, &vdp_flip_target); CHECK_ST_ERROR("Error when calling vdp_presentation_queue_target_create_x11") @@ -532,10 +530,11 @@ static int create_vdp_decoder(int max_refs) * connect to X server, create and map window, initialize all * VDPAU objects, create different surfaces etc. */ -static int config(uint32_t width, uint32_t height, uint32_t d_width, - uint32_t d_height, uint32_t flags, char *title, - uint32_t format) +static int config(struct vo *vo, uint32_t width, uint32_t height, + uint32_t d_width, uint32_t d_height, uint32_t flags, + char *title, uint32_t format) { + struct vo_x11_state *x11 = vo->x11; XVisualInfo vinfo; XSetWindowAttributes xswa; XWindowAttributes attribs; @@ -558,14 +557,15 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, { #ifdef CONFIG_XF86VM if (vm) - vo_vm_switch(); + vo_vm_switch(vo); else #endif - XGetWindowAttributes(mDisplay, DefaultRootWindow(mDisplay), &attribs); + XGetWindowAttributes(x11->display, DefaultRootWindow(x11->display), + &attribs); depth = attribs.depth; if (depth != 15 && depth != 16 && depth != 24 && depth != 32) depth = 24; - XMatchVisualInfo(mDisplay, mScreen, depth, TrueColor, &vinfo); + XMatchVisualInfo(x11->display, x11->screen, depth, TrueColor, &vinfo); xswa.background_pixel = 0; xswa.border_pixel = 0; @@ -573,18 +573,18 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, aspect ratio changes. */ xswamask = CWBorderPixel; - vo_x11_create_vo_window(&vinfo, vo_dx, vo_dy, d_width, d_height, + vo_x11_create_vo_window(vo, &vinfo, vo->dx, vo->dy, d_width, d_height, flags, CopyFromParent, "vdpau", title); - XChangeWindowAttributes(mDisplay, vo_window, xswamask, &xswa); + XChangeWindowAttributes(x11->display, x11->window, xswamask, &xswa); #ifdef CONFIG_XF86VM if (vm) { /* Grab the mouse pointer in our window */ if (vo_grabpointer) - XGrabPointer(mDisplay, vo_window, True, 0, + XGrabPointer(x11->display, x11->window, True, 0, GrabModeAsync, GrabModeAsync, - vo_window, None, CurrentTime); - XSetInputFocus(mDisplay, vo_window, RevertToNone, CurrentTime); + x11->window, None, CurrentTime); + XSetInputFocus(x11->display, x11->window, RevertToNone, CurrentTime); } #endif } @@ -593,7 +593,8 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, vo_fs = 1; /* -----VDPAU related code here -------- */ - if (vdp_flip_queue == VDP_INVALID_HANDLE && win_x11_init_vdpau_flip_queue()) + if (vdp_flip_queue == VDP_INVALID_HANDLE + && win_x11_init_vdpau_flip_queue(vo)) return -1; vdp_chroma_type = VDP_CHROMA_TYPE_420; @@ -619,17 +620,17 @@ static int config(uint32_t width, uint32_t height, uint32_t d_width, surface_num = 0; vid_surface_num = -1; - resize(); + resize(vo); return 0; } -static void check_events(void) +static void check_events(struct vo *vo) { - int e = vo_x11_check_events(mDisplay); + int e = vo_x11_check_events(vo); if (e & VO_EVENT_RESIZE) - resize(); + resize(vo); if ((e & VO_EVENT_EXPOSE || e & VO_EVENT_RESIZE) && int_pause) { /* did we already draw a buffer */ @@ -638,15 +639,15 @@ static void check_events(void) VdpStatus vdp_st; vdp_st = vdp_presentation_queue_display(vdp_flip_queue, output_surfaces[surface_num], - vo_dwidth, vo_dheight, + vo->dwidth, vo->dheight, 0); CHECK_ST_WARNING("Error when calling vdp_presentation_queue_display") } } } -static void draw_osd_I8A8(int x0,int y0, int w,int h, unsigned char *src, - unsigned char *srca, int stride) +static void draw_osd_I8A8(void *ctx, int x0, int y0, int w, int h, + unsigned char *src, unsigned char *srca, int stride) { VdpOutputSurface output_surface = output_surfaces[surface_num]; VdpStatus vdp_st; @@ -821,22 +822,23 @@ eosd_skip_upload: } } -static void draw_osd(void) +static void draw_osd(struct vo *vo, struct osd_state *osd) { mp_msg(MSGT_VO, MSGL_DBG2, "DRAW_OSD\n"); - vo_draw_text_ext(vo_dwidth, vo_dheight, border_x, border_y, border_x, border_y, - vid_width, vid_height, draw_osd_I8A8); + osd_draw_text_ext(osd, vo->dwidth, vo->dheight, border_x, border_y, + border_x, border_y, vid_width, vid_height, + draw_osd_I8A8, vo); } -static void flip_page(void) +static void flip_page(struct vo *vo) { VdpStatus vdp_st; mp_msg(MSGT_VO, MSGL_DBG2, "\nFLIP_PAGE VID:%u -> OUT:%u\n", surface_render[vid_surface_num].surface, output_surfaces[surface_num]); vdp_st = vdp_presentation_queue_display(vdp_flip_queue, output_surfaces[surface_num], - vo_dwidth, vo_dheight, + vo->dwidth, vo->dheight, 0); CHECK_ST_WARNING("Error when calling vdp_presentation_queue_display") @@ -844,8 +846,8 @@ static void flip_page(void) visible_buf = 1; } -static int draw_slice(uint8_t *image[], int stride[], int w, int h, - int x, int y) +static int draw_slice(struct vo *vo, uint8_t *image[], int stride[], int w, + int h, int x, int y) { VdpStatus vdp_st; struct vdpau_render_state *rndr = (struct vdpau_render_state *)image[0]; @@ -862,7 +864,7 @@ static int draw_slice(uint8_t *image[], int stride[], int w, int h, } -static int draw_frame(uint8_t *src[]) +static int draw_frame(struct vo *vo, uint8_t *src[]) { return VO_ERROR; } @@ -884,7 +886,7 @@ static struct vdpau_render_state *get_surface(int number) return &surface_render[number]; } -static uint32_t draw_image(mp_image_t *mpi) +static uint32_t draw_image(struct vo *vo, mp_image_t *mpi) { if (IMGFMT_IS_VDPAU(image_format)) { struct vdpau_render_state *rndr = mpi->priv; @@ -915,7 +917,7 @@ static uint32_t draw_image(mp_image_t *mpi) else top_field_first = 1; - video_to_output_surface(); + video_to_output_surface(vo); return VO_TRUE; } @@ -995,9 +997,9 @@ static void DestroyVdpauObjects(void) CHECK_ST_WARNING("Error when calling vdp_device_destroy") } -static void uninit(void) +static void uninit(struct vo *vo) { - if (!vo_config_count) + if (!vo->config_count) return; visible_buf = 0; @@ -1013,9 +1015,9 @@ static void uninit(void) eosd_targets = NULL; #ifdef CONFIG_XF86VM - vo_vm_close(); + vo_vm_close(vo); #endif - vo_x11_uninit(); + vo_x11_uninit(vo); dlclose(vdpau_lib_handle); } @@ -1050,7 +1052,7 @@ static const char help_msg[] = " Apply sharpening or softening, argument is strength from -1.0 to 1.0\n" ; -static int preinit(const char *arg) +static int preinit(struct vo *vo, const char *arg) { int i; static const char *vdpaulibrary = "libvdpau.so.1"; @@ -1086,7 +1088,7 @@ static int preinit(const char *arg) vdpau_device_create, vdpaulibrary); return -1; } - if (!vo_init() || win_x11_init_vdpau_procs()) + if (!vo_init(vo) || win_x11_init_vdpau_procs(vo)) return -1; decoder = VDP_INVALID_HANDLE; @@ -1117,7 +1119,7 @@ static int preinit(const char *arg) return 0; } -static int get_equalizer(char *name, int *value) { +static int get_equalizer(const char *name, int *value) { if (!strcasecmp(name, "brightness")) *value = procamp.brightness * 100; else if (!strcasecmp(name, "contrast")) @@ -1131,7 +1133,7 @@ static int get_equalizer(char *name, int *value) { return VO_TRUE; } -static int set_equalizer(char *name, int value) { +static int set_equalizer(const char *name, int value) { VdpStatus vdp_st; VdpCSCMatrix matrix; static const VdpVideoMixerAttribute attributes[] = {VDP_VIDEO_MIXER_ATTRIBUTE_CSC_MATRIX}; @@ -1157,7 +1159,7 @@ static int set_equalizer(char *name, int value) { return VO_TRUE; } -static int control(uint32_t request, void *data) +static int control(struct vo *vo, uint32_t request, void *data) { switch (request) { case VOCTRL_GET_DEINTERLACE: @@ -1190,19 +1192,19 @@ static int control(uint32_t request, void *data) case VOCTRL_GET_IMAGE: return get_image(data); case VOCTRL_DRAW_IMAGE: - return draw_image(data); + return draw_image(vo, data); case VOCTRL_BORDER: - vo_x11_border(); - resize(); - return VO_TRUE; + vo_x11_border(vo); + resize(vo); + return VO_TRUE; case VOCTRL_FULLSCREEN: - vo_x11_fullscreen(); - resize(); + vo_x11_fullscreen(vo); + resize(vo); return VO_TRUE; case VOCTRL_GET_PANSCAN: return VO_TRUE; case VOCTRL_SET_PANSCAN: - resize(); + resize(vo); return VO_TRUE; case VOCTRL_SET_EQUALIZER: { struct voctrl_set_equalizer_args *args = data; @@ -1214,10 +1216,10 @@ static int control(uint32_t request, void *data) return get_equalizer(args->name, args->valueptr); } case VOCTRL_ONTOP: - vo_x11_ontop(); + vo_x11_ontop(vo); return VO_TRUE; case VOCTRL_UPDATE_SCREENINFO: - update_xinerama_info(); + update_xinerama_info(vo); return VO_TRUE; case VOCTRL_DRAW_EOSD: if (!data) @@ -1229,13 +1231,13 @@ static int control(uint32_t request, void *data) mp_eosd_res_t *r = data; r->mt = r->mb = r->ml = r->mr = 0; if (vo_fs) { - r->w = vo_screenwidth; - r->h = vo_screenheight; + r->w = vo->opts->vo_screenwidth; + r->h = vo->opts->vo_screenheight; r->ml = r->mr = border_x; r->mt = r->mb = border_y; } else { - r->w = vo_dwidth; - r->h = vo_dheight; + r->w = vo->dwidth; + r->h = vo->dheight; } return VO_TRUE; } @@ -1243,4 +1245,21 @@ static int control(uint32_t request, void *data) return VO_NOTIMPL; } -/* @} */ +const struct vo_driver video_out_vdpau = { + .is_new = 1, + .info = &(struct vo_info_s){ + "VDPAU with X11", + "vdpau", + "Rajib Mahapatra and others", + "" + }, + .preinit = preinit, + .config = config, + .control = control, + .draw_frame = draw_frame, + .draw_slice = draw_slice, + .draw_osd = draw_osd, + .flip_page = flip_page, + .check_events = check_events, + .uninit = uninit, +}; -- cgit v1.2.3 From dc44507f2ad9d6301557d32d41a87cee6e6ae934 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Wed, 6 May 2009 00:17:21 +0300 Subject: vo_vdpau: Add template file for VDPAU functions Add a template file that contains a single listing of various information needed about the VDPAU interface functions, and is then included multiple times to create required declarations and tables. Previously some of the information needed to be duplicated for each of those uses. --- libvo/vdpau_template.c | 37 ++++++++++++++++++++ libvo/vo_vdpau.c | 93 ++++---------------------------------------------- 2 files changed, 44 insertions(+), 86 deletions(-) create mode 100644 libvo/vdpau_template.c (limited to 'libvo') diff --git a/libvo/vdpau_template.c b/libvo/vdpau_template.c new file mode 100644 index 0000000000..82660b9bb5 --- /dev/null +++ b/libvo/vdpau_template.c @@ -0,0 +1,37 @@ + +/* 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(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(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(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(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(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/vo_vdpau.c b/libvo/vo_vdpau.c index dee5c8adc4..5e1c6a937c 100644 --- a/libvo/vo_vdpau.c +++ b/libvo/vo_vdpau.c @@ -92,49 +92,9 @@ static VdpGetProcAddress *vdp_get_proc_address; static VdpPresentationQueueTarget vdp_flip_target; static VdpPresentationQueue vdp_flip_queue; -static VdpDeviceDestroy *vdp_device_destroy; -static VdpVideoSurfaceCreate *vdp_video_surface_create; -static VdpVideoSurfaceDestroy *vdp_video_surface_destroy; - -static VdpGetErrorString *vdp_get_error_string; - -/* May be used in software filtering/postprocessing options - * in MPlayer (./mplayer -vf ..) if we copy video_surface data to - * system memory. - */ -static VdpVideoSurfacePutBitsYCbCr *vdp_video_surface_put_bits_y_cb_cr; -static VdpOutputSurfacePutBitsNative *vdp_output_surface_put_bits_native; - -static VdpOutputSurfaceCreate *vdp_output_surface_create; -static VdpOutputSurfaceDestroy *vdp_output_surface_destroy; - -/* VideoMixer puts video_surface data on displayable output_surface. */ -static VdpVideoMixerCreate *vdp_video_mixer_create; -static VdpVideoMixerDestroy *vdp_video_mixer_destroy; -static VdpVideoMixerRender *vdp_video_mixer_render; -static VdpVideoMixerSetFeatureEnables *vdp_video_mixer_set_feature_enables; -static VdpVideoMixerSetAttributeValues *vdp_video_mixer_set_attribute_values; - -static VdpPresentationQueueTargetDestroy *vdp_presentation_queue_target_destroy; -static VdpPresentationQueueCreate *vdp_presentation_queue_create; -static VdpPresentationQueueDestroy *vdp_presentation_queue_destroy; -static VdpPresentationQueueDisplay *vdp_presentation_queue_display; -static VdpPresentationQueueBlockUntilSurfaceIdle *vdp_presentation_queue_block_until_surface_idle; -static VdpPresentationQueueTargetCreateX11 *vdp_presentation_queue_target_create_x11; - -static VdpOutputSurfaceRenderOutputSurface *vdp_output_surface_render_output_surface; -static VdpOutputSurfacePutBitsIndexed *vdp_output_surface_put_bits_indexed; -static VdpOutputSurfaceRenderBitmapSurface *vdp_output_surface_render_bitmap_surface; - -static VdpBitmapSurfaceCreate *vdp_bitmap_surface_create; -static VdpBitmapSurfaceDestroy *vdp_bitmap_surface_destroy; -static VdpBitmapSurfacePutBitsNative *vdp_bitmap_surface_putbits_native; - -static VdpDecoderCreate *vdp_decoder_create; -static VdpDecoderDestroy *vdp_decoder_destroy; -static VdpDecoderRender *vdp_decoder_render; - -static VdpGenerateCSCMatrix *vdp_generate_csc_matrix; +#define VDP_FUNCTION(vdp_type, _, mp_name) static vdp_type *vdp_##mp_name; +#include "vdpau_template.c" +#undef VDP_FUNCTION static void *vdpau_lib_handle; /* output_surfaces[NUM_OUTPUT_SURFACES] is misused for OSD. */ @@ -320,48 +280,9 @@ static int win_x11_init_vdpau_procs(struct vo *vo) const struct vdp_function *dsc; static const struct vdp_function vdp_func[] = { - {VDP_FUNC_ID_GET_ERROR_STRING, &vdp_get_error_string}, - {VDP_FUNC_ID_DEVICE_DESTROY, &vdp_device_destroy}, - {VDP_FUNC_ID_VIDEO_SURFACE_CREATE, &vdp_video_surface_create}, - {VDP_FUNC_ID_VIDEO_SURFACE_DESTROY, &vdp_video_surface_destroy}, - {VDP_FUNC_ID_VIDEO_SURFACE_PUT_BITS_Y_CB_CR, - &vdp_video_surface_put_bits_y_cb_cr}, - {VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_NATIVE, - &vdp_output_surface_put_bits_native}, - {VDP_FUNC_ID_OUTPUT_SURFACE_CREATE, &vdp_output_surface_create}, - {VDP_FUNC_ID_OUTPUT_SURFACE_DESTROY, &vdp_output_surface_destroy}, - {VDP_FUNC_ID_VIDEO_MIXER_CREATE, &vdp_video_mixer_create}, - {VDP_FUNC_ID_VIDEO_MIXER_DESTROY, &vdp_video_mixer_destroy}, - {VDP_FUNC_ID_VIDEO_MIXER_RENDER, &vdp_video_mixer_render}, - {VDP_FUNC_ID_VIDEO_MIXER_SET_FEATURE_ENABLES, - &vdp_video_mixer_set_feature_enables}, - {VDP_FUNC_ID_VIDEO_MIXER_SET_ATTRIBUTE_VALUES, - &vdp_video_mixer_set_attribute_values}, - {VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_DESTROY, - &vdp_presentation_queue_target_destroy}, - {VDP_FUNC_ID_PRESENTATION_QUEUE_CREATE, &vdp_presentation_queue_create}, - {VDP_FUNC_ID_PRESENTATION_QUEUE_DESTROY, - &vdp_presentation_queue_destroy}, - {VDP_FUNC_ID_PRESENTATION_QUEUE_DISPLAY, - &vdp_presentation_queue_display}, - {VDP_FUNC_ID_PRESENTATION_QUEUE_BLOCK_UNTIL_SURFACE_IDLE, - &vdp_presentation_queue_block_until_surface_idle}, - {VDP_FUNC_ID_PRESENTATION_QUEUE_TARGET_CREATE_X11, - &vdp_presentation_queue_target_create_x11}, - {VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_OUTPUT_SURFACE, - &vdp_output_surface_render_output_surface}, - {VDP_FUNC_ID_OUTPUT_SURFACE_PUT_BITS_INDEXED, - &vdp_output_surface_put_bits_indexed}, - {VDP_FUNC_ID_DECODER_CREATE, &vdp_decoder_create}, - {VDP_FUNC_ID_DECODER_RENDER, &vdp_decoder_render}, - {VDP_FUNC_ID_DECODER_DESTROY, &vdp_decoder_destroy}, - {VDP_FUNC_ID_BITMAP_SURFACE_CREATE, &vdp_bitmap_surface_create}, - {VDP_FUNC_ID_BITMAP_SURFACE_DESTROY, &vdp_bitmap_surface_destroy}, - {VDP_FUNC_ID_BITMAP_SURFACE_PUT_BITS_NATIVE, - &vdp_bitmap_surface_putbits_native}, - {VDP_FUNC_ID_OUTPUT_SURFACE_RENDER_BITMAP_SURFACE, - &vdp_output_surface_render_bitmap_surface}, - {VDP_FUNC_ID_GENERATE_CSC_MATRIX, &vdp_generate_csc_matrix}, +#define VDP_FUNCTION(_, macro_name, mp_name) {macro_name, &vdp_##mp_name}, +#include "vdpau_template.c" +#undef VDP_FUNCTION {0, NULL} }; @@ -796,7 +717,7 @@ static void generate_eosd(mp_eosd_images_t *imgs) { destRect.y0 = 0; destRect.x1 = i->w; destRect.y1 = i->h; - vdp_st = vdp_bitmap_surface_putbits_native(eosd_targets[eosd_render_count].surface, + vdp_st = vdp_bitmap_surface_put_bits_native(eosd_targets[eosd_render_count].surface, (const void *) &i->bitmap, &i->stride, &destRect); CHECK_ST_WARNING("EOSD: putbits failed") eosd_render_count++; -- cgit v1.2.3 From 72527eea10a4a4c2a03627cbd97dfc60bff4fd34 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Wed, 6 May 2009 00:32:09 +0300 Subject: vo_vdpau: Move VDPAU interface pointers into one struct Replace a bunch of vdp_* function pointer variables with one struct. A variable that was before named "vdp_xyz" is now the struct field "vdp.xyz". --- libvo/vo_vdpau.c | 108 ++++++++++++++++++++++++++++--------------------------- 1 file changed, 55 insertions(+), 53 deletions(-) (limited to 'libvo') diff --git a/libvo/vo_vdpau.c b/libvo/vo_vdpau.c index 5e1c6a937c..c924389509 100644 --- a/libvo/vo_vdpau.c +++ b/libvo/vo_vdpau.c @@ -59,14 +59,14 @@ #define CHECK_ST_ERROR(message) \ if (vdp_st != VDP_STATUS_OK) { \ mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] %s: %s\n", \ - message, vdp_get_error_string(vdp_st)); \ + message, vdp.get_error_string(vdp_st)); \ return -1; \ } #define CHECK_ST_WARNING(message) \ if (vdp_st != VDP_STATUS_OK) \ mp_msg(MSGT_VO, MSGL_WARN, "[vdpau] %s: %s\n", \ - message, vdp_get_error_string(vdp_st)); + message, vdp.get_error_string(vdp_st)); /* number of video and output surfaces */ #define NUM_OUTPUT_SURFACES 2 @@ -92,9 +92,11 @@ static VdpGetProcAddress *vdp_get_proc_address; static VdpPresentationQueueTarget vdp_flip_target; static VdpPresentationQueue vdp_flip_queue; -#define VDP_FUNCTION(vdp_type, _, mp_name) static vdp_type *vdp_##mp_name; +struct vdp_functions { +#define VDP_FUNCTION(vdp_type, _, mp_name) vdp_type *mp_name; #include "vdpau_template.c" #undef VDP_FUNCTION +} vdp; static void *vdpau_lib_handle; /* output_surfaces[NUM_OUTPUT_SURFACES] is misused for OSD. */ @@ -199,12 +201,12 @@ static void video_to_output_surface(struct vo *vo) VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD: VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD; output_surface = output_surfaces[surface_num]; - vdp_st = vdp_presentation_queue_block_until_surface_idle(vdp_flip_queue, + vdp_st = vdp.presentation_queue_block_until_surface_idle(vdp_flip_queue, output_surface, &dummy); - CHECK_ST_WARNING("Error when calling vdp_presentation_queue_block_until_surface_idle") + CHECK_ST_WARNING("Error when calling vdp.presentation_queue_block_until_surface_idle") - vdp_st = vdp_video_mixer_render(video_mixer, VDP_INVALID_HANDLE, 0, + vdp_st = vdp.video_mixer_render(video_mixer, VDP_INVALID_HANDLE, 0, field, 2, deint_surfaces + 1, deint_surfaces[0], 1, &surface_render[vid_surface_num].surface, @@ -253,11 +255,11 @@ static void resize(struct vo *vo) // Creation of output_surfaces for (i = 0; i <= NUM_OUTPUT_SURFACES; i++) { if (output_surfaces[i] != VDP_INVALID_HANDLE) - vdp_output_surface_destroy(output_surfaces[i]); - vdp_st = vdp_output_surface_create(vdp_device, VDP_RGBA_FORMAT_B8G8R8A8, + vdp.output_surface_destroy(output_surfaces[i]); + vdp_st = vdp.output_surface_create(vdp_device, VDP_RGBA_FORMAT_B8G8R8A8, output_surface_width, output_surface_height, &output_surfaces[i]); - CHECK_ST_WARNING("Error when calling vdp_output_surface_create") + CHECK_ST_WARNING("Error when calling vdp.output_surface_create") mp_msg(MSGT_VO, MSGL_DBG2, "OUT CREATE: %u\n", output_surfaces[i]); } } @@ -280,7 +282,7 @@ static int win_x11_init_vdpau_procs(struct vo *vo) const struct vdp_function *dsc; static const struct vdp_function vdp_func[] = { -#define VDP_FUNCTION(_, macro_name, mp_name) {macro_name, &vdp_##mp_name}, +#define VDP_FUNCTION(_, macro_name, mp_name) {macro_name, &vdp.mp_name}, #include "vdpau_template.c" #undef VDP_FUNCTION {0, NULL} @@ -293,11 +295,11 @@ static int win_x11_init_vdpau_procs(struct vo *vo) return -1; } - vdp_get_error_string = NULL; + vdp.get_error_string = NULL; for (dsc = vdp_func; dsc->pointer; dsc++) { vdp_st = vdp_get_proc_address(vdp_device, dsc->id, dsc->pointer); if (vdp_st != VDP_STATUS_OK) { - mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] Error when calling vdp_get_proc_address(function id %d): %s\n", dsc->id, vdp_get_error_string ? vdp_get_error_string(vdp_st) : "?"); + mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] Error when calling vdp_get_proc_address(function id %d): %s\n", dsc->id, vdp.get_error_string ? vdp.get_error_string(vdp_st) : "?"); return -1; } } @@ -310,13 +312,13 @@ static int win_x11_init_vdpau_flip_queue(struct vo *vo) struct vo_x11_state *x11 = vo->x11; VdpStatus vdp_st; - vdp_st = vdp_presentation_queue_target_create_x11(vdp_device, x11->window, + vdp_st = vdp.presentation_queue_target_create_x11(vdp_device, x11->window, &vdp_flip_target); - CHECK_ST_ERROR("Error when calling vdp_presentation_queue_target_create_x11") + CHECK_ST_ERROR("Error when calling vdp.presentation_queue_target_create_x11") - vdp_st = vdp_presentation_queue_create(vdp_device, vdp_flip_target, + vdp_st = vdp.presentation_queue_create(vdp_device, vdp_flip_target, &vdp_flip_queue); - CHECK_ST_ERROR("Error when calling vdp_presentation_queue_create") + CHECK_ST_ERROR("Error when calling vdp.presentation_queue_create") return 0; } @@ -356,7 +358,7 @@ static int create_vdp_mixer(VdpChromaType vdp_chroma_type) { if (sharpen) features[feature_count++] = VDP_VIDEO_MIXER_FEATURE_SHARPNESS; - vdp_st = vdp_video_mixer_create(vdp_device, feature_count, features, + vdp_st = vdp.video_mixer_create(vdp_device, feature_count, features, VDP_NUM_MIXER_PARAMETER, parameters, parameter_values, &video_mixer); @@ -366,13 +368,13 @@ static int create_vdp_mixer(VdpChromaType vdp_chroma_type) { if (deint < 3) feature_enables[0] = VDP_FALSE; if (feature_count) - vdp_video_mixer_set_feature_enables(video_mixer, feature_count, features, feature_enables); + vdp.video_mixer_set_feature_enables(video_mixer, feature_count, features, feature_enables); if (denoise) - vdp_video_mixer_set_attribute_values(video_mixer, 1, denoise_attrib, denoise_value); + vdp.video_mixer_set_attribute_values(video_mixer, 1, denoise_attrib, denoise_value); if (sharpen) - vdp_video_mixer_set_attribute_values(video_mixer, 1, sharpen_attrib, sharpen_value); + vdp.video_mixer_set_attribute_values(video_mixer, 1, sharpen_attrib, sharpen_value); if (!chroma_deint) - vdp_video_mixer_set_attribute_values(video_mixer, 1, skip_chroma_attrib, skip_chroma_value_ptr); + vdp.video_mixer_set_attribute_values(video_mixer, 1, skip_chroma_attrib, skip_chroma_value_ptr); return 0; } @@ -383,7 +385,7 @@ static void free_video_specific(void) { VdpStatus vdp_st; if (decoder != VDP_INVALID_HANDLE) - vdp_decoder_destroy(decoder); + vdp.decoder_destroy(decoder); decoder = VDP_INVALID_HANDLE; decoder_max_refs = -1; @@ -398,14 +400,14 @@ static void free_video_specific(void) { for (i = 0; i < MAX_VIDEO_SURFACES; i++) { if (surface_render[i].surface != VDP_INVALID_HANDLE) { - vdp_st = vdp_video_surface_destroy(surface_render[i].surface); + vdp_st = vdp.video_surface_destroy(surface_render[i].surface); CHECK_ST_WARNING("Error when calling vdp_video_surface_destroy") } surface_render[i].surface = VDP_INVALID_HANDLE; } if (video_mixer != VDP_INVALID_HANDLE) { - vdp_st = vdp_video_mixer_destroy(video_mixer); + vdp_st = vdp.video_mixer_destroy(video_mixer); CHECK_ST_WARNING("Error when calling vdp_video_mixer_destroy") } video_mixer = VDP_INVALID_HANDLE; @@ -416,7 +418,7 @@ static int create_vdp_decoder(int max_refs) VdpStatus vdp_st; VdpDecoderProfile vdp_decoder_profile; if (decoder != VDP_INVALID_HANDLE) - vdp_decoder_destroy(decoder); + vdp.decoder_destroy(decoder); switch (image_format) { case IMGFMT_VDPAU_MPEG1: vdp_decoder_profile = VDP_DECODER_PROFILE_MPEG1; @@ -435,7 +437,7 @@ static int create_vdp_decoder(int max_refs) vdp_decoder_profile = VDP_DECODER_PROFILE_VC1_ADVANCED; break; } - vdp_st = vdp_decoder_create(vdp_device, vdp_decoder_profile, + vdp_st = vdp.decoder_create(vdp_device, vdp_decoder_profile, vid_width, vid_height, max_refs, &decoder); CHECK_ST_WARNING("Failed creating VDPAU decoder"); if (vdp_st != VDP_STATUS_OK) { @@ -558,11 +560,11 @@ static void check_events(struct vo *vo) if (visible_buf) { /* redraw the last visible buffer */ VdpStatus vdp_st; - vdp_st = vdp_presentation_queue_display(vdp_flip_queue, + vdp_st = vdp.presentation_queue_display(vdp_flip_queue, output_surfaces[surface_num], vo->dwidth, vo->dheight, 0); - CHECK_ST_WARNING("Error when calling vdp_presentation_queue_display") + CHECK_ST_WARNING("Error when calling vdp.presentation_queue_display") } } } @@ -602,14 +604,14 @@ static void draw_osd_I8A8(void *ctx, int x0, int y0, int w, int h, pitch = w*2; // write source_data to osd_surface. - vdp_st = vdp_output_surface_put_bits_indexed(osd_surface, + vdp_st = vdp.output_surface_put_bits_indexed(osd_surface, VDP_INDEXED_FORMAT_I8A8, (const void *const*)&index_data, &pitch, &output_indexed_rect_vid, VDP_COLOR_TABLE_FORMAT_B8G8R8X8, (void *)palette); - CHECK_ST_WARNING("Error when calling vdp_output_surface_put_bits_indexed") + CHECK_ST_WARNING("Error when calling vdp.output_surface_put_bits_indexed") blend_state.struct_version = VDP_OUTPUT_SURFACE_RENDER_BLEND_STATE_VERSION; blend_state.blend_factor_source_color = VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE; @@ -619,14 +621,14 @@ static void draw_osd_I8A8(void *ctx, int x0, int y0, int w, int h, blend_state.blend_equation_color = VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_ADD; blend_state.blend_equation_alpha = VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_ADD; - vdp_st = vdp_output_surface_render_output_surface(output_surface, + vdp_st = vdp.output_surface_render_output_surface(output_surface, &output_indexed_rect_vid, osd_surface, &output_indexed_rect_vid, NULL, &blend_state, VDP_OUTPUT_SURFACE_RENDER_ROTATE_0); - CHECK_ST_WARNING("Error when calling vdp_output_surface_render_output_surface") + CHECK_ST_WARNING("Error when calling vdp.output_surface_render_output_surface") } static void draw_eosd(void) { @@ -644,7 +646,7 @@ static void draw_eosd(void) { blend_state.blend_equation_alpha = VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_ADD; for (i=0; iw, i->h, VDP_TRUE, &eosd_surfaces[found].surface); CHECK_ST_WARNING("EOSD: error when creating surface") eosd_surfaces[found].w = i->w; @@ -717,7 +719,7 @@ static void generate_eosd(mp_eosd_images_t *imgs) { destRect.y0 = 0; destRect.x1 = i->w; destRect.y1 = i->h; - vdp_st = vdp_bitmap_surface_put_bits_native(eosd_targets[eosd_render_count].surface, + vdp_st = vdp.bitmap_surface_put_bits_native(eosd_targets[eosd_render_count].surface, (const void *) &i->bitmap, &i->stride, &destRect); CHECK_ST_WARNING("EOSD: putbits failed") eosd_render_count++; @@ -758,10 +760,10 @@ static void flip_page(struct vo *vo) mp_msg(MSGT_VO, MSGL_DBG2, "\nFLIP_PAGE VID:%u -> OUT:%u\n", surface_render[vid_surface_num].surface, output_surfaces[surface_num]); - vdp_st = vdp_presentation_queue_display(vdp_flip_queue, output_surfaces[surface_num], + vdp_st = vdp.presentation_queue_display(vdp_flip_queue, output_surfaces[surface_num], vo->dwidth, vo->dheight, 0); - CHECK_ST_WARNING("Error when calling vdp_presentation_queue_display") + CHECK_ST_WARNING("Error when calling vdp.presentation_queue_display") surface_num = (surface_num + 1) % NUM_OUTPUT_SURFACES; visible_buf = 1; @@ -779,7 +781,7 @@ static int draw_slice(struct vo *vo, uint8_t *image[], int stride[], int w, && !create_vdp_decoder(max_refs)) return VO_FALSE; - vdp_st = vdp_decoder_render(decoder, rndr->surface, (void *)&rndr->info, rndr->bitstream_buffers_used, rndr->bitstream_buffers); + vdp_st = vdp.decoder_render(decoder, rndr->surface, (void *)&rndr->info, rndr->bitstream_buffers_used, rndr->bitstream_buffers); CHECK_ST_WARNING("Failed VDPAU decoder rendering"); return VO_TRUE; } @@ -796,7 +798,7 @@ static struct vdpau_render_state *get_surface(int number) return NULL; if (surface_render[number].surface == VDP_INVALID_HANDLE) { VdpStatus vdp_st; - vdp_st = vdp_video_surface_create(vdp_device, vdp_chroma_type, + vdp_st = vdp.video_surface_create(vdp_device, vdp_chroma_type, vid_width, vid_height, &surface_render[number].surface); CHECK_ST_WARNING("Error when calling vdp_video_surface_create") @@ -827,7 +829,7 @@ static uint32_t draw_image(struct vo *vo, mp_image_t *mpi) vid_surface_num = rndr - surface_render; if (image_format == IMGFMT_NV12) destdata[1] = destdata[2]; - vdp_st = vdp_video_surface_put_bits_y_cb_cr(rndr->surface, + vdp_st = vdp.video_surface_put_bits_y_cb_cr(rndr->surface, vdp_pixel_format, (const void *const*)destdata, mpi->stride); // pitch @@ -894,27 +896,27 @@ static void DestroyVdpauObjects(void) free_video_specific(); - vdp_st = vdp_presentation_queue_destroy(vdp_flip_queue); - CHECK_ST_WARNING("Error when calling vdp_presentation_queue_destroy") + vdp_st = vdp.presentation_queue_destroy(vdp_flip_queue); + CHECK_ST_WARNING("Error when calling vdp.presentation_queue_destroy") - vdp_st = vdp_presentation_queue_target_destroy(vdp_flip_target); - CHECK_ST_WARNING("Error when calling vdp_presentation_queue_target_destroy") + vdp_st = vdp.presentation_queue_target_destroy(vdp_flip_target); + CHECK_ST_WARNING("Error when calling vdp.presentation_queue_target_destroy") for (i = 0; i <= NUM_OUTPUT_SURFACES; i++) { - vdp_st = vdp_output_surface_destroy(output_surfaces[i]); + vdp_st = vdp.output_surface_destroy(output_surfaces[i]); output_surfaces[i] = VDP_INVALID_HANDLE; - CHECK_ST_WARNING("Error when calling vdp_output_surface_destroy") + CHECK_ST_WARNING("Error when calling vdp.output_surface_destroy") } for (i = 0; i Date: Wed, 6 May 2009 21:04:37 +0300 Subject: vo_vdpau: Replace global function table with context variable --- libvo/vo_vdpau.c | 239 ++++++++++++++++++++++++++++++++++--------------------- 1 file changed, 148 insertions(+), 91 deletions(-) (limited to 'libvo') diff --git a/libvo/vo_vdpau.c b/libvo/vo_vdpau.c index c924389509..c6e2973ddd 100644 --- a/libvo/vo_vdpau.c +++ b/libvo/vo_vdpau.c @@ -38,6 +38,7 @@ #include "config.h" #include "mp_msg.h" #include "options.h" +#include "talloc.h" #include "video_out.h" #include "x11_common.h" #include "aspect.h" @@ -59,14 +60,14 @@ #define CHECK_ST_ERROR(message) \ if (vdp_st != VDP_STATUS_OK) { \ mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] %s: %s\n", \ - message, vdp.get_error_string(vdp_st)); \ + message, vdp->get_error_string(vdp_st)); \ return -1; \ } #define CHECK_ST_WARNING(message) \ if (vdp_st != VDP_STATUS_OK) \ mp_msg(MSGT_VO, MSGL_WARN, "[vdpau] %s: %s\n", \ - message, vdp.get_error_string(vdp_st)); + message, vdp->get_error_string(vdp_st)); /* number of video and output surfaces */ #define NUM_OUTPUT_SURFACES 2 @@ -82,6 +83,16 @@ * Global variable declaration - VDPAU specific */ +struct vdp_functions { +#define VDP_FUNCTION(vdp_type, _, mp_name) vdp_type *mp_name; +#include "vdpau_template.c" +#undef VDP_FUNCTION +}; + +struct vdpctx { + struct vdp_functions *vdp; +}; + /* Declaration for all variables of win_x11_init_vdpau_procs() and * win_x11_init_vdpau_flip_queue() functions */ @@ -92,12 +103,6 @@ static VdpGetProcAddress *vdp_get_proc_address; static VdpPresentationQueueTarget vdp_flip_target; static VdpPresentationQueue vdp_flip_queue; -struct vdp_functions { -#define VDP_FUNCTION(vdp_type, _, mp_name) vdp_type *mp_name; -#include "vdpau_template.c" -#undef VDP_FUNCTION -} vdp; - static void *vdpau_lib_handle; /* output_surfaces[NUM_OUTPUT_SURFACES] is misused for OSD. */ #define osd_surface output_surfaces[NUM_OUTPUT_SURFACES] @@ -166,8 +171,6 @@ static VdpProcamp procamp; static int visible_buf; static int int_pause; -static void draw_eosd(void); - static void push_deint_surface(VdpVideoSurface surface) { deint_surfaces[2] = deint_surfaces[1]; @@ -176,9 +179,10 @@ static void push_deint_surface(VdpVideoSurface surface) } static void flip_page(struct vo *vo); -static void draw_osd(struct vo *vo, struct osd_state *osd); static void video_to_output_surface(struct vo *vo) { + struct vdpctx *vc = vo->priv; + struct vdp_functions *vdp = vc->vdp; VdpTime dummy; VdpStatus vdp_st; int i; @@ -192,7 +196,7 @@ static void video_to_output_surface(struct vo *vo) int field = VDP_VIDEO_MIXER_PICTURE_STRUCTURE_FRAME; VdpOutputSurface output_surface; if (i) { - draw_eosd(); + // draw_eosd(vo); //draw_osd(vo, NULL); flip_page(vo); } @@ -201,12 +205,12 @@ static void video_to_output_surface(struct vo *vo) VDP_VIDEO_MIXER_PICTURE_STRUCTURE_BOTTOM_FIELD: VDP_VIDEO_MIXER_PICTURE_STRUCTURE_TOP_FIELD; output_surface = output_surfaces[surface_num]; - vdp_st = vdp.presentation_queue_block_until_surface_idle(vdp_flip_queue, + vdp_st = vdp->presentation_queue_block_until_surface_idle(vdp_flip_queue, output_surface, &dummy); - CHECK_ST_WARNING("Error when calling vdp.presentation_queue_block_until_surface_idle") + CHECK_ST_WARNING("Error when calling vdp->presentation_queue_block_until_surface_idle") - vdp_st = vdp.video_mixer_render(video_mixer, VDP_INVALID_HANDLE, 0, + vdp_st = vdp->video_mixer_render(video_mixer, VDP_INVALID_HANDLE, 0, field, 2, deint_surfaces + 1, deint_surfaces[0], 1, &surface_render[vid_surface_num].surface, @@ -220,6 +224,8 @@ static void video_to_output_surface(struct vo *vo) static void resize(struct vo *vo) { + struct vdpctx *vc = vo->priv; + struct vdp_functions *vdp = vc->vdp; VdpStatus vdp_st; int i; struct vo_rect src_rect; @@ -255,11 +261,11 @@ static void resize(struct vo *vo) // Creation of output_surfaces for (i = 0; i <= NUM_OUTPUT_SURFACES; i++) { if (output_surfaces[i] != VDP_INVALID_HANDLE) - vdp.output_surface_destroy(output_surfaces[i]); - vdp_st = vdp.output_surface_create(vdp_device, VDP_RGBA_FORMAT_B8G8R8A8, + vdp->output_surface_destroy(output_surfaces[i]); + vdp_st = vdp->output_surface_create(vdp_device, VDP_RGBA_FORMAT_B8G8R8A8, output_surface_width, output_surface_height, &output_surfaces[i]); - CHECK_ST_WARNING("Error when calling vdp.output_surface_create") + CHECK_ST_WARNING("Error when calling vdp->output_surface_create") mp_msg(MSGT_VO, MSGL_DBG2, "OUT CREATE: %u\n", output_surfaces[i]); } } @@ -272,20 +278,23 @@ static void resize(struct vo *vo) static int win_x11_init_vdpau_procs(struct vo *vo) { struct vo_x11_state *x11 = vo->x11; + struct vdpctx *vc = vo->priv; + struct vdp_functions *vdp = talloc_zero(vc, struct vdp_functions); + vc->vdp = vdp; VdpStatus vdp_st; struct vdp_function { const int id; - void *pointer; + int offset; }; const struct vdp_function *dsc; static const struct vdp_function vdp_func[] = { -#define VDP_FUNCTION(_, macro_name, mp_name) {macro_name, &vdp.mp_name}, +#define VDP_FUNCTION(_, macro_name, mp_name) {macro_name, offsetof(struct vdp_functions, mp_name)}, #include "vdpau_template.c" #undef VDP_FUNCTION - {0, NULL} + {0, -1} }; vdp_st = vdp_device_create(x11->display, x11->screen, @@ -295,11 +304,12 @@ static int win_x11_init_vdpau_procs(struct vo *vo) return -1; } - vdp.get_error_string = NULL; - for (dsc = vdp_func; dsc->pointer; dsc++) { - vdp_st = vdp_get_proc_address(vdp_device, dsc->id, dsc->pointer); + vdp->get_error_string = NULL; + for (dsc = vdp_func; dsc->offset >= 0; dsc++) { + vdp_st = vdp_get_proc_address(vdp_device, dsc->id, + (void **)((char *)vdp + dsc->offset)); if (vdp_st != VDP_STATUS_OK) { - mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] Error when calling vdp_get_proc_address(function id %d): %s\n", dsc->id, vdp.get_error_string ? vdp.get_error_string(vdp_st) : "?"); + mp_msg(MSGT_VO, MSGL_ERR, "[vdpau] Error when calling vdp_get_proc_address(function id %d): %s\n", dsc->id, vdp->get_error_string ? vdp->get_error_string(vdp_st) : "?"); return -1; } } @@ -309,21 +319,26 @@ static int win_x11_init_vdpau_procs(struct vo *vo) /* Initialize vdpau_flip_queue, called from config() */ static int win_x11_init_vdpau_flip_queue(struct vo *vo) { + struct vdpctx *vc = vo->priv; + struct vdp_functions *vdp = vc->vdp; struct vo_x11_state *x11 = vo->x11; VdpStatus vdp_st; - vdp_st = vdp.presentation_queue_target_create_x11(vdp_device, x11->window, + vdp_st = vdp->presentation_queue_target_create_x11(vdp_device, x11->window, &vdp_flip_target); - CHECK_ST_ERROR("Error when calling vdp.presentation_queue_target_create_x11") + CHECK_ST_ERROR("Error when calling vdp->presentation_queue_target_create_x11") - vdp_st = vdp.presentation_queue_create(vdp_device, vdp_flip_target, + vdp_st = vdp->presentation_queue_create(vdp_device, vdp_flip_target, &vdp_flip_queue); - CHECK_ST_ERROR("Error when calling vdp.presentation_queue_create") + CHECK_ST_ERROR("Error when calling vdp->presentation_queue_create") return 0; } -static int create_vdp_mixer(VdpChromaType vdp_chroma_type) { +static int create_vdp_mixer(struct vo *vo, VdpChromaType vdp_chroma_type) +{ + struct vdpctx *vc = vo->priv; + struct vdp_functions *vdp = vc->vdp; #define VDP_NUM_MIXER_PARAMETER 3 #define MAX_NUM_FEATURES 5 int i; @@ -358,7 +373,7 @@ static int create_vdp_mixer(VdpChromaType vdp_chroma_type) { if (sharpen) features[feature_count++] = VDP_VIDEO_MIXER_FEATURE_SHARPNESS; - vdp_st = vdp.video_mixer_create(vdp_device, feature_count, features, + vdp_st = vdp->video_mixer_create(vdp_device, feature_count, features, VDP_NUM_MIXER_PARAMETER, parameters, parameter_values, &video_mixer); @@ -368,24 +383,27 @@ static int create_vdp_mixer(VdpChromaType vdp_chroma_type) { if (deint < 3) feature_enables[0] = VDP_FALSE; if (feature_count) - vdp.video_mixer_set_feature_enables(video_mixer, feature_count, features, feature_enables); + vdp->video_mixer_set_feature_enables(video_mixer, feature_count, features, feature_enables); if (denoise) - vdp.video_mixer_set_attribute_values(video_mixer, 1, denoise_attrib, denoise_value); + vdp->video_mixer_set_attribute_values(video_mixer, 1, denoise_attrib, denoise_value); if (sharpen) - vdp.video_mixer_set_attribute_values(video_mixer, 1, sharpen_attrib, sharpen_value); + vdp->video_mixer_set_attribute_values(video_mixer, 1, sharpen_attrib, sharpen_value); if (!chroma_deint) - vdp.video_mixer_set_attribute_values(video_mixer, 1, skip_chroma_attrib, skip_chroma_value_ptr); + vdp->video_mixer_set_attribute_values(video_mixer, 1, skip_chroma_attrib, skip_chroma_value_ptr); return 0; } // Free everything specific to a certain video file -static void free_video_specific(void) { +static void free_video_specific(struct vo *vo) +{ + struct vdpctx *vc = vo->priv; + struct vdp_functions *vdp = vc->vdp; int i; VdpStatus vdp_st; if (decoder != VDP_INVALID_HANDLE) - vdp.decoder_destroy(decoder); + vdp->decoder_destroy(decoder); decoder = VDP_INVALID_HANDLE; decoder_max_refs = -1; @@ -400,25 +418,27 @@ static void free_video_specific(void) { for (i = 0; i < MAX_VIDEO_SURFACES; i++) { if (surface_render[i].surface != VDP_INVALID_HANDLE) { - vdp_st = vdp.video_surface_destroy(surface_render[i].surface); + vdp_st = vdp->video_surface_destroy(surface_render[i].surface); CHECK_ST_WARNING("Error when calling vdp_video_surface_destroy") } surface_render[i].surface = VDP_INVALID_HANDLE; } if (video_mixer != VDP_INVALID_HANDLE) { - vdp_st = vdp.video_mixer_destroy(video_mixer); + vdp_st = vdp->video_mixer_destroy(video_mixer); CHECK_ST_WARNING("Error when calling vdp_video_mixer_destroy") } video_mixer = VDP_INVALID_HANDLE; } -static int create_vdp_decoder(int max_refs) +static int create_vdp_decoder(struct vo *vo, int max_refs) { + struct vdpctx *vc = vo->priv; + struct vdp_functions *vdp = vc->vdp; VdpStatus vdp_st; VdpDecoderProfile vdp_decoder_profile; if (decoder != VDP_INVALID_HANDLE) - vdp.decoder_destroy(decoder); + vdp->decoder_destroy(decoder); switch (image_format) { case IMGFMT_VDPAU_MPEG1: vdp_decoder_profile = VDP_DECODER_PROFILE_MPEG1; @@ -437,7 +457,7 @@ static int create_vdp_decoder(int max_refs) vdp_decoder_profile = VDP_DECODER_PROFILE_VC1_ADVANCED; break; } - vdp_st = vdp.decoder_create(vdp_device, vdp_decoder_profile, + vdp_st = vdp->decoder_create(vdp_device, vdp_decoder_profile, vid_width, vid_height, max_refs, &decoder); CHECK_ST_WARNING("Failed creating VDPAU decoder"); if (vdp_st != VDP_STATUS_OK) { @@ -471,8 +491,8 @@ static int config(struct vo *vo, uint32_t width, uint32_t height, image_format = format; vid_width = width; vid_height = height; - free_video_specific(); - if (IMGFMT_IS_VDPAU(image_format) && !create_vdp_decoder(2)) + free_video_specific(vo); + if (IMGFMT_IS_VDPAU(image_format) && !create_vdp_decoder(vo, 2)) return -1; visible_buf = 0; @@ -538,7 +558,7 @@ static int config(struct vo *vo, uint32_t width, uint32_t height, vdp_pixel_format = VDP_YCBCR_FORMAT_UYVY; vdp_chroma_type = VDP_CHROMA_TYPE_422; } - if (create_vdp_mixer(vdp_chroma_type)) + if (create_vdp_mixer(vo, vdp_chroma_type)) return -1; surface_num = 0; @@ -550,6 +570,9 @@ static int config(struct vo *vo, uint32_t width, uint32_t height, static void check_events(struct vo *vo) { + struct vdpctx *vc = vo->priv; + struct vdp_functions *vdp = vc->vdp; + int e = vo_x11_check_events(vo); if (e & VO_EVENT_RESIZE) @@ -560,11 +583,11 @@ static void check_events(struct vo *vo) if (visible_buf) { /* redraw the last visible buffer */ VdpStatus vdp_st; - vdp_st = vdp.presentation_queue_display(vdp_flip_queue, + vdp_st = vdp->presentation_queue_display(vdp_flip_queue, output_surfaces[surface_num], vo->dwidth, vo->dheight, 0); - CHECK_ST_WARNING("Error when calling vdp.presentation_queue_display") + CHECK_ST_WARNING("Error when calling vdp->presentation_queue_display") } } } @@ -572,6 +595,9 @@ static void check_events(struct vo *vo) static void draw_osd_I8A8(void *ctx, int x0, int y0, int w, int h, unsigned char *src, unsigned char *srca, int stride) { + struct vo *vo = ctx; + struct vdpctx *vc = vo->priv; + struct vdp_functions *vdp = vc->vdp; VdpOutputSurface output_surface = output_surfaces[surface_num]; VdpStatus vdp_st; int i, j; @@ -604,14 +630,14 @@ static void draw_osd_I8A8(void *ctx, int x0, int y0, int w, int h, pitch = w*2; // write source_data to osd_surface. - vdp_st = vdp.output_surface_put_bits_indexed(osd_surface, + vdp_st = vdp->output_surface_put_bits_indexed(osd_surface, VDP_INDEXED_FORMAT_I8A8, (const void *const*)&index_data, &pitch, &output_indexed_rect_vid, VDP_COLOR_TABLE_FORMAT_B8G8R8X8, (void *)palette); - CHECK_ST_WARNING("Error when calling vdp.output_surface_put_bits_indexed") + CHECK_ST_WARNING("Error when calling vdp->output_surface_put_bits_indexed") blend_state.struct_version = VDP_OUTPUT_SURFACE_RENDER_BLEND_STATE_VERSION; blend_state.blend_factor_source_color = VDP_OUTPUT_SURFACE_RENDER_BLEND_FACTOR_ONE; @@ -621,17 +647,20 @@ static void draw_osd_I8A8(void *ctx, int x0, int y0, int w, int h, blend_state.blend_equation_color = VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_ADD; blend_state.blend_equation_alpha = VDP_OUTPUT_SURFACE_RENDER_BLEND_EQUATION_ADD; - vdp_st = vdp.output_surface_render_output_surface(output_surface, + vdp_st = vdp->output_surface_render_output_surface(output_surface, &output_indexed_rect_vid, osd_surface, &output_indexed_rect_vid, NULL, &blend_state, VDP_OUTPUT_SURFACE_RENDER_ROTATE_0); - CHECK_ST_WARNING("Error when calling vdp.output_surface_render_output_surface") + CHECK_ST_WARNING("Error when calling vdp-