diff options
Diffstat (limited to 'src/video_out/video_out_xshm.c')
-rw-r--r-- | src/video_out/video_out_xshm.c | 190 |
1 files changed, 95 insertions, 95 deletions
diff --git a/src/video_out/video_out_xshm.c b/src/video_out/video_out_xshm.c index 74791f145..3d4dae3f9 100644 --- a/src/video_out/video_out_xshm.c +++ b/src/video_out/video_out_xshm.c @@ -1,13 +1,13 @@ /* * Copyright (C) 2000-2003 the xine project - * + * * This file is part of xine, a free video player. - * + * * xine 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. - * + * * xine 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 @@ -76,7 +76,7 @@ typedef struct { int flags; vo_scale_t sc; - + XImage *image; XShmSegmentInfo shminfo; @@ -100,7 +100,7 @@ typedef struct { int depth, bpp, bytes_per_pixel, image_byte_order; int use_shm; XColor black; - + int yuv2rgb_brightness; int yuv2rgb_contrast; int yuv2rgb_saturation; @@ -108,7 +108,7 @@ typedef struct { yuv2rgb_factory_t *yuv2rgb_factory; vo_scale_t sc; - + xshm_frame_t *cur_frame; x11osd *xoverlay; int ovl_changed; @@ -164,11 +164,11 @@ static void x11_DeInstallXErrorHandler (xshm_driver_t *this) { } /* - * allocate an XImage, try XShm first but fall back to + * allocate an XImage, try XShm first but fall back to * plain X11 if XShm should fail */ /* called xlocked */ -static XImage *create_ximage (xshm_driver_t *this, XShmSegmentInfo *shminfo, +static XImage *create_ximage (xshm_driver_t *this, XShmSegmentInfo *shminfo, int width, int height) { XImage *myimage = NULL; @@ -177,16 +177,16 @@ static XImage *create_ximage (xshm_driver_t *this, XShmSegmentInfo *shminfo, /* * try shm */ - + gX11Fail = 0; x11_InstallXErrorHandler (this); - myimage = XShmCreateImage(this->display, + myimage = XShmCreateImage(this->display, this->visual, this->depth, ZPixmap, NULL, shminfo, - width, + width, height); if (myimage == NULL ) { @@ -196,15 +196,15 @@ static XImage *create_ximage (xshm_driver_t *this, XShmSegmentInfo *shminfo, this->use_shm = 0; goto finishShmTesting; } - + this->bpp = myimage->bits_per_pixel; this->bytes_per_pixel = this->bpp / 8; this->image_byte_order = myimage->byte_order; - + shminfo->shmid=shmget(IPC_PRIVATE, - myimage->bytes_per_line * myimage->height, + myimage->bytes_per_line * myimage->height, IPC_CREAT | 0777); - + if (shminfo->shmid < 0 ) { xprintf(this->xine, XINE_VERBOSITY_LOG, _("video_out_xshm: %s: allocating image\n" @@ -212,9 +212,9 @@ static XImage *create_ximage (xshm_driver_t *this, XShmSegmentInfo *shminfo, this->use_shm = 0; goto finishShmTesting; } - + shminfo->shmaddr = (char *) shmat(shminfo->shmid, 0, 0); - + if (shminfo->shmaddr == ((char *) -1)) { xprintf(this->xine, XINE_VERBOSITY_LOG, _("video_out_xshm: shared memory error (address error) when allocating image \n" @@ -224,12 +224,12 @@ static XImage *create_ximage (xshm_driver_t *this, XShmSegmentInfo *shminfo, this->use_shm = 0; goto finishShmTesting; } - + shminfo->readOnly = False; myimage->data = shminfo->shmaddr; - + XShmAttach(this->display, shminfo); - + XSync(this->display, False); if (gX11Fail) { @@ -243,10 +243,10 @@ static XImage *create_ximage (xshm_driver_t *this, XShmSegmentInfo *shminfo, goto finishShmTesting; } - /* + /* * Now that the Xserver has learned about and attached to the * shared memory segment, delete it. It's actually deleted by - * the kernel when all users of that segment have detached from + * the kernel when all users of that segment have detached from * it. Gives an automatic shared memory cleanup in case we crash. */ shmctl (shminfo->shmid, IPC_RMID, 0); @@ -268,7 +268,7 @@ static XImage *create_ximage (xshm_driver_t *this, XShmSegmentInfo *shminfo, this->depth, ZPixmap, 0, NULL, - width, + width, height, 8, 0); @@ -284,8 +284,8 @@ static XImage *create_ximage (xshm_driver_t *this, XShmSegmentInfo *shminfo, } /* called xlocked */ -static void dispose_ximage (xshm_driver_t *this, - XShmSegmentInfo *shminfo, +static void dispose_ximage (xshm_driver_t *this, + XShmSegmentInfo *shminfo, XImage *myimage) { if (this->use_shm) { @@ -298,7 +298,7 @@ static void dispose_ximage (xshm_driver_t *this, shminfo->shmid = -1; } - } + } else XDestroyImage (myimage); } @@ -321,10 +321,10 @@ static uint32_t xshm_get_capabilities (vo_driver_t *this_gen) { static void xshm_frame_proc_slice (vo_frame_t *vo_img, uint8_t **src) { xshm_frame_t *frame = (xshm_frame_t *) vo_img ; /*xshm_driver_t *this = (xshm_driver_t *) vo_img->driver; */ - - vo_img->proc_called = 1; - - if( frame->vo_frame.crop_left || frame->vo_frame.crop_top || + + vo_img->proc_called = 1; + + if( frame->vo_frame.crop_left || frame->vo_frame.crop_top || frame->vo_frame.crop_right || frame->vo_frame.crop_bottom ) { /* we don't support crop, so don't even waste cpu cycles. @@ -332,7 +332,7 @@ static void xshm_frame_proc_slice (vo_frame_t *vo_img, uint8_t **src) { */ return; } - + lprintf ("copy... (format %d)\n", frame->format); if (frame->format == XINE_IMGFMT_YV12) @@ -341,7 +341,7 @@ static void xshm_frame_proc_slice (vo_frame_t *vo_img, uint8_t **src) { else frame->yuv2rgb->yuy22rgb_fun (frame->yuv2rgb, frame->rgb_dst, src[0]); - + lprintf ("copy...done\n"); } @@ -398,10 +398,10 @@ static vo_frame_t *xshm_alloc_frame (vo_driver_t *this_gen) { /* * supply required functions/fields */ - + frame->vo_frame.proc_slice = xshm_frame_proc_slice; frame->vo_frame.proc_frame = NULL; - frame->vo_frame.field = xshm_frame_field; + frame->vo_frame.field = xshm_frame_field; frame->vo_frame.dispose = xshm_frame_dispose; frame->vo_frame.driver = this_gen; @@ -461,7 +461,7 @@ static void xshm_update_frame_format (vo_driver_t *this_gen, frame->sc.video_pixel_aspect, &gui_width, &gui_height, &gui_pixel_aspect); - + /* find out if we need to adapt this frame */ do_adapt = 0; @@ -486,7 +486,7 @@ static void xshm_update_frame_format (vo_driver_t *this_gen, frame->sc.user_ratio = this->sc.user_ratio; xshm_compute_ideal_size (this, frame); - + /* now we have updated video_aspect_pixel we use the callback */ /* again to obtain the correct gui_width and gui_height values. */ frame->sc.dest_size_cb (frame->sc.user_data, width, height, @@ -494,20 +494,20 @@ static void xshm_update_frame_format (vo_driver_t *this_gen, &gui_width, &gui_height, &gui_pixel_aspect); } - + if ((frame->sc.gui_width != gui_width) || (frame->sc.gui_height != gui_height) || do_adapt) { - + do_adapt = 1; frame->sc.gui_width = gui_width; frame->sc.gui_height = gui_height; - + xshm_compute_rgb_size (this, frame); - + lprintf ("gui_size has changed => adapt\n"); } - + /* ok, now do what we have to do */ @@ -564,7 +564,7 @@ static void xshm_update_frame_format (vo_driver_t *this_gen, lprintf ("stripe out_ht=%i, deliv_ht=%i\n", frame->sc.output_height, frame->sc.delivered_height); - /* + /* * set up colorspace converter */ @@ -620,7 +620,7 @@ static void xshm_overlay_clut_yuv2rgb(xshm_driver_t *this, vo_overlay_t *overla } } -static void xshm_overlay_begin (vo_driver_t *this_gen, +static void xshm_overlay_begin (vo_driver_t *this_gen, vo_frame_t *frame_gen, int changed) { xshm_driver_t *this = (xshm_driver_t *) this_gen; @@ -628,10 +628,10 @@ static void xshm_overlay_begin (vo_driver_t *this_gen, if( this->ovl_changed && this->xoverlay ) { LOCK_DISPLAY(this); - x11osd_clear(this->xoverlay); + x11osd_clear(this->xoverlay); UNLOCK_DISPLAY(this); } - + this->alphablend_extra_data.offset_x = frame_gen->overlay_offset_x; this->alphablend_extra_data.offset_y = frame_gen->overlay_offset_y; } @@ -648,7 +648,7 @@ static void xshm_overlay_end (vo_driver_t *this_gen, vo_frame_t *vo_img) { this->ovl_changed = 0; } -static void xshm_overlay_blend (vo_driver_t *this_gen, +static void xshm_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, vo_overlay_t *overlay) { xshm_driver_t *this = (xshm_driver_t *) this_gen; xshm_frame_t *frame = (xshm_frame_t *) frame_gen; @@ -658,13 +658,13 @@ static void xshm_overlay_blend (vo_driver_t *this_gen, if( overlay->unscaled ) { if( this->ovl_changed && this->xoverlay ) { LOCK_DISPLAY(this); - x11osd_blend(this->xoverlay, overlay); + x11osd_blend(this->xoverlay, overlay); UNLOCK_DISPLAY(this); } } else { if (!overlay->rgb_clut || !overlay->hili_rgb_clut) xshm_overlay_clut_yuv2rgb (this, overlay, frame); - + switch (this->bpp) { case 16: _x_blend_rgb16 ((uint8_t *)frame->image->data, overlay, @@ -685,7 +685,7 @@ static void xshm_overlay_blend (vo_driver_t *this_gen, &this->alphablend_extra_data); break; default: - xprintf(this->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->xine, XINE_VERBOSITY_DEBUG, "xine-lib:video_out_xshm:xshm_overlay_blend: Cannot blend bpp:%i\n", this->bpp); /* it should never get here, unless a user tries to play in bpp:8 */ break; @@ -696,12 +696,12 @@ static void xshm_overlay_blend (vo_driver_t *this_gen, static void clean_output_area (xshm_driver_t *this, xshm_frame_t *frame) { int i; - + memcpy( this->sc.border, frame->sc.border, sizeof(this->sc.border) ); - + LOCK_DISPLAY(this); XSetForeground (this->display, this->gc, this->black.pixel); - + for( i = 0; i < 4; i++ ) { if( this->sc.border[i].w && this->sc.border[i].h ) XFillRectangle(this->display, this->drawable, this->gc, @@ -712,7 +712,7 @@ static void clean_output_area (xshm_driver_t *this, xshm_frame_t *frame) { x11osd_resize (this->xoverlay, this->sc.gui_width, this->sc.gui_height); this->ovl_changed = 1; } - + UNLOCK_DISPLAY(this); } @@ -724,15 +724,15 @@ static int xshm_redraw_needed (vo_driver_t *this_gen) { this->sc.delivered_height = this->cur_frame->sc.delivered_height; this->sc.delivered_width = this->cur_frame->sc.delivered_width; this->sc.video_pixel_aspect = this->cur_frame->sc.video_pixel_aspect; - if( _x_vo_scale_redraw_needed( &this->sc ) ) { + if( _x_vo_scale_redraw_needed( &this->sc ) ) { clean_output_area (this, this->cur_frame); ret = 1; } - } + } else ret = 1; - + return ret; } @@ -745,22 +745,22 @@ static void xshm_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) { frame->vo_frame.id, frame->sc.output_width, frame->sc.output_height); - /* + /* * tell gui that we are about to display a frame, * ask for offset */ - + this->sc.delivered_height = frame->sc.delivered_height; this->sc.delivered_width = frame->sc.delivered_width; this->sc.video_pixel_aspect = frame->sc.video_pixel_aspect; - if( _x_vo_scale_redraw_needed( &this->sc ) ) { + if( _x_vo_scale_redraw_needed( &this->sc ) ) { clean_output_area (this, frame); } - + if (this->cur_frame) { - if ( (this->cur_frame->sc.output_width != frame->sc.output_width) + if ( (this->cur_frame->sc.output_width != frame->sc.output_width) || (this->cur_frame->sc.output_height != frame->sc.output_height) || (this->cur_frame->sc.output_xoffset != frame->sc.output_xoffset) || (this->cur_frame->sc.output_yoffset != frame->sc.output_yoffset) ) @@ -770,10 +770,10 @@ static void xshm_display_frame (vo_driver_t *this_gen, vo_frame_t *frame_gen) { } this->cur_frame = frame; - + LOCK_DISPLAY(this); lprintf ("display locked...\n"); - + if (this->use_shm) { lprintf ("put image (shm)\n"); @@ -824,14 +824,14 @@ static int xshm_get_property (vo_driver_t *this_gen, int property) { case VO_PROP_OUTPUT_YOFFSET: return this->cur_frame->sc.output_yoffset; default: - xprintf(this->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video_out_xshm: tried to get unsupported property %d\n", property); } return 0; } -static int xshm_set_property (vo_driver_t *this_gen, +static int xshm_set_property (vo_driver_t *this_gen, int property, int value) { xshm_driver_t *this = (xshm_driver_t *) this_gen; @@ -840,7 +840,7 @@ static int xshm_set_property (vo_driver_t *this_gen, if (value>=XINE_VO_ASPECT_NUM_RATIOS) value = XINE_VO_ASPECT_AUTO; this->sc.user_ratio = value; - xprintf(this->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video_out_xshm: aspect ratio changed to %s\n", _x_vo_scale_aspect_ratio_name(value)); } else if (property == VO_PROP_BRIGHTNESS) { @@ -874,7 +874,7 @@ static int xshm_set_property (vo_driver_t *this_gen, this->sc.force_redraw = 1; } else { - xprintf (this->xine, XINE_VERBOSITY_DEBUG, + xprintf (this->xine, XINE_VERBOSITY_DEBUG, "video_out_xshm: tried to set unsupported property %d\n", property); } @@ -900,7 +900,7 @@ static void xshm_get_property_min_max (vo_driver_t *this_gen, } } -static int xshm_gui_data_exchange (vo_driver_t *this_gen, +static int xshm_gui_data_exchange (vo_driver_t *this_gen, int data_type, void *data) { xshm_driver_t *this = (xshm_driver_t *) this_gen; @@ -911,15 +911,15 @@ static int xshm_gui_data_exchange (vo_driver_t *this_gen, #endif case XINE_GUI_SEND_EXPOSE_EVENT: - + lprintf ("expose event\n"); if (this->cur_frame) { XExposeEvent * xev = (XExposeEvent *) data; - + if (xev && xev->count == 0) { int i; - + LOCK_DISPLAY(this); if (this->use_shm) { XShmPutImage(this->display, @@ -929,7 +929,7 @@ static int xshm_gui_data_exchange (vo_driver_t *this_gen, False); } else { - XPutImage(this->display, + XPutImage(this->display, this->drawable, this->gc, this->cur_frame->image, 0, 0, this->cur_frame->sc.output_xoffset, this->cur_frame->sc.output_yoffset, this->cur_frame->sc.output_width, this->cur_frame->sc.output_height); @@ -952,7 +952,7 @@ static int xshm_gui_data_exchange (vo_driver_t *this_gen, } } break; - + case XINE_GUI_SEND_DRAWABLE_CHANGED: this->drawable = (Drawable) data; @@ -970,7 +970,7 @@ static int xshm_gui_data_exchange (vo_driver_t *this_gen, if (this->cur_frame) { x11_rectangle_t *rect = data; int x1, y1, x2, y2; - + _x_vo_scale_translate_gui2video(&this->cur_frame->sc, rect->x, rect->y, &x1, &y1); @@ -993,16 +993,16 @@ static int xshm_gui_data_exchange (vo_driver_t *this_gen, static void xshm_dispose (vo_driver_t *this_gen) { xshm_driver_t *this = (xshm_driver_t *) this_gen; - + if (this->cur_frame) this->cur_frame->vo_frame.dispose (&this->cur_frame->vo_frame); this->yuv2rgb_factory->dispose (this->yuv2rgb_factory); - + LOCK_DISPLAY(this); XFreeGC(this->display, this->gc); UNLOCK_DISPLAY(this); - + if( this->xoverlay ) { LOCK_DISPLAY(this); x11osd_destroy (this->xoverlay); @@ -1010,7 +1010,7 @@ static void xshm_dispose (vo_driver_t *this_gen) { } _x_alphablend_free(&this->alphablend_extra_data); - + free (this); } @@ -1022,7 +1022,7 @@ static int ImlibPaletteLUTGet(xshm_driver_t *this) { int format_ret; long length; Atom to_get; - + retval = NULL; length = 0x7fffffff; to_get = XInternAtom(this->display, "_IMLIB_COLORMAP", False); @@ -1034,7 +1034,7 @@ static int ImlibPaletteLUTGet(xshm_driver_t *this) { if (format_ret == 8) { unsigned int i; unsigned long j; - + j = 1 + retval[0]*4; this->yuv2rgb_cmap = malloc(sizeof(uint8_t) * 32 * 32 * 32); for (i = 0; i < 32 * 32 * 32 && j < num_ret; i++) @@ -1082,14 +1082,14 @@ static vo_driver_t *xshm_open_plugin_2 (video_driver_class_t *class_gen, const v int swapped; int cpu_byte_order; XColor dummy; - + this = (xshm_driver_t *) calloc(1, sizeof(xshm_driver_t)); if (!this) return NULL; _x_alphablend_init(&this->alphablend_extra_data, class->xine); - + this->display = visual->display; this->screen = visual->screen; @@ -1102,9 +1102,9 @@ static vo_driver_t *xshm_open_plugin_2 (video_driver_class_t *class_gen, const v this->sc.frame_output_cb = visual->frame_output_cb; this->sc.dest_size_cb = visual->dest_size_cb; this->sc.user_data = visual->user_data; - + this->sc.user_ratio = XINE_VO_ASPECT_AUTO; - + this->drawable = visual->d; this->cur_frame = NULL; LOCK_DISPLAY(this); @@ -1112,7 +1112,7 @@ static vo_driver_t *xshm_open_plugin_2 (video_driver_class_t *class_gen, const v UNLOCK_DISPLAY(this); this->xoverlay = NULL; this->ovl_changed = 0; - + this->x11_old_error_handler = NULL; this->xine = class->xine; @@ -1129,7 +1129,7 @@ static vo_driver_t *xshm_open_plugin_2 (video_driver_class_t *class_gen, const v this->vo_driver.gui_data_exchange = xshm_gui_data_exchange; this->vo_driver.dispose = xshm_dispose; this->vo_driver.redraw_needed = xshm_redraw_needed; - + LOCK_DISPLAY(this); XAllocNamedColor (this->display, DefaultColormap (this->display, this->screen), @@ -1151,7 +1151,7 @@ static vo_driver_t *xshm_open_plugin_2 (video_driver_class_t *class_gen, const v UNLOCK_DISPLAY(this); this->visual = attribs.visual; this->depth = attribs.depth; - + if (this->depth>16) xprintf(this->xine, XINE_VERBOSITY_LOG, _("\n\nWARNING: current display depth is %d. For better performance\n" @@ -1164,7 +1164,7 @@ static vo_driver_t *xshm_open_plugin_2 (video_driver_class_t *class_gen, const v LOCK_DISPLAY(this); if (XShmQueryExtension(this->display)) { this->use_shm = 1; - } + } else { xprintf(this->xine, XINE_VERBOSITY_LOG, _("video_out_xshm: MIT shared memory extension not present on display.\n")); @@ -1186,7 +1186,7 @@ static vo_driver_t *xshm_open_plugin_2 (video_driver_class_t *class_gen, const v */ cpu_byte_order = htonl(1) == 1 ? MSBFirst : LSBFirst; swapped = cpu_byte_order != this->image_byte_order; - + xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video_out_xshm: video mode depth is %d (%d bpp), %s, %sswapped,\n" "\tred: %08lx, green: %08lx, blue: %08lx\n", @@ -1250,16 +1250,16 @@ static vo_driver_t *xshm_open_plugin_2 (video_driver_class_t *class_gen, const v } if (!mode) { - xprintf (this->xine, XINE_VERBOSITY_LOG, + xprintf (this->xine, XINE_VERBOSITY_LOG, _("video_out_xshm: your video mode was not recognized, sorry :-(\n")); return NULL; } - + this->yuv2rgb_brightness = 0; this->yuv2rgb_contrast = 128; this->yuv2rgb_saturation = 128; - - this->yuv2rgb_factory = yuv2rgb_factory_init (mode, swapped, + + this->yuv2rgb_factory = yuv2rgb_factory_init (mode, swapped, this->yuv2rgb_cmap); this->yuv2rgb_factory->set_csc_levels (this->yuv2rgb_factory, this->yuv2rgb_brightness, @@ -1287,7 +1287,7 @@ static vo_driver_t *xshm_open_plugin_old (video_driver_class_t *class_gen, const visual.frame_output_cb = old_visual->frame_output_cb; visual.lock_display = NULL; visual.unlock_display = NULL; - + return xshm_open_plugin_2(class_gen, (void *)&visual); } @@ -1347,7 +1347,7 @@ static const vo_info_t vo_info_xshm_2 = { */ const plugin_info_t xine_plugin_info[] EXPORTED = { - /* type, API, "name", version, special_info, init_function */ + /* type, API, "name", version, special_info, init_function */ { PLUGIN_VIDEO_OUT, 21, "xshm", XINE_VERSION_CODE, &vo_info_xshm, xshm_init_class }, { PLUGIN_VIDEO_OUT, 21, "xshm", XINE_VERSION_CODE, &vo_info_xshm_2, xshm_init_class_2 }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } |