[PATCH] SUN XVR-100 VO driver
Hi! Here is a vo driver proted from xine, for sun xvr-100 (bastardized ati radeon 7000) used in some SPARC desktops (at least). When I have time and motivation, I might also port the pgx64 driver from xine also, but first I need to get hold on a sun ultra 5. It needs to be used with -vo xover:xvr100 if used under X window, otherwise the window is not managed. bye Denes -- --- What kills me, doesn't make me stronger.
On Wed, 18 Jul 2007 21:40:32 +0200, Balatoni Denes scribed:
+ * SUN XVR-100 (ATI Radeon 7000) VO driver for SPARC Solaris(at least) + * + * Copyright (C) 2000-2004 Robin Kay <komadori [at] gekkou [dot] co [dot] uk> + * Copyright (C) 2004 Jake Goerzen + * Copyright (C) 2007 Denes Balatoni
as diego would say: "Please use a standard license header, compare vidix/vidixlib.c for an example." -compn
Hi! Wednesday 18 July 2007 21:57-kor Compn ezt írta:
as diego would say:
"Please use a standard license header, compare vidix/vidixlib.c for an example."
Ok, new patch attached. As a matter of fact, I meant to include a proper license header, only I didn't find one in the files in mplayer I looked at :)
-compn
bye Denes
Hi! Would somebody comment, if not apply this patch? Wednesday 18 July 2007 22:37-kor Balatoni Denes ezt írta:
Hi!
Wednesday 18 July 2007 21:57-kor Compn ezt írta:
as diego would say:
"Please use a standard license header, compare vidix/vidixlib.c for an example."
Ok, new patch attached. As a matter of fact, I meant to include a proper license header, only I didn't find one in the files in mplayer I looked at :)
-compn
bye Denes
bye Denes ps: actually this is a temporary solution, the permanent solution would be to make vidix run on sparc solaris. this however is not trivial, although probably not impossible.
On Wed, Jul 18, 2007 at 10:37:44PM +0200, Balatoni Denes wrote:
Wednesday 18 July 2007 21:57-kor Compn ezt írta:
as diego would say:
"Please use a standard license header, compare vidix/vidixlib.c for an example."
Ok, new patch attached. As a matter of fact, I meant to include a proper license header, only I didn't find one in the files in mplayer I looked at :)
Yes, MPlayer is still messy in that regard. The situation should be getting better in the future, though.
--- mplayer.old/configure 2007-07-18 21:16:00.000000000 +0200 +++ mplayer/configure 2007-07-18 22:32:40.000000000 +0200 @@ -3626,6 +3630,32 @@ fi echores "$_tdfxvid"
+echocheck "xvr100" +if test "$_xvr100" = auto ; then +cat > $TMPC << EOF +#include <sys/fbio.h> +#include <sys/visual_io.h> +int main(void) {
nit: trailing whitespace
+ioctl(pfb_devfd, VIS_GETIDENTIFIER, &ident) +ioctl(pfb_devfd, FBIOGATTR, &attr)
ioctl is a macro?
--- mplayer.old/libvo/vo_xvr100.c 1970-01-01 01:00:00.000000000 +0100 +++ mplayer/libvo/vo_xvr100.c 2007-07-18 22:35:12.000000000 +0200 @@ -0,0 +1,478 @@ +/* + * SUN XVR-100 (ATI Radeon 7000) VO driver for SPARC Solaris(at least) + * + * Copyright (C) 2000-2004 Robin Kay <komadori [at] gekkou [dot] co [dot] uk> + * Copyright (C) 2004 Jake Goerzen + * Copyright (C) 2007 Denes Balatoni + * + * This file is part of MPlayer. + * + * MPlayer 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. + * + * MPlayer 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 + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with MPlayer; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
nit: trailing whitespace
+ * written for xine by + * Robin Kay <komadori [at] gekkou [dot] co [dot] uk> + * + * Sun XVR-100 framebuffer graciously donated by Jake Goerzen. + * + * Ported to mplayer by Denes Balatoni + * Contains portions from the mga and tdfix_vid vo drivers + * + * no double-buffering, as it would slow down playback (waiting for vertical retraces) + * FIXME: only YV12 supported for now
Please put this at the top of the header along with the copyright notices.
+ if(!(flags & VOFLAG_XOVERLAY_SUB_VO)) {
I prefer a space between if and the opening parentheses. You use this inconsistently. Otherwise the patch looks OK from my side. Diego
Hi! Thanks for the review Diego, new pathc attached. Sunday 22 July 2007 23:23-kor Diego Biurrun ezt írta:
nit: trailing whitespace
Those should be fixed.
+ioctl(pfb_devfd, VIS_GETIDENTIFIER, &ident) +ioctl(pfb_devfd, FBIOGATTR, &attr)
ioctl is a macro?
I admit the configure part was completly broken, this should be working (tested).
+ * written for xine by + * Robin Kay <komadori [at] gekkou [dot] co [dot] uk> + * + * Sun XVR-100 framebuffer graciously donated by Jake Goerzen. + * + * Ported to mplayer by Denes Balatoni + * Contains portions from the mga and tdfix_vid vo drivers + * + * no double-buffering, as it would slow down playback (waiting for vertical retraces) + * FIXME: only YV12 supported for now
Please put this at the top of the header along with the copyright notices.
Done.
+ if(!(flags & VOFLAG_XOVERLAY_SUB_VO)) {
I prefer a space between if and the opening parentheses. You use this inconsistently.
Done.
Otherwise the patch looks OK from my side.
Diego
bye Denes -- --- What kills me, doesn't make me stronger.
On Mon, Jul 23, 2007 at 08:27:22PM +0200, Balatoni Denes wrote:
Thanks for the review Diego, new pathc attached.
You are most welcome.
--- mplayer.old/libvo/vo_xvr100.c 1970-01-01 01:00:00.000000000 +0100 +++ mplayer/libvo/vo_xvr100.c 2007-07-23 15:49:38.011174000 +0200 @@ -0,0 +1,478 @@ +/* This actually doesn't change a thing, width greater than 1536 still won't work... */ +#if 0 + /* if the source width was larger than what would fit in overlay scaler increase step_by values */ + i=pfb_srcwidth; + while(i>/*pPriv->overlay_scaler_buffer_width*/1536){ + h_step++; + h_inc >>=1; + i=i/2; + } +#endif
I don't like #if 0 blocks in code and some lines in this file are terribly long.
+#if 0 /* doesn't work for some reason */ + if (mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; + if (!(mpi->flags&MP_IMGFLAG_PLANAR)) return VO_FALSE; // FIXME: impossible for YV12, right? + if (!(mpi->flags&MP_IMGFLAG_ACCEPT_STRIDE)) return VO_FALSE; + + mpi->planes[0]=pfb_vbase + pfb_buffer1; + if (mpi->flags&MP_IMGFLAG_SWAPPED){ + mpi->planes[1]=pfb_vbase + pfb_buffer3; + mpi->planes[2]=pfb_vbase + pfb_buffer2; + } else { + mpi->planes[1]=pfb_vbase + pfb_buffer2; + mpi->planes[2]=pfb_vbase + pfb_buffer3; + } + mpi->stride[0]=pfb_stride1; + mpi->stride[1]=mpi->stride[2]=pfb_stride2; + mpi->flags|=MP_IMGFLAG_DIRECT; + + return VO_TRUE; +#endif
Same here, you could also put the return statements on their own line. This needs a review from someone familiar with the vo system, Reimar? As I said, the parts I maintain are OK. Diego
On Mon, 23 Jul 2007 20:27:22 +0200 Balatoni Denes <dbalatoni@programozo.hu> wrote:
+ * no double-buffering, as it would slow down playback (waiting for vertical retraces)
Why that? In the typical case the wait time is negligable enouth, and the user can still disable it if he want. It doesn't matter much atm but you should definitly consider implementing double buffering.
+/* This actually doesn't change a thing, width greater than 1536 still won't work... */
You should consider putting a check for the image size in config() until this issue is solved.
+ +static int config(uint32_t width, uint32_t height, uint32_t d_width, + uint32_t d_height, uint32_t flags, char *title, + uint32_t format) { + + pfb_srcwidth=width; + pfb_srcheight=height; + + if (!(flags & VOFLAG_XOVERLAY_SUB_VO)) { + aspect_save_orig(width,height); + aspect_save_prescale(d_width,d_height); + aspect_save_screenres(pfb_xres,pfb_yres); + if( flags&VOFLAG_FULLSCREEN) { /* -fs */ + aspect(&pfb_dstwidth,&pfb_dstheight, A_ZOOM); + pfb_fs = 1; + } else { + aspect(&pfb_dstwidth,&pfb_dstheight, A_NOZOOM); + pfb_fs = 0; + } + } else { + pfb_dstwidth=d_width; + pfb_dstheight=d_height; + } + + if (pfb_xres > pfb_dstwidth) { + pfb_wx0 = (pfb_xres - pfb_dstwidth) / 2; + pfb_wx1 = pfb_wx0 + pfb_dstwidth; + } + else { + pfb_wx0 = 0; + pfb_wx1 = pfb_xres; + } + + if (pfb_yres > pfb_dstheight) { + pfb_wy0 = (pfb_yres - pfb_dstheight) / 2; + pfb_wy1 = pfb_wy0 + pfb_dstheight; + } + else { + pfb_wy0 = 0; + pfb_wy1 = pfb_yres; + } + + pfb_stride1=(pfb_srcwidth+15) & ~15; + pfb_stride2=pfb_stride3=(((pfb_srcwidth+1)>>1)+15) & ~15; + + pfb_buffer1 = pfb_free_top - (pfb_stride1*pfb_srcheight+pfb_stride2*((pfb_srcheight+1) & ~1)); + pfb_buffer2 = pfb_buffer1 + pfb_stride1*pfb_srcheight; + pfb_buffer3 = pfb_buffer2 + pfb_stride2*((pfb_srcheight+1)>>1); + + pfb_overlay_on(); + + return 0; +} + [...] + +static uint32_t pfb_fullscreen() { + if (!pfb_fs) { + aspect(&pfb_dstwidth,&pfb_dstheight, A_ZOOM); + pfb_fs = 1; + } else { + aspect(&pfb_dstwidth,&pfb_dstheight, A_NOZOOM); + pfb_fs = 0; + } + + if (pfb_xres > pfb_dstwidth) { + pfb_wx0 = (pfb_xres - pfb_dstwidth) / 2; + pfb_wx1 = pfb_wx0 + pfb_dstwidth; + } + else { + pfb_wx0 = 0; + pfb_wx1 = pfb_xres; + } + + if (pfb_yres > pfb_dstheight) { + pfb_wy0 = (pfb_yres - pfb_dstheight) / 2; + pfb_wy1 = pfb_wy0 + pfb_dstheight; + } + else { + pfb_wy0 = 0; + pfb_wy1 = pfb_yres; + } + + pfb_overlay_on(); + + return VO_TRUE; +}
This could be done with less code duplication.
+static uint32_t get_image(mp_image_t *mpi){ + return VO_FALSE; +#if 0 /* doesn't work for some reason */
What is not working exactly?
+ if (mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; + if (!(mpi->flags&MP_IMGFLAG_PLANAR)) return VO_FALSE; // FIXME: impossible for YV12, right? + if (!(mpi->flags&MP_IMGFLAG_ACCEPT_STRIDE)) return VO_FALSE; + + mpi->planes[0]=pfb_vbase + pfb_buffer1; + if (mpi->flags&MP_IMGFLAG_SWAPPED){ + mpi->planes[1]=pfb_vbase + pfb_buffer3; + mpi->planes[2]=pfb_vbase + pfb_buffer2; + } else { + mpi->planes[1]=pfb_vbase + pfb_buffer2; + mpi->planes[2]=pfb_vbase + pfb_buffer3; + }
This is wrong. MP_IMGFLAG_SWAPPED mean that the planes are swaped in memory. However the mpi->planes pointers are always in the same order (YUV), so this flag is irrelevant unless you access the 3 planes as a single chunk of memory.
+static int query_format(uint32_t format) +{ + switch(format){ + case IMGFMT_YV12:
I420 should work just fine too.
+ return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW |VFCAP_HWSCALE_UP|VFCAP_HWSCALE_DOWN|VFCAP_ACCEPT_STRIDE; + } + return 0;
The rest look ok afaict. Albeu
On Wed, 2007-07-25 at 20:04 +0200, Alban Bedel wrote:
On Mon, 23 Jul 2007 20:27:22 +0200 Balatoni Denes <dbalatoni@programozo.hu> wrote:
+ * no double-buffering, as it would slow down playback (waiting for vertical retraces)
Why that? In the typical case the wait time is negligable enouth, and the user can still disable it if he want. It doesn't matter much atm but you should definitly consider implementing double buffering.
Not having double buffering (in the sense that decoding a frame will immediately display it, and the following flip_page() is a no-op) will screw up video timing. MPlayer decodes a frame immediately after the timed flip of the _previous_ frame, and only considers the timing of this frame for the flip_page() call. If you have a video with low-fps parts this will cause noticeable errors.
Hi! Wednesday 25 July 2007 20:04-kor Alban Bedel ezt írta:
+ * no double-buffering, as it would slow down playback (waiting for vertical retraces)
Why that? In the typical case the wait time is negligable enouth, and the user can still disable it if he want. It doesn't matter much atm but you should definitly consider implementing double buffering.
I did try it, it was much slower, so I didn't like it. Maybe in the future (btw it seems two vertical retraces are needed until the page is flipped, and that is slow).
+/* This actually doesn't change a thing, width greater than 1536 still won't work... */
You should consider putting a check for the image size in config() until this issue is solved.
It works, but there is a pink stripe on the right side. So IMO the user should choose whether he/she wants pink stripe (-vo xover:xvr100) or unusably slow playback (-vo x11).
+ if (pfb_xres > pfb_dstwidth) { + pfb_wx0 = (pfb_xres - pfb_dstwidth) / 2; + pfb_wx1 = pfb_wx0 + pfb_dstwidth; + } + else { + pfb_wx0 = 0; + pfb_wx1 = pfb_xres; + } + + if (pfb_yres > pfb_dstheight) { + pfb_wy0 = (pfb_yres - pfb_dstheight) / 2; + pfb_wy1 = pfb_wy0 + pfb_dstheight; + } + else { + pfb_wy0 = 0; + pfb_wy1 = pfb_yres; + } + + pfb_overlay_on(); + + return VO_TRUE; +}
This could be done with less code duplication.
Like moving 15 trivial lines of code to a separate function? What's the point of that?
+static uint32_t get_image(mp_image_t *mpi){ + return VO_FALSE; +#if 0 /* doesn't work for some reason */
What is not working exactly?
-vfm ffmpeg -dr always says "stride changed" or something like that (I don't have the message at hand), and some frames are not shown.
+ if (mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; + if (!(mpi->flags&MP_IMGFLAG_PLANAR)) return VO_FALSE; // FIXME: impossible for YV12, right? + if (!(mpi->flags&MP_IMGFLAG_ACCEPT_STRIDE)) return VO_FALSE; + + mpi->planes[0]=pfb_vbase + pfb_buffer1; + if (mpi->flags&MP_IMGFLAG_SWAPPED){ + mpi->planes[1]=pfb_vbase + pfb_buffer3; + mpi->planes[2]=pfb_vbase + pfb_buffer2; + } else { + mpi->planes[1]=pfb_vbase + pfb_buffer2; + mpi->planes[2]=pfb_vbase + pfb_buffer3; + }
This is wrong. MP_IMGFLAG_SWAPPED mean that the planes are swaped in memory. However the mpi->planes pointers are always in the same order (YUV), so this flag is irrelevant unless you access the 3 planes as a single chunk of memory.
Ok, than this will be removed.
+static int query_format(uint32_t format) +{ + switch(format){ + case IMGFMT_YV12:
I420 should work just fine too.
This will be included.
+ return VFCAP_CSP_SUPPORTED | VFCAP_CSP_SUPPORTED_BY_HW |VFCAP_HWSCALE_UP|VFCAP_HWSCALE_DOWN|VFCAP_ACCEPT_STRIDE; + } + return 0;
The rest look ok afaict.
Thanks, patch will be coming tomorrow.
Albeu
bye Denes
On Wed, 25 Jul 2007 21:34:40 +0200 Balatoni Denes <dbalatoni@interware.hu> wrote:
Hi!
Wednesday 25 July 2007 20:04-kor Alban Bedel ezt írta:
+ * no double-buffering, as it would slow down playback (waiting for vertical retraces)
Why that? In the typical case the wait time is negligable enouth, and the user can still disable it if he want. It doesn't matter much atm but you should definitly consider implementing double buffering.
I did try it, it was much slower, so I didn't like it. Maybe in the future (btw it seems two vertical retraces are needed until the page is flipped, and that is slow).
You don't have to vsync the flip, it's probably preferable, but not requiered. However as Uoti pointed out you will need double buffer for a proper timing.
+/* This actually doesn't change a thing, width greater than 1536 still won't work... */
You should consider putting a check for the image size in config() until this issue is solved.
It works, but there is a pink stripe on the right side. So IMO the user should choose whether he/she wants pink stripe (-vo xover:xvr100) or unusably slow playback (-vo x11).
Is the image scaled down or a part missing? If a part is missing I would not consider that usefull and imho config() should fail. But if it's scaled down, you could compute the effective size and pass it back to xover to allow it to correctly resize the window.
+ if (pfb_xres > pfb_dstwidth) { + pfb_wx0 = (pfb_xres - pfb_dstwidth) / 2; + pfb_wx1 = pfb_wx0 + pfb_dstwidth; + } + else { + pfb_wx0 = 0; + pfb_wx1 = pfb_xres; + } + + if (pfb_yres > pfb_dstheight) { + pfb_wy0 = (pfb_yres - pfb_dstheight) / 2; + pfb_wy1 = pfb_wy0 + pfb_dstheight; + } + else { + pfb_wy0 = 0; + pfb_wy1 = pfb_yres; + } + + pfb_overlay_on(); + + return VO_TRUE; +}
This could be done with less code duplication.
Like moving 15 trivial lines of code to a separate function? What's the point of that?
How trivial it is doesn't matter imho, as soon as it exceed 2 or 3 lines duplicated code just make maitenance harder.
+static uint32_t get_image(mp_image_t *mpi){ + return VO_FALSE; +#if 0 /* doesn't work for some reason */
What is not working exactly?
-vfm ffmpeg -dr always says "stride changed" or something like that (I don't have the message at hand), and some frames are not shown.
You probably hit this pb: http://article.gmane.org/gmane.comp.video.mplayer.devel/1130 It's a limitation of lavc, if it work fine with TEMP buffers you should enable it imho. Albeu
Hi! Wednesday 25 July 2007 22:56-kor Alban Bedel ezt írta:
I did try it, it was much slower, so I didn't like it. Maybe in the future (btw it seems two vertical retraces are needed until the page is flipped, and that is slow).
You don't have to vsync the flip, it's probably preferable, but not requiered. However as Uoti pointed out you will need double buffer for a proper timing.
It has to wait for the retrace, otherwise after flip_page mplayer starts rendering in the backbuffer, but it is still shown -> ugly artifact. Triple buffering would help, but I think I will just leave it for now.
It works, but there is a pink stripe on the right side. So IMO the user should choose whether he/she wants pink stripe (-vo xover:xvr100) or unusably slow playback (-vo x11).
Is the image scaled down or a part missing? If a part is missing I would not consider that usefull and imho config() should fail. But if it's scaled down, you could compute the effective size and pass it back to xover to allow it to correctly resize the window.
A part is missing. It is exactly as usefull as -vo x11 (have you seen hd video decoding + c scaler downscaling on an UltraSPARC - like a very very very slow slideshow). This is really my opinion, because changing config would be easy, but as I described, not wanted.
This could be done with less code duplication.
Like moving 15 trivial lines of code to a separate function? What's the point of that?
How trivial it is doesn't matter imho, as soon as it exceed 2 or 3 lines duplicated code just make maitenance harder.
Ok, so it will be moved into a separate function.
What is not working exactly?
-vfm ffmpeg -dr always says "stride changed" or something like that (I don't have the message at hand), and some frames are not shown.
You probably hit this pb: http://article.gmane.org/gmane.comp.video.mplayer.devel/1130 It's a limitation of lavc, if it work fine with TEMP buffers you should enable it imho.
Ok, great, probably this was it. But how can I test this TEMP buffer thing?
Albeu
thanks bye Denes
On Wed, 25 Jul 2007 23:35:46 +0200 Balatoni Denes <dbalatoni@interware.hu> wrote:
Hi!
Wednesday 25 July 2007 22:56-kor Alban Bedel ezt írta:
I did try it, it was much slower, so I didn't like it. Maybe in the future (btw it seems two vertical retraces are needed until the page is flipped, and that is slow).
You don't have to vsync the flip, it's probably preferable, but not requiered. However as Uoti pointed out you will need double buffer for a proper timing.
It has to wait for the retrace, otherwise after flip_page mplayer starts rendering in the backbuffer, but it is still shown -> ugly artifact. Triple buffering would help, but I think I will just leave it for now.
I fear there is some misunderstanding here. So let's try to clear things a bit, the basic flow in mplayer from the vo pov is: 1) The frame is decoded and passed to the vo 2) Sleep until it's time to show the new frame 3) Call flip to show the new frame To do this with a typical overlay, you WILL need 2 buffer. One to display the current frame and one to draw the new one, with flip() switching the role of the 2. Anyway, this is really trivial to implement, so I fail to see why you insist on keeping a totaly broken behaviour instead.
It works, but there is a pink stripe on the right side. So IMO the user should choose whether he/she wants pink stripe (-vo xover:xvr100) or unusably slow playback (-vo x11).
Is the image scaled down or a part missing? If a part is missing I would not consider that usefull and imho config() should fail. But if it's scaled down, you could compute the effective size and pass it back to xover to allow it to correctly resize the window.
A part is missing. It is exactly as usefull as -vo x11 (have you seen hd video decoding + c scaler downscaling on an UltraSPARC - like a very very very slow slideshow). This is really my opinion, because changing config would be easy, but as I described, not wanted.
I see your point. However mplayer has a large user base, so we must be carefull with such things to avoid getting too many useless complaints and bug reports. I see 2 solutions: 1) Fail at config() and add an option to continue anyway. 2) Print a big fat warning and continue. I would prefer 1), but in both case it should make it perfectly clear that it's a hw limitation, don't complain, don't report it as a bug, etc
What is not working exactly?
-vfm ffmpeg -dr always says "stride changed" or something like that (I don't have the message at hand), and some frames are not shown.
You probably hit this pb: http://article.gmane.org/gmane.comp.video.mplayer.devel/1130 It's a limitation of lavc, if it work fine with TEMP buffers you should enable it imho.
Ok, great, probably this was it. But how can I test this TEMP buffer thing?
With a filter, for ex. expand with the osd enabled or scale. With -v the requested mpi types will be displayed. Albeu
Hi! Thursday 26 July 2007 17:45-kor Alban Bedel ezt írta:
You don't have to vsync the flip, it's probably preferable, but not requiered. However as Uoti pointed out you will need double buffer for a proper timing.
It has to wait for the retrace, otherwise after flip_page mplayer starts rendering in the backbuffer, but it is still shown -> ugly artifact. Triple buffering would help, but I think I will just leave it for now.
I fear there is some misunderstanding here. So let's try to clear things a bit, the basic flow in mplayer from the vo pov is:
1) The frame is decoded and passed to the vo 2) Sleep until it's time to show the new frame 3) Call flip to show the new frame
To do this with a typical overlay, you WILL need 2 buffer. One to display the current frame and one to draw the new one, with flip() switching the role of the 2. Anyway, this is really trivial to implement, so I fail to see why you insist on keeping a totaly broken behaviour instead.
I understood. What I wrote is I think correct, still. You need triple-buffering. Otherwise - to reiterate - after page flip mplayer starts rendering to the backbuffer. But it is still visible (for two vertical retraces), so there is an artifact. Then it's flipped (after two vertical retraces) so there is another flicker. I know it's easy to do triple buffering (as I said there was double buffering, but I removed it because I didn't like it), but I have already spent enough time with this stuff, so I think I will leave fixing this to another time, not in the near future.
A part is missing. It is exactly as usefull as -vo x11 (have you seen hd video decoding + c scaler downscaling on an UltraSPARC - like a very very very slow slideshow). This is really my opinion, because changing config would be easy, but as I described, not wanted.
I see your point. However mplayer has a large user base, so we must be carefull with such things to avoid getting too many useless complaints and bug reports. I see 2 solutions:
1) Fail at config() and add an option to continue anyway. 2) Print a big fat warning and continue.
I went with 2. But I am afraid if every xvr-100 user started complaining, you still wouldn't get too many emails (because of their low number, that is).
You probably hit this pb: http://article.gmane.org/gmane.comp.video.mplayer.devel/1130 It's a limitation of lavc, if it work fine with TEMP buffers you should enable it imho.
Ok, great, probably this was it. But how can I test this TEMP buffer thing?
With a filter, for ex. expand with the osd enabled or scale. With -v the requested mpi types will be displayed.
Thanks, tried it, it works - also other samples worked without TEMP buffer. So I enabled it.
Albeu
bye Denes
Hello, You use a pfb_ prefix everywhere IMO that is really pointless and just bloats the text, and might even be really confusing since name of the vo is xvr100, not pfb. On Mon, Jul 23, 2007 at 08:27:22PM +0200, Balatoni Denes wrote:
@@ -144,6 +147,9 @@
vo_functions_t* video_out_drivers[] = { +#ifdef HAVE_XVR100 + &video_out_xvr100, +#endif #ifdef HAVE_TDFX_VID &video_out_tdfx_vid, #endif
I doubt it is justified putting this before all other vos, IMO at least xv if available should be tried first.
+#define PFB_OV0_V_INC 0x109 +#define PFB_OV0_P1_V_ACCUM_INIT 0x10A +#define PFB_OV0_P23_V_ACCUM_INIT 0x10B +#define PFB_OV0_P1_BLANK_LINES_AT_TOP 0x10C +#define PFB_OV0_P23_BLANK_LINES_AT_TOP 0x10D
Where do these come from? They aren't in some system or vidix header already somewhere?
+static int pfb_buffer1, pfb_buffer2, pfb_buffer3; +static int pfb_stride1, pfb_stride2, pfb_stride3;
Why not use an array?
+static short int pfb_wx0, pfb_wy0, pfb_wx1, pfb_wy1; +static int pfb_xres,pfb_yres; +static int pfb_free_top; +static int pfb_fs; +static int pfb_usecolorkey=0; +static uint32_t pfb_colorkey;
Why not reuse vo_fs, vo_dx, vo_dy, vo_screenwidth, vo_screenheight and vo_colorkey? vo_colorkey contains the information of both pfb_colorkey and pfb_usecolorkey, if (vo_colorkey & 0xff000000) != 0 then colorkey is disabled.
+void pfb_overlay_on() {
All functions (unless part of the vo API like reinit, config etc.) should have doxygen-compatible comments.
+/* This actually doesn't change a thing, width greater than 1536 still won't work... */ +#if 0 + /* if the source width was larger than what would fit in overlay scaler increase step_by values */
Well, I'd be surprised if the scaler didn't always read a full line at once into its buffer, so this just can't work. IMO remove it.
+ pfb_vregs[PFB_OV0_REG_LOAD_CNTL] = PFB_OV0_REG_LOAD_LOCK; + while (!(pfb_vregs[PFB_OV0_REG_LOAD_CNTL] & PFB_OV0_REG_LOAD_LOCK_READBACK)) {}
This is not time critical I think, so you should sleep here instead of doing such a tight busy loop.
+ pfb_vregs[PFB_OV0_P1_H_ACCUM_INIT] = (((0x00005000 + h_inc) << 7) & 0x000f8000) | (((0x00005000 + h_inc) << 15) & 0xf0000000); + pfb_vregs[PFB_OV0_P23_H_ACCUM_INIT] = (((0x0000A000 + h_inc) << 6) & 0x000f8000) | (((0x0000A000 + h_inc) << 14) & 0x70000000);
I am quite sure this can be simplified, and esp. in a way that makes it clearer how to extend it to non-YV12. I mean e.g. (0x0000A000 + h_inc) << 6 == (0x00005000 + h_inc/2) << 7. And it can be & 0xf0000000 in both cases, does not make any difference. I do not know how you came to that code, so maybe it makes sense how you did it (then you should add comments to explain it), otherwise this is simpler (making heavy use of h_inc <= 0x1fff): // handle high-part of h_inc h_inc >>= 8; pfb_vregs[PFB_OV0_P1_H_ACCUM_INIT] = ((h_inc ^ 0x10) << 15) | ((h_inc & 0x10) << 24) | (1 << 29); h_inc >>= 1; pfb_vregs[PFB_OV0_P23_H_ACCUM_INIT] = ((h_inc ^ 0x10) << 15) | ((h_inc & 0x10) << 24) | (1 << 29);
+ if (pfb_usecolorkey) { + pfb_vregs[PFB_OV0_GRPH_KEY_CLR_LOW] = pfb_colorkey; + pfb_vregs[PFB_OV0_GRPH_KEY_CLR_HIGH] = pfb_colorkey | 0xff000000; + pfb_vregs[PFB_OV0_KEY_CNTL] = PFB_OV0_KEY_EN; + } else { + pfb_vregs[PFB_OV0_GRPH_KEY_CLR_LOW] = 0; + pfb_vregs[PFB_OV0_GRPH_KEY_CLR_HIGH] = 0 | 0xff000000; + pfb_vregs[PFB_OV0_KEY_CNTL] = 0x010; + }
Why is PFB_OV0_KEY_EN a define but 0x010 not? And do you really need to set the colour key when you disable it?
+ pfb_buffer1 = pfb_free_top - (pfb_stride1*pfb_srcheight+pfb_stride2*((pfb_srcheight+1) & ~1));
You should check that this does not underflow.
+ pfb_free_top = attr.fbtype.fb_size - 0x2000;
Hm... this seems really weird to me, please comment the idea behind this.
+ page_size = sysconf(_SC_PAGE_SIZE); + + if ((pfb_vbase = mmap(NULL, (((PFB_VRAM_MMAPLEN + page_size - 1) / page_size) * page_size), PROT_READ | PROT_WRITE, MAP_SHARED, pfb_devfd, PFB_VRAM_MMAPBASE)) == MAP_FAILED) {
According to the man page there is no reason to page-align the length argument of mmap. And for VRAM it is probably a given anyway.
+ long page_size; + + if (!vo_config_count) + return; + + pfb_overlay_off(); + page_size = sysconf(_SC_PAGE_SIZE); + munmap(pfb_vbase, (((PFB_VRAM_MMAPLEN + page_size - 1) / page_size) * page_size)); + munmap(pfb_vregs, (((PFB_REGS_MMAPLEN + page_size - 1) / page_size) * page_size));
Same here.
+static uint32_t get_image(mp_image_t *mpi){ + return VO_FALSE; +#if 0 /* doesn't work for some reason */
If it doesn't work you should find out why, it might hide some bug. If you need help, explain more precisely why it doesn't work. And anyway, this code does not have to work 100% flawless, it can be disable at runtime via -nodr (which btw. is default) anyway.
+ if (mpi->flags&MP_IMGFLAG_READABLE) return VO_FALSE; + if (!(mpi->flags&MP_IMGFLAG_PLANAR)) return VO_FALSE; // FIXME: impossible for YV12, right? + if (!(mpi->flags&MP_IMGFLAG_ACCEPT_STRIDE)) return VO_FALSE;
Probably your error is that you did not exclude MP_IMGTYPE_IPB and MP_IMGTYPE_IP. You can't handle those since they require you to provide multiple buffers (if mplayer was sane this would have been covered by mpi->flags&MP_IMGFLAG_READABLE already :-( ).
+static int draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y) +{ + mem2agpcpy_pic(pfb_vbase + pfb_buffer1 + pfb_stride1 * y + x, src[0], w, h, pfb_stride1, stride[0]); + mem2agpcpy_pic(pfb_vbase + pfb_buffer2 + pfb_stride2 * (y>>1) + (x>>1), src[1], (w>>1), (h>>1), pfb_stride2, stride[1]); + mem2agpcpy_pic(pfb_vbase + pfb_buffer3 + pfb_stride2 * (y>>1) + (x>>1), src[2], (w>>1), (h>>1), pfb_stride2, stride[2]);
Just do x >>= 1; y >>= 1; w >>= 1; h >>= 1; after the part handling the Y case IMO. Makes it easier to extend to non-YV12 as well. Greetings, Reimar Döffinger
I have attached a patch which implements most of Diego's and Albeu's and Reimar's suggestions. Thursday 26 July 2007 17:22-kor Reimar Döffinger ezt írta:
Hello,
You use a pfb_ prefix everywhere IMO that is really pointless and just bloats the text, and might even be really confusing since name of the vo is xvr100, not pfb.
pfb is the solaris driver's name, xvr-100 is the cards name. There is a prefix intentionally, because these should be in the VOs private context, if one existed. But if one day VOs have private contexts, it will (would) be easier to convert to priv->stuff . It is bad design, that VOs are not reentrant and are using static variables. So this should stay, this is my opinion.
On Mon, Jul 23, 2007 at 08:27:22PM +0200, Balatoni Denes wrote:
@@ -144,6 +147,9 @@
vo_functions_t* video_out_drivers[] = { +#ifdef HAVE_XVR100 + &video_out_xvr100, +#endif #ifdef HAVE_TDFX_VID &video_out_tdfx_vid, #endif
I doubt it is justified putting this before all other vos, IMO at least xv if available should be tried first.
1) It is faster than XV. 2) xv is not even available in sparc solaris as of now (remember, this is for SPARC Solaris).
+#define PFB_OV0_V_INC 0x109 +#define PFB_OV0_P1_V_ACCUM_INIT 0x10A +#define PFB_OV0_P23_V_ACCUM_INIT 0x10B +#define PFB_OV0_P1_BLANK_LINES_AT_TOP 0x10C +#define PFB_OV0_P23_BLANK_LINES_AT_TOP 0x10D
Where do these come from? They aren't in some system or vidix header already somewhere?
Well, obviously this driver does the same thing as the vidix radeon driver (only worse). But it was much easier to port this driver from XINE (the hardware driver parts are from XINE, if you have not realised from the copyright notice), the way it is than to correctly port vidix to sparc solaris (I am actually thinking of the later, but I don't know enough of these proprietary solaris framebuffer drivers to do it). So yes, probably they are available, but I won't find as it could be redundant later, and it would be a half solution.
+static int pfb_buffer1, pfb_buffer2, pfb_buffer3; +static int pfb_stride1, pfb_stride2, pfb_stride3;
Why not use an array?
Done.
+static short int pfb_wx0, pfb_wy0, pfb_wx1, pfb_wy1; +static int pfb_xres,pfb_yres; +static int pfb_free_top; +static int pfb_fs; +static int pfb_usecolorkey=0; +static uint32_t pfb_colorkey;
Why not reuse vo_fs, vo_dx, vo_dy, vo_screenwidth, vo_screenheight and vo_colorkey? vo_colorkey contains the information of both pfb_colorkey and pfb_usecolorkey, if (vo_colorkey & 0xff000000) != 0 then colorkey is disabled.
Well, the colorkey is passed to the driver by the xover interface. Otherwise I don't know how they should be used, but feel free to change it.
+void pfb_overlay_on() {
All functions (unless part of the vo API like reinit, config etc.) should have doxygen-compatible comments.
They should, but almost nothing else have doxygen comments in mplayer. I understand you think it would be cool, so feel free to add doxygen comments to mplayer, instead of directing me to do more extra work.
+/* This actually doesn't change a thing, width greater than 1536 still won't work... */ +#if 0 + /* if the source width was larger than what would fit in overlay scaler increase step_by values */
Well, I'd be surprised if the scaler didn't always read a full line at once into its buffer, so this just can't work. IMO remove it.
Yes, as Albeu suggested, this is removed, and a warning is issued if width is greater than 1536.
+ pfb_vregs[PFB_OV0_REG_LOAD_CNTL] = PFB_OV0_REG_LOAD_LOCK; + while (!(pfb_vregs[PFB_OV0_REG_LOAD_CNTL] & PFB_OV0_REG_LOAD_LOCK_READBACK)) {}
This is not time critical I think, so you should sleep here instead of doing such a tight busy loop.
Done.
+ pfb_vregs[PFB_OV0_P1_H_ACCUM_INIT] = (((0x00005000 + h_inc) << 7) & 0x000f8000) | (((0x00005000 + h_inc) << 15) & 0xf0000000); + pfb_vregs[PFB_OV0_P23_H_ACCUM_INIT] = (((0x0000A000 + h_inc) << 6) & 0x000f8000) | (((0x0000A000 + h_inc) << 14) & 0x70000000);
I am quite sure this can be simplified, and esp. in a way that makes it clearer how to extend it to non-YV12. I mean e.g. (0x0000A000 + h_inc) << 6 == (0x00005000 + h_inc/2) << 7. And it can be & 0xf0000000 in both cases, does not make any difference. I do not know how you came to that code, so maybe it makes sense how you did it (then you should add comments to explain it), otherwise this is simpler (making heavy use of h_inc <= 0x1fff): // handle high-part of h_inc h_inc >>= 8; pfb_vregs[PFB_OV0_P1_H_ACCUM_INIT] = ((h_inc ^ 0x10) << 15) | ((h_inc & 0x10) << 24) | (1 << 29); h_inc >>= 1; pfb_vregs[PFB_OV0_P23_H_ACCUM_INIT] = ((h_inc ^ 0x10) << 15) | ((h_inc & 0x10) << 24) | (1 << 29);
As I said, this is from xine. In xine non YV12 is handled the same way, so I don't think it's a problem. If you want to rewrite it to something that looks better to you, feel free (it's GPL after all)
+ if (pfb_usecolorkey) { + pfb_vregs[PFB_OV0_GRPH_KEY_CLR_LOW] = pfb_colorkey; + pfb_vregs[PFB_OV0_GRPH_KEY_CLR_HIGH] = pfb_colorkey | 0xff000000; + pfb_vregs[PFB_OV0_KEY_CNTL] = PFB_OV0_KEY_EN; + } else { + pfb_vregs[PFB_OV0_GRPH_KEY_CLR_LOW] = 0; + pfb_vregs[PFB_OV0_GRPH_KEY_CLR_HIGH] = 0 | 0xff000000; + pfb_vregs[PFB_OV0_KEY_CNTL] = 0x010; + }
Why is PFB_OV0_KEY_EN a define but 0x010 not? And do you really need to set the colour key when you disable it?
0x10 is from trial and error. I have removed setting the colorkey when it's not used (it still works).
+ pfb_buffer1 = pfb_free_top - (pfb_stride1*pfb_srcheight+pfb_stride2*((pfb_srcheight+1) & ~1));
You should check that this does not underflow.
Done (the contents of the framebuffer could still be messed up, but that's life).
+ pfb_free_top = attr.fbtype.fb_size - 0x2000;
Hm... this seems really weird to me, please comment the idea behind this.
This is, again, from xine. As I don't have any good documentation on the sparc solaris framebuffer drivers (and there might be none), let's assume they knew what they were doing.
+ page_size = sysconf(_SC_PAGE_SIZE); + + if ((pfb_vbase = mmap(NULL, (((PFB_VRAM_MMAPLEN + page_size - 1) / page_size) * page_size), PROT_READ | PROT_WRITE, MAP_SHARED, pfb_devfd, PFB_VRAM_MMAPBASE)) == MAP_FAILED) {
According to the man page there is no reason to page-align the length argument of mmap. And for VRAM it is probably a given anyway.
Ok, removed.
+static uint32_t get_image(mp_image_t *mpi){ + return VO_FALSE; +#if 0 /* doesn't work for some reason */
If it doesn't work you should find out why, it might hide some bug. If you need help, explain more precisely why it doesn't work. And anyway, this code does not have to work 100% flawless, it can be disable at runtime via -nodr (which btw. is default) anyway.
Albeu has answered this, and now it is enabled, because it works with TEMP buffer.
+static int draw_slice(uint8_t *src[], int stride[], int w,int h,int x,int y) +{ + mem2agpcpy_pic(pfb_vbase + pfb_buffer1 + pfb_stride1 * y + x, src[0], w, h, pfb_stride1, stride[0]); + mem2agpcpy_pic(pfb_vbase + pfb_buffer2 + pfb_stride2 * (y>>1) + (x>>1), src[1], (w>>1), (h>>1), pfb_stride2, stride[1]); + mem2agpcpy_pic(pfb_vbase + pfb_buffer3 + pfb_stride2 * (y>>1) + (x>>1), src[2], (w>>1), (h>>1), pfb_stride2, stride[2]);
Just do x >>= 1; y >>= 1; w >>= 1; h >>= 1; after the part handling the Y case IMO. Makes it easier to extend to non-YV12 as well.
Ok, done.
Greetings, Reimar Döffinger
Dear MPlayer developers, my free time and motivation beutifying the code to your taste lasted for so long, now you are on your own. i have already spent alltogether like 3 hours correcting the code according to your (Diego, Reimar and You) suggestions. This is quite a lot considering that the driver has always been working reasonable well, and the coding rules were obeyed from the beginning (except for a few slipped in trailing whitspaces and a broken configure part). I won't spend more time on it anymore. Maybe in the future I will fix outstanding issues like the lack of UYVY support (this is in fact a problem with MJPEGs) though. Meanwhile I think you should commit the driver, as it - to emphasize once more - works reasonably well. best regards Denes
Hello, On Thu, Jul 26, 2007 at 11:51:40PM +0200, Balatoni Denes wrote:
I have attached a patch which implements most of Diego's and Albeu's and Reimar's suggestions.
In my opinion this has still quite a few rough edges, but given the author is not overjoyed to do code cosmetics ;-), it is already in xine and the aren't enough people interested to find many testers and code-cleaners I intend to apply within the next 5 days. Does anyone object? Greetings, Reimar Döffinger
Reimar Döffinger wrote:
Hello, On Thu, Jul 26, 2007 at 11:51:40PM +0200, Balatoni Denes wrote:
I have attached a patch which implements most of Diego's and Albeu's and Reimar's suggestions.
In my opinion this has still quite a few rough edges, but given the author is not overjoyed to do code cosmetics ;-), it is already in xine and the aren't enough people interested to find many testers and code-cleaners I intend to apply within the next 5 days. Does anyone object
Its not a lack of interest -- its a lack of hardware. I've tested this patch on a Sun Fire V210 that has an XVR-100 running Solaris 10 and did not experience any problems. As the maintainer of the Solaris port (which this patch mostly effects), it has my blessings to be committed. Thanks, -- Derek E. Lewis delewis@acm.org http://delewis.blogspot.com
participants (8)
-
Alban Bedel -
Balatoni Denes -
Balatoni Denes -
Compn -
Derek E. Lewis -
Diego Biurrun -
Reimar Döffinger -
Uoti Urpala