Welcome Guest ( Log In | Register )


Important

The forums will be closing permanently the weekend of March 15th. Please see the notice in the announcements forum for details.

 
Vshader Scripit For Ycbcr 4:4:4, Need some help to creat one
« Next Oldest | Next Newest » Track this topic | Email this topic | Print this topic
krt47
Posted: Feb 21 2014, 01:06 AM


Member


Group: Members
Posts: 13
Member No.: 37399
Joined: 4-November 13



hi there, it's been awhile. i was wounder if any budy can help me to create a script from rgb32 to YCBCR 4:4:4 Subchroma. can some please help me create one for vshader filter?

thanks
 
     Top
raffriff42
Posted: Feb 21 2014, 02:24 PM


Advanced Member


Group: Members
Posts: 384
Member No.: 35081
Joined: 25-June 12



CODE
// RGB to YCbCr
sampler src;

float4 PS(float2 uv: TEXCOORD0) : COLOR0 {
float4 px;

// Note that we are using full-range equations here, not the standard encoding
// with headroom.
//
// Y   =     0.299  R + 0.587  G + 0.114  B
// Cb  =   - 0.1687 R - 0.3313 G + 0.5    B + 128
// Cr  =     0.5    R - 0.4187 G - 0.0813 B + 128

float3x3 mx=float3x3(
 float3(0.5, 0.299, -0.1687),
 float3(-0.4187, 0.587, -0.3313),
 float3(-0.0813, 0.114, 0.5)
);

px = tex2D(src, uv);

float3 cyc = mul(px.rgb, mx) + float3(128.0/255.0, 0, 128.0/255.0);

return float4(cyc, px.a);
}

technique {
pass {
 PixelShader = compile ps_3_0 PS();
}
}
Sources
https://www.google.com/search?q=directx+sha...shader+fx+ycbcr
http://www.virtualdub.org/blog/pivot/entry.php?id=154
http://www.virtualdub.org/downloads/vdshad...der-1.0-src.zip
 
     Top
krt47
Posted: Feb 21 2014, 08:34 PM


Member


Group: Members
Posts: 13
Member No.: 37399
Joined: 4-November 13



it's change the color to ycbcr instead of 4:4:4 see

before
http://imageshack.com/a/img21/9836/vsq5.png
after
http://imageshack.com/a/img208/7448/r979.png

how come the the script seems to change the black and white colors? is suppose to change seem the colors that are black and white to purple? how com it dosen't change other colors?

at least far as i know it's suppose not change the black and white colors. the other colors suppose be more vivid.

oh and p.s. i asked for rgba32 to ycbcr 4:4:4 color format instead of rgb to ycbcr. sorry i made a mistake about what i said up above.
 
     Top
raffriff42
Posted: Feb 22 2014, 02:43 AM


Advanced Member


Group: Members
Posts: 384
Member No.: 35081
Joined: 25-June 12



It looks like YCbCr is being displayed *as if* it was GBR. You need to flag your output somehow as YCbCr. Examine the ConvertFormat filter source code (src\VDFilters\source\VFConvertFormat.cpp), and search Vdub source for kPixFormat_*. Sorry I'm not more help here.

EDIT - avisynth script confirming my guess
(you have a 4-pixel shift problem as well, hopefully someone more knowledgeable can help you with that)
CODE
Before=ImageSource("vsq5.png")
After=ImageSource("r979.png")  

## http://avisynth.nl/index.php/Swap
AfterYUV=YToUV(
\  After.ShowBlue  .ConvertToY8, /* U (Cb) channel */
\  After.ShowRed   .ConvertToY8, /* V (Cr) channel */
\  After.ShowGreen .ConvertToY8) /* Y channel */

## compare clips - for use in frame step mode only!
return Interleave(
\  Before.Subtitle("Before"),
\  Overlay(Before, AfterYUV, x=-4).Subtitle("AfterYUV"))


This post has been edited by raffriff42 on Feb 22 2014, 03:58 AM
 
     Top
krt47
Posted: Feb 22 2014, 02:47 PM


Member


Group: Members
Posts: 13
Member No.: 37399
Joined: 4-November 13



QUOTE (raffriff42 @ Feb 22 2014, 02:43 AM)
It looks like YCbCr is being displayed *as if* it was GBR. You need to flag your output somehow as YCbCr. Examine the ConvertFormat filter source code (src\VDFilters\source\VFConvertFormat.cpp), and search Vdub source for kPixFormat_*. Sorry I'm not more help here.

EDIT - avisynth script confirming my guess
(you have a 4-pixel shift problem as well, hopefully someone more knowledgeable can help you with that)
CODE
Before=ImageSource("vsq5.png")
After=ImageSource("r979.png")  

## http://avisynth.nl/index.php/Swap
AfterYUV=YToUV(
\  After.ShowBlue  .ConvertToY8, /* U (Cb) channel */
\  After.ShowRed   .ConvertToY8, /* V (Cr) channel */
\  After.ShowGreen .ConvertToY8) /* Y channel */

## compare clips - for use in frame step mode only!
return Interleave(
\  Before.Subtitle("Before"),
\  Overlay(Before, AfterYUV, x=-4).Subtitle("AfterYUV"))

thank for your feedback. i sure hope some can help me with this. anyone else know how i can do this with vshader?
 
     Top
phaeron
Posted: Feb 23 2014, 09:25 PM


Virtualdub Developer


Group: Administrator
Posts: 7773
Member No.: 61
Joined: 30-July 02



If you're using VDShader, the 4-pixel shift problem was a bug with earlier versions in the SSE2 JIT -- check that you are using version 1.4.

Also, if all you want to do is change the pixel format and not actually the colors in the image, the Convert Format filter will convert to 4:4:4. However...

QUOTE

the other colors suppose be more vivid


...this wouldn't be expected. Converting between encoding formats isn't supposed to change saturation/contrast/brightness.
 
    Top
Altaf
Posted: Feb 24 2014, 04:23 PM


Advanced Member


Group: Members
Posts: 75
Member No.: 36396
Joined: 9-April 13



I don't know as to make 4:4:4. I read that the size of the file decreases at the same quality.
 
     Top
krt47
Posted: Feb 24 2014, 08:45 PM


Member


Group: Members
Posts: 13
Member No.: 37399
Joined: 4-November 13



QUOTE (phaeron @ Feb 23 2014, 09:25 PM)
If you're using VDShader, the 4-pixel shift problem was a bug with earlier versions in the SSE2 JIT -- check that you are using version 1.4.

Also, if all you want to do is change the pixel format and not actually the colors in the image, the Convert Format filter will convert to 4:4:4. However...

QUOTE

the other colors suppose be more vivid


...this wouldn't be expected. Converting between encoding formats isn't supposed to change saturation/contrast/brightness.

ok phaeron the 4-pixel shift was fixed in what now? please specify? i don't see a filter or the time line in the log where the 4-pixel shift was fixed.
 
     Top
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:
7 replies since Feb 21 2014, 01:06 AM Track this topic | Email this topic | Print this topic

<< Back to VirtualDub Filters and Filter Development