Welcome to Doom9's Forum, THE in-place to be for everyone interested in DVD conversion. Before you start posting please read the forum rules. By posting to this forum you agree to abide by the rules. |
16th April 2005, 15:18 | #1 | Link |
brainless
Join Date: Mar 2003
Location: Germany
Posts: 3,653
|
feature request: extractred/green/blue() ; mergergb()
I want to start a feature request for a functionality AVIsynth already offers for YUV-based video:
y=greyscale() u=utoy() v=vtoy() ytouv(u,v,y) I would like to see the same for rgb24 and rgb32 chroma: r=extractred() / rtoy() b=extractgreen() / gtoy() g=extractblue() / btoy() mergergb(r,g,b) is there a chance to get these functions?
__________________
Don't forget the 'c'! Don't PM me for technical support, please. |
16th April 2005, 16:07 | #2 | Link |
AviSynth Enthusiast
Join Date: Jul 2002
Location: California, U.S.
Posts: 1,267
|
Splitting can be done with RGBAdjust:
Code:
r = c.RGBAdjust(1, 0, 0, 0) g = c.RGBAdjust(0, 1, 0, 0) b = c.RGBAdjust(0, 0, 1, 0) |
16th April 2005, 16:34 | #3 | Link |
brainless
Join Date: Mar 2003
Location: Germany
Posts: 3,653
|
That's what I've already found out.
but merging with overlay introduces big brightness loss and abusing subtract & invert to build an add() function also fails
__________________
Don't forget the 'c'! Don't PM me for technical support, please. |
16th April 2005, 20:23 | #5 | Link |
Registered User
Join Date: Aug 2004
Location: Denmark
Posts: 807
|
get it here
From the readme: syntax RtoRGB() copies the Red value to Green and Blue resulting in a greyscale image. GtoRGB() copies the Green value to Red and Blue resulting in a greyscale image. BtoRGB() copies the Blue value to Red and Green resulting in a greyscale image. MergeRGB(clip R,clip G,clip B) copies the green value from G to R and the blue value from B to R Todo: Add mmx support. 0.1 first release. sourcecode released under GPL se copying.txt Last edited by tsp; 17th April 2005 at 14:11. |
17th April 2005, 15:13 | #6 | Link |
interlace this!
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
|
cool! thanks! i've been wanting something like this for ages (though only idly - otherwise i'd have made a thread...).
IMHO this should end up in the avs core, alongside it's cousins utoy, vtoy, etc.
__________________
sucking the life out of your videos since 2004 |
17th April 2005, 17:39 | #8 | Link |
brainless
Join Date: Mar 2003
Location: Germany
Posts: 3,653
|
Many thanks TSP!
I've digged out an about 1.5 years old function from me to test it: Clearscale. Code:
function clearscale(clip i, int width, int height, int "filter") { filter=default(filter,2) i.converttorgb32() #resize to destination size with triple width; #add 3 pixels on the right side to get room for image shifting bicubicresize((width*3),height).addborders(0,0,3,0) #do a prefiltering to supress color speckling (filter==0) ? last : (filter==1) ? last.blur(1,0) : last.blur(1,0).blur(1,0) # select spatial correct color planes R=crop(2,0,-1,0).pointresize(width,height).RtoRGB() G=crop(1,0,-2,0).pointresize(width,height).GtoRGB() B=crop(0,0,-3,0).pointresize(width,height).BtoRGB() #finally merge color planes MergeRGB(R,G,B) } Of coure, the images needs to be saved either lossless (PNG, BMP, TIF) or with non-subsampled-chroma JPG. With your plugin I got it working again without cracking my brain about subtract, layers and so on
__________________
Don't forget the 'c'! Don't PM me for technical support, please. Last edited by scharfis_brain; 17th April 2005 at 20:37. |
17th April 2005, 19:44 | #9 | Link |
Registered User
Join Date: Oct 2001
Posts: 195
|
scharfis_brain,
I can't get it - the Clearscale. In fact every 3 subpixels on LCD matrix are threaded as single pixel, so by this script you'll probably change the overall image look,collor crispness etc... It's somehow an opposite to debayer filter? Did you see an improvement on your side (I don't have a LCD panel around yet) ? |
17th April 2005, 20:36 | #10 | Link |
brainless
Join Date: Mar 2003
Location: Germany
Posts: 3,653
|
Nonono...
the clearscale effekt only becomes visible if you are downsizing a crisp image at least by a factor of three in the horizontal dimension! It works similar to Microsofts Cleartype or Adobes Cooltype. Have a look: the original (360x360): bicubic to 120x120: pointscaling: clearscale with 2pass, 1pass and without filtering:
__________________
Don't forget the 'c'! Don't PM me for technical support, please. Last edited by scharfis_brain; 18th April 2005 at 16:57. |
18th April 2005, 01:12 | #12 | Link |
Registered User
Join Date: Aug 2004
Location: Denmark
Posts: 807
|
I added some mmx optimization to the code. I'm not sure it was worth it but try and see if you get any speed increase.
link to version 0.2: http://www.tsp.person.dk/RGBmanipulate02.zip |
18th April 2005, 05:03 | #13 | Link |
interlace this!
Join Date: Jun 2003
Location: i'm in ur transfers, addin noise
Posts: 4,555
|
the twopass pic doesn't look any different on this LCD panel... but that might be because the screen's set to 16bpp (the viddy card is pretty old unfortunately, and can't go as high as the screen it's plugged into without going to 16bpp)
__________________
sucking the life out of your videos since 2004 |
21st April 2005, 01:45 | #15 | Link |
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
Tsp,
Neat It's not easy getting MMX to work fast. Try using flavours of punpck[lh][bwd][wdq] to distribute the colour channels throughout the pixel rather than masking and shifting. Try to access memory aligned 64bits at a time. Dear all, Also might it be useful (it could be faster) to export the colour channels to a YV12[0..255] luma plane, dummying up the chroma planes as grey or maybe the colour for bonus points. This feature rates going into the core. Just need some time... IanB |
23rd April 2005, 09:10 | #17 | Link |
Avisynth Developer
Join Date: Jan 2003
Location: Melbourne, Australia
Posts: 3,167
|
tsp,
Layer and Overlay make use of the Alpha channel. Generally it is preferable not to clobber the alpha channel. However given this filter currently copies a chosen channel to the other 2 it is not a great stretch to define it to copy a channel to the other 3. It certainly makes the MMX code easier. And the core currently has a ShowAlpha(clip, string pixel_type) which is just C code, it copies the Alpha to the R, G and B channels, so there is a precedent. For the MMX code I was thinking along the lines of Code:
movq mm0,[src] movq mm1,[src+8] pand mm0,k000000ff000000ff // dd p1, p0 pand mm1,k000000ff000000ff // dd p3, p2 packssdw mm0,mm1 // dw p3, p2, p1, p0 packuswb mm0,mm0 // db p3, p2, p1, p0, p3, p2, p1, p0 punpcklbw mm0,mm0 // db p3, p3, p2, p2, p1, p1, p0, p0 movq mm1,mm0 punpcklbw mm0,mm0 // db p1, p1, p1, p1, p0, p0, p0, p0 punpckhbw mm1,mm1 // db p3, p3, p3, p3, p2, p2, p2, p2 movq [dst],mm0 movq [dst+8],mm1 IanB |
24th April 2005, 18:20 | #18 | Link | |
Retired AviSynth Dev ;)
Join Date: Nov 2001
Location: Dark Side of the Moon
Posts: 3,480
|
Quote:
__________________
Regards, sh0dan // VoxPod |
|
25th April 2005, 00:13 | #19 | Link |
Registered User
Join Date: Aug 2004
Location: Denmark
Posts: 807
|
more update. now the mmx should work correctly. Get version 0.3 here.
The current mmx code preserves the alpha channel. The reason to kill the channel would be speed. IanB's code performce about 22% faster than the c code in my last test(RtoRGB). The current mmx code is about 15% faster than the c code. I think I will just add an option to keep the alpha channel then people get a choice what to get. Also I will convert the inline assembly to softwire there is to much repeated mmx code. |
30th April 2005, 01:00 | #20 | Link |
Registered User
Join Date: Aug 2004
Location: Denmark
Posts: 807
|
Version 0.4 is ready. Get it here.
Softwire is really nice but it's irritating that I can't convert a __cdecl function pointer to a thiscall function pointer without using inline asm. I thought reinterpret_cast would work but it didn't. scharfis_brain: you don't need RtoRGB,GtoRGB,BtoRGB for your function MergeRGB will do. From the readme.txt RGBmanipulate mirrors the function utoy vtoy mergeLuma/chroma for the rgb colorspace syntax: RtoRGB(bool useMMX,bool overwritealpha, bool usemmx) copies the Red channel to Green and Blue resulting in a greyscale image. GtoRGB(bool useMMX,bool overwritealpha, bool usemmx) copies the Green channel to Red and Blue resulting in a greyscale image. BtoRGB(bool useMMX,bool overwritealpha, bool usemmx) copies the Blue channel to Red and Green resulting in a greyscale image. usemmx: enables mmx optimization. Default true overwritealpha: If true the alpha channel is also overwriten (this is faster). Default false MergeRGB(clip R,clip G,clip B,clip A,int alphachannel,bool usemmx) Merge the Red channel from R the green channel from G and the blue channel from B if A is specified(you don't have to) the alpha channel from A is used. alphachannel specifies where the alpha channels should be used from if A isn't specified: 0 copies the alpha channel from R 1 copies the alpha channel from G 2 copies the alpha channel from B 3 zeroes the alpha channel Default 0 |
Thread Tools | Search this Thread |
Display Modes | |
|
|