Re: [PATCH] radeon Xv alpha blending support

2003-11-20 Thread Vladimir Dergachev
Hi Alex :)

   Thanks for the patch !

   May I suggest that you change XV_GR_ALPHA and XV_OV_ALPHA to
   XV_GRAPHICS_ALPHA and XV_OVERLAY_ALPHA ? This does not cost anything
   in terms of performance.

best

   Vladimir Dergachev

On Wed, 19 Nov 2003, Alex Deucher wrote:

 The attached patch adds alpha blending support to the video overlay on
 radeon hardware.  It's been tested on my 9200.  It adds three new Xv
 attributes: XV_ALPHA_MODE, XV_GR_ALPHA, and XV_OV_ALPHA.

 XV_ALPHA_MODE - (0 or 1) selects the alpha blending mode.  right now it
 only supports key and global modes, per-pixel can be added later. 0 is
 key mode, 1 is global mode. Key mode blends the overlay or graphics
 layer with the colorkey.  Global mode blends the graphics layer and the
 overlay.

 XV_GR_ALPHA - (0-255) set the alpha level of the graphics layer
 (everything but the overlay) (applies to either mode)

 XV_OV_ALPHA - (0-255) set the alpha level of the overlay (applies to
 either mode)

 The patch is against DRI cvs, but should apply pretty easily to any
 tree.  I'm not 100% clear on the function the first two fields of
 OV0_KEY_CNTL, perhaps someone out there could explain it to me. see my
 comments in the code.  let me know if you have any comments or
 questions.  Is it worth opening a bug in bugzilla for this?

 The patch and binaries also are available here:
 http://www.botchco.com/alex/radeon/xv_alpha/

 Look out for an improved Xv gamma patch soon.

 Thanks,

 Alex


 __
 Do you Yahoo!?
 Protect your identity with Yahoo! Mail AddressGuard
 http://antispam.yahoo.com/whatsnewfree
___
Devel mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/devel


Re: [PATCH] radeon Xv alpha blending support

2003-11-20 Thread Thomas Winischhofer
Alex Deucher wrote:
The attached patch adds alpha blending support to the video overlay on
radeon hardware.  It's been tested on my 9200.  It adds three new Xv
attributes: XV_ALPHA_MODE, XV_GR_ALPHA, and XV_OV_ALPHA.
XV_ALPHA_MODE - (0 or 1) selects the alpha blending mode.  right now it
only supports key and global modes, per-pixel can be added later. 0 is
key mode, 1 is global mode. Key mode blends the overlay or graphics
layer with the colorkey.  Global mode blends the graphics layer and the
overlay.
XV_GR_ALPHA - (0-255) set the alpha level of the graphics layer
(everything but the overlay) (applies to either mode)
XV_OV_ALPHA - (0-255) set the alpha level of the overlay (applies to
either mode)
The patch is against DRI cvs, but should apply pretty easily to any
tree.  I'm not 100% clear on the function the first two fields of
OV0_KEY_CNTL, perhaps someone out there could explain it to me. see my
comments in the code.  let me know if you have any comments or
questions.  Is it worth opening a bug in bugzilla for this?
The patch and binaries also are available here:
http://www.botchco.com/alex/radeon/xv_alpha/
Look out for an improved Xv gamma patch soon.
Alex,

while you are at it, does the radeon hardware support chroma-keying? 
(Chroma keying means the overlay is shown if the _video_ color is within 
a certain range. Chroma-Keying is extremely useful for creating blue-box 
like effects, like for example people in front of a blue background, 
which is being replaced by the graphics at playback time).

If so, you might want to take a look at the sis driver. Besides, the sis 
driver also has a property named XV_DISABLE_COLORKEY to avoid the 
problem of the colorkey always drawn. This works more or less by 1) 
disabling the colorkey in the video code, and 2) by ignoring accelerator 
fill-commands with the colorkey as foreground color. Of course, this is 
no bullet-proof method, but perhaps this is helpful for you, too.

Thomas

--
Thomas Winischhofer
Vienna/Austria
thomas AT winischhofer DOT net  *** http://www.winischhofer.net/
twini AT xfree86 DOT org


___
Devel mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/devel


Re: [PATCH] radeon Xv alpha blending support

