Re: [sdljava-users] SDLVideoTest fails on FC4
Status: Beta
Brought to you by:
ivan_ganza
From: Ivan Z. G. <iva...@ya...> - 2006-03-06 02:50:04
|
Hi Shane, Had a glance at the code. From what I see it should be no problem to=20 get the YUV stuff implemented. I'll try to get it soon. Most likely I=20 will work on it next weekend... Cheers, -Ivan/ Ivan Z. Ganza wrote: > Great thanks, > > I will have a look at this and get back to you. > > Much appreciated, > -Ivan/ > > Shane M. Walton wrote: > >> Ivan, >> >> Here you go. Just press the "q" key to quit the example. >> >> Shane >> >> Ivan Z. Ganza wrote: >> >>> Greeting Shane, >>> >>> Any example code you can provide in C++ would be helpful. Or if you=20 >>> could give me a C program I can compile and run against sdl that=20 >>> tests the YUV I could then implement enough so those calls can be=20 >>> made on the sdljava side. Once I can see how the code needs to be=20 >>> utilized I can have some idea if it can be done easily... >>> >>> Thanks, >>> -Ivan/ >>> >>> Shane M. Walton wrote: >>> >>>> Thanks Ivan. >>>> >>>> The SDL_Overlay is very powerful when one would like to render video. >>>> >>>> Typically MPEG codecs encode/decode pixels into a YUV color space=20 >>>> which is more efficient to operate on than RGB. So DVD/MPEG2=20 >>>> rendering applications usually take advantage of the YUV overlay=20 >>>> acceleration capabilities of a video card. This is known as Xv in=20 >>>> the Linux world. All in all, what you get is the video on the=20 >>>> screen with little or no CPU overhead. The overlay architecture=20 >>>> also typically have scaling capabilities, which look much softer=20 >>>> than any software routine. >>>> >>>> I think it would be very worthwhile to have SDL_Overlay(s)=20 >>>> implemented in sdljava, as Java in general really seems to be=20 >>>> missing efficient video rendering capabilities. >>>> >>>> I can provide you with C/C++ source code examples if you are=20 >>>> interested in adding the SDL_Overlay functionality. It really=20 >>>> isn't too difficult. I would offer to add it, but I don't have a=20 >>>> clue as to how SWIG works, but always willing to learn. >>>> >>>> Shane >>>> >>>> Ivan Z. Ganza wrote: >>>> >>>>> Greetings Shane, >>>>> >>>>> Sorry that your having trouble. I just tried it myself and I don't=20 >>>>> see the image either. Just a blank window. Not sure when this=20 >>>>> stopped working. Should hit myself for not regression testing. I=20 >>>>> will try to figure out the problem. >>>>> >>>>> Don't want to add more bad news but I never implemented the YUV=20 >>>>> Overlay stuff. Don't really know much about that aspect. Is it=20 >>>>> just a few method calls or much more involved? I think I remember=20 >>>>> it wasn't easy to map (via swig) initially so that is why I=20 >>>>> skipped it. >>>>> >>>>> testimage seems to be working fine though. hmm. >>>>> >>>>> -Ivan/ >>>>> >>>>> Shane M. Walton wrote: >>>>> >>>>>> The current binary download for Linux i386 doesn=92t give me the=20 >>>>>> NullPointerException, but it doesn=92t show the test_bmp.bmp aka=20 >>>>>> power plant. >>>>>> >>>>>> My ultimate goal is to create a Java video application that can=20 >>>>>> render video using the YUV Overlay. Maybe it would just work, but=20 >>>>>> I don=92t feel all warm and fuzzy if the test application doesn=92= t.=20 >>>>>> Has anybody else had this issue? >>>>>> >>>>>> Shane >>>>>> >>>>>> ------------------------------------------------------------------= ------=20 >>>>>> >>>>>> >>>>>> *From:* sdl...@li...=20 >>>>>> [mailto:sdl...@li...] *On Behalf Of=20 >>>>>> *Shane M. Walton >>>>>> *Sent:* Friday, March 03, 2006 7:35 AM >>>>>> *To:* sdl...@li... >>>>>> *Subject:* [sdljava-users] SDLVideoTest fails on FC4 >>>>>> >>>>>> OS: Fedora Core 4 (i686) >>>>>> >>>>>> SDL: 1.2.8-3.2 >>>>>> >>>>>> JDK: Sun 1.5.0_06 >>>>>> >>>>>> SWIG: 1.3.24-2 >>>>>> >>>>>> The following happens with both stable release and cvs trunk=20 >>>>>> checkout: >>>>>> >>>>>> java -Djava.library.path=3D./lib -cp ./classes/=20 >>>>>> sdljava.video.SDLVideoTest >>>>>> >>>>>> Video subsystem initialized >>>>>> >>>>>> java.lang.NullPointerException >>>>>> >>>>>> at sdljava.video.SDLPixelFormat.getPalette(SDLPixelFormat.java:61) >>>>>> >>>>>> at sdljava.video.SDLPixelFormat.toString(SDLPixelFormat.java:375) >>>>>> >>>>>> at sdljava.video.SDLSurface.toString(SDLSurface.java:1122) >>>>>> >>>>>> at java.lang.String.valueOf(String.java:2577) >>>>>> >>>>>> at java.lang.StringBuffer.append(StringBuffer.java:220) >>>>>> >>>>>> at sdljava.video.SDLVideoTest.init(SDLVideoTest.java:21) >>>>>> >>>>>> at sdljava.video.SDLVideoTest.main(SDLVideoTest.java:70) >>>>>> >>>>>> Seems like all accessors in SDLPixelFormat throw a=20 >>>>>> NullPointerException. >>>>>> >>>>>> Thanks. >>>>>> >>>>>> Shane >>>>>> >>>>> >>>>> >>>>> >>>>> ------------------------------------------------------- >>>>> This SF.Net email is sponsored by xPML, a groundbreaking scripting=20 >>>>> language >>>>> that extends applications into web and mobile media. Attend the=20 >>>>> live webcast >>>>> and join the prime developer group breaking into this new coding=20 >>>>> territory! >>>>> http://sel.as-us.falkag.net/sel?cmd=3Dk&kid=110944&bid$1720&dat=121= 642 >>>>> _______________________________________________ >>>>> sdljava-users mailing list >>>>> sdl...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/sdljava-users >>>>> >>>> >>>> >>>> >>>> ------------------------------------------------------- >>>> This SF.Net email is sponsored by xPML, a groundbreaking scripting=20 >>>> language >>>> that extends applications into web and mobile media. Attend the=20 >>>> live webcast >>>> and join the prime developer group breaking into this new coding=20 >>>> territory! >>>> http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=3D110944&bid=3D241720&= dat=3D121642=20 >>>> >>>> _______________________________________________ >>>> sdljava-users mailing list >>>> sdl...@li... >>>> https://lists.sourceforge.net/lists/listinfo/sdljava-users >>> >>> >>> >>> >>> >>> >>> ------------------------------------------------------- >>> This SF.Net email is sponsored by xPML, a groundbreaking scripting=20 >>> language >>> that extends applications into web and mobile media. Attend the live=20 >>> webcast >>> and join the prime developer group breaking into this new coding=20 >>> territory! >>> http://sel.as-us.falkag.net/sel?cmd=3Dk&kid=110944&bid$1720&dat=12164= 2 >>> _______________________________________________ >>> sdljava-users mailing list >>> sdl...@li... >>> https://lists.sourceforge.net/lists/listinfo/sdljava-users >>> >> >> ----------------------------------------------------------------------= -- >> >> /* >> * Libavformat API example: Output a media file in any supported >> * libavformat format. The default codecs are used. >> * >> * Copyright (c) 2003 Fabrice Bellard >> * >> * Permission is hereby granted, free of charge, to any person=20 >> obtaining a copy >> * of this software and associated documentation files (the=20 >> "Software"), to deal >> * in the Software without restriction, including without limitation=20 >> the rights >> * to use, copy, modify, merge, publish, distribute, sublicense,=20 >> and/or sell >> * copies of the Software, and to permit persons to whom the Software i= s >> * furnished to do so, subject to the following conditions: >> * >> * The above copyright notice and this permission notice shall be=20 >> included in >> * all copies or substantial portions of the Software. >> * >> * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,=20 >> EXPRESS OR >> * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF=20 >> MERCHANTABILITY, >> * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT=20 >> SHALL >> * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES=20 >> OR OTHER >> * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,=20 >> ARISING FROM, >> * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER=20 >> DEALINGS IN >> * THE SOFTWARE. >> */ >> >> /* >> * The above is included per the fill_yuv_image() function I borrowed=20 >> from the >> * FFmpeg output_example.c. It is a cool little YUV generator... >> * >> */ >> >> #include <stdio.h> // for fprintf >> #include <unistd.h> // for usleep >> >> #include <SDL/SDL.h> >> >> typedef struct { >> unsigned char *data[4] ; >> int linesize[4] ; >> } myImage ; >> >> void fill_yuv_image(myImage *pict, int frame_index, int width, int=20 >> height) >> { >> int x, y, i; >> >> i =3D frame_index; >> >> /* Y */ >> for(y=3D0;y<height;y++) { >> for(x=3D0;x<width;x++) { >> pict->data[0][y * pict->linesize[0] + x] =3D x + y + i * 3; >> } >> } >> >> /* Cb and Cr or U and V */ >> for(y=3D0;y<height/2;y++) { >> for(x=3D0;x<width/2;x++) { >> pict->data[1][y * pict->linesize[1] + x] =3D 128 + y + i * = 2; >> pict->data[2][y * pict->linesize[2] + x] =3D 64 + x + i * 5= ; >> } >> } >> } >> >> int main ( int argc, char *argv[] ) >> { >> int flags, cnt =3D 0, looping =3D 1, w =3D 640, h =3D 480 ; >> SDL_Surface *surface ; >> SDL_Overlay *overlay ; >> SDL_Rect area ; >> SDL_Event event ; >> myImage image ; >> >> SDL_Init ( SDL_INIT_VIDEO ) ; >> >> flags =3D SDL_HWSURFACE | SDL_ASYNCBLIT | SDL_HWACCEL ; >> if ( ( surface =3D SDL_SetVideoMode ( w, h, 0, flags ) ) =3D=3D NULL= ) >> { >> fprintf ( stderr, "SDL_SetVideoMode: %s\n", SDL_GetError() ) ; >> return -1 ; >> } >> >> /* >> * request a YVU420P overlay - Y + V + U >> */ >> overlay =3D SDL_CreateYUVOverlay ( w, h, SDL_YV12_OVERLAY, surface )= ; >> if ( overlay =3D=3D NULL ) >> { >> fprintf ( stderr, "SDL_CreateYUVOverlay: %s\n", SDL_GetError() ) = ; >> goto cleanup ; >> } >> >> area.x =3D 0 ; >> area.y =3D 0 ; >> area.w =3D w ; >> area.h =3D h ; >> >> while ( looping ) >> { >> /* >> * lock the YUV overlay surface before messing with the pixels >> */ >> SDL_LockYUVOverlay ( overlay ) ; >> >> /* >> * swap the U and V planes since... >> * the overlay is YVU420P and the image YUV420P >> */ >> image.data[0] =3D overlay->pixels[0] ; >> image.data[1] =3D overlay->pixels[2] ; >> image.data[2] =3D overlay->pixels[1] ; >> image.linesize[0] =3D overlay->pitches[0] ; >> image.linesize[1] =3D overlay->pitches[2] ; >> image.linesize[2] =3D overlay->pitches[1] ; >> >> /* >> * copy in a YUV image >> */ >> fill_yuv_image ( &image, cnt++, w, h ) ; >> >> /* >> * unlock the YUV overlay surface after messing with the pixels >> */ >> SDL_UnlockYUVOverlay ( overlay ) ; >> >> /* >> * finally, display the YUV image >> */ >> SDL_DisplayYUVOverlay ( overlay, &area ) ; >> >> /* >> * check to see if the "q" key was pressed to quit >> */ >> if ( SDL_PollEvent ( &event ) ) >> { >> if ( event.type =3D=3D SDL_KEYDOWN ) >> { >> switch ( event.key.keysym.sym ) >> { >> case SDLK_q: >> looping =3D 0 ; >> break ; >> } >> } >> } >> >> /* >> * sleep for a bit to avoid over-driving the CPU >> */ >> usleep ( 20000 ) ; >> } >> >> SDL_FreeYUVOverlay ( overlay ) ; >> >> cleanup: >> >> SDL_Quit ( ) ; >> >> return 0 ; >> } >> =20 >> > > > > ------------------------------------------------------- > This SF.Net email is sponsored by xPML, a groundbreaking scripting=20 > language > that extends applications into web and mobile media. Attend the live=20 > webcast > and join the prime developer group breaking into this new coding=20 > territory! > http://sel.as-us.falkag.net/sel?cmd=3Dlnk&kid=110944&bid$1720&dat=12164= 2 > _______________________________________________ > sdljava-users mailing list > sdl...@li... > https://lists.sourceforge.net/lists/listinfo/sdljava-users |