Video Rendering with SDL_Overlay

First, thanks for making such an easy to use API vs.
understanding how the Xv extension works.

A system that I work with draws multiple video streams
from host memory to the screen. It was brought to my
attention that the Xv/SDL_Overlay would be the most
efficient way to put UYVY packed data on the video
card.

My question is… what is the correct way to draw data
over the overlay? The data may be bitmaps, font,
lines, arcs, etc. Here is an example of the basic
algorithm:

while (1)
{
LockSurface(pSurface)
LockOverlay(pOverlay)

FrameSync(frame) // wait for video frame

copy(frame, pOverlay->pixels[0])

UnlockOverlay(pOverlay)
UnlockSurface(pSurface)
}

If I wanted to draw a “t” breaking the screen into
four quadrants, how should I go about this? I tried
using SDL_FillRect() with a rectangle with width an
height of one to make a line and then do a
SDL_UpdateRect() only on the portion that I just drew
the lines. It would look something like this:

while (1)
{
LockSurface(pSurface)
LockOverlay(pOverlay)

FrameSync(frame) // wait for video frame

copy(frame, pOverlay->pixels[0])

// draw horizontal line
SDL_FillRect(pSurface, rect, color)
SDL_UpdateRect(pSurface, rect)

// draw vertical line
SDL_FillRect(pSurface, rect, color)
SDL_UpdateRect(pSurface, rect)

UnlockOverlay(pOverlay)
UnlockSurface(pSurface)
}

Am I doing this at the correct time? I moved the line
drawing methods outside the locking mechanisms and it
doesn’t seem to make any difference. I also notice
that the overhead starts increasing with just a few
lines. I will need to draw more complicated data on
the video overlay and am concerned that the overhead
will compound.

What I would really like to do is draw this overlay
once and have it be blitted automatically until I
choose to change it. Any thoughts, corrections, or
just good advice is welcome. Thanks.

Regards,

Shane=====
Regards,

Shane M. Walton, Software Engineer
Digital System Resources, Inc.
@Shane_Walton


Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/

Hi,

It seems that the following post by Shane Walton on 2003-10-28 didnot get much attention. Since I am having the same
question, I re-post it here. Hopefully some experts can help me. Basically, the question is how to draw graphics (for
example, lines) on Video Overlay (for example, YUVOverlay). I know that I can work at the pixel level of the YUVOverlay,
but are there other efficient ways to do that, for example, to use some graphic libraries to create the lines and then
output the video and the lines together?

Thanks.
Yunwei

[SDL] Video Rendering with SDL_Overlay
Shane Walton sdl at libsdl.org
Tue Oct 28 20:17:01 2003

Previous message: [SDL] SDL on FreeBSD
Next message: [SDL] SDL Library Documentation
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]--------------------------------------------------------------------------------

First, thanks for making such an easy to use API vs.
understanding how the Xv extension works.

A system that I work with draws multiple video streams
from host memory to the screen. It was brought to my
attention that the Xv/SDL_Overlay would be the most
efficient way to put UYVY packed data on the video
card.

My question is… what is the correct way to draw data
over the overlay? The data may be bitmaps, font,
lines, arcs, etc. Here is an example of the basic
algorithm:

while (1)
{
LockSurface(pSurface)
LockOverlay(pOverlay)

FrameSync(frame) // wait for video frame

copy(frame, pOverlay->pixels[0])

UnlockOverlay(pOverlay)
UnlockSurface(pSurface)
}

If I wanted to draw a “t” breaking the screen into
four quadrants, how should I go about this? I tried
using SDL_FillRect() with a rectangle with width an
height of one to make a line and then do a
SDL_UpdateRect() only on the portion that I just drew
the lines. It would look something like this:

while (1)
{
LockSurface(pSurface)
LockOverlay(pOverlay)

FrameSync(frame) // wait for video frame

copy(frame, pOverlay->pixels[0])

// draw horizontal line
SDL_FillRect(pSurface, rect, color)
SDL_UpdateRect(pSurface, rect)

// draw vertical line
SDL_FillRect(pSurface, rect, color)
SDL_UpdateRect(pSurface, rect)

UnlockOverlay(pOverlay)
UnlockSurface(pSurface)
}

Am I doing this at the correct time? I moved the line
drawing methods outside the locking mechanisms and it
doesn’t seem to make any difference. I also notice
that the overhead starts increasing with just a few
lines. I will need to draw more complicated data on
the video overlay and am concerned that the overhead
will compound.

What I would really like to do is draw this overlay
once and have it be blitted automatically until I
choose to change it. Any thoughts, corrections, or
just good advice is welcome. Thanks.

Regards,

Shane

=====
Regards,

Shane M. Walton, Software Engineer
Digital System Resources, Inc.
dsrelist at yahoo.com


Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/


Previous message: [SDL] SDL on FreeBSD
Next message: [SDL] SDL Library Documentation
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]

Yunwei,

I would be glad to hand over a function that I wrote to blit RGB images with
a known constant color background to the YV12 YUV format. It works pretty
well with the SDL_Surface created by the SDL_ttf library.

You should be able to draw a line in RGB format and blit it as well. The
function takes in the following: SDL_Overlay, SDL_Surface, x offset, and a y
offset.

Now that I am thinking of it, I didn’t really put in any boundary checking,
but wouldn’t be too hard to add.

Shane> -----Original Message-----

From: sdl-bounces+swalton75=cox.net at libsdl.org [mailto:sdl-
bounces+swalton75=cox.net at libsdl.org] On Behalf Of yunwei at cogeco.ca
Sent: Tuesday, April 04, 2006 1:27 PM
To: sdl at libsdl.org
Subject: [SDL] Video Rendering with SDL_Overlay

Hi,

It seems that the following post by Shane Walton on 2003-10-28 didnot get
much attention. Since I am having the same
question, I re-post it here. Hopefully some experts can help me.
Basically, the question is how to draw graphics (for
example, lines) on Video Overlay (for example, YUVOverlay). I know that I
can work at the pixel level of the YUVOverlay,
but are there other efficient ways to do that, for example, to use some
graphic libraries to create the lines and then
output the video and the lines together?

Thanks.
Yunwei

[SDL] Video Rendering with SDL_Overlay
Shane Walton sdl at libsdl.org
Tue Oct 28 20:17:01 2003

Previous message: [SDL] SDL on FreeBSD
Next message: [SDL] SDL Library Documentation
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]



First, thanks for making such an easy to use API vs.
understanding how the Xv extension works.

A system that I work with draws multiple video streams
from host memory to the screen. It was brought to my
attention that the Xv/SDL_Overlay would be the most
efficient way to put UYVY packed data on the video
card.

My question is… what is the correct way to draw data
over the overlay? The data may be bitmaps, font,
lines, arcs, etc. Here is an example of the basic
algorithm:

while (1)
{
LockSurface(pSurface)
LockOverlay(pOverlay)

FrameSync(frame) // wait for video frame

copy(frame, pOverlay->pixels[0])

UnlockOverlay(pOverlay)
UnlockSurface(pSurface)
}

If I wanted to draw a “t” breaking the screen into
four quadrants, how should I go about this? I tried
using SDL_FillRect() with a rectangle with width an
height of one to make a line and then do a
SDL_UpdateRect() only on the portion that I just drew
the lines. It would look something like this:

while (1)
{
LockSurface(pSurface)
LockOverlay(pOverlay)

FrameSync(frame) // wait for video frame

copy(frame, pOverlay->pixels[0])

// draw horizontal line
SDL_FillRect(pSurface, rect, color)
SDL_UpdateRect(pSurface, rect)

// draw vertical line
SDL_FillRect(pSurface, rect, color)
SDL_UpdateRect(pSurface, rect)

UnlockOverlay(pOverlay)
UnlockSurface(pSurface)
}

Am I doing this at the correct time? I moved the line
drawing methods outside the locking mechanisms and it
doesn’t seem to make any difference. I also notice
that the overhead starts increasing with just a few
lines. I will need to draw more complicated data on
the video overlay and am concerned that the overhead
will compound.

What I would really like to do is draw this overlay
once and have it be blitted automatically until I
choose to change it. Any thoughts, corrections, or
just good advice is welcome. Thanks.

Regards,

Shane

=====
Regards,

Shane M. Walton, Software Engineer
Digital System Resources, Inc.
dsrelist at yahoo.com


Do you Yahoo!?
Exclusive Video Premiere - Britney Spears
http://launch.yahoo.com/promos/britneyspears/



Previous message: [SDL] SDL on FreeBSD
Next message: [SDL] SDL Library Documentation
Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]


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

Hi Shane,

Thanks a lot. It will be great if you can share the function you wrote for
this.
I guess that my question is this. I know how to display video on SDL_Overlay
and how to draw a line on SDL_Surface. I just don’t know how to combine them
together without flashing on the screen. Is the following procedure
correct to achieve this, please?

LockSurface(pSurface);

LockOverlay(pOverlay);

copy(frame, pOverlay->pixels[0]);

draw_lines(pSurface);

UnlockOverlay(pOverlay);

UnlockSurface(pSurface);

DisplayOverlay(pOverlay);

UpdateRect(pSurface);

Thanks.

Yunwei

Shane M. Walton walton at tcni.com

Yunwei,

I would be glad to hand over a function that I wrote to blit RGB images with
a known constant color background to the YV12 YUV format. It works pretty
well with the SDL_Surface created by the SDL_ttf library.

You should be able to draw a line in RGB format and blit it as well. The
function takes in the following: SDL_Overlay, SDL_Surface, x offset, and a y
offset.

Now that I am thinking of it, I didn’t really put in any boundary checking,
but wouldn’t be too hard to add.

Shane> Hi,

It seems that the following post by Shane Walton on 2003-10-28 didnot get
much attention. Since I am having the same
question, I re-post it here. Hopefully some experts can help me.
Basically, the question is how to draw graphics (for
example, lines) on Video Overlay (for example, YUVOverlay). I know that I
can work at the pixel level of the YUVOverlay,
but are there other efficient ways to do that, for example, to use some
graphic libraries to create the lines and then
output the video and the lines together?

Thanks.
Yunwei



First, thanks for making such an easy to use API vs.
understanding how the Xv extension works.

A system that I work with draws multiple video streams
from host memory to the screen. It was brought to my
attention that the Xv/SDL_Overlay would be the most
efficient way to put UYVY packed data on the video
card.

My question is… what is the correct way to draw data
over the overlay? The data may be bitmaps, font,
lines, arcs, etc. Here is an example of the basic
algorithm:

while (1)
{
LockSurface(pSurface)
LockOverlay(pOverlay)

FrameSync(frame) // wait for video frame

copy(frame, pOverlay->pixels[0])

UnlockOverlay(pOverlay)
UnlockSurface(pSurface)
}

If I wanted to draw a “t” breaking the screen into
four quadrants, how should I go about this? I tried
using SDL_FillRect() with a rectangle with width an
height of one to make a line and then do a
SDL_UpdateRect() only on the portion that I just drew
the lines. It would look something like this:

while (1)
{
LockSurface(pSurface)
LockOverlay(pOverlay)

FrameSync(frame) // wait for video frame

copy(frame, pOverlay->pixels[0])

// draw horizontal line
SDL_FillRect(pSurface, rect, color)
SDL_UpdateRect(pSurface, rect)

// draw vertical line
SDL_FillRect(pSurface, rect, color)
SDL_UpdateRect(pSurface, rect)

UnlockOverlay(pOverlay)
UnlockSurface(pSurface)
}

Am I doing this at the correct time? I moved the line
drawing methods outside the locking mechanisms and it
doesn’t seem to make any difference. I also notice
that the overhead starts increasing with just a few
lines. I will need to draw more complicated data on
the video overlay and am concerned that the overhead
will compound.

