From dc44507f2ad9d6301557d32d41a87cee6e6ae934 Mon Sep 17 00:00:00 2001 From: Uoti Urpala Date: Wed, 6 May 2009 00:17:21 +0300 Subject: [PATCH] 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. --- TOOLS/vdpau_functions.py | 56 ++++++++++++++++++++++++ libvo/vdpau_template.c | 37 ++++++++++++++++ libvo/vo_vdpau.c | 93 +++------------------------------------- 3 files changed, 100 insertions(+), 86 deletions(-) create mode 100644 TOOLS/vdpau_functions.py create mode 100644 libvo/vdpau_template.c diff --git a/TOOLS/vdpau_functions.py b/TOOLS/vdpau_functions.py new file mode 100644 index 0000000000..386d70ab33 --- /dev/null +++ b/TOOLS/vdpau_functions.py @@ -0,0 +1,56 @@ +# Generate vdpau_template.c + +functions = """ +# get_error_string should be first, because the function lookup loop should +# have it available to print errors for other functions +get_error_string + +bitmap_surface_create +bitmap_surface_destroy +bitmap_surface_put_bits_native +decoder_create +decoder_destroy +decoder_render +device_destroy +generate_csc_matrix GenerateCSCMatrix # CSC completely capitalized +output_surface_create +output_surface_destroy +output_surface_put_bits_indexed +output_surface_put_bits_native +output_surface_render_bitmap_surface +output_surface_render_output_surface +presentation_queue_block_until_surface_idle +presentation_queue_create +presentation_queue_destroy +presentation_queue_display +presentation_queue_target_create_x11 +presentation_queue_target_destroy +video_mixer_create +video_mixer_destroy +video_mixer_render +video_mixer_set_attribute_values +video_mixer_set_feature_enables +video_surface_create +video_surface_destroy +video_surface_put_bits_y_cb_cr +""" + +print(""" +/* 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. + */ +""") +for line in functions.splitlines(): + parts = line.split('#')[0].strip().split() + if not parts: + continue # empty/comment line + if len(parts) > 1: + mp_name, vdpau_name = parts + else: + mp_name = parts[0] + vdpau_name = ''.join(part.capitalize() for part in mp_name.split('_')) + macro_name = mp_name.upper() + print('VDP_FUNCTION(Vdp%s, VDP_FUNC_ID_%s, %s)' % (vdpau_name, macro_name, mp_name)) 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++;