2003-11-20 Thread Alex Deucher
--- Thomas Winischhofer [EMAIL PROTECTED] wrote:
 Alex Deucher wrote:
  The attached patch adds alpha blending support to the video overlay
 on
  radeon hardware.  It's been tested on my 9200.  It adds three new
 Xv
  attributes: XV_ALPHA_MODE, XV_GR_ALPHA, and XV_OV_ALPHA.
  
  XV_ALPHA_MODE - (0 or 1) selects the alpha blending mode.  right
 now it
  only supports key and global modes, per-pixel can be added later. 0
 is
  key mode, 1 is global mode. Key mode blends the overlay or graphics
  layer with the colorkey.  Global mode blends the graphics layer and
 the
  overlay.
  
  XV_GR_ALPHA - (0-255) set the alpha level of the graphics layer
  (everything but the overlay) (applies to either mode)
  
  XV_OV_ALPHA - (0-255) set the alpha level of the overlay (applies
 to
  either mode)
  
  The patch is against DRI cvs, but should apply pretty easily to any
  tree.  I'm not 100% clear on the function the first two fields of
  OV0_KEY_CNTL, perhaps someone out there could explain it to me. see
 my
  comments in the code.  let me know if you have any comments or
  questions.  Is it worth opening a bug in bugzilla for this?
  
  The patch and binaries also are available here:
  http://www.botchco.com/alex/radeon/xv_alpha/
  
  Look out for an improved Xv gamma patch soon.
 
 Alex,
 
 while you are at it, does the radeon hardware support chroma-keying? 
 (Chroma keying means the overlay is shown if the _video_ color is
 within 
 a certain range. Chroma-Keying is extremely useful for creating
 blue-box 
 like effects, like for example people in front of a blue background, 
 which is being replaced by the graphics at playback time).
 

I'm not sure, I'll have to double check the databooks.  Unfortunately,
I'm not an expert when it comes to keying and video stuff so the
descriptions of various bitfields in the hardware and how that
translates to what they do is somewhat confusing.

 If so, you might want to take a look at the sis driver. Besides, the
 sis 
 driver also has a property named XV_DISABLE_COLORKEY to avoid the 
 problem of the colorkey always drawn. This works more or less by 1) 
 disabling the colorkey in the video code, and 2) by ignoring
 accelerator 
 fill-commands with the colorkey as foreground color. Of course, this
 is 
 no bullet-proof method, but perhaps this is helpful for you, too.

radeon has an option XV_AUTOPAINT_COLORKEY that enables or disables the
auto filling of the colorkey by the driver (stops
xf86XVFillKeyHelper()).  is this equivalent to what your option does? 
I'm not sure if there is a way to turn off the color key or not.  Do
any other radeon developers out there know if this is possible?  I've
tried adjusting the alpha values on the colorkey to fully transparent,
but it doesn't seem to make a difference.  what I'd like to do is be
able to display the video is a clear window so the video will belnd
with the desktop rather than the colorkey when in global alpha mode.

I'll take a look at the sis code and see how it matches up to the
radeon hardware.

Thanks,

Alex


__
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/
___
Devel mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/devel


Re: [PATCH] radeon Xv alpha blending support

2003-11-20 Thread Thomas Winischhofer
Alex Deucher wrote:
radeon has an option XV_AUTOPAINT_COLORKEY that enables or disables the
auto filling of the colorkey by the driver (stops
xf86XVFillKeyHelper()).  is this equivalent to what your option does? 
Not entirely. AUTOPAINT_COLORKEY does not stop applications from drawing 
the colorkey themselves (as, I think, for example Xine does). That is 
done by the accelerator engine, that checks the color given to the fill 
functions. (Granted, this only works if the accelerators are on, but who 
is using a [working] driver without acceration these days)

Thomas

--
Thomas Winischhofer
Vienna/Austria
thomas AT winischhofer DOT net  *** http://www.winischhofer.net/
twini AT xfree86 DOT org


___
Devel mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/devel


Re: [PATCH] radeon Xv alpha blending support

2003-11-20 Thread Alex Deucher
This is probably due to my limited understanding of writing Xv apps but
how do you keep the app from drawing the colorkey itself?  isn't it
just an X rectangle?  is there an Xv function that the app uses or does
it just draw a rectangle and paint it the colorkey color?  How does the
sis driver do it (if it does)?  what does the output look like with no
colorkey drawn?  if it just the desktop or it it just some undefined
area?  does Xv even work without a colokey?  I thought that's how the
overly worked it overlays the video data based on regions painted with
the colorkey.  I suppose in global alpha mode though (on radeon), it
will blend the video with whatever the graphics layer shows so if I
could get rid of that rectangle of color, I'd get a nice blend with the
desktop and any windows over or under it.

Alex

--- Thomas Winischhofer [EMAIL PROTECTED] wrote:
 Alex Deucher wrote:
  radeon has an option XV_AUTOPAINT_COLORKEY that enables or disables
 the
  auto filling of the colorkey by the driver (stops
  xf86XVFillKeyHelper()).  is this equivalent to what your option
 does? 
 
 Not entirely. AUTOPAINT_COLORKEY does not stop applications from
 drawing 
 the colorkey themselves (as, I think, for example Xine does). That is
 
 done by the accelerator engine, that checks the color given to the
 fill 
 functions. (Granted, this only works if the accelerators are on, but
 who 
 is using a [working] driver without acceration these days)
 
 Thomas
 


__
Do you Yahoo!?
Free Pop-Up Blocker - Get it now
http://companion.yahoo.com/
___
Devel mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/devel


Re: [PATCH] radeon Xv alpha blending support