What I would really like to do is draw this overlay
once and have it be blitted automatically until I
choose to change it. Any thoughts, corrections, or
just good advice is welcome. Thanks.

Regards,

Shane

=====
Regards,

Yunwei,

What you are trying to do is render video and then draw a line over that video through two different hardware mechanisms, which is fine, but can be expensive.

I think this would fix your flashing problem:

LockOverlay(pOverlay);
copy(frame, pOverlay->pixels[0]);
UnlockOverlay(pOverlay);
DisplayOverlay(pOverlay);

LockSurface(pSurface);
draw_lines(pSurface);
UnlockSurface(pSurface);
UpdateRect(pSurface);

The flashing may depend on what flags you used with SDL_SetVideoMode(), like SDL_DOUBLEBUF.

The best way is to draw the line in the same color space as the YUV image by drawing it on the overlay itself.

See the attached, it wasn’t really meant for drawing lines, but you should be able to figure out how to write a function for that purpose.

In the spirit of open source and as I commented a while back in this group as to how SDL is lacking drawing primitives for YUV formats, it would be appreciated if you post your findings.

Shane>

From: “yjia”
Date: 2006/04/04 Tue PM 04:31:15 EDT
To:
Subject: Re: [SDL] Video Rendering with SDL_Overlay

Hi Shane,

Thanks a lot. It will be great if you can share the function you wrote for
this.
I guess that my question is this. I know how to display video on SDL_Overlay
and how to draw a line on SDL_Surface. I just don’t know how to combine them
together without flashing on the screen. Is the following procedure
correct to achieve this, please?

LockSurface(pSurface);

LockOverlay(pOverlay);

copy(frame, pOverlay->pixels[0]);

draw_lines(pSurface);

UnlockOverlay(pOverlay);

UnlockSurface(pSurface);

DisplayOverlay(pOverlay);

UpdateRect(pSurface);

Thanks.

Yunwei

Shane M. Walton walton at tcni.com

Yunwei,

I would be glad to hand over a function that I wrote to blit RGB images with
a known constant color background to the YV12 YUV format. It works pretty
well with the SDL_Surface created by the SDL_ttf library.

You should be able to draw a line in RGB format and blit it as well. The
function takes in the following: SDL_Overlay, SDL_Surface, x offset, and a y
offset.

Now that I am thinking of it, I didn’t really put in any boundary checking,
but wouldn’t be too hard to add.

Shane

Hi,

It seems that the following post by Shane Walton on 2003-10-28 didnot get
much attention. Since I am having the same
question, I re-post it here. Hopefully some experts can help me.
Basically, the question is how to draw graphics (for
example, lines) on Video Overlay (for example, YUVOverlay). I know that I
can work at the pixel level of the YUVOverlay,
but are there other efficient ways to do that, for example, to use some
graphic libraries to create the lines and then
output the video and the lines together?

Thanks.
Yunwei



First, thanks for making such an easy to use API vs.
understanding how the Xv extension works.

A system that I work with draws multiple video streams
from host memory to the screen. It was brought to my
attention that the Xv/SDL_Overlay would be the most
efficient way to put UYVY packed data on the video
card.

My question is… what is the correct way to draw data
over the overlay? The data may be bitmaps, font,
lines, arcs, etc. Here is an example of the basic
algorithm:

while (1)
{
LockSurface(pSurface)
LockOverlay(pOverlay)

FrameSync(frame) // wait for video frame

copy(frame, pOverlay->pixels[0])

UnlockOverlay(pOverlay)
UnlockSurface(pSurface)
}

If I wanted to draw a “t” breaking the screen into
four quadrants, how should I go about this? I tried
using SDL_FillRect() with a rectangle with width an
height of one to make a line and then do a
SDL_UpdateRect() only on the portion that I just drew
the lines. It would look something like this:

