Improve FPS handling
This commit is contained in:
parent
08811b747b
commit
c817f73051
@ -54,11 +54,6 @@ int camera_configure_isp(camera_t *camera, float high_div, float low_div)
|
|||||||
|
|
||||||
link_t *links = camera->links;
|
link_t *links = camera->links;
|
||||||
|
|
||||||
if (camera->options.fps > 0) {
|
|
||||||
camera->codec_jpeg->capture_list->fmt_interval_us = 1000 * 1000 / camera->options.fps;
|
|
||||||
printf("buffer_lock.c: frame interval: %d\n", camera->codec_jpeg->capture_list->fmt_interval_us);
|
|
||||||
}
|
|
||||||
|
|
||||||
*links++ = (link_t){ camera->camera->capture_list, { camera->isp_srgb->output_list } };
|
*links++ = (link_t){ camera->camera->capture_list, { camera->isp_srgb->output_list } };
|
||||||
|
|
||||||
if (camera->isp_yuuv_low) {
|
if (camera->isp_yuuv_low) {
|
||||||
|
@ -47,10 +47,10 @@ void buffer_lock_capture(buffer_lock_t *buf_lock, buffer_t *buf)
|
|||||||
buffer_consumed(buf_lock->buf, buf_lock->name);
|
buffer_consumed(buf_lock->buf, buf_lock->name);
|
||||||
buf_lock->buf = NULL;
|
buf_lock->buf = NULL;
|
||||||
buf_lock->buf_time_us = now;
|
buf_lock->buf_time_us = now;
|
||||||
} else if (now - buf_lock->buf_time_us < buf->buf_list->fmt_interval_us) {
|
} else if (now - buf_lock->buf_time_us < buf_lock->frame_interval_ms * 1000) {
|
||||||
buf_lock->dropped++;
|
buf_lock->dropped++;
|
||||||
|
|
||||||
E_LOG_DEBUG(buf_lock, "Dropped buffer %s (refs=%d), frame=%d/%d, frame_us=%.1f",
|
E_LOG_DEBUG(buf_lock, "Dropped buffer %s (refs=%d), frame=%d/%d, frame_ms=%.1f",
|
||||||
dev_name(buf), buf ? buf->mmap_reflinks : 0,
|
dev_name(buf), buf ? buf->mmap_reflinks : 0,
|
||||||
buf_lock->counter, buf_lock->dropped,
|
buf_lock->counter, buf_lock->dropped,
|
||||||
(now - captured_time_us) / 1000.0f);
|
(now - captured_time_us) / 1000.0f);
|
||||||
@ -59,7 +59,7 @@ void buffer_lock_capture(buffer_lock_t *buf_lock, buffer_t *buf)
|
|||||||
buffer_use(buf);
|
buffer_use(buf);
|
||||||
buf_lock->buf = buf;
|
buf_lock->buf = buf;
|
||||||
buf_lock->counter++;
|
buf_lock->counter++;
|
||||||
E_LOG_DEBUG(buf_lock, "Captured buffer %s (refs=%d), frame=%d/%d, processing_us=%.1f, frame_us=%.1f",
|
E_LOG_DEBUG(buf_lock, "Captured buffer %s (refs=%d), frame=%d/%d, processing_ms=%.1f, frame_ms=%.1f",
|
||||||
dev_name(buf), buf ? buf->mmap_reflinks : 0,
|
dev_name(buf), buf ? buf->mmap_reflinks : 0,
|
||||||
buf_lock->counter, buf_lock->dropped,
|
buf_lock->counter, buf_lock->dropped,
|
||||||
(now - captured_time_us) / 1000.0f,
|
(now - captured_time_us) / 1000.0f,
|
||||||
|
@ -14,6 +14,8 @@ typedef struct buffer_lock_s {
|
|||||||
int refs;
|
int refs;
|
||||||
int dropped;
|
int dropped;
|
||||||
uint64_t timeout_us;
|
uint64_t timeout_us;
|
||||||
|
|
||||||
|
int frame_interval_ms;
|
||||||
} buffer_lock_t;
|
} buffer_lock_t;
|
||||||
|
|
||||||
#define DEFAULT_BUFFER_LOCK_TIMEOUT 16 // ~60fps
|
#define DEFAULT_BUFFER_LOCK_TIMEOUT 16 // ~60fps
|
||||||
|
@ -67,10 +67,16 @@ int _build_fds(link_t *all_links, struct pollfd *fds, link_t **links, buffer_lis
|
|||||||
}
|
}
|
||||||
|
|
||||||
int count_enqueued = buffer_list_count_enqueued(source);
|
int count_enqueued = buffer_list_count_enqueued(source);
|
||||||
|
bool can_dequeue = count_enqueued > 0;
|
||||||
|
|
||||||
|
if (now_us - source->last_dequeued_us < source->fmt_interval_us) {
|
||||||
|
can_dequeue = false;
|
||||||
|
*max_timeout_ms = MIN(*max_timeout_ms, (source->last_dequeued_us + source->fmt_interval_us - now_us) / 1000);
|
||||||
|
}
|
||||||
|
|
||||||
fds[n].fd = source->device->fd;
|
fds[n].fd = source->device->fd;
|
||||||
fds[n].events = POLLHUP;
|
fds[n].events = POLLHUP;
|
||||||
if (count_enqueued > 0)
|
if (can_dequeue)
|
||||||
fds[n].events |= POLLIN;
|
fds[n].events |= POLLIN;
|
||||||
fds[n].revents = 0;
|
fds[n].revents = 0;
|
||||||
buf_lists[n] = source;
|
buf_lists[n] = source;
|
||||||
|
@ -11,6 +11,9 @@ typedef struct log_options_s {
|
|||||||
|
|
||||||
extern log_options_t log_options;
|
extern log_options_t log_options;
|
||||||
|
|
||||||
|
#define MIN(a, b) ((a) < (b) ? (a) : (b))
|
||||||
|
#define MAX(a, b) ((a) > (b) ? (a) : (b))
|
||||||
|
|
||||||
// assumes that name is first item
|
// assumes that name is first item
|
||||||
#define dev_name(dev) (dev ? *(const char**)dev : "?")
|
#define dev_name(dev) (dev ? *(const char**)dev : "?")
|
||||||
#define E_LOG_ERROR(dev, _msg, ...) do { fprintf(stderr, "%s: %s: " _msg "\n", __FILENAME__, dev_name(dev), ##__VA_ARGS__); goto error; } while(0)
|
#define E_LOG_ERROR(dev, _msg, ...) do { fprintf(stderr, "%s: %s: " _msg "\n", __FILENAME__, dev_name(dev), ##__VA_ARGS__); goto error; } while(0)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user