diff --git a/hw/buffer_list.c b/hw/buffer_list.c index 88ba5c5..1e7fbf3 100644 --- a/hw/buffer_list.c +++ b/hw/buffer_list.c @@ -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); diff --git a/hw/device.c b/hw/device.c index 4625e1d..29c0ced 100644 --- a/hw/device.c +++ b/hw/device.c @@ -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: diff --git a/hw/device.h b/hw/device.h index 459d31b..1d83270 100644 --- a/hw/device.h +++ b/hw/device.h @@ -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); diff --git a/hw/links.c b/hw/links.c index d88a87c..b4d5522 100644 --- a/hw/links.c +++ b/hw/links.c @@ -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; diff --git a/hw/links.h b/hw/links.h index f5c726c..360e6bd 100644 --- a/hw/links.h +++ b/hw/links.h @@ -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;