while (1)
{
LockSurface(pSurface)
LockOverlay(pOverlay)

FrameSync(frame) // wait for video frame

copy(frame, pOverlay->pixels[0])

// draw horizontal line
SDL_FillRect(pSurface, rect, color)
SDL_UpdateRect(pSurface, rect)

// draw vertical line
SDL_FillRect(pSurface, rect, color)
SDL_UpdateRect(pSurface, rect)

UnlockOverlay(pOverlay)
UnlockSurface(pSurface)
}

Am I doing this at the correct time? I moved the line
drawing methods outside the locking mechanisms and it
doesn’t seem to make any difference. I also notice
that the overhead starts increasing with just a few
lines. I will need to draw more complicated data on
the video overlay and am concerned that the overhead
will compound.

What I would really like to do is draw this overlay
once and have it be blitted automatically until I
choose to change it. Any thoughts, corrections, or
just good advice is welcome. Thanks.

Regards,

Shane

=====
Regards,


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

-------------- next part --------------
A non-text attachment was scrubbed…
Name: blitrgbtoyuv.c
Type: text/x-csrc
Size: 7533 bytes
Desc: not available
URL: http://lists.libsdl.org/pipermail/sdl-libsdl.org/attachments/20060404/4c0aba58/attachment.c

Thanks a lot, Shane. I appreciate your help very much.
Sure, I will post my findings later on.

Yunwei> ----- Original Message -----

From: swalton75@cox.net [mailto:swalton75 at cox.net]
Sent: April 4, 2006 7:00 PM
To: sdl at libsdl.org
Cc: @yjia
Subject: Re: Re: [SDL] Video Rendering with SDL_Overlay

Yunwei,

What you are trying to do is render video and then draw a line over that
video through two different hardware mechanisms, which is fine, but can be
expensive.

I think this would fix your flashing problem:

LockOverlay(pOverlay);
copy(frame, pOverlay->pixels[0]);
UnlockOverlay(pOverlay);
DisplayOverlay(pOverlay);

LockSurface(pSurface);
draw_lines(pSurface);
UnlockSurface(pSurface);
UpdateRect(pSurface);

The flashing may depend on what flags you used with SDL_SetVideoMode(), like
SDL_DOUBLEBUF.

The best way is to draw the line in the same color space as the YUV image by
drawing it on the overlay itself.

See the attached, it wasn’t really meant for drawing lines, but you should
be able to figure out how to write a function for that purpose.

In the spirit of open source and as I commented a while back in this group
as to how SDL is lacking drawing primitives for YUV formats, it would be
appreciated if you post your findings.

Shane

From: “yjia” <@yjia>
Date: 2006/04/04 Tue PM 04:31:15 EDT
To:
Subject: Re: [SDL] Video Rendering with SDL_Overlay

Hi Shane,

Thanks a lot. It will be great if you can share the function you wrote
for this.
I guess that my question is this. I know how to display video on
SDL_Overlay and how to draw a line on SDL_Surface. I just don’t know how
to combine them
together without flashing on the screen. Is the following procedure
correct to achieve this, please?

LockSurface(pSurface);

LockOverlay(pOverlay);

copy(frame, pOverlay->pixels[0]);

draw_lines(pSurface);

UnlockOverlay(pOverlay);

UnlockSurface(pSurface);

DisplayOverlay(pOverlay);

UpdateRect(pSurface);

Thanks.

Yunwei

Shane M. Walton walton at tcni.com

Yunwei,

I would be glad to hand over a function that I wrote to blit RGB
images with a known constant color background to the YV12 YUV format.
It works pretty well with the SDL_Surface created by the SDL_ttf library.

You should be able to draw a line in RGB format and blit it as well.
The function takes in the following: SDL_Overlay, SDL_Surface, x
offset, and a y offset.

Now that I am thinking of it, I didn’t really put in any boundary
checking, but wouldn’t be too hard to add.

Shane

Hi,

