diff options
Diffstat (limited to 'src/video_out/video_out_fb.c')
-rw-r--r-- | src/video_out/video_out_fb.c | 156 |
1 files changed, 78 insertions, 78 deletions
diff --git a/src/video_out/video_out_fb.c b/src/video_out/video_out_fb.c index f37b345ce..e6e30af7e 100644 --- a/src/video_out/video_out_fb.c +++ b/src/video_out/video_out_fb.c @@ -1,13 +1,13 @@ /* * Copyright (C) 2000-2007 the xine project and Fredrik Noring - * + * * 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 @@ -27,7 +27,7 @@ * @author Fredrik Noring <noring@nocrew.org>: * Zero copy buffers and clean up. * - * @author Aaron Holtzman <aholtzma@ess.engr.uvic.ca>: + * @author Aaron Holtzman <aholtzma@ess.engr.uvic.ca>: * Based on xine's video_out_xshm.c, based on mpeg2dec code from * * @author Geert Uytterhoeven and Chris Lawrence: @@ -52,8 +52,8 @@ #include <unistd.h> #include <sys/types.h> #include <sys/stat.h> -#include <fcntl.h> - +#include <fcntl.h> + #include "xine.h" #include <xine/video_out.h> @@ -95,13 +95,13 @@ typedef struct fb_frame_s int format; int flags; - + vo_scale_t sc; yuv2rgb_t *yuv2rgb; /* yuv2rgb converter for this frame */ uint8_t *rgb_dst; int yuv_stride; - + int bytes_per_line; uint8_t* video_mem; /* mmapped video memory */ @@ -118,12 +118,12 @@ typedef struct fb_driver_s int fd; int mem_size; uint8_t* video_mem_base; /* mmapped video memory */ - + int depth, bpp, bytes_per_pixel; - + int total_num_native_buffers; int used_num_buffers; - + int yuv2rgb_mode; int yuv2rgb_swap; int yuv2rgb_brightness; @@ -136,11 +136,11 @@ typedef struct fb_driver_s /* size / aspect ratio calculations */ vo_scale_t sc; - + int fb_bytes_per_line; fb_frame_t *cur_frame, *old_frame; - + struct fb_var_screeninfo fb_var; struct fb_fix_screeninfo fb_fix; @@ -165,10 +165,10 @@ static uint32_t fb_get_capabilities(vo_driver_t *this_gen) static void fb_frame_proc_slice(vo_frame_t *vo_img, uint8_t **src) { fb_frame_t *frame = (fb_frame_t *)vo_img ; - + vo_img->proc_called = 1; - - if( frame->vo_frame.crop_left || frame->vo_frame.crop_top || + + 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. @@ -188,18 +188,18 @@ static void fb_frame_proc_slice(vo_frame_t *vo_img, uint8_t **src) static void fb_frame_field(vo_frame_t *vo_img, int which_field) { fb_frame_t *frame = (fb_frame_t *)vo_img ; - + switch(which_field) { case VO_TOP_FIELD: frame->rgb_dst = frame->data; break; - + case VO_BOTTOM_FIELD: frame->rgb_dst = frame->data + frame->bytes_per_line ; break; - + case VO_BOTH_FIELDS: frame->rgb_dst = frame->data; break; @@ -232,16 +232,16 @@ static vo_frame_t *fb_alloc_frame(vo_driver_t *this_gen) memcpy(&frame->sc, &this->sc, sizeof(vo_scale_t)); pthread_mutex_init(&frame->vo_frame.mutex, NULL); - + /* supply required functions */ frame->vo_frame.proc_slice = fb_frame_proc_slice; frame->vo_frame.proc_frame = NULL; - frame->vo_frame.field = fb_frame_field; + frame->vo_frame.field = fb_frame_field; frame->vo_frame.dispose = fb_frame_dispose; frame->vo_frame.driver = this_gen; - + frame->this = this; - + /* colorspace converter for this frame */ frame->yuv2rgb = this->yuv2rgb_factory->create_converter(this->yuv2rgb_factory); @@ -272,7 +272,7 @@ static void fb_compute_ideal_size(fb_driver_t *this, fb_frame_t *frame) static void fb_compute_rgb_size(fb_driver_t *this, fb_frame_t *frame) { _x_vo_scale_compute_output_size(&frame->sc); - + /* avoid problems in yuv2rgb */ if(frame->sc.output_height < (frame->sc.delivered_height+15) >> 4) frame->sc.output_height = (frame->sc.delivered_height+15) >> 4; @@ -281,7 +281,7 @@ static void fb_compute_rgb_size(fb_driver_t *this, fb_frame_t *frame) frame->sc.output_width = 8; /* yuv2rgb_mlib needs an even YUV2 width */ - if (frame->sc.output_width & 1) + if (frame->sc.output_width & 1) frame->sc.output_width++; lprintf("frame source %d x %d => screen output %d x %d%s\n", @@ -309,7 +309,7 @@ static void setup_colorspace_converter(fb_frame_t *frame, int flags) frame->bytes_per_line * 2); frame->yuv_stride = frame->bytes_per_line * 2; break; - + case VO_BOTH_FIELDS: frame->yuv2rgb-> configure(frame->yuv2rgb, @@ -331,7 +331,7 @@ static void frame_reallocate(fb_driver_t *this, fb_frame_t *frame, av_freep(&frame->vo_frame.base[0]); av_freep(&frame->vo_frame.base[1]); av_freep(&frame->vo_frame.base[2]); - + if(this->use_zero_copy) { frame->data = frame->video_mem + @@ -351,7 +351,7 @@ static void frame_reallocate(fb_driver_t *this, fb_frame_t *frame, frame->vo_frame.pitches[0] = 8*((width + 7) / 8); frame->vo_frame.pitches[1] = 8*((width + 15) / 16); frame->vo_frame.pitches[2] = 8*((width + 15) / 16); - + frame->vo_frame.base[0] = av_mallocz(frame->vo_frame.pitches[0] * height); frame->vo_frame.base[1] = av_mallocz(frame->vo_frame.pitches[1] * ((height+1)/2)); frame->vo_frame.base[2] = av_mallocz(frame->vo_frame.pitches[2] * ((height+1)/2)); @@ -359,11 +359,11 @@ static void frame_reallocate(fb_driver_t *this, fb_frame_t *frame, else { frame->vo_frame.pitches[0] = 8 * ((width + 3) / 4); - + frame->vo_frame.base[0] = av_mallocz(frame->vo_frame.pitches[0] * height); } } - + static void fb_update_frame_format(vo_driver_t *this_gen, vo_frame_t *frame_gen, uint32_t width, uint32_t height, @@ -371,7 +371,7 @@ static void fb_update_frame_format(vo_driver_t *this_gen, { fb_driver_t *this = (fb_driver_t *)this_gen; fb_frame_t *frame = (fb_frame_t *)frame_gen; - + flags &= VO_BOTH_FIELDS; /* Find out if we need to adapt this frame. */ @@ -401,7 +401,7 @@ static void fb_update_frame_format(vo_driver_t *this_gen, else frame->bytes_per_line = frame->sc.output_width * this->bytes_per_pixel; - + setup_colorspace_converter(frame, flags); } @@ -413,7 +413,7 @@ static void fb_overlay_clut_yuv2rgb(fb_driver_t *this, { size_t i; clut_t* clut = (clut_t*)overlay->color; - + if(!overlay->rgb_clut) { for(i = 0; @@ -429,11 +429,11 @@ static void fb_overlay_clut_yuv2rgb(fb_driver_t *this, } overlay->rgb_clut++; } - + if(!overlay->hili_rgb_clut) { clut = (clut_t*) overlay->hili_color; - + for(i = 0; i < sizeof(overlay->color)/sizeof(overlay->color[0]); i++) @@ -475,7 +475,7 @@ static void fb_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, frame->sc.delivered_height, &this->alphablend_extra_data); break; - + case 24: _x_blend_rgb24(frame->data, overlay, @@ -485,7 +485,7 @@ static void fb_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, frame->sc.delivered_height, &this->alphablend_extra_data); break; - + case 32: _x_blend_rgb32(frame->data, overlay, @@ -495,7 +495,7 @@ static void fb_overlay_blend (vo_driver_t *this_gen, vo_frame_t *frame_gen, frame->sc.delivered_height, &this->alphablend_extra_data); break; - } + } } } @@ -517,11 +517,11 @@ static void fb_display_frame(vo_driver_t *this_gen, vo_frame_t *frame_gen) this->sc.output_width = frame->sc.output_width; this->sc.output_height = frame->sc.output_height; - xprintf(this->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video_out_fb: gui size %d x %d, frame size %d x %d\n", this->sc.gui_width, this->sc.gui_height, frame->sc.output_width, frame->sc.output_height); - + memset(this->video_mem_base, 0, this->mem_size); } @@ -538,10 +538,10 @@ static void fb_display_frame(vo_driver_t *this_gen, vo_frame_t *frame_gen) (&this->old_frame->vo_frame); this->old_frame = this->cur_frame; this->cur_frame = frame; - + this->fb_var.yoffset = frame->yoffset; if(ioctl(this->fd, FBIOPAN_DISPLAY, &this->fb_var) == -1) - xprintf(this->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video_out_fb: ioctl FBIOPAN_DISPLAY failed: %s\n", strerror(errno)); } else @@ -550,14 +550,14 @@ static void fb_display_frame(vo_driver_t *this_gen, vo_frame_t *frame_gen) frame->sc.output_yoffset * this->fb_bytes_per_line + frame->sc.output_xoffset * this->bytes_per_pixel; src = frame->data; - + for(y = 0; y < frame->sc.output_height; y++) { xine_fast_memcpy(dst, src, frame->bytes_per_line); src += frame->bytes_per_line; dst += this->fb_bytes_per_line; - } - + } + frame->vo_frame.free(&frame->vo_frame); } } @@ -580,7 +580,7 @@ static int fb_get_property(vo_driver_t *this_gen, int property) case VO_PROP_WINDOW_WIDTH: return this->sc.gui_width; - + case VO_PROP_WINDOW_HEIGHT: return this->sc.gui_height; @@ -597,7 +597,7 @@ static int fb_get_property(vo_driver_t *this_gen, int property) return this->cur_frame->sc.output_yoffset; default: - xprintf(this->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video_out_fb: tried to get unsupported property %d\n", property); } @@ -614,7 +614,7 @@ static int fb_set_property(vo_driver_t *this_gen, int property, int value) 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_fb: aspect ratio changed to %s\n", _x_vo_scale_aspect_ratio_name_table[value]); break; @@ -643,7 +643,7 @@ static int fb_set_property(vo_driver_t *this_gen, int property, int value) break; default: - xprintf(this->xine, XINE_VERBOSITY_DEBUG, + xprintf(this->xine, XINE_VERBOSITY_DEBUG, "video_out_fb: tried to set unsupported property %d\n", property); } @@ -681,8 +681,8 @@ static int fb_gui_data_exchange(vo_driver_t *this_gen, static void fb_dispose(vo_driver_t *this_gen) { fb_driver_t *this = (fb_driver_t *)this_gen; - - munmap(0, this->mem_size); + + munmap(0, this->mem_size); close(this->fd); _x_alphablend_free(&this->alphablend_extra_data); @@ -693,7 +693,7 @@ static void fb_dispose(vo_driver_t *this_gen) static int get_fb_var_screeninfo(int fd, struct fb_var_screeninfo *var, xine_t *xine) { int i; - + if(ioctl(fd, FBIOGET_VSCREENINFO, var)) { xprintf(xine, XINE_VERBOSITY_DEBUG, "video_out_fb: ioctl FBIOGET_VSCREENINFO: %s\n", strerror(errno)); @@ -714,7 +714,7 @@ static int get_fb_var_screeninfo(int fd, struct fb_var_screeninfo *var, xine_t * continue; break; } - + /* Get proper value for maximized var->yres_virtual. */ if(ioctl(fd, FBIOGET_VSCREENINFO, var) == -1) { @@ -814,26 +814,26 @@ static int open_fb_device(config_values_t *config, xine_t *xine) { device_name = "/dev/fb1"; fd = open(device_name, O_RDWR); - + if(fd < 0) - { + { device_name = "/dev/fb0"; fd = open(device_name, O_RDWR); } } - + if(fd < 0) { - xprintf(xine, XINE_VERBOSITY_DEBUG, + xprintf(xine, XINE_VERBOSITY_DEBUG, "video_out_fb: Unable to open device \"%s\", aborting: %s\n", device_name, strerror(errno)); return -1; } - + config->update_string(config, devkey, device_name); return fd; } - + static int mode_visual(fb_driver_t *this, config_values_t *config, struct fb_var_screeninfo *var, struct fb_fix_screeninfo *fix) @@ -859,7 +859,7 @@ static int mode_visual(fb_driver_t *this, config_values_t *config, if(!var->blue.offset) return MODE_16_RGB; return MODE_16_BGR; - + case 15: if(!var->blue.offset) return MODE_15_RGB; @@ -867,16 +867,16 @@ static int mode_visual(fb_driver_t *this, config_values_t *config, case 8: if(!var->blue.offset) - return MODE_8_RGB; - return MODE_8_BGR; + return MODE_8_RGB; + return MODE_8_BGR; } } - + xprintf(this->xine, XINE_VERBOSITY_LOG, _("%s: Your video mode was not recognized, sorry.\n"), LOG_MODULE); return 0; } - + static int setup_yuv2rgb(fb_driver_t *this, config_values_t *config, struct fb_var_screeninfo *var, struct fb_fix_screeninfo *fix) @@ -890,13 +890,13 @@ static int setup_yuv2rgb(fb_driver_t *this, config_values_t *config, this->yuv2rgb_contrast = this->yuv2rgb_saturation = 128; this->yuv2rgb_factory = yuv2rgb_factory_init(this->yuv2rgb_mode, - this->yuv2rgb_swap, + this->yuv2rgb_swap, this->yuv2rgb_cmap); this->yuv2rgb_factory->set_csc_levels (this->yuv2rgb_factory, this->yuv2rgb_brightness, this->yuv2rgb_contrast, this->yuv2rgb_saturation); - + return 1; } @@ -917,7 +917,7 @@ static void setup_buffers(fb_driver_t *this, * bpp <= 32 * msb_right = 0 */ - + this->bytes_per_pixel = (this->fb_var.bits_per_pixel + 7)/8; this->bpp = this->bytes_per_pixel * 8; this->depth = this->fb_var.red.length + @@ -926,9 +926,9 @@ static void setup_buffers(fb_driver_t *this, this->total_num_native_buffers = var->yres_virtual / var->yres; this->used_num_buffers = 0; - + this->cur_frame = this->old_frame = 0; - + xprintf(this->xine, XINE_VERBOSITY_LOG, _("%s: %d video RAM buffers are available.\n"), LOG_MODULE, this->total_num_native_buffers); @@ -938,7 +938,7 @@ static void setup_buffers(fb_driver_t *this, xprintf(this->xine, XINE_VERBOSITY_LOG, _("WARNING: %s: Zero copy buffers are DISABLED because only %d buffers\n" " are available which is less than the recommended %d buffers. Lowering\n" - " the frame buffer resolution might help.\n"), + " the frame buffer resolution might help.\n"), LOG_MODULE, this->total_num_native_buffers, RECOMMENDED_NUM_BUFFERS); } else @@ -966,11 +966,11 @@ static vo_driver_t *fb_open_plugin(video_driver_class_t *class_gen, fb_driver_t *this; fb_class_t *class; fb_visual_t *visual = NULL; - + if (visual_gen) { visual = (fb_visual_t *) visual_gen; } - + class = (fb_class_t *)class_gen; config = class->config; @@ -980,7 +980,7 @@ static vo_driver_t *fb_open_plugin(video_driver_class_t *class_gen, return NULL; _x_alphablend_init(&this->alphablend_extra_data, class->xine); - + register_callbacks(this); this->fd = open_fb_device(config, class->xine); @@ -992,7 +992,7 @@ static vo_driver_t *fb_open_plugin(video_driver_class_t *class_gen, goto error; if (!set_fb_palette (this->fd, &this->fb_var)) goto error; - + this->xine = class->xine; if(this->fb_fix.line_length) @@ -1001,7 +1001,7 @@ static vo_driver_t *fb_open_plugin(video_driver_class_t *class_gen, this->fb_bytes_per_line = (this->fb_var.xres_virtual * this->fb_var.bits_per_pixel)/8; - + _x_vo_scale_init(&this->sc, 0, 0, config); this->sc.gui_width = this->fb_var.xres; this->sc.gui_height = this->fb_var.yres; @@ -1027,10 +1027,10 @@ static vo_driver_t *fb_open_plugin(video_driver_class_t *class_gen, this->fb_var.red.length, this->fb_var.red.offset, this->fb_var.green.length, this->fb_var.green.offset, this->fb_var.blue.length, this->fb_var.blue.offset); - + if(!setup_yuv2rgb(this, config, &this->fb_var, &this->fb_fix)) goto error; - + /* mmap whole video memory */ this->mem_size = this->fb_fix.smem_len; this->video_mem_base = mmap(0, this->mem_size, PROT_READ | PROT_WRITE, @@ -1064,7 +1064,7 @@ static const vo_info_t vo_info_fb = /* exported plugin catalog entry */ 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, 22, "fb", XINE_VERSION_CODE, &vo_info_fb, fb_init_class }, { PLUGIN_NONE, 0, "", 0, NULL, NULL } }; |