-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Initial implementation of yuv444in420 encoding
- Loading branch information
Showing
22 changed files
with
396 additions
and
63 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
Large diffs are not rendered by default.
Oops, something went wrong.
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
3 changes: 3 additions & 0 deletions
3
src_assets/windows/assets/shaders/directx/convert_yuv444in420_nv12_uv_ps.hlsl
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,3 @@ | ||
#include "include/convert_base.hlsl" | ||
|
||
#include "include/convert_yuv444in420_ps_base.hlsl" |
3 changes: 3 additions & 0 deletions
3
src_assets/windows/assets/shaders/directx/convert_yuv444in420_nv12_uv_ps_linear.hlsl
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,3 @@ | ||
#include "include/convert_linear_base.hlsl" | ||
|
||
#include "include/convert_yuv444in420_ps_base.hlsl" |
4 changes: 4 additions & 0 deletions
4
src_assets/windows/assets/shaders/directx/convert_yuv444in420_nv12_y_ps.hlsl
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,4 @@ | ||
#include "include/convert_base.hlsl" | ||
|
||
#define PLANAR_VIEWPORTS | ||
#include "include/convert_yuv444in420_ps_base.hlsl" |
4 changes: 4 additions & 0 deletions
4
src_assets/windows/assets/shaders/directx/convert_yuv444in420_nv12_y_ps_linear.hlsl
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,4 @@ | ||
#include "include/convert_linear_base.hlsl" | ||
|
||
#define PLANAR_VIEWPORTS | ||
#include "include/convert_yuv444in420_ps_base.hlsl" |
4 changes: 4 additions & 0 deletions
4
src_assets/windows/assets/shaders/directx/convert_yuv444in420_p010_uv_ps.hlsl
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,4 @@ | ||
#include "include/convert_base.hlsl" | ||
|
||
#define P010 | ||
#include "include/convert_yuv444in420_ps_base.hlsl" |
4 changes: 4 additions & 0 deletions
4
src_assets/windows/assets/shaders/directx/convert_yuv444in420_p010_uv_ps_linear.hlsl
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,4 @@ | ||
#include "include/convert_linear_base.hlsl" | ||
|
||
#define P010 | ||
#include "include/convert_yuv444in420_ps_base.hlsl" |
4 changes: 4 additions & 0 deletions
4
...s/windows/assets/shaders/directx/convert_yuv444in420_p010_uv_ps_perceptual_quantizer.hlsl
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,4 @@ | ||
#include "include/convert_perceptual_quantizer_base.hlsl" | ||
|
||
#define P010 | ||
#include "include/convert_yuv444in420_ps_base.hlsl" |
5 changes: 5 additions & 0 deletions
5
src_assets/windows/assets/shaders/directx/convert_yuv444in420_p010_y_ps.hlsl
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,5 @@ | ||
#include "include/convert_base.hlsl" | ||
|
||
#define PLANAR_VIEWPORTS | ||
#define P010 | ||
#include "include/convert_yuv444in420_ps_base.hlsl" |
5 changes: 5 additions & 0 deletions
5
src_assets/windows/assets/shaders/directx/convert_yuv444in420_p010_y_ps_linear.hlsl
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,5 @@ | ||
#include "include/convert_linear_base.hlsl" | ||
|
||
#define PLANAR_VIEWPORTS | ||
#define P010 | ||
#include "include/convert_yuv444in420_ps_base.hlsl" |
5 changes: 5 additions & 0 deletions
5
...ts/windows/assets/shaders/directx/convert_yuv444in420_p010_y_ps_perceptual_quantizer.hlsl
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,5 @@ | ||
#include "include/convert_perceptual_quantizer_base.hlsl" | ||
|
||
#define PLANAR_VIEWPORTS | ||
#define P010 | ||
#include "include/convert_yuv444in420_ps_base.hlsl" |
1 change: 1 addition & 0 deletions
1
src_assets/windows/assets/shaders/directx/convert_yuv444in420_uv_vs.hlsl
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 @@ | ||
#include "include/convert_yuv444in420_vs_base.hlsl" |
2 changes: 2 additions & 0 deletions
2
src_assets/windows/assets/shaders/directx/convert_yuv444in420_y_vs.hlsl
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,2 @@ | ||
#define PLANAR_VIEWPORTS | ||
#include "include/convert_yuv444in420_vs_base.hlsl" |
51 changes: 51 additions & 0 deletions
51
src_assets/windows/assets/shaders/directx/include/convert_yuv444in420_ps_base.hlsl
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,51 @@ | ||
Texture2D image : register(t0); | ||
SamplerState def_sampler : register(s0); | ||
|
||
#ifndef PLANAR_VIEWPORTS | ||
cbuffer color_matrix_cbuffer : register(b0) { | ||
float4 color_vec_y; | ||
float4 color_vec_u; | ||
float4 color_vec_v; | ||
float2 range_y; | ||
float2 range_uv; | ||
}; | ||
#endif | ||
|
||
#include "include/base_vs_types.hlsl" | ||
|
||
#ifdef PLANAR_VIEWPORTS | ||
uint main_ps(vertex_t input) : SV_Target | ||
#else | ||
uint2 main_ps(vertex_t input) : SV_Target | ||
#endif | ||
{ | ||
// Y U V | ||
// +-------+ +---+ +---+ | ||
// | | | | | | | ||
// VP0-> | Y | |UR | |VR | | ||
// | | | | | | | ||
// +---+---+ +---+ +---+ | ||
// | | | | ||
// VP1-> |UL |VL | <-VP2 | ||
// | | | | ||
// +---+---+ | ||
|
||
float3 rgb = CONVERT_FUNCTION(image.Sample(def_sampler, input.tex_coord, 0).rgb); | ||
|
||
#ifdef PLANAR_VIEWPORTS | ||
float y = dot(input.color_vec.xyz, rgb) + input.color_vec.w; | ||
#ifdef P010 | ||
return uint(y) << 6; | ||
#else | ||
return uint(y); | ||
#endif | ||
#else | ||
float u = dot(color_vec_u.xyz, rgb) + color_vec_u.w; | ||
float v = dot(color_vec_v.xyz, rgb) + color_vec_v.w; | ||
#ifdef P010 | ||
return uint2(u, v) << 6; | ||
#else | ||
return uint2(u, v); | ||
#endif | ||
#endif | ||
} |
125 changes: 125 additions & 0 deletions
125
src_assets/windows/assets/shaders/directx/include/convert_yuv444in420_vs_base.hlsl
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,125 @@ | ||
cbuffer rotate_texture_steps_cbuffer : register(b1) { | ||
int rotate_texture_steps; | ||
}; | ||
|
||
#ifdef PLANAR_VIEWPORTS | ||
cbuffer color_matrix_cbuffer : register(b3) { | ||
float4 color_vec_y; | ||
float4 color_vec_u; | ||
float4 color_vec_v; | ||
float2 range_y; | ||
float2 range_uv; | ||
}; | ||
#endif | ||
|
||
#include "include/base_vs_types.hlsl" | ||
|
||
vertex_t main_vs(uint vertex_id : SV_VertexID) | ||
{ | ||
vertex_t output; | ||
float2 tex_coord; | ||
|
||
// id=1 -> + | ||
// |\ | ||
// | \ | ||
// | \ | ||
// +---+ | ||
// | |\ | ||
// id=0 -> +---+-+ <- id=3 | ||
|
||
// Y U V | ||
// +-------+ +---+ +---+ | ||
// | | | | | | | ||
// VP0-> | Y | |UR | |VR | | ||
// | | | | | | | ||
// +---+---+ +---+ +---+ | ||
// | | | | ||
// VP1-> |UL |VL | <-VP2 | ||
// | | | | ||
// +---+---+ | ||
|
||
#ifdef PLANAR_VIEWPORTS | ||
switch (vertex_id) { | ||
case 0: | ||
output.viewpoint_pos = float4(-1, -1, 0, 1); | ||
tex_coord = float2(0, 1); | ||
output.viewport = 0; | ||
output.color_vec = color_vec_y; | ||
break; | ||
case 1: | ||
output.viewpoint_pos = float4(-1, 3, 0, 1); | ||
tex_coord = float2(0, -1); | ||
output.viewport = 0; | ||
output.color_vec = color_vec_y; | ||
break; | ||
case 2: | ||
output.viewpoint_pos = float4(3, -1, 0, 1); | ||
tex_coord = float2(2, 1); | ||
output.viewport = 0; | ||
output.color_vec = color_vec_y; | ||
break; | ||
|
||
case 3: | ||
output.viewpoint_pos = float4(-1, -1, 0, 1); | ||
tex_coord = float2(0, 1); | ||
output.viewport = 1; | ||
output.color_vec = color_vec_u; | ||
break; | ||
case 4: | ||
output.viewpoint_pos = float4(-1, 3, 0, 1); | ||
tex_coord = float2(0, -1); | ||
output.viewport = 1; | ||
output.color_vec = color_vec_u; | ||
break; | ||
case 5: | ||
output.viewpoint_pos = float4(7, -1, 0, 1); | ||
tex_coord = float2(2, 1); | ||
output.viewport = 1; | ||
output.color_vec = color_vec_u; | ||
break; | ||
|
||
case 6: | ||
output.viewpoint_pos = float4(-1, -1, 0, 1); | ||
tex_coord = float2(0, 1); | ||
output.viewport = 2; | ||
output.color_vec = color_vec_v; | ||
break; | ||
case 7: | ||
output.viewpoint_pos = float4(-1, 3, 0, 1); | ||
tex_coord = float2(0, -1); | ||
output.viewport = 2; | ||
output.color_vec = color_vec_v; | ||
break; | ||
case 8: | ||
output.viewpoint_pos = float4(7, -1, 0, 1); | ||
tex_coord = float2(2, 1); | ||
output.viewport = 2; | ||
output.color_vec = color_vec_v; | ||
break; | ||
} | ||
#else | ||
if (vertex_id == 0) { | ||
output.viewpoint_pos = float4(-3, -1, 0, 1); | ||
tex_coord = float2(0, 1); | ||
} | ||
else if (vertex_id == 1) { | ||
output.viewpoint_pos = float4(-3, 5, 0, 1); | ||
tex_coord = float2(0, -2); | ||
} | ||
else { | ||
output.viewpoint_pos = float4(5, -1, 0, 1); | ||
tex_coord = float2(2, 1); | ||
} | ||
#endif | ||
|
||
if (rotate_texture_steps != 0) { | ||
float rotation_radians = radians(90 * rotate_texture_steps); | ||
float2x2 rotation_matrix = { cos(rotation_radians), -sin(rotation_radians), | ||
sin(rotation_radians), cos(rotation_radians) }; | ||
float2 rotation_center = { 0.5, 0.5 }; | ||
tex_coord = round(rotation_center + mul(rotation_matrix, tex_coord - rotation_center)); | ||
} | ||
output.tex_coord = tex_coord; | ||
|
||
return output; | ||
} |