It seems that the following post by Shane Walton on 2003-10-28
didnot get much attention. Since I am having the same question, I
re-post it here. Hopefully some experts can help me.
Basically, the question is how to draw graphics (for example, lines)
on Video Overlay (for example, YUVOverlay). I know that I can work
at the pixel level of the YUVOverlay, but are there other efficient
ways to do that, for example, to use some graphic libraries to
create the lines and then output the video and the lines together?

Thanks.
Yunwei




First, thanks for making such an easy to use API vs.
understanding how the Xv extension works.

A system that I work with draws multiple video streams from host
memory to the screen. It was brought to my attention that the
Xv/SDL_Overlay would be the most efficient way to put UYVY packed
data on the video card.

My question is… what is the correct way to draw data over the
overlay? The data may be bitmaps, font, lines, arcs, etc. Here is
an example of the basic
algorithm:

while (1)
{
LockSurface(pSurface)
LockOverlay(pOverlay)

FrameSync(frame) // wait for video frame

copy(frame, pOverlay->pixels[0])

UnlockOverlay(pOverlay)
UnlockSurface(pSurface)
}

If I wanted to draw a “t” breaking the screen into four quadrants,
how should I go about this? I tried using SDL_FillRect() with a
rectangle with width an height of one to make a line and then do a
SDL_UpdateRect() only on the portion that I just drew the lines. It
would look something like this:

while (1)
{
LockSurface(pSurface)
LockOverlay(pOverlay)

FrameSync(frame) // wait for video frame

copy(frame, pOverlay->pixels[0])

// draw horizontal line
SDL_FillRect(pSurface, rect, color)
SDL_UpdateRect(pSurface, rect)

// draw vertical line
SDL_FillRect(pSurface, rect, color)
SDL_UpdateRect(pSurface, rect)

UnlockOverlay(pOverlay)
UnlockSurface(pSurface)
}

Am I doing this at the correct time? I moved the line drawing
methods outside the locking mechanisms and it doesn’t seem to make
any difference. I also notice that the overhead starts increasing
with just a few lines. I will need to draw more complicated data on
the video overlay and am concerned that the overhead will compound.

What I would really like to do is draw this overlay once and have it
be blitted automatically until I choose to change it. Any thoughts,
corrections, or just good advice is welcome. Thanks.

Regards,

Shane

=====
Regards,


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

Hi Shane,

I tried the approach you mentioned to fix flashing but did not totally get
rid of the flashing. I used the following line to initialize video mode:

SDL_SetVideoMode(width, height, 0, SDL_HWSURFACE)

By drawing on YUVOverlay directly, I was able to get rid of the flashing, as
expected. However, non-horizontal lines, if drawn with color, showed colored
dots nearby the lines. This is also expected since in the five YUV formats
supported by SDL, UV are shared by two or four neighbouring Y samples. So,
my conclusion is that we can draw lines directly on YUVOverlay, but a
reasonably good quality can only be achieve if the lines are drawn in
grey-scale. To draw colored lines of any angles, we may have to convert the
color space to RGB.

By the way, Bresenham’s line-drawing algorithm can be found in
http://www.cs.unc.edu/~mcmillan/comp136/Lecture6/Lines.html

Thanks.
Yunwei> ----- Original Message -----

From: swalton75@cox.net [mailto:swalton75 at cox.net]
Sent: April 4, 2006 7:00 PM
To: sdl at libsdl.org
Cc: @yjia
Subject: Re: Re: [SDL] Video Rendering with SDL_Overlay

Yunwei,

What you are trying to do is render video and then draw a line over that
video through two different hardware mechanisms, which is fine, but can be
expensive.

I think this would fix your flashing problem:

LockOverlay(pOverlay);
copy(frame, pOverlay->pixels[0]);
UnlockOverlay(pOverlay);
DisplayOverlay(pOverlay);

LockSurface(pSurface);
draw_lines(pSurface);
UnlockSurface(pSurface);
UpdateRect(pSurface);

The flashing may depend on what flags you used with SDL_SetVideoMode(), like
SDL_DOUBLEBUF.

