aire39
Posts: 29
Joined: Sat Sep 23, 2017 10:43 am

getting mmal buffer from queue timing

Fri Aug 23, 2019 12:09 am

I'm using the isp component for mmal to convert an image from rgba to yuv (i420). I'm using an already defined vcsm buffer as a data source
for the input buffer.

Code: Select all

input_port->encoding = MMAL_ENCODING_RGBA;
[...]
auto input_buffer_pool = mmal_port_create_buffers(input_port, 1/*num bufs*/, 0 /*buf size*/);
[...]
auto input_buffer = mmal_queue_wait(input_buffer_pool->queue); // this takes 16ms (?)
input_buffer->allloc_data = data_size;
input_buffer->length      = data_size;
input_buffer->data        = vcsm_hdl_to_hdl(vcsm_handle);

auto time_start = chrono...;
mmal_send_buffer(input_port, input_buffer);
auto time_start = chrono...;

// print out time... prints ~16ms

Code: Select all

void callback_inputbuffer(MMAL_PORT_T* port, MMAL_HEADER_BUFFER_T* buffer)
{
    mmal_buffer_header_release(buffer);
}

I'm noticing a 16ms wait time on the mmal_queue_wait call which doesn't make sense to me. This happens on the 1st call so I wouldn't expect this since the buffer should initially exist in the pool. I also noticed that for some reason the mmal_queue_wait would run 4ms more or less depending if the monitor was sleeping or awake. Is the isp tied to a displays refresh rate?

6by9
Raspberry Pi Engineer & Forum Moderator
Raspberry Pi Engineer & Forum Moderator
Posts: 7513
Joined: Wed Dec 04, 2013 11:27 am
Location: ZZ9 Plural Z Alpha, aka just outside Cambridge.

Re: getting mmal buffer from queue timing

Fri Aug 23, 2019 6:19 am

Odd. Check the queue length before calling the wait. https://github.com/raspberrypi/userland ... al_queue.c

The isp is driven off the vpu core clock. I'd need to check if that had frequency scaling, but I believe so due to the issues with the mini uart speeds changing due to clock changes. The display will put in a minimum clock speed requirement. The isp component probably doesn't.
Software Engineer at Raspberry Pi Trading. Views expressed are still personal views.
I'm not interested in doing contracts for bespoke functionality - please don't ask.

aire39
Posts: 29
Joined: Sat Sep 23, 2017 10:43 am

Re: getting mmal buffer from queue timing

Fri Aug 23, 2019 6:24 pm

So there was a problem in the way I was releasing the buffers for the output buffer pool. I would notice an ENOMEM. I have fixed that issue so when I check the queue size for both the input and output buffer pools I'm getting the correct length before grabbing a buffer.

I would like some insight into when the conversion takes place. I send the input buffer it takes ~16ms for it send and the input callback to happen. I set the input buffer data ptr to use a vcsm_hdl_ptr as the source as I'm passing an already generated frame through.

Does the conversion work get done on the send of the input buffer? or is a copy possibly being done?

Return to “Graphics programming”