Improve decoder and add buffer validator

This commit is contained in:
Kamil Trzcinski 2022-04-08 10:57:55 +02:00
parent 6806a6bdf2
commit 1352df220b
5 changed files with 11 additions and 2 deletions

View File

@ -79,8 +79,7 @@ retry:
// JPEG is in 16x16 blocks (shrink image to fit) (but adapt to 32x32)
// And ISP output
if (strstr(buf_list->name, "JPEG") || strstr(buf_list->name, "H264") || buf_list->do_capture && strstr(buf_list->name, "ISP")
|| strstr(buf_list->name, "DECODER")) {
if (strstr(buf_list->name, "JPEG") || strstr(buf_list->name, "H264") || buf_list->do_capture && strstr(buf_list->name, "ISP")) {
width = shrink_to_block(width, 32);
height = shrink_to_block(height, 32);
E_LOG_VERBOSE(buf_list, "Adapting size to 32x32 block: %dx%d vs %dx%d", orig_width, orig_height, width, height);

View File

@ -181,6 +181,7 @@ int device_set_decoder_start(device_t *dev, bool do_on)
E_LOG_DEBUG(dev, "Setting decoder state %s...", do_on ? "Start" : "Stop");
E_XIOCTL(dev, dev->fd, VIDIOC_DECODER_CMD, &cmd, "Cannot set decoder state");
dev->decoder_started = do_on;
return 0;
error:

View File

@ -15,6 +15,7 @@ typedef struct device_s {
struct device_s *output_device;
bool paused;
bool decoder_started;
} device_t;
device_t *device_open(const char *name, const char *path);

View File

@ -101,6 +101,11 @@ int links_enqueue_from_source(buffer_list_t *buf_list, link_t *link)
E_LOG_ERROR(buf_list, "No buffer dequeued from source?");
}
if (link->callbacks.validate_buffer && !link->callbacks.validate_buffer(link, buf)) {
E_LOG_DEBUG(buf_list, "Buffer rejected by validation");
return 0;
}
for (int j = 0; link->sinks[j]; j++) {
if (link->sinks[j]->device->paused) {
continue;

View File

@ -6,9 +6,11 @@
typedef struct buffer_s buffer_t;
typedef struct buffer_list_s buffer_list_t;
typedef struct link_s link_t;
typedef void (*link_on_buffer)(buffer_t *buf);
typedef bool (*link_check_streaming)();
typedef bool (*link_validate_buffer)(struct link_s *link, buffer_t *buf);
typedef struct link_s {
struct buffer_list_s *source; // capture_list
@ -16,6 +18,7 @@ typedef struct link_s {
struct {
link_on_buffer on_buffer;
link_check_streaming check_streaming;
link_validate_buffer validate_buffer;
} callbacks;
} link_t;