Image Inverted in SDL_Surface?

hi ppl,
i was writing an AVI player (for playing AVI in cutscenes etc) … i have done alomost all the basic stuff … now what i do is i read the bitmap(BITMAPHEADERINFO thingy) data and blit it on my screen (SDL Surface) … since i am not actually creating a texture … this is how i do it …
first get the frame data header …
(LPBITMAPINFOHEADER)AVIStreamGetFrame(pgf, frame);

get the actual raw data …
pdata=(char *)lpbi+lpbi->biSize;

create a SDL surface using the data just read:
SDL_CreateRGBSurfaceFrom(pdata, info.dwWidth, info.dwHeight, sampleSize, info.dwWidth* (sampleSize/8),R_mask, G_mask, B_mask, A_mask);

finally blit the surface:
SDL_BlitSurface(frame, NULL, S, &dest);
SDL_UpdateRects(S, 1, &src1);

but the problem i am facing is that the video is playing upside down … i dunno wat is the problem … but i think that i am not using SDL_BlitSurface properly

now since i am not creating a texture and then mapping it on some surface hence cannot invert texture coords … how can i inverse the bitmap data in my case (i do not want to use any brute force thing like reversing the data using a loop etc.)
if have asked a few ppl and they have also faced similar problems …
well apart from the main question … i wud also like to know if it is better the way in which i am doing it or is it better that i make texture from the data and map it on some quad?? …

thanx in advance,
enygmyx.---------------------------------
Do you Yahoo!?
Yahoo! Hotjobs: Enter the “Signing Bonus” Sweepstakes

Not familiar with the “AVIStreamGetFrame()” thingy you’re calling, but is
it spitting out an actual BitMaP, as in a Windows BMP?

If so, I believe those are stored (at least when saved to disk) upside-down.

Could be the problem.

Hopefully I’m not making a complete fool of myself. :wink: Good lucK!

-bill!On Mon, Jan 12, 2004 at 10:39:55PM -0800, sohyl siddiqui wrote:

hi ppl,
i was writing an AVI player (for playing AVI in cutscenes etc) … i have done alomost all the basic stuff … now what i do is i read the bitmap(BITMAPHEADERINFO thingy) data and blit it on my screen (SDL Surface) … since i am not actually creating a texture … this is how i do it …
first get the frame data header …
(LPBITMAPINFOHEADER)AVIStreamGetFrame(pgf, frame);

I believe some AVI codecs store the video upside down, i’ve seen this before
when it uses an incorrect decoder to display the video (all the different
standards, ick).

Have you tried displaying this video in a standalone player, and are you sure
it’s correctly finding the right codec to use ?

Not familiar with the AVI API, so just adding a few thoughts.

John

Bill Kendrick wrote:> On Mon, Jan 12, 2004 at 10:39:55PM -0800, sohyl siddiqui wrote:

hi ppl,
i was writing an AVI player (for playing AVI in cutscenes etc) … i have done alomost all the basic stuff … now what i do is i read the bitmap(BITMAPHEADERINFO thingy) data and blit it on my screen (SDL Surface) … since i am not actually creating a texture … this is how i do it …
first get the frame data header …
(LPBITMAPINFOHEADER)AVIStreamGetFrame(pgf, frame);

Not familiar with the “AVIStreamGetFrame()” thingy you’re calling, but is
it spitting out an actual BitMaP, as in a Windows BMP?

If so, I believe those are stored (at least when saved to disk) upside-down.

Could be the problem.

Hopefully I’m not making a complete fool of myself. :wink: Good lucK!

-bill!


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

yeah, windows bmp are upside down, my suggestion is instead of
blitting the whole thing with one SDL_BlitSurface, just blit every row
of data, starting with the last one and blitting it first, reversing
while you blit.

Bill Kendrick wrote:

