diff --git a/modules/hw/mmal/codec.c b/modules/hw/mmal/codec.c index 1f2dfe25ad6a598a08ccac2b00fa354d085c051a..0d856de2a13d8370b37edada09b5cc1e834700e1 100644 --- a/modules/hw/mmal/codec.c +++ b/modules/hw/mmal/codec.c @@ -392,7 +392,6 @@ static int send_output_buffer(decoder_t *dec) picture_sys_t *p_sys; picture_t *picture = NULL; MMAL_STATUS_T status; - unsigned buffer_size = 0; int ret = 0; if (!sys->output->is_enabled) @@ -417,12 +416,10 @@ static int send_output_buffer(decoder_t *dec) } p_sys = picture->p_sys; - for (int i = 0; i < picture->i_planes; i++) - buffer_size += picture->p[i].i_lines * picture->p[i].i_pitch; - if (sys->output_pool) { - mmal_buffer_header_reset(buffer); - buffer->alloc_size = sys->output->buffer_size; + unsigned buffer_size = 0; + for (int i = 0; i < picture->i_planes; i++) + buffer_size += picture->p[i].i_lines * picture->p[i].i_pitch; if (buffer_size < sys->output->buffer_size) { msg_Err(dec, "Retrieved picture with too small data block (%d < %d)", buffer_size, sys->output->buffer_size); @@ -430,6 +427,9 @@ static int send_output_buffer(decoder_t *dec) goto err; } + mmal_buffer_header_reset(buffer); + buffer->alloc_size = sys->output->buffer_size; + if (!sys->opaque) buffer->data = picture->p[0].p_pixels; } else {