summaryrefslogtreecommitdiff
path: root/src/video_out/video_out_fb.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/video_out/video_out_fb.c')
-rw-r--r--src/video_out/video_out_fb.c184
1 files changed, 66 insertions, 118 deletions
diff --git a/src/video_out/video_out_fb.c b/src/video_out/video_out_fb.c
index e88def112..17224ecad 100644
--- a/src/video_out/video_out_fb.c
+++ b/src/video_out/video_out_fb.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2000-2003 the xine project and Fredrik Noring
+ * Copyright (C) 2000-2007 the xine project and Fredrik Noring
*
* This file is part of xine, a free video player.
*
@@ -15,31 +15,29 @@
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
- *
- * $Id: video_out_fb.c,v 1.49 2006/12/19 19:10:51 dsalt Exp $
- *
- * video_out_fb.c, frame buffer xine driver by Miguel Freitas
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110, USA
+ */
+
+/**
+ * @file
+ * @brief Frame buffer xine driver
*
- * Contributors:
+ * @author Miguel Freitas
*
- * Fredrik Noring <noring@nocrew.org>: Zero copy buffers and clean up.
+ * @author Fredrik Noring <noring@nocrew.org>:
+ * Zero copy buffers and clean up.
*
- * based on xine's video_out_xshm.c...
- * ...based on mpeg2dec code from
- * 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
*
- * ideas from ppmtofb - Display P?M graphics on framebuffer devices
- * by Geert Uytterhoeven and Chris Lawrence
+ * @author Geert Uytterhoeven and Chris Lawrence:
+ * Ideas from ppmtofb - Display P?M graphics on framebuffer devices.
*
- * Note: Use this with fbxine. It may work with the regular xine too,
- * provided the visual type is changed (see below).
+ * @note Use this with fbxine.
*
- * TODO: VT switching (configurable)
+ * @todo VT Switching (configurable)
*/
-/* #define USE_X11_VISUAL */
-
#define RECOMMENDED_NUM_BUFFERS 5
#define MAXIMUM_NUM_BUFFERS 25
@@ -57,7 +55,7 @@
#include <fcntl.h>
#include "xine.h"
-#include "video_out.h"
+#include <xine/video_out.h>
#include <errno.h>
@@ -80,10 +78,10 @@
#define LOG
*/
-#include "xine_internal.h"
+#include <xine/xine_internal.h>
#include "yuv2rgb.h"
-#include "xineutils.h"
-#include "vo_scale.h"
+#include <xine/xineutils.h>
+#include <xine/vo_scale.h>
typedef struct fb_frame_s
{
@@ -99,7 +97,6 @@ typedef struct fb_frame_s
yuv2rgb_t *yuv2rgb; /* yuv2rgb converter for this frame */
uint8_t *rgb_dst;
int yuv_stride;
- int stripe_height, stripe_inc;
int bytes_per_line;
@@ -182,7 +179,6 @@ static void fb_frame_proc_slice(vo_frame_t *vo_img, uint8_t **src)
else
frame->yuv2rgb->yuy22rgb_fun(frame->yuv2rgb,
frame->rgb_dst, src[0]);
- frame->rgb_dst += frame->stripe_inc;
}
static void fb_frame_field(vo_frame_t *vo_img, int which_field)
@@ -193,21 +189,18 @@ static void fb_frame_field(vo_frame_t *vo_img, int which_field)
{
case VO_TOP_FIELD:
frame->rgb_dst = frame->data;
- frame->stripe_inc = 2*frame->stripe_height *
- frame->bytes_per_line;
break;
case VO_BOTTOM_FIELD:
frame->rgb_dst = frame->data +
frame->bytes_per_line ;
- frame->stripe_inc = 2*frame->stripe_height *
- frame->bytes_per_line;
break;
case VO_BOTH_FIELDS:
frame->rgb_dst = frame->data;
break;
}
+ frame->yuv2rgb->next_slice (frame->yuv2rgb, NULL);
}
static void fb_frame_dispose(vo_frame_t *vo_img)
@@ -304,11 +297,11 @@ static void setup_colorspace_converter(fb_frame_t *frame, int flags)
frame->yuv2rgb->
configure(frame->yuv2rgb,
frame->sc.delivered_width,
- 16,
+ frame->sc.delivered_height,
2 * frame->vo_frame.pitches[0],
2 * frame->vo_frame.pitches[1],
frame->sc.output_width,
- frame->stripe_height,
+ frame->sc.output_height,
frame->bytes_per_line * 2);
frame->yuv_stride = frame->bytes_per_line * 2;
break;
@@ -317,60 +310,24 @@ static void setup_colorspace_converter(fb_frame_t *frame, int flags)
frame->yuv2rgb->
configure(frame->yuv2rgb,
frame->sc.delivered_width,
- 16,
+ frame->sc.delivered_height,
frame->vo_frame.pitches[0],
frame->vo_frame.pitches[1],
frame->sc.output_width,
- frame->stripe_height,
+ frame->sc.output_height,
frame->bytes_per_line);
frame->yuv_stride = frame->bytes_per_line;
break;
}
}
-static void reset_dest_pointers(fb_frame_t *frame, int flags)
-{
- switch(flags)
- {
- case VO_TOP_FIELD:
- frame->rgb_dst = frame->data;
- frame->stripe_inc = 2 * frame->stripe_height *
- frame->bytes_per_line;
- break;
-
- case VO_BOTTOM_FIELD:
- frame->rgb_dst = frame->data +
- frame->bytes_per_line ;
- frame->stripe_inc = 2 * frame->stripe_height *
- frame->bytes_per_line;
- break;
-
- case VO_BOTH_FIELDS:
- frame->rgb_dst = frame->data;
- frame->stripe_inc = frame->stripe_height *
- frame->bytes_per_line;
- break;
- }
-}
-
static void frame_reallocate(fb_driver_t *this, fb_frame_t *frame,
uint32_t width, uint32_t height, int format)
{
- if(frame->chunk[0])
- {
- free(frame->chunk[0]);
- frame->chunk[0] = NULL;
- }
- if(frame->chunk[1])
- {
- free(frame->chunk[1]);
- frame->chunk[1] = NULL;
- }
- if(frame->chunk[2])
- {
- free(frame->chunk[2]);
- frame->chunk[2] = NULL;
- }
+ free(frame->chunk[0]);
+ free(frame->chunk[1]);
+ free(frame->chunk[2]);
+ memset(frame->chunk, 0, sizeof(frame->chunk[0])*3);
if(this->use_zero_copy)
{
@@ -380,10 +337,9 @@ static void frame_reallocate(fb_driver_t *this, fb_frame_t *frame,
}
else
{
- if(frame->data)
- free(frame->data);
- frame->data = xine_xmalloc(frame->sc.output_width *
- frame->sc.output_height *
+ free(frame->data);
+ frame->data = xine_xcalloc(frame->sc.output_width *
+ frame->sc.output_height,
this->bytes_per_pixel);
}
@@ -457,8 +413,6 @@ static void fb_update_frame_format(vo_driver_t *this_gen,
frame_reallocate(this, frame, width, height, format);
- frame->stripe_height = 16 * frame->sc.output_height /
- frame->sc.delivered_height;
if(this->use_zero_copy)
frame->bytes_per_line = this->fb_bytes_per_line;
else
@@ -468,13 +422,13 @@ static void fb_update_frame_format(vo_driver_t *this_gen,
setup_colorspace_converter(frame, flags);
}
- reset_dest_pointers(frame, flags);
+ fb_frame_field(frame_gen, flags);
}
static void fb_overlay_clut_yuv2rgb(fb_driver_t *this,
vo_overlay_t *overlay, fb_frame_t *frame)
{
- int i;
+ size_t i;
clut_t* clut = (clut_t*)overlay->color;
if(!overlay->rgb_clut)
@@ -646,7 +600,19 @@ static int fb_get_property(vo_driver_t *this_gen, int property)
case VO_PROP_WINDOW_HEIGHT:
return this->sc.gui_height;
-
+
+ case VO_PROP_OUTPUT_WIDTH:
+ return this->cur_frame->sc.output_width;
+
+ case VO_PROP_OUTPUT_HEIGHT:
+ return this->cur_frame->sc.output_height;
+
+ case VO_PROP_OUTPUT_XOFFSET:
+ return this->cur_frame->sc.output_xoffset;
+
+ case VO_PROP_OUTPUT_YOFFSET:
+ return this->cur_frame->sc.output_yoffset;
+
default:
xprintf(this->xine, XINE_VERBOSITY_DEBUG,
"video_out_fb: tried to get unsupported property %d\n", property);
@@ -666,7 +632,7 @@ static int fb_set_property(vo_driver_t *this_gen, int property, int value)
value = XINE_VO_ASPECT_AUTO;
this->sc.user_ratio = value;
xprintf(this->xine, XINE_VERBOSITY_DEBUG,
- "video_out_fb: aspect ratio changed to %s\n", _x_vo_scale_aspect_ratio_name(value));
+ "video_out_fb: aspect ratio changed to %s\n", _x_vo_scale_aspect_ratio_name_table[value]);
break;
case VO_PROP_BRIGHTNESS:
@@ -789,7 +755,7 @@ static int get_fb_fix_screeninfo(int fd, struct fb_fix_screeninfo *fix, xine_t *
fix->type != FB_TYPE_PACKED_PIXELS)
{
xprintf(xine, XINE_VERBOSITY_LOG,
- _("video_out_fb: only packed truecolor/directcolor is supported (%d).\n"
+ _("video_out_fb: only packed truecolour/directcolour is supported (%d).\n"
" Check 'fbset -i' or try 'fbset -depth 16'.\n"), fix->visual);
return 0;
}
@@ -842,8 +808,8 @@ static void register_callbacks(fb_driver_t *this)
static int open_fb_device(config_values_t *config, xine_t *xine)
{
- static char devkey[] = "video.device.fb_device"; /* Why static? */
- char *device_name;
+ static const char devkey[] = "video.device.fb_device";
+ const char *device_name;
int fd;
/* This config entry is security critical, is it really necessary
@@ -924,7 +890,7 @@ static int mode_visual(fb_driver_t *this, config_values_t *config,
}
}
- xprintf(this->xine, XINE_VERBOSITY_LOG, _("video_out_fb: Your video mode was not recognized, sorry.\n"));
+ xprintf(this->xine, XINE_VERBOSITY_LOG, _("%s: Your video mode was not recognized, sorry.\n"), LOG_MODULE);
return 0;
}
@@ -981,16 +947,16 @@ static void setup_buffers(fb_driver_t *this,
this->cur_frame = this->old_frame = 0;
xprintf(this->xine, XINE_VERBOSITY_LOG,
- _("video_out_fb: %d video RAM buffers are available.\n"), this->total_num_native_buffers);
+ _("%s: %d video RAM buffers are available.\n"), LOG_MODULE, this->total_num_native_buffers);
if(this->total_num_native_buffers < RECOMMENDED_NUM_BUFFERS)
{
this->use_zero_copy = 0;
xprintf(this->xine, XINE_VERBOSITY_LOG,
- _("WARNING: video_out_fb: Zero copy buffers are DISABLED because only %d buffers\n"
+ _("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"),
- this->total_num_native_buffers, RECOMMENDED_NUM_BUFFERS);
+ LOG_MODULE, this->total_num_native_buffers, RECOMMENDED_NUM_BUFFERS);
}
else
{
@@ -998,8 +964,8 @@ static void setup_buffers(fb_driver_t *this,
this->fb_var.yoffset = this->fb_var.yres;
if(ioctl(this->fd, FBIOPAN_DISPLAY, &this->fb_var) == -1) {
xprintf(this->xine, XINE_VERBOSITY_LOG,
- _("WARNING: video_out_fb: Zero copy buffers are DISABLED because kernel driver\n"
- " do not support screen panning (used for frame flips).\n"));
+ _("WARNING: %s: Zero copy buffers are DISABLED because kernel driver\n"
+ " do not support screen panning (used for frame flips).\n"), LOG_MODULE);
} else {
this->fb_var.yoffset = 0;
ioctl(this->fd, FBIOPAN_DISPLAY, &this->fb_var);
@@ -1067,12 +1033,13 @@ static vo_driver_t *fb_open_plugin(video_driver_class_t *class_gen,
if(this->depth > 16)
xprintf(this->xine, XINE_VERBOSITY_LOG,
- _("WARNING: video_out_fb: current display depth is %d. For better performance\n"
- " a depth of 16 bpp is recommended!\n\n"), this->depth);
+ _("WARNING: %s: current display depth is %d. For better performance\n"
+ " a depth of 16 bpp is recommended!\n\n"), LOG_MODULE, this->depth);
xprintf(class->xine, XINE_VERBOSITY_DEBUG,
- "video_out_fb: video mode depth is %d (%d bpp),\n"
+ "%s: video mode depth is %d (%d bpp),\n"
" red: %d/%d, green: %d/%d, blue: %d/%d\n",
+ LOG_MODULE,
this->depth, this->bpp,
this->fb_var.red.length, this->fb_var.red.offset,
this->fb_var.green.length, this->fb_var.green.offset,
@@ -1091,30 +1058,14 @@ error:
return 0;
}
-static char* fb_get_identifier(video_driver_class_t *this_gen)
-{
- return "fb";
-}
-
-static char* fb_get_description(video_driver_class_t *this_gen)
-{
- return _("Xine video output plugin using the Linux frame buffer device");
-}
-
-static void fb_dispose_class(video_driver_class_t *this_gen)
-{
- fb_class_t *this = (fb_class_t *)this_gen;
- free(this);
-}
-
static void *fb_init_class(xine_t *xine, void *visual_gen)
{
fb_class_t *this = (fb_class_t *)xine_xmalloc(sizeof(fb_class_t));
this->driver_class.open_plugin = fb_open_plugin;
- this->driver_class.get_identifier = fb_get_identifier;
- this->driver_class.get_description = fb_get_description;
- this->driver_class.dispose = fb_dispose_class;
+ this->driver_class.identifier = "fb";
+ this->driver_class.description = N_("Xine video output plugin using the Linux frame buffer device");
+ this->driver_class.dispose = default_video_driver_class_dispose;
this->config = xine->config;
this->xine = xine;
@@ -1125,16 +1076,13 @@ static void *fb_init_class(xine_t *xine, void *visual_gen)
static const vo_info_t vo_info_fb =
{
1, /* priority */
-#ifdef USE_X11_VISUAL
- XINE_VISUAL_TYPE_X11 /* visual type */
-#else
XINE_VISUAL_TYPE_FB /* visual type */
-#endif
};
/* exported plugin catalog entry */
const plugin_info_t xine_plugin_info[] EXPORTED = {
/* type, API, "name", version, special_info, init_function */
- { PLUGIN_VIDEO_OUT, 21, "fb", XINE_VERSION_CODE, &vo_info_fb, fb_init_class },
+ { PLUGIN_VIDEO_OUT, 22, "fb", XINE_VERSION_CODE, &vo_info_fb, fb_init_class },
{ PLUGIN_NONE, 0, "", 0, NULL, NULL }
};
+