|
List Info
Thread: new here + yuv player
|
|
| new here + yuv player |
  United States |
2007-06-02 09:06:25 |
|
Hi,
> Welcome to the JEDI-SDL mailing list. Please feel free to introduce
> yourself to eveyone on the mailing list.
my name is David Pethes. I'm quite new to JEDI-SDL and SDL in general.
I'm not very experienced programmer neither, my longest program is about
1000 lines long. I created my first SDL proggie a year and half ago,
it's a classical flying-through starfield demo.
I wasn't coding through last year much, only app I can remember doing is
a Huffman coder, as I'm interested in data compression, video in
particular. Many video en/decoding projects (xvid, x264, ffmpeg) include
a (usually quite simple) player for specific video files based on SDL.
And at the beginning of this year I decided to write my own, mainly for
fun and to practice SDL video output, event handling and to learn a bit
of assembly - I wanted to do a fast colorspace conversion from YUV
colorspace, in which the video is stored, to RGB colorspace, which is
used by SDL. Reading through the documentation and source code of simple
players written in C (from above mentioned projects) I realized, that
this can be done directly through SDL overlays too, but I wanted to do
it myself nonetheless (and I still want to rewrite my colorspace
conversion code into SIMD instructions once...) and make the overlay
stuff optional.
Recently, I switched to JEDI-SDL headers, and on Monday I've found that
my player crashes when using overlay. I discovered that there's a bug in
sdl.pas header, so I posted a patch to Dominique, since he was mentioned
in the header and listed as project admin on SF. He asked me for a
working overlay stuff example, so I revamped my player to an example for
using overlays. After a few mails later I made it compatible with Delphi
too, and he was so kind that he included it in Demo section Also, he
told me about jedi-sdl site, list and pascalgamedev. I'm glad I could
join. So much for introduction... I'll try to be brief for now on.
I attached a new patch, that adds resizing to yuv player example (and
fixes some comments' indentation). It's another advantage of using
overlays, you don't have to resize the image on your own. The downsize
is, that the resize algorithm is nearest neighbor, so it looks kinda
blocky. I decided to add this because it seems to me that there's no SDL
overlay tutorial for pascal (or at all? I gave a try to search, couldn't
find any), since it's usually useless for game devs. Comments and
suggestions welcomed.
Greetings,
David
----------
Index: yuv_player.dpr
===================================================================
RCS file: /cvsroot/jedi-sdl/JEDI-SDLv1.0/Demos/2D/YuvPlayer/yuv_player.dpr,v
retrieving revision 1.2
diff -u -r1.2 yuv_player.dpr
--- yuv_player.dpr 31 May 2007 22:46:58 -0000 1.2
+++ yuv_player.dpr 2 Jun 2007 12:29:04 -0000
 -60,7 +60,7 
{ v = (height/2) * (width/2) }
{ }
{ usage: }
-{ yuv_player <filename< [options] }
+{ yuv_player <filename> [options] }
{ input must be raw YUV 4:2:0 file }
{ options: }
{ -w <int> set width ( default 320 ) }
 -70,6 +70,7 
{ keys: }
{ q, Esc quit }
{ p pause }
+{ r reset window dimensions to input dimensions }
{ }
{ Revision History }
{ ---------------- }
 -105,8 +106,8 
var
//image properties
- width : word = DEFAULT_WIDTH;
- height : word = DEFAULT_HEIGHT;
+ width : word;
+ height : word;
iyuv : yuv_image_t;
swapuv : boolean;
 -121,6 +122,8 
//sdl vars
screen : PSDL_Surface;
+ scr_width : word = DEFAULT_WIDTH;
+ scr_height : word = DEFAULT_HEIGHT;
overlay : PSDL_Overlay;
drect : TSDL_Rect;
event : TSDL_Event;
 -219,7 +222,7 
{
- init_sdl, init_display, quit_sdl
+ init_sdl, init_display, init_overlay, quit_sdl
}
procedure init_sdl;
 -230,21 +233,26 
end;
procedure init_display;
+;var
+ flags : UInt32;
begin
- screen := SDL_SetVideoMode( width, height, DISPLAY_BPP, SDL_SWSURFACE );
+ flags := SDL_SWSURFACE or SDL_RESIZABLE;
+ screen := SDL_SetVideoMode( scr_width, scr_height, DISPLAY_BPP, flags );
if screen = nil then
yp_error( 'yp_init_sdl: SDL_SetVideoMode failed' );
SDL_WM_SetCaption( 'yuv player', nil );
- //create overlay for screen
+ drect.x := 0;
+ drect.y := 0;
+ drect.w := scr_width;
+ drect.h := scr_height;
+end;
+
+procedure init_overlay;
+;begin
overlay := SDL_CreateYUVOverlay( width, height, OVERLAY_CSP, screen );
if overlay = nil then
yp_error( 'yp_init_sdl: SDL_CreateYUVOverlay failed' );
-
- drect.x := 0;
- drect.y := 0;
- drect.w := width;
- drect.h := height;
end;
procedure quit_sdl;
 -323,6 +331,7 
writeln( 'keys:' );
writeln( ' q, Esc quit' );
writeln( ' p pause' );
+ writeln( ' r reset window dimensions to input dimensions');
end;
{
 -342,6 +351,8 
halt;
end;
+ width := scr_width;
+ height := scr_height;
in_file_name := ParamStr( 1 );
if ParamCount > 1 then
 -361,12 +372,14 
val( ParamStr( c + 1 ), width, e );
if e <> 0 then
yp_error( 'wrong parameters' );
+ scr_width := width;
end;
if ParamStr( c ) = '-h' then
begin
val( ParamStr( c + 1 ), height, e );
if e <> 0 then
yp_error( 'wrong parameters' );
+ scr_height := height;
end;
if ParamStr( c ) = '-?' then
help;
 -387,6 +400,7 
open_file;
init_sdl;
init_display;
+ init_overlay;
writeln( 'playing: ', in_file_name, ', ', in_frame_count, ' frames, ',
width, 'x', height, ' ', fps, ' fps' );
 -403,10 +417,10 
begin
SDL_PollEvent( event );
case event.type_ of
- //quit
+ //quit
SDL_QUITEV :
play := false;
- //key pressed
+ //key pressed
SDL_KEYDOWN :
case event.key.keysym.sym of
SDLK_q,
 -422,13 +436,27 
write( ' ', #13 ); //clear the 'pause' text
pause_pressed := true;
end;
+ //reset window dimensions to input dimensions
+ SDLK_r :
+ begin
+ scr_width := width;
+ scr_height := height;
+ init_display;
+ end;
end;
- //key released
+ //key released
SDL_KEYUP :
case event.key.keysym.sym of
SDLK_p :
pause_pressed := false;
end;
+ //resize
+ SDL_VIDEORESIZE :
+ begin
+ scr_width := event.resize.w;
+ scr_height := event.resize.h;
+ init_display;
+ end;
end;
//if the player is not paused and it's time for a new frame,
[Non-text portions of this message have been removed]
__._,_.___
.
__,_._,___
|
| Re: new here + yuv player |
  Spain |
2007-06-02 20:14:47 |
|
At 16:06 02/06/2007, you wrote:
>Hi,
>
>> Welcome to the JEDI-SDL mailing list. Please feel free to introduce
>> yourself to eveyone on the mailing list.
>
>my name is David Pethes. I'm quite new to JEDI-SDL and SDL in general.
>I'm not very experienced programmer neither, my longest program is about
>1000 lines long. I created my first SDL proggie a year and half ago,
>it's a classical flying-through starfield demo.
>
>I wasn't coding through last year much, only app I can remember doing is
>a Huffman coder, as I'm interested in data compression, video in
>particular. Many video en/decoding projects (xvid, x264, ffmpeg) include
>a (usually quite simple) player for specific video files based on SDL.
>And at the beginning of this year I decided to write my own, mainly for
>fun and to practice SDL video output, event handling and to learn a bit
>of assembly - I wanted to do a fast colorspace conversion from YUV
>colorspace, in which the video is stored, to RGB colorspace, which is
>used by SDL. Reading through the documentation and source code of simple
>players written in C (from above mentioned projects) I realized, that
>this can be done directly through SDL overlays too, but I wanted to do
>it myself nonetheless (and I still want to rewrite my colorspace
>conversion code into SIMD instructions once...) and make the overlay
>stuff optional.
>
>Recently, I switched to JEDI-SDL headers, and on Monday I've found that
>my player crashes when using overlay. I discovered that there's a bug in
>sdl.pas header, so I posted a patch to Dominique, since he was mentioned
>in the header and listed as project admin on SF. He asked me for a
>working overlay stuff example, so I revamped my player to an example for
>using overlays. After a few mails later I made it compatible with Delphi
>too, and he was so kind that he included it in Demo section Also, he
>told me about jedi-sdl site, list and pascalgamedev. I'm glad I could
>join. So much for introduction... I'll try to be brief for now on.
>
>I attached a new patch, that adds resizing to yuv player example (and
>fixes some comments' indentation). It's another advantage of using
>overlays, you don't have to resize the image on your own. The downsize
>is, that the resize algorithm is nearest neighbor, so it looks kinda
>blocky. I decided to add this because it seems to me that there's no SDL
>overlay tutorial for pascal (or at all? I gave a try to search, couldn't
>find any), since it's usually useless for game devs. Comments and
>suggestions welcomed.
There is a pascal unit with glue-code for ffmpeg library. This library is "de facto" standard opensource for video/audio processing (view, edit, compress, decompress, recode, etc...). DOn't remember the url, but one of the developers is Christian Iversen, you can contact him at chriversSPAMOUT%40iversen-net.dk">chriversSPAMOUT iversen-net.dk
HTH
>Greetings,
>
>David
----------------------------------------------------------
Usuario de FreeBSD3;Xfce, OpenOffice y muchos mas OSS.
Microsoft declara que el OSS viola 235 patentes. Por favor, DENUNCIAME.
__._,_.___
.
__,_._,___
|
| Re: new here + yuv player |
  United States |
2007-06-03 03:23:10 |
|
Hi David,
Welcome to the mailing list.
The changes are checked in. Please confirm that they work as advertised.
Dominique.
David Pethes wrote:
> Hi,
>
>> Welcome to the JEDI-SDL mailing list. Please feel free to introduce
>> yourself to eveyone on the mailing list.
>
> my name is David Pethes. I'm quite new to JEDI-SDL and SDL in general.
> I'm not very experienced programmer neither, my longest program is about
> 1000 lines long. I created my first SDL proggie a year and half ago,
> it's a classical flying-through starfield demo.
>
> I wasn't coding through last year much, only app I can remember doing is
> a Huffman coder, as I'm interested in data compression, video in
> particular. Many video en/decoding projects (xvid, x264, ffmpeg) include
> a (usually quite simple) player for specific video files based on SDL.
> And at the beginning of this year I decided to write my own, mainly for
> fun and to practice SDL video output, event handling and to learn a bit
> of assembly - I wanted to do a fast colorspace conversion from YUV
> colorspace, in which the video is stored, to RGB colorspace, which is
> used by SDL. Reading through the documentation and source code of simple
> players written in C (from above mentioned projects) I realized, that
> this can be done directly through SDL overlays too, but I wanted to do
> it myself nonetheless (and I still want to rewrite my colorspace
> conversion code into SIMD instructions once...) and make the overlay
> stuff optional.
>
> Recently, I switched to JEDI-SDL headers, and on Monday I've found that
> my player crashes when using overlay. I discovered that there's a bug in
> sdl.pas header, so I posted a patch to Dominique, since he was mentioned
> in the header and listed as project admin on SF. He asked me for a
> working overlay stuff example, so I revamped my player to an example for
> using overlays. After a few mails later I made it compatible with Delphi
> too, and he was so kind that he included it in Demo section Also, he
> told me about jedi-sdl site, list and pascalgamedev. I'm glad I could
> join. So much for introduction... I'll try to be brief for now on.
>
>
> I attached a new patch, that adds resizing to yuv player example (and
> fixes some comments' indentation). It's another advantage of using
> overlays, you don't have to resize the image on your own. The downsize
> is, that the resize algorithm is nearest neighbor, so it looks kinda
> blocky. I decided to add this because it seems to me that there's no SDL
> overlay tutorial for pascal (or at all? I gave a try to search, couldn't
> find any), since it's usually useless for game devs. Comments and
> suggestions welcomed.
> Greetings,
>
> David
>
>
>
> ----------
>
> Index: yuv_player.dpr
> ===================================================================
> RCS file: /cvsroot/jedi-sdl/JEDI-SDLv1.0/Demos/2D/YuvPlayer/yuv_player.dpr,v
> retrieving revision 1.2
> diff -u -r1.2 yuv_player.dpr
> --- yuv_player.dpr 31 May 2007 22:46:58 -0000 1.2
> +++ yuv_player.dpr 2 Jun 2007 12:29:04 -0000
>  -60,7 +60,7  
> { v = (height/2) * (width/2) }
> { }
> { usage: }
> -{ yuv_player <filename< [options] }
> +{ yuv_player <filename> [options] }
> { input must be raw YUV 4:2:0 file }
> { options: }
> { -w <int> set width ( default 320 ) }
>  -70,6 +70,7  
> { keys: }
> { q, Esc quit }
> { p pause }
> +{ r reset window dimensions to input dimensions }
> { }
> { Revision History }
> { ---------------- }
>  -105,8 +106,8  
>
> var
> //image properties
> - width : word = DEFAULT_WIDTH;
> - height : word = DEFAULT_HEIGHT;
> + width : word;
> + height : word;
> iyuv : yuv_image_t;
> swapuv : boolean;
>
>  -121,6 +122,8  
>
> //sdl vars
> screen : PSDL_Surface;
> + scr_width : word = DEFAULT_WIDTH;
> + scr_height : word = DEFAULT_HEIGHT;
> overlay : PSDL_Overlay;
> drect : TSDL_Rect;
> event : TSDL_Event;
>  -219,7 +222,7  
>
>
> {
> - init_sdl, init_display, quit_sdl
> + init_sdl, init_display, init_overlay, quit_sdl
> }
>
> procedure init_sdl;
>  -230,21 +233,26  
> end;
>
> procedure init_display;
> +var
> + flags : UInt32;
> begin
> - screen := SDL_SetVideoMode( width, height, DISPLAY_BPP, SDL_SWSURFACE );
> + flags := SDL_SWSURFACE or SDL_RESIZABLE;
> + screen := SDL_SetVideoMode( scr_width, scr_height, DISPLAY_BPP, flags );
> if screen = nil then
> yp_error( 'yp_init_sdl: SDL_SetVideoMode failed' );
> SDL_WM_SetCaption( 'yuv player', nil );
>
> - //create overlay for screen
> + drect.x := 0;
> + drect.y := 0;
> + drect.w := scr_width;
> + drect.h := scr_height;
> +end;
> +
> +procedure init_overlay;
> +begin
> overlay := SDL_CreateYUVOverlay( width, height, OVERLAY_CSP, screen );
> if overlay = nil then
> yp_error( 'yp_init_sdl: SDL_CreateYUVOverlay failed' );
> -
> - drect.x := 0;
> - drect.y := 0;
> - drect.w := width;
> - drect.h := height;
> end;
>
> procedure quit_sdl;
>  -323,6 +331,7  
> writeln( 'keys:' );
> writeln( ' q, Esc quit' );
> writeln( ' p pause' );
> + writeln( ' r reset window dimensions to input dimensions');
> end;
>
> {
>  -342,6 +351,8  
> halt;
> end;
>
> + width := scr_width;
> + height := scr_height;
> in_file_name := ParamStr( 1 );
>
> if ParamCount > 1 then
>  -361,12 +372,14  
> val( ParamStr( c + 1 ), width, e );
> if e <> 0 then
> yp_error( 'wrong parameters' );
> + scr_width := width;
> end;
> if ParamStr( c ) = '-h' then
> begin
> val( ParamStr( c + 1 ), height, e );
> if e <> 0 then
> yp_error( 'wrong parameters' );
> + scr_height := height;
> end;
> if ParamStr( c ) = '-?' then
> help;
>  -387,6 +400,7  
> open_file;
> init_sdl;
> init_display;
> + init_overlay;
> writeln( 'playing: ', in_file_name, ', ', in_frame_count, ' frames, ',
> width, 'x', height, ' ', fps, ' fps' );
>
>  -403,10 +417,10  
> begin
> SDL_PollEvent( event );
> case event.type_ of
> - //quit
> + //quit
> SDL_QUITEV :
> play := false;
> - //key pressed
> + //key pressed
> SDL_KEYDOWN :
> case event.key.keysym.sym of
> SDLK_q,
>  -422,13 +436,27  
> write( ' ', #13 ); //clear the 'pause' text
> pause_pressed := true;
> end;
> + //reset window dimensions to input dimensions
> + SDLK_r :
> + begin
> + scr_width := width;
> + scr_height := height;
> + init_display;
> + end;
> end;
> - //key released
> + //key released
> SDL_KEYUP :
> case event.key.keysym.sym of
> SDLK_p :
> pause_pressed := false;
> end;
> + //resize
> + SDL_VIDEORESIZE :
> + begin
> + scr_width := event.resize.w;
> + scr_height := event.resize.h;
> + init_display;
> + end;
> end;
>
> //if the player is not paused and it's time for a new frame,
>
>
> [Non-text portions of this message have been removed]
> | |