wip yuyv
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
TARGET ?= forge
|
||||
INSTALL_DIR ?= $(HOME)/.local/bin
|
||||
TEST_ARGS ?= --frag=./shaders --frag-config=./config/shaders.cfg --video-in=/dev/video0 --tempo=30
|
||||
TEST_ARGS ?= --frag=./shaders --frag-config=./config/shaders.cfg --video-in=/dev/video2 --video-in=/dev/video9 --tempo=30
|
||||
SHELL := /bin/bash
|
||||
|
||||
.PHONY: build
|
||||
|
||||
+15
-13
@@ -7,23 +7,25 @@ UNIFORM_SEED_PREFIX=seed
|
||||
UNIFORM_STATE_PREFIX=state
|
||||
UNIFORM_TEX_PREFIX=tex
|
||||
|
||||
TEX_COUNT=8
|
||||
|
||||
FRAG_COUNT=8
|
||||
FRAG_OUTPUT=7
|
||||
FRAG_MONITOR=8
|
||||
|
||||
FRAG_1_OUT=2
|
||||
FRAG_3_OUT=3
|
||||
FRAG_2_OUT=5
|
||||
FRAG_4_OUT=6
|
||||
FRAG_5_OUT=7
|
||||
FRAG_6_OUT=0
|
||||
TEX_COUNT=10
|
||||
|
||||
IN_COUNT=2
|
||||
|
||||
IN_1_OUT=1
|
||||
IN_2_OUT=4
|
||||
IN_2_OUT=2
|
||||
|
||||
FRAG_COUNT=10
|
||||
FRAG_OUTPUT=9
|
||||
FRAG_MONITOR=10
|
||||
|
||||
FRAG_1_OUT=3
|
||||
FRAG_2_OUT=4
|
||||
FRAG_3_OUT=5
|
||||
FRAG_4_OUT=6
|
||||
FRAG_5_OUT=7
|
||||
FRAG_6_OUT=8
|
||||
FRAG_7_OUT=9
|
||||
FRAG_8_OUT=0
|
||||
|
||||
SUB_TYPE_COUNT=3
|
||||
SUB_1_PREFIX=src_
|
||||
|
||||
+22
-17
@@ -21,12 +21,12 @@ uniform int seed6;
|
||||
uniform int seed7;
|
||||
uniform int seed8;
|
||||
|
||||
uniform int state1_1;
|
||||
uniform int state2_1;
|
||||
uniform int state3_2;
|
||||
uniform int state4_2;
|
||||
uniform int state5_3;
|
||||
uniform int state3_1;
|
||||
uniform int state4_1;
|
||||
uniform int state5_2;
|
||||
uniform int state6_2;
|
||||
uniform int state7_3;
|
||||
uniform int state8_2;
|
||||
|
||||
// 2. textures
|
||||
// ---------------
|
||||
@@ -40,6 +40,7 @@ uniform sampler2D tex5;
|
||||
uniform sampler2D tex6;
|
||||
uniform sampler2D tex7;
|
||||
uniform sampler2D tex8;
|
||||
uniform sampler2D tex9;
|
||||
|
||||
// 3. definitions
|
||||
// --------------
|
||||
@@ -1039,7 +1040,7 @@ subroutine(src_stage_sub) vec4 src_5(vec2 vUV, int seed)
|
||||
// SRC 6 : video in 1 + thru
|
||||
subroutine(src_stage_sub) vec4 src_6(vec2 vUV, int seed)
|
||||
{
|
||||
return src_thru(vUV, tex1, seed);
|
||||
return src_thru(vUV, tex3, seed);
|
||||
}
|
||||
|
||||
// SRC 7 : cp437
|
||||
@@ -1157,7 +1158,7 @@ subroutine(src_stage_sub) vec4 src_10(vec2 vUV, int seed)
|
||||
// SRC 11 : video in 2 + thru
|
||||
subroutine(src_stage_sub) vec4 src_11(vec2 vUV, int seed)
|
||||
{
|
||||
return src_thru(vUV, tex2, seed);
|
||||
return src_thru(vUV, tex4, seed);
|
||||
}
|
||||
|
||||
// TODO SRC 12
|
||||
@@ -1239,16 +1240,16 @@ subroutine(src_stage_sub) vec4 src_16(vec2 vUV, int seed)
|
||||
int page = 0; // TODO debug page
|
||||
int selected_src = 0; // TODO debug selected
|
||||
int selected_fx = 0; // TODO debug selected
|
||||
int selected_srca = state1_1;
|
||||
int selected_srcb = state2_1;
|
||||
int selected_fxa = state3_2;
|
||||
int selected_fxb = state4_2;
|
||||
int selected_mfx = state6_2;
|
||||
float fxa_value = magic(seed3);
|
||||
float fxb_value = magic(seed4);
|
||||
float mfx_value = magic(seed6);
|
||||
float mix_value = magic(seed5);
|
||||
int mix_type = state5_3 % 2;
|
||||
int selected_srca = state3_1;
|
||||
int selected_srcb = state4_1;
|
||||
int selected_fxa = state5_2;
|
||||
int selected_fxb = state6_2;
|
||||
int selected_mfx = state8_2;
|
||||
float fxa_value = magic(seed5);
|
||||
float fxb_value = magic(seed6);
|
||||
float mfx_value = magic(seed8);
|
||||
float mix_value = magic(seed7);
|
||||
int mix_type = state7_3 % 2;
|
||||
|
||||
// logic
|
||||
|
||||
@@ -1919,3 +1920,7 @@ subroutine(mix_stage_sub) vec4 mix_16(vec2 vUV, sampler2D ta, sampler2D tb, int
|
||||
{
|
||||
return mix_2(vUV, ta, tb, seed);
|
||||
}
|
||||
|
||||
// TODO temp
|
||||
|
||||
const mat4x4 yuv_to_rgb = {{1,0,1.13983,0},{1,-0.39465,-0.5806,0},{1,2.03211,0,0},{0,0,0,1}};
|
||||
+12
-5
@@ -1,12 +1,19 @@
|
||||
// SRC A
|
||||
// VIDEO 1
|
||||
// -----------
|
||||
// IN: 0 (OUT)
|
||||
// IN: 1 (IN A)
|
||||
// OUT: 2 (FX A)
|
||||
// IN: 1 (RAW IN A)
|
||||
// OUT: 3 (IN A)
|
||||
|
||||
in vec2 vUV;
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
fragColor = src_stage(vUV, seed1);
|
||||
float r, g, b, y, u, v;
|
||||
vec4 src = texture(tex1, vec2(vUV.x, 1 - vUV.y));
|
||||
y = src.r;
|
||||
u = src.g - 0.5;
|
||||
v = src.a - 0.5;
|
||||
r = y + 1.13983 * v;
|
||||
g = y - 0.39465 * u - 0.58060 * v;
|
||||
b = y + 2.03211 * u;
|
||||
fragColor = vec4(r, g, b, 1.0);
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
// MONITOR
|
||||
// ---
|
||||
|
||||
in vec2 vUV;
|
||||
out vec4 fragColor;
|
||||
|
||||
float s(vec2 uv, float x0, float y0) {
|
||||
return step(x0, uv.x) * step(-x0 - 1, -uv.x) * step(y0, uv.y) *
|
||||
step(-y0 - 1, -uv.y);
|
||||
}
|
||||
|
||||
const int texts[8][5] = {
|
||||
{0x49, 0x4E, 0x20, 0x41, 0x00}, // IN A
|
||||
{0x49, 0x4E, 0x20, 0x42, 0x00}, // IN B
|
||||
{0x53, 0x52, 0x43, 0x20, 0x41}, // SRC A
|
||||
{0x53, 0x52, 0x43, 0x20, 0x42}, // SRC B
|
||||
{0x46, 0x58, 0x20, 0x41, 0x00}, // FX A
|
||||
{0x46, 0x58, 0x20, 0x42, 0x00}, // FX B
|
||||
{0x41, 0x2B, 0x42, 0x00, 0x00}, // A+B
|
||||
{0x4D, 0x46, 0x58, 0x00, 0x00}, // MFX
|
||||
};
|
||||
|
||||
void main() {
|
||||
vec2 uv0 = vUV.st;
|
||||
float ratio = iResolution.x / iResolution.y;
|
||||
vec2 uv1 = (uv0 - .5) * vec2(ratio, 1);
|
||||
|
||||
vec2 uv2 = uv0 * 3;
|
||||
vec2 uv3 = uv1 * 60;
|
||||
|
||||
vec4 c = vec4(0);
|
||||
|
||||
c += s(uv2,0,2) * texture(tex3, uv2);
|
||||
c += s(uv2,1,2) * texture(tex5, uv2);
|
||||
c += s(uv2,2,2) * texture(tex7, uv2);
|
||||
|
||||
c += s(uv2,0,1) * texture(tex4, uv2);
|
||||
c += s(uv2,1,1) * texture(tex6, uv2);
|
||||
c += s(uv2,2,1) * texture(tex8, uv2);
|
||||
|
||||
c += s(uv2,0,0) * src_16(mod(uv2, 1), 0);
|
||||
c += s(uv2,1,0) * texture(tex9, uv2);
|
||||
c += s(uv2,2,0) * texture(tex0, uv2);
|
||||
|
||||
float f = 0;
|
||||
float t = 0;
|
||||
|
||||
f += rect(uv3, vec2(-51, 28.5), vec2(2.1, 0.7));
|
||||
t += write_5(uv3, vec2(-53,28), texts[0]);
|
||||
f += rect(uv3, vec2(-51, 8.5), vec2(2.1, 0.7));
|
||||
t += write_5(uv3, vec2(-53,8), texts[1]);
|
||||
f += rect(uv3, vec2(-14.5, 28.5), vec2(2.6, 0.7));
|
||||
t += write_5(uv3, vec2(-17,28), texts[2]);
|
||||
f += rect(uv3, vec2(-14.5, 8.5), vec2(2.6, 0.7));
|
||||
t += write_5(uv3, vec2(-17,8), texts[3]);
|
||||
f += rect(uv3, vec2(21, 28.5), vec2(2.1, 0.7));
|
||||
t += write_5(uv3, vec2(19,28), texts[4]);
|
||||
f += rect(uv3, vec2(21, 8.5), vec2(2.1, 0.7));
|
||||
t += write_5(uv3, vec2(19,8), texts[5]);
|
||||
f += rect(uv3, vec2(-15.5, -11.5), vec2(1.6, 0.7));
|
||||
t += write_5(uv3, vec2(-17,-12), texts[6]);
|
||||
f += rect(uv3, vec2(20.5, -11.5), vec2(1.6, 0.7));
|
||||
t += write_5(uv3, vec2(19,-12), texts[7]);
|
||||
|
||||
fragColor = mix(c, vec4(f - t), f);
|
||||
}
|
||||
+12
-5
@@ -1,12 +1,19 @@
|
||||
// SRC B
|
||||
// VIDEO 2
|
||||
// -----------
|
||||
// IN: 0 (OUT)
|
||||
// IN: 4 (IN B)
|
||||
// OUT: 5 (FX B)
|
||||
// IN: 2 (RAW IN B)
|
||||
// OUT: 4 (IN B)
|
||||
|
||||
in vec2 vUV;
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
fragColor = src_stage(vUV, seed2);
|
||||
float r, g, b, y, u, v;
|
||||
vec4 src = texture(tex2, vec2(vUV.x, 1 - vUV.y));
|
||||
y = src.r;
|
||||
u = src.g - 0.5;
|
||||
v = src.a - 0.5;
|
||||
r = y + 1.13983 * v;
|
||||
g = y - 0.39465 * u - 0.58060 * v;
|
||||
b = y + 2.03211 * u;
|
||||
fragColor = vec4(r, g, b, 1.0);
|
||||
}
|
||||
+4
-6
@@ -1,12 +1,10 @@
|
||||
// FX A
|
||||
// -------------
|
||||
// IN: 2 (SRC A)
|
||||
// IN: 3 (FX A)
|
||||
// OUT: 3 (A+B)
|
||||
// SRC A
|
||||
// -----------
|
||||
// OUT: 5 (FX A)
|
||||
|
||||
in vec2 vUV;
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
fragColor = fx_stage(vUV, tex2, tex3, seed3);
|
||||
fragColor = src_stage(vUV, seed3);
|
||||
}
|
||||
+4
-6
@@ -1,12 +1,10 @@
|
||||
// FX B
|
||||
// -------------
|
||||
// IN: 5 (SRC B)
|
||||
// IN: 6 (FX B)
|
||||
// OUT: 6 (A+B)
|
||||
// SRC B
|
||||
// -----------
|
||||
// OUT: 6 (FX B)
|
||||
|
||||
in vec2 vUV;
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
fragColor = fx_stage(vUV, tex5, tex6, seed4);
|
||||
fragColor = src_stage(vUV, seed4);
|
||||
}
|
||||
+6
-6
@@ -1,12 +1,12 @@
|
||||
// A+B
|
||||
// ------------
|
||||
// IN: 3 (FX A)
|
||||
// IN: 6 (FX B)
|
||||
// OUT: 7 (MFX)
|
||||
// FX A
|
||||
// -------------
|
||||
// IN: 5 (SRC A)
|
||||
// IN: 7 (FX A)
|
||||
// OUT: 7 (A+B)
|
||||
|
||||
in vec2 vUV;
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
fragColor = mix_stage(vUV, tex3, tex6, seed5);
|
||||
fragColor = fx_stage(vUV, tex5, tex7, seed5);
|
||||
}
|
||||
+6
-6
@@ -1,12 +1,12 @@
|
||||
// MFX
|
||||
// ------------
|
||||
// IN: 7 (A+B)
|
||||
// IN: 0 (OUT)
|
||||
// OUT: 0 (OUT)
|
||||
// FX B
|
||||
// -------------
|
||||
// IN: 6 (SRC B)
|
||||
// IN: 8 (FX B)
|
||||
// OUT: 8 (A+B)
|
||||
|
||||
in vec2 vUV;
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
fragColor = fx_stage(vUV, tex7, tex0, seed6);
|
||||
fragColor = fx_stage(vUV, tex6, tex8, seed6);
|
||||
}
|
||||
+6
-3
@@ -1,9 +1,12 @@
|
||||
// OUT
|
||||
// ---
|
||||
// A+B
|
||||
// ------------
|
||||
// IN: 7 (FX A)
|
||||
// IN: 8 (FX B)
|
||||
// OUT: 9 (MFX)
|
||||
|
||||
in vec2 vUV;
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
fragColor = texture(tex0, vUV);
|
||||
fragColor = mix_stage(vUV, tex7, tex8, seed7);
|
||||
}
|
||||
+6
-58
@@ -1,64 +1,12 @@
|
||||
// MONITOR
|
||||
// ---
|
||||
// MFX
|
||||
// ------------
|
||||
// IN: 9 (A+B)
|
||||
// IN: 0 (OUT)
|
||||
// OUT: 0 (OUT)
|
||||
|
||||
in vec2 vUV;
|
||||
out vec4 fragColor;
|
||||
|
||||
float s(vec2 uv, float x0, float y0) {
|
||||
return step(x0, uv.x) * step(-x0 - 1, -uv.x) * step(y0, uv.y) *
|
||||
step(-y0 - 1, -uv.y);
|
||||
}
|
||||
|
||||
const int texts[8][5] = {
|
||||
{0x49, 0x4E, 0x20, 0x41, 0x00}, // IN A
|
||||
{0x49, 0x4E, 0x20, 0x42, 0x00}, // IN B
|
||||
{0x53, 0x52, 0x43, 0x20, 0x41}, // SRC A
|
||||
{0x53, 0x52, 0x43, 0x20, 0x42}, // SRC B
|
||||
{0x46, 0x58, 0x20, 0x41, 0x00}, // FX A
|
||||
{0x46, 0x58, 0x20, 0x42, 0x00}, // FX B
|
||||
{0x41, 0x2B, 0x42, 0x00, 0x00}, // A+B
|
||||
{0x4D, 0x46, 0x58, 0x00, 0x00}, // MFX
|
||||
};
|
||||
|
||||
void main() {
|
||||
vec2 uv0 = vUV.st;
|
||||
float ratio = iResolution.x / iResolution.y;
|
||||
vec2 uv1 = (uv0 - .5) * vec2(ratio, 1);
|
||||
|
||||
vec2 uv2 = uv0 * 3;
|
||||
vec2 uv3 = uv1 * 60;
|
||||
|
||||
vec4 c = vec4(0);
|
||||
|
||||
c += s(uv2,0,2) * texture(tex1, uv2);
|
||||
c += s(uv2,1,2) * texture(tex2, uv2);
|
||||
c += s(uv2,2,2) * texture(tex3, uv2);
|
||||
c += s(uv2,0,1) * texture(tex4, uv2);
|
||||
c += s(uv2,1,1) * texture(tex5, uv2);
|
||||
c += s(uv2,2,1) * texture(tex6, uv2);
|
||||
c += s(uv2,0,0) * src_16(mod(uv2, 1), 0);
|
||||
c += s(uv2,1,0) * texture(tex7, uv2);
|
||||
c += s(uv2,2,0) * texture(tex0, uv2);
|
||||
|
||||
float f = 0;
|
||||
float t = 0;
|
||||
|
||||
f += rect(uv3, vec2(-51, 28.5), vec2(2.1, 0.7));
|
||||
t += write_5(uv3, vec2(-53,28), texts[0]);
|
||||
f += rect(uv3, vec2(-51, 8.5), vec2(2.1, 0.7));
|
||||
t += write_5(uv3, vec2(-53,8), texts[1]);
|
||||
f += rect(uv3, vec2(-14.5, 28.5), vec2(2.6, 0.7));
|
||||
t += write_5(uv3, vec2(-17,28), texts[2]);
|
||||
f += rect(uv3, vec2(-14.5, 8.5), vec2(2.6, 0.7));
|
||||
t += write_5(uv3, vec2(-17,8), texts[3]);
|
||||
f += rect(uv3, vec2(21, 28.5), vec2(2.1, 0.7));
|
||||
t += write_5(uv3, vec2(19,28), texts[4]);
|
||||
f += rect(uv3, vec2(21, 8.5), vec2(2.1, 0.7));
|
||||
t += write_5(uv3, vec2(19,8), texts[5]);
|
||||
f += rect(uv3, vec2(-15.5, -11.5), vec2(1.6, 0.7));
|
||||
t += write_5(uv3, vec2(-17,-12), texts[6]);
|
||||
f += rect(uv3, vec2(20.5, -11.5), vec2(1.6, 0.7));
|
||||
t += write_5(uv3, vec2(19,-12), texts[7]);
|
||||
|
||||
fragColor = mix(c, vec4(f - t), f);
|
||||
fragColor = fx_stage(vUV, tex9, tex0, seed8);
|
||||
}
|
||||
@@ -0,0 +1,9 @@
|
||||
// OUT
|
||||
// ---
|
||||
|
||||
in vec2 vUV;
|
||||
out vec4 fragColor;
|
||||
|
||||
void main() {
|
||||
fragColor = texture(tex0, vUV);
|
||||
}
|
||||
+2
-2
@@ -94,8 +94,8 @@ static void link_video_to_texture(ShaderProgram *program, VideoDevice *device,
|
||||
(EGLClientBuffer)NULL, attrib_list);
|
||||
|
||||
if (device->dma_image == EGL_NO_IMAGE_KHR) {
|
||||
log_error("(%s) eglCreateImageKHR failed", device->name);
|
||||
program->error = true;
|
||||
log_error("(%s) eglCreateImageKHR failed %04x", device->name,
|
||||
eglGetError());
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
+2
-2
@@ -63,8 +63,8 @@ static bool set_device_format(VideoDevice *device, unsigned int preferred_width,
|
||||
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||
fmt.fmt.pix.width = preferred_width;
|
||||
fmt.fmt.pix.height = preferred_height;
|
||||
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_BGRX32;
|
||||
fmt.fmt.pix.field = V4L2_FIELD_NONE;
|
||||
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
|
||||
fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
|
||||
|
||||
if (ioctl(device->fd, VIDIOC_S_FMT, &fmt) == -1) {
|
||||
log_warn("(%s) Format set failed", device->name);
|
||||
|
||||
Reference in New Issue
Block a user