forked from kirides/GD3D11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Decode video frame on gpu via pixel shader
- Loading branch information
1 parent
2435f19
commit a00243e
Showing
5 changed files
with
233 additions
and
247 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
//-------------------------------------------------------------------------------------- | ||
// Textures and Samplers | ||
//-------------------------------------------------------------------------------------- | ||
SamplerState SS_Linear : register( s0 ); | ||
Texture2D TX_TextureY : register( t0 ); | ||
Texture2D TX_TextureU : register( t1 ); | ||
Texture2D TX_TextureV : register( t2 ); | ||
|
||
//-------------------------------------------------------------------------------------- | ||
// Input / Output structures | ||
//-------------------------------------------------------------------------------------- | ||
struct PS_INPUT | ||
{ | ||
float2 vTexcoord : TEXCOORD0; | ||
float2 vTexcoord2 : TEXCOORD1; | ||
float4 vDiffuse : TEXCOORD2; | ||
float3 vNormalVS : TEXCOORD4; | ||
float3 vViewPosition : TEXCOORD5; | ||
float4 vPosition : SV_POSITION; | ||
}; | ||
|
||
//-------------------------------------------------------------------------------------- | ||
// Pixel Shader | ||
//-------------------------------------------------------------------------------------- | ||
float4 PSMain( PS_INPUT Input ) : SV_TARGET | ||
{ | ||
const float3 offset = {-0.0627451017, -0.501960814, -0.501960814}; | ||
const float3 Rcoeff = {1.1644, 0.0000, 1.7927}; | ||
const float3 Gcoeff = {1.1644, -0.2132, -0.5329}; | ||
const float3 Bcoeff = {1.1644, 2.1124, 0.0000}; | ||
|
||
float4 color; | ||
|
||
float3 yuv; | ||
yuv.x = TX_TextureY.Sample(SS_Linear, Input.vTexcoord).r; | ||
yuv.y = TX_TextureU.Sample(SS_Linear, Input.vTexcoord).r; | ||
yuv.z = TX_TextureV.Sample(SS_Linear, Input.vTexcoord).r; | ||
|
||
yuv += offset; | ||
color.r = saturate(dot(yuv, Rcoeff)); | ||
color.g = saturate(dot(yuv, Gcoeff)); | ||
color.b = saturate(dot(yuv, Bcoeff)); | ||
color.a = 1.0f; | ||
|
||
return color; | ||
} | ||
|
Oops, something went wrong.