pass internal size to video
This commit is contained in:
+1
-1
@@ -25,7 +25,7 @@ build:
|
|||||||
|
|
||||||
.PHONY: run
|
.PHONY: run
|
||||||
run: build
|
run: build
|
||||||
./build/$(TARGET) $(TEST_ARGS) --monitor-only --internal-size=240 --hot-reload
|
./build/$(TARGET) $(TEST_ARGS) --monitor-only --internal-size=480 --hot-reload
|
||||||
|
|
||||||
.PHONY: demo
|
.PHONY: demo
|
||||||
demo: build
|
demo: build
|
||||||
|
|||||||
@@ -134,11 +134,11 @@ make -f Makefile.dev release-arch
|
|||||||
- [ ] Clean code and fix things
|
- [ ] Clean code and fix things
|
||||||
- [ ] Video input
|
- [ ] Video input
|
||||||
- [x] Fixed camera video
|
- [x] Fixed camera video
|
||||||
- [x] Pass video info to shaders
|
- [ ] Pass video info to shaders
|
||||||
- [x] Sub process video reading
|
- [x] Sub process video reading
|
||||||
- [x] Shader based format mapping
|
- [x] Shader based format mapping
|
||||||
- [x] Video mapping config file
|
- [x] Video mapping config file
|
||||||
- [ ] Get first video size matching internal size
|
- [x] Get first video size matching internal size
|
||||||
- [ ] Clean code and fix things
|
- [ ] Clean code and fix things
|
||||||
- [x] Monitor screen
|
- [x] Monitor screen
|
||||||
- [x] 2nd window
|
- [x] 2nd window
|
||||||
|
|||||||
+1
-1
@@ -7,5 +7,5 @@ in vec2 vUV;
|
|||||||
out vec4 fragColor;
|
out vec4 fragColor;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
fragColor = yuyvTex(tex1, vUV, 320);
|
fragColor = yuyvTex(tex1, vUV, 480); // TODO uniform
|
||||||
}
|
}
|
||||||
+1
-1
@@ -7,5 +7,5 @@ in vec2 vUV;
|
|||||||
out vec4 fragColor;
|
out vec4 fragColor;
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
fragColor = yuyvTex(tex2, vUV, 320);
|
fragColor = yuyvTex(tex2, vUV, 320); // TODO uniform
|
||||||
}
|
}
|
||||||
+4
-3
@@ -145,13 +145,14 @@ static void free_files(unsigned int frag_count) {
|
|||||||
file_free(&common_shader_code, true);
|
file_free(&common_shader_code, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void init_devices(char *video_in[MAX_VIDEO], unsigned int video_count) {
|
static void init_devices(char *video_in[MAX_VIDEO], unsigned int video_count,
|
||||||
|
unsigned int internal_size) {
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
|
|
||||||
devices = malloc(video_count * sizeof(VideoDevice));
|
devices = malloc(video_count * sizeof(VideoDevice));
|
||||||
|
|
||||||
for (i = 0; i < video_count; i++) {
|
for (i = 0; i < video_count; i++) {
|
||||||
devices[i] = video_init(video_in[i], 320, 240); // TODO define in args
|
devices[i] = video_init(video_in[i], internal_size);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -242,7 +243,7 @@ void forge_run(Parameters params) {
|
|||||||
|
|
||||||
context.internal_size = params.internal_size;
|
context.internal_size = params.internal_size;
|
||||||
|
|
||||||
init_devices(params.video_in, params.video_count);
|
init_devices(params.video_in, params.video_count, params.internal_size);
|
||||||
|
|
||||||
if (params.output) {
|
if (params.output) {
|
||||||
window_output = window_init(PACKAGE " " VERSION, params.output_screen,
|
window_output = window_init(PACKAGE " " VERSION, params.output_screen,
|
||||||
|
|||||||
+54
-7
@@ -2,6 +2,7 @@
|
|||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <linux/videodev2.h>
|
#include <linux/videodev2.h>
|
||||||
#include <log.h>
|
#include <log.h>
|
||||||
|
#include <stdbool.h>
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <sys/ioctl.h>
|
#include <sys/ioctl.h>
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
@@ -92,8 +93,51 @@ static bool check_device_caps(VideoDevice *device) {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
static bool set_device_format(VideoDevice *device, unsigned int preferred_width,
|
static bool get_available_sizes(VideoDevice *device,
|
||||||
unsigned int preferred_height) {
|
unsigned int preferred_height) {
|
||||||
|
struct v4l2_frmsizeenum fmt_enum;
|
||||||
|
unsigned int index;
|
||||||
|
|
||||||
|
memset(&fmt_enum, 0, sizeof(fmt_enum));
|
||||||
|
|
||||||
|
index = 0;
|
||||||
|
fmt_enum.index = index;
|
||||||
|
fmt_enum.pixel_format = V4L2_PIX_FMT_YUYV;
|
||||||
|
|
||||||
|
device->width = 0;
|
||||||
|
device->height = 0;
|
||||||
|
|
||||||
|
while (ioctl(device->fd, VIDIOC_ENUM_FRAMESIZES, &fmt_enum) == 0) {
|
||||||
|
if (fmt_enum.type == V4L2_FRMSIZE_TYPE_DISCRETE) {
|
||||||
|
log_trace("(%s) %d: %dx%d", device->name, index, fmt_enum.discrete.width,
|
||||||
|
fmt_enum.discrete.height);
|
||||||
|
|
||||||
|
if (fmt_enum.discrete.height == preferred_height) {
|
||||||
|
device->height = preferred_height;
|
||||||
|
if (device->width == 0 || device->width < fmt_enum.discrete.width) {
|
||||||
|
device->width = fmt_enum.discrete.width;
|
||||||
|
}
|
||||||
|
} else if (fmt_enum.discrete.height < preferred_height &&
|
||||||
|
fmt_enum.discrete.height > device->height) {
|
||||||
|
device->height = fmt_enum.discrete.height;
|
||||||
|
device->width = fmt_enum.discrete.width;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
memset(&fmt_enum, 0, sizeof(fmt_enum));
|
||||||
|
fmt_enum.index = ++index;
|
||||||
|
fmt_enum.pixel_format = V4L2_PIX_FMT_YUYV;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (device->height == 0) {
|
||||||
|
device->error = true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
static bool set_device_format(VideoDevice *device) {
|
||||||
struct v4l2_format fmt;
|
struct v4l2_format fmt;
|
||||||
|
|
||||||
device->output = false;
|
device->output = false;
|
||||||
@@ -101,8 +145,8 @@ static bool set_device_format(VideoDevice *device, unsigned int preferred_width,
|
|||||||
memset(&fmt, 0, sizeof(fmt));
|
memset(&fmt, 0, sizeof(fmt));
|
||||||
|
|
||||||
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
fmt.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
|
||||||
fmt.fmt.pix.width = preferred_width;
|
fmt.fmt.pix.width = device->width;
|
||||||
fmt.fmt.pix.height = preferred_height;
|
fmt.fmt.pix.height = device->height;
|
||||||
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
|
fmt.fmt.pix.pixelformat = V4L2_PIX_FMT_YUYV;
|
||||||
fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
|
fmt.fmt.pix.field = V4L2_FIELD_INTERLACED;
|
||||||
|
|
||||||
@@ -205,8 +249,7 @@ static void close_stream(VideoDevice device) {
|
|||||||
ioctl(device.fd, VIDIOC_STREAMOFF, &buf_type);
|
ioctl(device.fd, VIDIOC_STREAMOFF, &buf_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
VideoDevice video_init(char *name, unsigned int preferred_width,
|
VideoDevice video_init(char *name, unsigned int preferred_height) {
|
||||||
unsigned int preferred_height) {
|
|
||||||
VideoDevice device;
|
VideoDevice device;
|
||||||
|
|
||||||
device = open_device(name);
|
device = open_device(name);
|
||||||
@@ -219,7 +262,11 @@ VideoDevice video_init(char *name, unsigned int preferred_width,
|
|||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!set_device_format(&device, preferred_width, preferred_height)) {
|
if (!get_available_sizes(&device, preferred_height)) {
|
||||||
|
return device;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!set_device_format(&device)) {
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-2
@@ -3,8 +3,7 @@
|
|||||||
#ifndef VIDEO_H
|
#ifndef VIDEO_H
|
||||||
#define VIDEO_H
|
#define VIDEO_H
|
||||||
|
|
||||||
VideoDevice video_init(char *name, unsigned int preferred_width,
|
VideoDevice video_init(char *name, unsigned int preferred_height);
|
||||||
unsigned int preferred_height);
|
|
||||||
|
|
||||||
void video_background_read(VideoDevice *device, bool *stop);
|
void video_background_read(VideoDevice *device, bool *stop);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user