2003-11-20 Thread Thomas Winischhofer
Alex Deucher wrote:
This is probably due to my limited understanding of writing Xv apps but
how do you keep the app from drawing the colorkey itself?  isn't it
I simply assume that the app will, some way or the other, in the end use 
the XAA accelerator functions. As I said, my method is not bullet-proof.

just an X rectangle?  is there an Xv function that the app uses or does
it just draw a rectangle and paint it the colorkey color?  How does the
sis driver do it (if it does)?  what does the output look like with no
colorkey drawn? 
The depends. Earlier versions of mplayer (0.9) left the background 
visible (ie didn't overwrite the window at startup); later versions 
paint the window black at start, for what reason ever.

The real application for this feature is, of course, not a generic app 
like mplayer but a specially written app that utilizes the blue-screen 
technique for displaying a background and a video which is chroma-keyed, 
such as a weather forecast where the presenter stands in front of a blue 
wall and the viewer sees a weather map instead of the blue background. A 
real-life application of this kind (using SiS hardware and my driver) is 
installed at a local government's exhibition in Austria; visitors are 
presented a virtual TV interview person on screen and are being filmed 
during that interview. Afterwards they can watch the interview (which is 
being cut in real-time) and see themselves in a beautiful TV studio, 
while the cabin where the interview took place has a simple plain green 
background wall.)

does Xv even work without a colokey? 
Yes, at least on SiS hardware. There are 16 combinations of src and dst 
combination (video-ROPs) available, include the standard one (video if 
background = colorkey) and all possible combinations of chroma- and 
colorkey (which monstly aren't so useful after all).

 I thought that's how the overly worked it overlays the video data based
 on regions painted with the colorkey.
That's one of 16 possible ways.

I suppose in global alpha mode though (on radeon), it
will blend the video with whatever the graphics layer shows so if I
could get rid of that rectangle of color, I'd get a nice blend with the
desktop and any windows over or under it.
I think it will be like that: If the alpha stuff is activated, the video 
overlay doesn't care about the colorkey anymore. Or perhaps you need to 
change the ROP (if such a thing is on Radeon) to ignore the colorkey. Do 
you see the entire video (if alpha avtive) even if another window covers 
a part of the video window?

Thomas

--
Thomas Winischhofer
Vienna/Austria
thomas AT winischhofer DOT net  http://www.winischhofer.net/
twini AT xfree86 DOT org
___
Devel mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/devel


Re: [PATCH] radeon Xv alpha blending support

2003-11-20 Thread Thomas Winischhofer
Alex Deucher wrote:
does Xv even work without a colokey? 
Yes, at least on SiS hardware. There are 16 combinations of src and
dst 
combination (video-ROPs) available, include the standard one (video
if 
background = colorkey) and all possible combinations of chroma- and 
colorkey (which monstly aren't so useful after all).

I'm not sure if they refer to source and destination, but on radeon you
I guess whatever the docs call source and destination refers to 
source = video and destination = graphics.

can adjust keycontrol based on graphics or video values and it's that
part that I don't understand.  there are three bit fields: one for
graphics, one for video and then a mix field that sets whether you
display video and graphics or video or graphics.  Perhaps you can help
me interpret what they do.
Sure, but I am afraid I need the exact wording of the docs.

I think it will be like that: If the alpha stuff is activated, the
video 
overlay doesn't care about the colorkey anymore. Or perhaps you need
to 
change the ROP (if such a thing is on Radeon) to ignore the colorkey.
Do 
you see the entire video (if alpha avtive) even if another window
covers 
a part of the video window?

yes exactly!

there are 3 alpha modes: key, global, and per-pixel.  
 key uses the
colorkey to display the overlay but can blend against the colorkey
value. It's useful for fading in/out the desktop or the video.
 global
mode blends the video with the graphics layer no matter what.  so any
windows over or under the video get blended and you can't obsure the
overlay, it just blends.  
 per pixel mode seems like the most flexible,
but I can get anything useful out of it because I think it assumes you
have an alpha channel in the framebuffer ( or , etc. formats). 
Supposedly meaning:

1) key: If video or graphics data is inside or outside a certain color 
range (colorkey = graphics, chromakey = video, whatever they mean by 
key), do something - like, as you say, blend against the colorkey. Hm, 
I don't see any real usefulness in this. Did you experiment with that? 
Is it really the colorkey the blend against?

2) Global - simplest variant: Define one global alpha value for the 
whole overlay, regardless of the video's or and background's color.

3) per pixel: Second your idea, assumingly this will require a 32 bit 
ARGB graphics background; video is being blended with the background 
depending on the background's alpha value. (The other way round would be 
somewhat impossible as video data can't contain alpha data, unless the 
ATI folks expect highly unusual and non-standard video data; don't think 
so.)

Thomas

--
Thomas Winischhofer
Vienna/Austria
thomas AT winischhofer DOT net  http://www.winischhofer.net/
twini AT xfree86 DOT org
___
Devel mailing list
[EMAIL PROTECTED]
http://XFree86.Org/mailman/listinfo/devel