[MPlayer-dev-eng] [PATCH] OpenBSD cvidix support
Ian Lindsay
iml04 at hampshire.edu
Mon Jan 17 08:28:21 CET 2005
Uses the /dev/xf86 aperture driver on OpenBSD. Also, tests <sys/mman.h>
instead of arbitrarily defining MAP_FAILED to -1.
works OK except video is offset from top-left so that bottom and right
are cropped a bit. tested on nvidia_vid with:
# mplayer -nosound Furi_Kuri_-_1* -v -vo cvidix \
-screenw 640 -screenh 400 -aspect 1.6 -sid 0
(using -slang en claimed to display subtitle stream 4, but didn't)
-------------- next part --------------
Index: configure
===================================================================
RCS file: /cvsroot/mplayer/main/configure,v
retrieving revision 1.953
diff -u -Ilibvo -r1.953 configure
--- configure 16 Jan 2005 22:01:52 -0000 1.953
+++ configure 17 Jan 2005 07:04:34 -0000
@@ -2641,6 +2641,23 @@
fi
echores "$_mman"
+cat > $TMPC << EOF
+#include <sys/types.h>
+#include <sys/mman.h>
+#ifndef MAP_FAILED
+#error
+#else
+int main(void) { return 0; }
+#endif
+EOF
+_mman_has_map_failed=no
+cc_check && _mman_has_map_failed=yes
+if test "$_mman_has_map_failed" = yes ; then
+ _def_mman_has_map_failed=''
+else
+ _def_mman_has_map_failed='#define MAP_FAILED ((void *) -1)'
+fi
+
echocheck "dynamic loader"
cat > $TMPC << EOF
#include <dlfcn.h>
@@ -6829,11 +6846,6 @@
/* use GNU internationalization */
$_def_i18n
-/* missing mmap function on libc5 systems */
-#ifndef MAP_FAILED
-# define MAP_FAILED ((void *) -1)
-#endif
-
/* use setlocale() function */
$_def_setlocale
@@ -7003,6 +7015,7 @@
/* Define this if your system has the "sys/mman.h" header file */
$_def_mman
+$_def_mman_has_map_failed
/* Define this if you have the elf dynamic linker -ldl library */
$_def_dl
Index: libdha/libdha.c
===================================================================
RCS file: /cvsroot/mplayer/main/libdha/libdha.c,v
retrieving revision 1.12
diff -u -Ilibvo -r1.12 libdha.c
--- libdha/libdha.c 26 Mar 2004 12:15:54 -0000 1.12
+++ libdha/libdha.c 17 Jan 2005 07:04:34 -0000
@@ -50,6 +50,10 @@
# endif
# endif /* SVR4 */
+#if defined(__OpenBSD__)
+#define DEV_APERTURE "/dev/xf86"
+#endif
+
/* Generic version */
#include <sys/mman.h>
@@ -117,6 +121,25 @@
#endif
dev_mem_way:
+ if (mem_fd != -1)
+ goto mmap;
+
+#ifdef DEV_APERTURE
+ if ((mem_fd = open(DEV_APERTURE, O_RDWR)) == -1)
+ perror("libdha: opening aperture failed");
+ else {
+ void *p = mmap(0,size,PROT_READ|PROT_WRITE,MAP_SHARED,mem_fd,base);
+
+ if (p == MAP_FAILED) {
+ perror("libdha: mapping aperture failed");
+ close(mem_fd);
+ mem_fd = -1;
+ }
+ else
+ return p;
+ }
+#endif
+
if ( (mem_fd = open(DEV_MEM,O_RDWR)) == -1)
{
perror("libdha: opening /dev/mem failed");
Index: libvo/font_load_ft.c
===================================================================
RCS file: /cvsroot/mplayer/main/libvo/font_load_ft.c,v
retrieving revision 1.15
diff -u -Ilibvo -r1.15 font_load_ft.c
--- libvo/font_load_ft.c 28 Oct 2004 01:15:52 -0000 1.15
+++ libvo/font_load_ft.c 17 Jan 2005 07:04:34 -0000
@@ -94,21 +94,26 @@
#define DEBUG 0
-//static double ttime;
-
-
static void paste_bitmap(unsigned char *bbuffer, FT_Bitmap *bitmap, int x, int y, int width, int height, int bwidth) {
- int drow = x+y*width;
+ int drow = x + y * width;
int srow = 0;
- int sp, dp, w, h;
- if (bitmap->pixel_mode==ft_pixel_mode_mono)
- for (h = bitmap->rows; h>0 && height > 0; --h, height--, drow+=width, srow+=bitmap->pitch)
- for (w = bwidth, sp=dp=0; w>0; --w, ++dp, ++sp)
- bbuffer[drow+dp] = (bitmap->buffer[srow+sp/8] & (0x80>>(sp%8))) ? 255:0;
+ int w, h;
+ unsigned sp, dp;
+
+ if (bitmap->pixel_mode == ft_pixel_mode_mono)
+ for (h = bitmap->rows; h > 0 && height > 0; --h, height--) {
+ for (w = bwidth, sp = dp = 0; w > 0; --w, ++dp, ++sp)
+ bbuffer[drow+dp] = (bitmap->buffer[srow+sp/8] & (0x80>>(sp%8))) ? 255:0;
+ drow += width;
+ srow += bitmap->pitch;
+ }
else
- for (h = bitmap->rows; h>0 && height > 0; --h, height--, drow+=width, srow+=bitmap->pitch)
- for (w = bwidth, sp=dp=0; w>0; --w, ++dp, ++sp)
+ for (h = bitmap->rows; h > 0 && height > 0; --h, height--) {
+ for (w = bwidth, sp = dp = 0; w>0; --w, ++dp, ++sp)
bbuffer[drow+dp] = bitmap->buffer[srow+sp];
+ drow += width;
+ srow += bitmap->pitch;
+ }
}
@@ -117,15 +122,13 @@
int unicode) {
FT_Error error;
FT_Face face = desc->faces[pic_idx];
- int const load_flags = FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING;
int ymin = INT_MAX, ymax = INT_MIN;
int space_advance = 20;
int width, height;
unsigned char *bbuffer;
int i, uni_charmap = 1;
- error = FT_Select_Charmap(face, ft_encoding_unicode);
-// fprintf(stderr, "select unicode charmap: %d\n", error);
+ FT_Select_Charmap(face, ft_encoding_unicode);
if (face->charmap==NULL || face->charmap->encoding!=ft_encoding_unicode) {
WARNING("Unicode charmap not available for this font. Very bad!");
@@ -134,7 +137,6 @@
if (error) WARNING("No charmaps! Strange.");
}
- /* set size */
if (FT_IS_SCALABLE(face)) {
error = FT_Set_Char_Size(face, 0, floatTof266(ppem), 0, 0);
if (error) WARNING("FT_Set_Char_Size failed.");
@@ -157,7 +159,7 @@
WARNING("Selected font is fixed-width.");
/* compute space advance */
- error = FT_Load_Char(face, ' ', load_flags);
+ error = FT_Load_Char(face, ' ', FT_LOAD_NO_HINTING);
if (error) WARNING("spacewidth set to default.");
else space_advance = f266ToInt(face->glyph->advance.x);
@@ -187,8 +189,6 @@
}
desc->glyph_index[unicode?character:code] = glyph_index;
}
-// fprintf(stderr, "font height: %lf\n", (double)(face->bbox.yMax-face->bbox.yMin)/(double)face->units_per_EM*ppem);
-// fprintf(stderr, "font width: %lf\n", (double)(face->bbox.xMax-face->bbox.xMin)/(double)face->units_per_EM*ppem);
ymax = (double)(face->bbox.yMax)/(double)face->units_per_EM*ppem+1;
ymin = (double)(face->bbox.yMin)/(double)face->units_per_EM*ppem-1;
@@ -217,7 +217,6 @@
if (desc->max_height < height) desc->max_height = height;
desc->pic_b[pic_idx]->charheight = height;
-// fprintf(stderr, "font height2: %d\n", height);
desc->pic_b[pic_idx]->baseline = ymax + padding;
desc->pic_b[pic_idx]->padding = padding;
desc->pic_b[pic_idx]->current_alloc = 0;
@@ -471,18 +470,24 @@
static void resample_alpha(unsigned char *abuf, unsigned char *bbuf, int width, int height, int stride, float factor)
{
- int f=factor*256.0f;
- int i,j;
+ int f = factor * 256.0f;
+ int i, j, x, y;
+ unsigned char *a, *b;
+
for (i = 0; i < height; i++) {
- unsigned char *a = abuf+i*stride;
- unsigned char *b = bbuf+i*stride;
- for(j=0;j<width;j++,a++,b++){
- int x=*a; // alpha
- int y=*b; // bitmap
- x=255-((x*f)>>8); // scale
- if (x+y>255) x=255-y; // to avoid overflows
- if (x<1) x=1; else if (x>=252) x=0;
- *a=x;
+ a = abuf + i * stride;
+ b = bbuf + i * stride;
+
+ for(j = 0; j < width; j++, a++, b++) {
+ x = *a; // alpha
+ y = *b; // bitmap
+
+ x = 255 - ((x * f) >> 8); // scale
+ if (x + y > 255) x = 255 - y; // to avoid overflows
+ if (x < 1) x = 1;
+ else if (x > 251) x = 0;
+
+ *a = x;
}
}
}
@@ -492,25 +497,20 @@
{
FT_GlyphSlot slot;
FT_UInt glyph_index;
- FT_BitmapGlyph glyph;
int width, height, stride, maxw, off;
unsigned char *abuffer, *bbuffer;
- int const load_flags = FT_LOAD_DEFAULT | FT_LOAD_NO_HINTING;
- int pen_xa;
+ int error, pen_xa;
int font = desc->font[c];
- int error;
-// fprintf(stderr, "render_one_glyph %d\n", c);
-
if (!desc->dynamic) return;
if (desc->width[c] != -1) return;
if (desc->font[c] == -1) return;
glyph_index = desc->glyph_index[c];
- // load glyph
- error = FT_Load_Glyph(desc->faces[font], glyph_index, load_flags);
+ error = FT_Load_Glyph(desc->faces[font], glyph_index, FT_LOAD_NO_HINTING \
+ | FT_LOAD_RENDER);
if (error) {
WARNING("FT_Load_Glyph 0x%02x (char 0x%04x) failed.", glyph_index, c);
desc->font[c] = -1;
@@ -518,41 +518,17 @@
}
slot = desc->faces[font]->glyph;
- // render glyph
- if (slot->format != ft_glyph_format_bitmap) {
- error = FT_Render_Glyph(slot, ft_render_mode_normal);
- if (error) {
- WARNING("FT_Render_Glyph 0x%04x (char 0x%04x) failed.", glyph_index, c);
- desc->font[c] = -1;
- return;
- }
- }
-
- // extract glyph image
- error = FT_Get_Glyph(slot, (FT_Glyph*)&glyph);
- if (error) {
- WARNING("FT_Get_Glyph 0x%04x (char 0x%04x) failed.", glyph_index, c);
- desc->font[c] = -1;
- return;
- }
-
-// fprintf(stderr, "glyph generated\n");
-
maxw = desc->pic_b[font]->charwidth;
- if (glyph->bitmap.width > maxw) {
+ if (slot->bitmap.width > maxw) {
fprintf(stderr, "glyph too wide!\n");
}
- // allocate new memory, if needed
-// fprintf(stderr, "\n%d %d %d\n", desc->pic_b[font]->charwidth, desc->pic_b[font]->charheight, desc->pic_b[font]->current_alloc);
if (desc->pic_b[font]->current_count >= desc->pic_b[font]->current_alloc) {
int newsize = desc->pic_b[font]->charwidth*desc->pic_b[font]->charheight*(desc->pic_b[font]->current_alloc+ALLOC_INCR);
int increment = desc->pic_b[font]->charwidth*desc->pic_b[font]->charheight*ALLOC_INCR;
desc->pic_b[font]->current_alloc += ALLOC_INCR;
-// fprintf(stderr, "\nns = %d inc = %d\n", newsize, increment);
-
desc->pic_b[font]->bmp = realloc(desc->pic_b[font]->bmp, newsize);
desc->pic_a[font]->bmp = realloc(desc->pic_a[font]->bmp, newsize);
@@ -567,16 +543,12 @@
off = desc->pic_b[font]->current_count*desc->pic_b[font]->charwidth*desc->pic_b[font]->charheight;
paste_bitmap(bbuffer+off,
- &glyph->bitmap,
- desc->pic_b[font]->padding + glyph->left,
- desc->pic_b[font]->baseline - glyph->top,
+ &slot->bitmap,
+ desc->pic_b[font]->padding + slot->bitmap_left,
+ desc->pic_b[font]->baseline - slot->bitmap_top,
desc->pic_b[font]->charwidth, desc->pic_b[font]->charheight,
- glyph->bitmap.width <= maxw ? glyph->bitmap.width : maxw);
-
-// fprintf(stderr, "glyph pasted\n");
- FT_Done_Glyph((FT_Glyph)glyph);
+ slot->bitmap.width <= maxw ? slot->bitmap.width : maxw);
- /* advance pen */
pen_xa = f266ToInt(slot->advance.x) + 2*desc->pic_b[font]->padding;
if (pen_xa > maxw) pen_xa = maxw;
@@ -594,14 +566,11 @@
desc->tables.omt, desc->tables.o_r, desc->tables.o_w,
desc->tables.o_size);
}
-// fprintf(stderr, "fg: outline t = %lf\n", GetTimer()-t);
- if (desc->tables.g_r) {
+ if (desc->tables.g_r)
blur(abuffer+off, desc->tables.tmp, width, height, stride,
desc->tables.gt2, desc->tables.g_r,
desc->tables.g_w);
-// fprintf(stderr, "fg: blur t = %lf\n", GetTimer()-t);
- }
resample_alpha(abuffer+off, bbuffer+off, width, height, stride, font_factor);
-------------- next part --------------
MPlayer dev-CVS-050117-00:26-2.95.3 (C) 2000-2005 MPlayer Team
CPU: Advanced Micro Devices Athlon 4 /Athlon MP/XP Palomino (Family: 6, Stepping: 2)
Detected cache-line size is 64 bytes
CPUflags: MMX: 1 MMX2: 1 3DNow: 1 3DNow2: 1 SSE: 1 SSE2: 0
Compiled for x86 CPU with extensions: MMX MMX2 3DNow 3DNowEx SSE
CommandLine:init_freetype
get_path('font/font.desc') -> '/root/.mplayer/font/font.desc'
font: can't open file: /root/.mplayer/font/font.desc
font: can't open file: /usr/local/share/mplayer/font/font.desc
Using MMX (with tiny bit MMX2) Optimized OnScreenDisplay
Using nanosleep() timing
get_path('input.conf') -> '/root/.mplayer/input.conf'
Can't open input config file /root/.mplayer/input.conf: No such file or directory
Can't open input config file /usr/local/etc/mplayer/input.conf: No such file or directory
Falling back on default (hardcoded) input config
get_path('Furi_Kuri_-_1v3_-_Furi_Kuri_(FLCL)_-_[zx](abe499b6)(dub.sub_jap.eng.eng)[AniDB].ogm.conf') -> '/root/.mplayer/Furi_Kuri_-_1v3_-_Furi_Kuri_(FLCL)_-_[zx](abe499b6)(dub.sub_jap.eng.eng)[AniDB].ogm.conf'
Playing Furi_Kuri_-_1v3_-_Furi_Kuri_(FLCL)_-_[zx](abe499b6)(dub.sub_jap.eng.eng)[AniDB].ogm.
[file] File size is 368923368 bytes
STREAM: [file] Furi_Kuri_-_1v3_-_Furi_Kuri_(FLCL)_-_[zx](abe499b6)(dub.sub_jap.eng.eng)[AniDB].ogm
STREAM: Description: File
STREAM: Author: Albeu
STREAM: Comment: based on the code from ??? (probably Arpi)
Checking for YUV4MPEG2
ASF_check: not ASF guid!
Checking for Nullsoft Streaming Video
Checking for NuppelVideo
Checking for REAL
Checking for SMJPEG
Searching demuxer type for filename Furi_Kuri_-_1v3_-_Furi_Kuri_(FLCL)_-_[zx](abe499b6)(dub.sub_jap.eng.eng)[AniDB].ogm ext: .ogm
Trying demuxer 18 based on filename extension
==> Found video stream: 0
Ogg stream 0 is video (new hdr)
======= VIDEO Format ======
biSize 40
biWidth 640
biHeight 480
biPlanes 1
biBitCount 24
biCompression 808802372='DX50'
biSizeImage 921600
===========================
==> Found audio stream: 1
Ogg : stream 1 is vorbis
==> Found audio stream: 2
Ogg : stream 2 is vorbis
==> Found audio stream: 3
Ogg : stream 3 is vorbis
Ogg stream 4 is text
Ogg stream 5 is text
Ogg demuxer: Displaying subtitle stream id 4
Ogg stream length (granulepos): 35452
Ogg demuxer : found 3 audio streams, 1 video stream and 2 text streams
Ogg file format detected.
VIDEO: [DX50] 640x480 24bpp 23.976 fps 0.0 kbps ( 0.0 kbyte/s)
[V] filefmt:18 fourcc:0x30355844 size:640x480 fps:23.98 ftime:=0.0417
get_path('sub/') -> '/root/.mplayer/sub/'
get_path('default.sub') -> '/root/.mplayer/default.sub'
vo_cvidix: No vidix driver name provided, probing available ones (-v option for details)!
vidixlib: PROBING: /usr/local/lib/mplayer/vidix/cyberblade_vid.so
[cyberblade] Can't find chip
vidixlib: PROBING: /usr/local/lib/mplayer/vidix/mach64_vid.so
[mach64] Can't find chip
vidixlib: PROBING: /usr/local/lib/mplayer/vidix/mga_crtc2_vid.so
[mga] probe
[mga] found 6 pci devices
[mga] Can't find chip
vidixlib: PROBING: /usr/local/lib/mplayer/vidix/mga_vid.so
[mga] probe
[mga] found 6 pci devices
[mga] Can't find chip
vidixlib: PROBING: /usr/local/lib/mplayer/vidix/nvidia_vid.so
[nvidia_vid] Found chip: NV20 [GeForce3]
vidixlib: /usr/local/lib/mplayer/vidix/nvidia_vid.so probed o'k
vidixlib: will use /usr/local/lib/mplayer/vidix/nvidia_vid.so driver
vidixlib: Attempt to initialize driver at: 0x6825338
[nvidia_vid] arch 20 register base 883fb000
[nvidia_vid] detected memory size 64 MB
[nvidia_vid] unable to setup MTRR: Function not implemented
[nvidia_vid] text mode: 640x400
vidixlib: '/usr/local/lib/mplayer/vidix/nvidia_vid.so'successfully loaded
VIDIX: Description: NVIDIA RIVA OVERLAY DRIVER
VIDIX: Author: Sascha Sommer <saschasommer at freenet.de>
==========================================================================
Opening video decoder: [ffmpeg] FFmpeg's libavcodec codec family
INFO: libavcodec init OK!
Selected video codec: [ffodivx] vfm:ffmpeg (FFmpeg MPEG-4)
==========================================================================
Audio: no sound
Freeing 0 unused audio chunks.
Starting playback...
Language: FLCL - Episode 1 - Fooly Cooly
Name: FLCL - Episode 1 - Fooly Cooly
Language: English
Language: Director's Comments
[ffmpeg] aspect_ratio: 1.333333
VDec: vo config request - 640 x 480 (preferred csp: Planar YV12)
Trying filter chain: vo
Could not find matching colorspace - retrying with -vf scale...
Opening video filter: [scale]
SwScale params: -1 x -1 (-1=no scaling)
Trying filter chain: scale vo
VDec: using Planar YV12 as output csp (no 0)
Movie-Aspect is 1.60:1 - prescaling to correct movie aspect.
VO Config (640x480->768x480,flags=0,'MPlayer',0x32315659)
SwScaler: reducing / aligning filtersize 1 -> 4
SwScaler: reducing / aligning filtersize 1 -> 4
SwScaler: reducing / aligning filtersize 1 -> 1
SwScaler: reducing / aligning filtersize 5 -> 4
SwScaler: BICUBIC scaler, from Planar YV12 to Packed YUY2 using MMX2
SwScaler: using 4-tap MMX scaler for horizontal luminance scaling
SwScaler: using 4-tap MMX scaler for horizontal chrominance scaling
SwScaler: using n-tap MMX scaler for vertical scaling (BGR)
SwScaler: 640x480 -> 640x480
REQ: flags=0x437 req=0x0
VO: [cvidix] 640x480 => 768x480 Packed YUY2
VO: Description: console VIDIX
VO: Author: Sascha Sommer
called vixConfigPlayback
[nvidia_vid] setting up a 768x400-0x0 video window (src 640x480), format 0x32595559
vosub_vidix: using 3 buffer(s)
[nvidia_vid] set colorkey 0xff00
*** [vo] Allocating mp_image_t, 640x480x16bpp YUV packed, 614400 bytes
*** [scale] Allocating (slices) mp_image_t, 640x480x12bpp YUV planar, 460800 bytes
V: 0.0 1/ 1 ??% ??% ??,?% 0 0
*** [scale] Allocating (slices) mp_image_t, 640x480x12bpp YUV planar, 460800 bytes
get_path('subfont.ttf') -> '/root/.mplayer/subfont.ttf'
Unicode font: 657 glyphs.
V: 0.0 2/ 2 ??% ??% ??,?% 0 0
*** [scale] Allocating (slices) mp_image_t, 640x480x12bpp YUV planar, 460800 bytes
vo: x11 uninit called but X11 not inited..
Exiting... (Quit)
More information about the MPlayer-dev-eng
mailing list