hi ppl,
i was writing an AVI player (for playing AVI in cutscenes etc) … i
have done alomost all the basic stuff … now what i do is i read the
bitmap(BITMAPHEADERINFO thingy) data and blit it on my screen (SDL Surface)
… since i am not actually creating a texture … this is how i do it

first get the frame data header …
(LPBITMAPINFOHEADER)AVIStreamGetFrame(pgf, frame);

Not familiar with the “AVIStreamGetFrame()” thingy you’re calling, but is
it spitting out an actual BitMaP, as in a Windows BMP?

If so, I believe those are stored (at least when saved to disk)
upside-down.> On Mon, Jan 12, 2004 at 10:39:55PM -0800, sohyl siddiqui wrote:

Could be the problem.

Hopefully I’m not making a complete fool of myself. :wink: Good lucK!

-bill!


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

Try to use Overlays. It should take care of the things.
In my case it works like this:

SDL_LockYUVOverlay( g_cOverlay );
img_convert( &cDest, PIX_FMT_YUV420P, &cSrc, cCodec->pix_fmt, w, h );
SDL_UnlockYUVOverlay( g_cOverlay );
SDL_DisplayYUVOverlay( g_cOverlay, &cRect);

Bors/> ----- Original Message -----

From: john@nextraweb.com (John Drinkwater)
To: sdl at libsdl.org
Date: Tue, 13 Jan 2004 17:10:45 +0000
Subject: Re: [SDL] Image Inverted in SDL_Surface ???

I believe some AVI codecs store the video upside down, i’ve seen this before
when it uses an incorrect decoder to display the video (all the different
standards, ick).

Have you tried displaying this video in a standalone player, and are you sure
it’s correctly finding the right codec to use ?

Not familiar with the AVI API, so just adding a few thoughts.

John

Bill Kendrick wrote:

On Mon, Jan 12, 2004 at 10:39:55PM -0800, sohyl siddiqui wrote:

hi ppl,
i was writing an AVI player (for playing AVI in cutscenes etc) … i have done alomost all the basic stuff … now what i do is i read the bitmap(BITMAPHEADERINFO thingy) data and blit it on my screen (SDL Surface) … since i am not actually creating a texture … this is how i do it …
first get the frame data header …
(LPBITMAPINFOHEADER)AVIStreamGetFrame(pgf, frame);

Not familiar with the “AVIStreamGetFrame()” thingy you’re calling, but is
it spitting out an actual BitMaP, as in a Windows BMP?

If so, I believe those are stored (at least when saved to disk) upside-down.

Could be the problem.

Hopefully I’m not making a complete fool of myself. :wink: Good lucK!

-bill!


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl


SDL mailing list
SDL at libsdl.org
http://www.libsdl.org/mailman/listinfo/sdl

You said something about SDL_Rect? Maybe you put in the corners of the
rectangle backward, making the image flip. I’m not well-versed with SDL, so I
may be wrong. Just trying to point out the simplest thing so you might fix it
first, if it is the problem, before you look too far :)–
Duncan “Bojangles” Domingue

-I cna ytpe 300 wrods pre mniute

thanx for the help ppl …
bill :
yes there is actual BMP data and by the time i read ur post i had found out that it was stored upside down …

John:
the video plays fine in a stand alone player …

now that i know that the bitmap data is stored upside down … i basically want some function in SDL that wud invert the screen efficiently … otherwise i cud flip the BMP data myself in an inefficient loop … but i dont want to do that …

also i wud like to ask if it is better to make a texture or do it the way i am doing it (performance wise)…i did it using SDL_BlitSurface cus i personally thought that it wud be faster than making a texture and mapping it on a quad …

thanx,
enygmyx.---------------------------------
Do you Yahoo!?
Yahoo! Hotjobs: Enter the “Signing Bonus” Sweepstakes

Maybe you could set the rectangle you are using for the image to be upside
down, not complicating things? It’s worth a try. :slight_smile: Just trying to make life
simple.–
Duncan “Bojangles” Domingue

-I cna ytpe 300 wrods pre mniute