The best way is to draw the line in the same color space as the YUV image by
drawing it on the overlay itself.

See the attached, it wasn’t really meant for drawing lines, but you should
be able to figure out how to write a function for that purpose.

In the spirit of open source and as I commented a while back in this group
as to how SDL is lacking drawing primitives for YUV formats, it would be
appreciated if you post your findings.

Shane

From: “yjia” <@yjia>
Date: 2006/04/04 Tue PM 04:31:15 EDT
To:
Subject: Re: [SDL] Video Rendering with SDL_Overlay

Hi Shane,

Thanks a lot. It will be great if you can share the function you wrote
for this.
I guess that my question is this. I know how to display video on
SDL_Overlay and how to draw a line on SDL_Surface. I just don’t know how
to combine them
together without flashing on the screen. Is the following procedure
correct to achieve this, please?

LockSurface(pSurface);

LockOverlay(pOverlay);

copy(frame, pOverlay->pixels[0]);

draw_lines(pSurface);

UnlockOverlay(pOverlay);

UnlockSurface(pSurface);

DisplayOverlay(pOverlay);

UpdateRect(pSurface);

Thanks.

Yunwei

Shane M. Walton walton at tcni.com

Yunwei,

I would be glad to hand over a function that I wrote to blit RGB
images with a known constant color background to the YV12 YUV format.
It works pretty well with the SDL_Surface created by the SDL_ttf library.

You should be able to draw a line in RGB format and blit it as well.
The function takes in the following: SDL_Overlay, SDL_Surface, x
offset, and a y offset.

Now that I am thinking of it, I didn’t really put in any boundary
checking, but wouldn’t be too hard to add.

Shane

Hi,

It seems that the following post by Shane Walton on 2003-10-28
didnot get much attention. Since I am having the same question, I
re-post it here. Hopefully some experts can help me.
Basically, the question is how to draw graphics (for example, lines)
on Video Overlay (for example, YUVOverlay). I know that I can work
at the pixel level of the YUVOverlay, but are there other efficient
ways to do that, for example, to use some graphic libraries to
create the lines and then output the video and the lines together?

Thanks.
Yunwei




First, thanks for making such an easy to use API vs.
understanding how the Xv extension works.

A system that I work with draws multiple video streams from host
memory to the screen. It was brought to my attention that the
Xv/SDL_Overlay would be the most efficient way to put UYVY packed
data on the video card.

My question is… what is the correct way to draw data over the
overlay? The data may be bitmaps, font, lines, arcs, etc. Here is
an example of the basic
algorithm:

while (1)
{
LockSurface(pSurface)
LockOverlay(pOverlay)

FrameSync(frame) // wait for video frame

copy(frame, pOverlay->pixels[0])

UnlockOverlay(pOverlay)
UnlockSurface(pSurface)
}

If I wanted to draw a “t” breaking the screen into four quadrants,
how should I go about this? I tried using SDL_FillRect() with a
rectangle with width an height of one to make a line and then do a
SDL_UpdateRect() only on the portion that I just drew the lines. It
would look something like this:

while (1)
{
LockSurface(pSurface)
LockOverlay(pOverlay)

FrameSync(frame) // wait for video frame

copy(frame, pOverlay->pixels[0])

// draw horizontal line
SDL_FillRect(pSurface, rect, color)
SDL_UpdateRect(pSurface, rect)

// draw vertical line
SDL_FillRect(pSurface, rect, color)
SDL_UpdateRect(pSurface, rect)

UnlockOverlay(pOverlay)
UnlockSurface(pSurface)
}

Am I doing this at the correct time? I moved the line drawing
methods outside the locking mechanisms and it doesn’t seem to make
any difference. I also notice that the overhead starts increasing
with just a few lines. I will need to draw more complicated data on
the video overlay and am concerned that the overhead will compound.

What I would really like to do is draw this overlay once and have it
be blitted automatically until I choose to change it. Any thoughts,
corrections, or just good advice is welcome. Thanks.

Regards,

Shane

=====
Regards,


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