Commit 23ac1163 authored by Julian Scheel's avatar Julian Scheel Committed by Rémi Denis-Courmont

mmal/deinterlace: Explicitly count buffers in transit

The previous approach of calculating the buffers in transit was broken because
it assumed that buffers which were currently processed in the video output
stage are in transit. In fact only those buffers which are currently handed
off to the mmal output port of the filter plugin are to be counted as buffers
in transit. Fixing this avoids some framedrops due to missing/late buffers.
Signed-off-by: default avatarJulian Scheel <julian@jusst.de>
Signed-off-by: default avatarRémi Denis-Courmont <remi@remlab.net>
parent 152c5ba4
...@@ -66,6 +66,9 @@ struct filter_sys_t { ...@@ -66,6 +66,9 @@ struct filter_sys_t {
MMAL_QUEUE_T *filtered_pictures; MMAL_QUEUE_T *filtered_pictures;
vlc_mutex_t mutex; vlc_mutex_t mutex;
/* statistics */
int output_in_transit;
}; };
static void control_port_cb(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer); static void control_port_cb(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer);
...@@ -365,6 +368,7 @@ static int send_output_buffer(filter_t *filter) ...@@ -365,6 +368,7 @@ static int send_output_buffer(filter_t *filter)
ret = -1; ret = -1;
goto out; goto out;
} }
sys->output_in_transit++;
out: out:
return ret; return ret;
...@@ -377,9 +381,7 @@ static void fill_output_port(filter_t *filter) ...@@ -377,9 +381,7 @@ static void fill_output_port(filter_t *filter)
unsigned max_buffers_in_transit = __MAX(sys->output->buffer_num, unsigned max_buffers_in_transit = __MAX(sys->output->buffer_num,
MIN_NUM_BUFFERS_IN_TRANSIT); MIN_NUM_BUFFERS_IN_TRANSIT);
unsigned buffers_available = mmal_queue_length(sys->output_pool->queue); unsigned buffers_available = mmal_queue_length(sys->output_pool->queue);
unsigned buffers_in_transit = sys->output_pool->headers_num - buffers_available - unsigned buffers_to_send = max_buffers_in_transit - sys->output_in_transit;
mmal_queue_length(sys->filtered_pictures);
unsigned buffers_to_send = max_buffers_in_transit - buffers_in_transit;
unsigned i; unsigned i;
if (buffers_to_send > buffers_available) if (buffers_to_send > buffers_available)
...@@ -387,7 +389,7 @@ static void fill_output_port(filter_t *filter) ...@@ -387,7 +389,7 @@ static void fill_output_port(filter_t *filter)
#ifndef NDEBUG #ifndef NDEBUG
msg_Dbg(filter, "Send %d buffers to output port (available: %d, in_transit: %d, buffer_num: %d)", msg_Dbg(filter, "Send %d buffers to output port (available: %d, in_transit: %d, buffer_num: %d)",
buffers_to_send, buffers_available, buffers_in_transit, buffers_to_send, buffers_available, sys->output_in_transit,
sys->output->buffer_num); sys->output->buffer_num);
#endif #endif
for (i = 0; i < buffers_to_send; ++i) { for (i = 0; i < buffers_to_send; ++i) {
...@@ -499,6 +501,7 @@ static void output_port_cb(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer) ...@@ -499,6 +501,7 @@ static void output_port_cb(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer)
picture_Release(picture); picture_Release(picture);
buffer->user_data = NULL; buffer->user_data = NULL;
} }
sys->output_in_transit--;
} else if (buffer->cmd == MMAL_EVENT_FORMAT_CHANGED) { } else if (buffer->cmd == MMAL_EVENT_FORMAT_CHANGED) {
msg_Warn(filter, "MMAL_EVENT_FORMAT_CHANGED seen but not handled"); msg_Warn(filter, "MMAL_EVENT_FORMAT_CHANGED seen but not handled");
mmal_buffer_header_release(buffer); mmal_buffer_header_release(buffer);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment