diff --git a/README.md b/README.md index a2f6ab1..208c4f0 100644 --- a/README.md +++ b/README.md @@ -139,7 +139,7 @@ make -f Makefile.dev release-arch - [x] Shader based format mapping - [x] Video mapping config file - [x] Get first video size matching internal size - - [ ] other internal size for video + - [x] other internal size for video - [ ] Clean code and fix things - [x] Monitor screen - [x] 2nd window diff --git a/src/args.c b/src/args.c index ae23581..d377094 100644 --- a/src/args.c +++ b/src/args.c @@ -23,8 +23,9 @@ static void print_help(int status_code) { "[-mo] " "[-f=DIR_PATH] " "[-fc=CFG_PATH] " - "[-v=FILE] " "[-is=SIZE] " + "[-v=FILE] " + "[-vs=SIZE] " "[-t=TEMPO] " "[--demo] " "[-w] " @@ -40,11 +41,11 @@ static void print_help(int status_code) { " -f, --frag fragment shaders directory (default: TODO)\n" " -fc, --frag-config fragment shaders config file (default: " "TODO)\n" + " -is, --internal-size internal texture height (default: 720)\n" " -v, --video-in path to video capture device (multiple " "allowed)\n" - " -is, --internal-size internal texture height (default: 720)\n" - "(default: " - "3)\n" + " -vs, --video-size video capture desired height (default: " + "internal texture height)\n" " -t, --tempo base tempo (default: 60)\n" " --demo demonstration mode\n" " -w, --windowed not fullscreen\n"); @@ -93,6 +94,7 @@ Parameters args_parse(int argc, char **argv) { params.frag_path = 0; params.frag_config_path = 0; params.internal_size = 720; + params.video_size = 0; params.base_tempo = 60.0f; params.demo = false; params.windowed = false; @@ -114,12 +116,20 @@ Parameters args_parse(int argc, char **argv) { params.frag_path = value; } else if (is_arg(arg, "-fc") || is_arg(arg, "--frag-config")) { params.frag_config_path = value; - } else if (is_arg(arg, "-v") || is_arg(arg, "--video-in")) { - params.video_in[params.video_in_count++] = value; - } else if (is_arg(arg, "-t") || is_arg(arg, "--tempo")) { - params.base_tempo = (float)parse_uint(arg, value); } else if (is_arg(arg, "-is") || is_arg(arg, "--internal-size")) { params.internal_size = parse_uint(arg, value); + if (params.internal_size == 0) { + invalid_value(arg, value); + } + } else if (is_arg(arg, "-v") || is_arg(arg, "--video-in")) { + params.video_in[params.video_in_count++] = value; + } else if (is_arg(arg, "-vs") || is_arg(arg, "--video-size")) { + params.video_size = parse_uint(arg, value); + if (params.video_size == 0) { + invalid_value(arg, value); + } + } else if (is_arg(arg, "-t") || is_arg(arg, "--tempo")) { + params.base_tempo = (float)parse_uint(arg, value); } else if (is_arg(arg, "-m") || is_arg(arg, "--monitor")) { params.monitor = true; params.monitor_screen = parse_uint(arg, value); @@ -151,5 +161,9 @@ Parameters args_parse(int argc, char **argv) { exit(EXIT_FAILURE); } + if (params.video_size == 0) { + params.video_size = params.internal_size; + } + return params; } \ No newline at end of file diff --git a/src/forge.c b/src/forge.c index de4a75d..8267ec2 100644 --- a/src/forge.c +++ b/src/forge.c @@ -160,13 +160,13 @@ static void free_files(unsigned int frag_count) { } static void init_inputs(char *video_in[MAX_VIDEO], unsigned int input_count, - unsigned int internal_size) { + unsigned int video_size) { unsigned int i; inputs = malloc(input_count * sizeof(VideoCapture)); for (i = 0; i < input_count; i++) { - inputs[i] = video_init(video_in[i], internal_size); + inputs[i] = video_init(video_in[i], video_size); } } @@ -257,7 +257,7 @@ void forge_run(Parameters params) { context.internal_height = params.internal_size; - init_inputs(params.video_in, params.video_in_count, params.internal_size); + init_inputs(params.video_in, params.video_in_count, params.video_size); if (params.output) { window_output = window_init(PACKAGE " " VERSION, params.output_screen, diff --git a/src/shaders.c b/src/shaders.c index 97c6f7c..f01e253 100644 --- a/src/shaders.c +++ b/src/shaders.c @@ -73,6 +73,7 @@ static void link_input_to_texture(ShaderProgram *program, VideoCapture *input, unsigned int texture_index) { input->dma_image = EGL_NO_IMAGE_KHR; + // https://registry.khronos.org/EGL/extensions/EXT/EGL_EXT_image_dma_buf_import.txt const EGLint attrib_list[] = {EGL_WIDTH, input->width, EGL_HEIGHT, @@ -104,8 +105,8 @@ static void link_input_to_texture(ShaderProgram *program, VideoCapture *input, GL_UNSIGNED_BYTE, 0); // https://registry.khronos.org/OpenGL/extensions/EXT/EXT_EGL_image_storage.txt - glEGLImageTargetTextureStorageEXT(program->textures[texture_index], - (GLeglImageOES)input->dma_image, NULL); + glEGLImageTargetTexStorageEXT(GL_TEXTURE_2D, (GLeglImageOES)input->dma_image, + NULL); log_info("Texture %d linked to %s", texture_index, input->name); } diff --git a/src/types.h b/src/types.h index ad9c264..ae60597 100644 --- a/src/types.h +++ b/src/types.h @@ -22,6 +22,7 @@ typedef struct Parameters { char *frag_path; char *frag_config_path; unsigned int internal_size; + unsigned int video_size; float base_tempo; bool demo; bool windowed;