Merge commit '7621e2f8dec938cf48181c8b10afc9b01f444e68' into beta

This commit is contained in:
Ilya Laktyushin
2025-12-06 02:17:48 +04:00
commit 8344b97e03
28070 changed files with 7995182 additions and 0 deletions
@@ -0,0 +1,49 @@
#include <metal_stdlib>
using namespace metal;
typedef struct {
packed_float2 position;
packed_float2 texcoord;
} Vertex;
typedef struct {
float4 position[[position]];
float2 texcoord;
} Varyings;
vertex Varyings i420VertexPassthrough(constant Vertex *verticies[[buffer(0)]],
unsigned int vid[[vertex_id]]) {
Varyings out;
constant Vertex &v = verticies[vid];
out.position = float4(float2(v.position), 0.0, 1.0);
out.texcoord = v.texcoord;
return out;
}
fragment half4 i420FragmentColorConversion(
Varyings in[[stage_in]],
texture2d<float, access::sample> textureY[[texture(0)]],
texture2d<float, access::sample> textureU[[texture(1)]],
texture2d<float, access::sample> textureV[[texture(2)]]) {
constexpr sampler s(address::clamp_to_edge, filter::linear);
float y;
float u;
float v;
float r;
float g;
float b;
// Conversion for YUV to rgb from http://www.fourcc.org/fccyvrgb.php
y = textureY.sample(s, in.texcoord).r;
u = textureU.sample(s, in.texcoord).r;
v = textureV.sample(s, in.texcoord).r;
u = u - 0.5;
v = v - 0.5;
r = y + 1.403 * v;
g = y - 0.344 * u - 0.714 * v;
b = y + 1.770 * u;
float4 out = float4(r, g, b, 1.0);
return half4(out);
}
@@ -0,0 +1,57 @@
#include <metal_stdlib>
using namespace metal;
typedef struct {
packed_float2 position;
packed_float2 texcoord;
} Vertex;
typedef struct {
float4 position[[position]];
float2 texcoord;
} Varyings;
vertex Varyings nv12VertexPassthrough(
constant Vertex *verticies[[buffer(0)]],
unsigned int vid[[vertex_id]]
) {
Varyings out;
constant Vertex &v = verticies[vid];
out.position = float4(float2(v.position), 0.0, 1.0);
out.texcoord = v.texcoord;
return out;
}
float4 samplePoint(texture2d<float, access::sample> textureY, texture2d<float, access::sample> textureCbCr, sampler s, float2 texcoord) {
float y;
float2 uv;
y = textureY.sample(s, texcoord).r;
uv = textureCbCr.sample(s, texcoord).rg - float2(0.5, 0.5);
// Conversion for YUV to rgb from http://www.fourcc.org/fccyvrgb.php
float4 out = float4(y + 1.403 * uv.y, y - 0.344 * uv.x - 0.714 * uv.y, y + 1.770 * uv.x, 1.0);
return out;
}
fragment half4 nv12FragmentColorConversion(
Varyings in[[stage_in]],
texture2d<float, access::sample> textureY[[texture(0)]],
texture2d<float, access::sample> textureCbCr[[texture(1)]]
) {
constexpr sampler s(address::clamp_to_edge, filter::linear);
float4 out = samplePoint(textureY, textureCbCr, s, in.texcoord);
return half4(out);
}
fragment half4 blitFragmentColorConversion(
Varyings in[[stage_in]],
texture2d<float, access::sample> texture[[texture(0)]]
) {
constexpr sampler s(address::clamp_to_edge, filter::linear);
float4 out = texture.sample(s, in.texcoord);
return half4(out);
}