3 * Copyright (c) 2015 Rodger Combs
5 * This file is part of Libav.
7 * Libav is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * Libav is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with Libav; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
28 #include <interface/mmal/mmal.h>
29 #include <interface/mmal/util/mmal_util.h>
30 #include <interface/mmal/util/mmal_util_params.h>
31 #include <interface/mmal/util/mmal_default_components.h>
32 #include <interface/mmal/vc/mmal_vc_api.h>
36 #include "libavutil/atomic.h"
37 #include "libavutil/avassert.h"
38 #include "libavutil/buffer.h"
39 #include "libavutil/common.h"
40 #include "libavutil/opt.h"
41 #include "libavutil/log.h"
43 typedef struct FFBufferEntry {
49 struct FFBufferEntry *next;
52 // MMAL_POOL_T destroys all of its MMAL_BUFFER_HEADER_Ts. If we want correct
53 // refcounting for AVFrames, we can free the MMAL_POOL_T only after all AVFrames
54 // have been unreferenced.
55 typedef struct FFPoolRef {
56 volatile int refcount;
60 typedef struct FFBufferRef {
61 MMAL_BUFFER_HEADER_T *buffer;
65 typedef struct MMALDecodeContext {
69 AVBitStreamFilterContext *bsfc;
71 MMAL_COMPONENT_T *decoder;
72 MMAL_QUEUE_T *queue_decoded_frames;
76 // Waiting input packets. Because the libavcodec API requires decoding and
77 // returning packets in lockstep, it can happen that queue_decoded_frames
78 // contains almost all surfaces - then the decoder input queue can quickly
79 // fill up and won't accept new input either. Without consuming input, the
80 // libavcodec API can't return new frames, and we have a logical deadlock.
81 // This is avoided by queuing such buffers here.
82 FFBufferEntry *waiting_buffers, *waiting_buffers_tail;
85 int64_t frames_output;
90 // Assume decoder is guaranteed to produce output after at least this many
91 // packets (where each packet contains 1 frame).
92 #define MAX_DELAYED_FRAMES 16
94 static void ffmmal_poolref_unref(FFPoolRef *ref)
96 if (ref && avpriv_atomic_int_add_and_fetch(&ref->refcount, -1) == 0) {
97 mmal_pool_destroy(ref->pool);
102 static void ffmmal_release_frame(void *opaque, uint8_t *data)
104 FFBufferRef *ref = (void *)data;
106 mmal_buffer_header_release(ref->buffer);
107 ffmmal_poolref_unref(ref->pool);
112 // Setup frame with a new reference to buffer. The buffer must have been
113 // allocated from the given pool.
114 static int ffmmal_set_ref(AVFrame *frame, FFPoolRef *pool,
115 MMAL_BUFFER_HEADER_T *buffer)
117 FFBufferRef *ref = av_mallocz(sizeof(*ref));
119 return AVERROR(ENOMEM);
122 ref->buffer = buffer;
124 frame->buf[0] = av_buffer_create((void *)ref, sizeof(*ref),
125 ffmmal_release_frame, NULL,
126 AV_BUFFER_FLAG_READONLY);
127 if (!frame->buf[0]) {
129 return AVERROR(ENOMEM);
132 avpriv_atomic_int_add_and_fetch(&ref->pool->refcount, 1);
133 mmal_buffer_header_acquire(buffer);
135 frame->format = AV_PIX_FMT_MMAL;
136 frame->data[3] = (uint8_t *)ref->buffer;
140 static void ffmmal_stop_decoder(AVCodecContext *avctx)
142 MMALDecodeContext *ctx = avctx->priv_data;
143 MMAL_COMPONENT_T *decoder = ctx->decoder;
144 MMAL_BUFFER_HEADER_T *buffer;
146 mmal_port_disable(decoder->input[0]);
147 mmal_port_disable(decoder->output[0]);
148 mmal_port_disable(decoder->control);
150 mmal_port_flush(decoder->input[0]);
151 mmal_port_flush(decoder->output[0]);
152 mmal_port_flush(decoder->control);
154 while ((buffer = mmal_queue_get(ctx->queue_decoded_frames)))
155 mmal_buffer_header_release(buffer);
157 while (ctx->waiting_buffers) {
158 FFBufferEntry *buffer = ctx->waiting_buffers;
160 ctx->waiting_buffers = buffer->next;
162 av_buffer_unref(&buffer->ref);
165 ctx->waiting_buffers_tail = NULL;
167 ctx->frames_output = ctx->eos_received = ctx->eos_sent = ctx->packets_sent = 0;
170 static av_cold int ffmmal_close_decoder(AVCodecContext *avctx)
172 MMALDecodeContext *ctx = avctx->priv_data;
175 ffmmal_stop_decoder(avctx);
177 mmal_component_destroy(ctx->decoder);
179 mmal_queue_destroy(ctx->queue_decoded_frames);
180 mmal_pool_destroy(ctx->pool_in);
181 ffmmal_poolref_unref(ctx->pool_out);
184 av_bitstream_filter_close(ctx->bsfc);
191 static void input_callback(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer)
194 AVBufferRef *buf = buffer->user_data;
195 av_buffer_unref(&buf);
197 mmal_buffer_header_release(buffer);
200 static void output_callback(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer)
202 AVCodecContext *avctx = (AVCodecContext*)port->userdata;
203 MMALDecodeContext *ctx = avctx->priv_data;
205 mmal_queue_put(ctx->queue_decoded_frames, buffer);
208 static void control_port_cb(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer)
210 AVCodecContext *avctx = (AVCodecContext*)port->userdata;
211 MMAL_STATUS_T status;
213 if (buffer->cmd == MMAL_EVENT_ERROR) {
214 status = *(uint32_t *)buffer->data;
215 av_log(avctx, AV_LOG_ERROR, "MMAL error %d on control port\n", (int)status);
218 av_get_codec_tag_string(s, sizeof(s), buffer->cmd);
219 av_log(avctx, AV_LOG_WARNING, "Unknown MMAL event %s on control port\n", s);
222 mmal_buffer_header_release(buffer);
225 // Feed free output buffers to the decoder.
226 static int ffmmal_fill_output_port(AVCodecContext *avctx)
228 MMALDecodeContext *ctx = avctx->priv_data;
229 MMAL_BUFFER_HEADER_T *buffer;
230 MMAL_STATUS_T status;
233 return AVERROR_UNKNOWN; // format change code failed with OOM previously
235 while ((buffer = mmal_queue_get(ctx->pool_out->pool->queue))) {
236 if ((status = mmal_port_send_buffer(ctx->decoder->output[0], buffer))) {
237 mmal_buffer_header_release(buffer);
238 av_log(avctx, AV_LOG_ERROR, "MMAL error %d when sending output buffer.\n", (int)status);
239 return AVERROR_UNKNOWN;
246 static enum AVColorSpace ffmmal_csp_to_av_csp(MMAL_FOURCC_T fourcc)
249 case MMAL_COLOR_SPACE_BT470_2_BG:
250 case MMAL_COLOR_SPACE_BT470_2_M:
251 case MMAL_COLOR_SPACE_ITUR_BT601: return AVCOL_SPC_BT470BG;
252 case MMAL_COLOR_SPACE_ITUR_BT709: return AVCOL_SPC_BT709;
253 case MMAL_COLOR_SPACE_FCC: return AVCOL_SPC_FCC;
254 case MMAL_COLOR_SPACE_SMPTE240M: return AVCOL_SPC_SMPTE240M;
255 default: return AVCOL_SPC_UNSPECIFIED;
259 static int ffmal_update_format(AVCodecContext *avctx)
261 MMALDecodeContext *ctx = avctx->priv_data;
262 MMAL_STATUS_T status;
264 MMAL_COMPONENT_T *decoder = ctx->decoder;
265 MMAL_ES_FORMAT_T *format_out = decoder->output[0]->format;
267 ffmmal_poolref_unref(ctx->pool_out);
268 if (!(ctx->pool_out = av_mallocz(sizeof(*ctx->pool_out)))) {
269 ret = AVERROR(ENOMEM);
272 ctx->pool_out->refcount = 1;
277 if ((status = mmal_port_parameter_set_uint32(decoder->output[0], MMAL_PARAMETER_EXTRA_BUFFERS, ctx->extra_buffers)))
280 if (avctx->pix_fmt == AV_PIX_FMT_MMAL) {
281 format_out->encoding = MMAL_ENCODING_OPAQUE;
283 format_out->encoding_variant = format_out->encoding = MMAL_ENCODING_I420;
286 if ((status = mmal_port_format_commit(decoder->output[0])))
289 if ((ret = ff_set_dimensions(avctx, format_out->es->video.crop.x + format_out->es->video.crop.width,
290 format_out->es->video.crop.y + format_out->es->video.crop.height)) < 0)
293 if (format_out->es->video.par.num && format_out->es->video.par.den) {
294 avctx->sample_aspect_ratio.num = format_out->es->video.par.num;
295 avctx->sample_aspect_ratio.den = format_out->es->video.par.den;
298 avctx->colorspace = ffmmal_csp_to_av_csp(format_out->es->video.color_space);
300 decoder->output[0]->buffer_size =
301 FFMAX(decoder->output[0]->buffer_size_min, decoder->output[0]->buffer_size_recommended);
302 decoder->output[0]->buffer_num =
303 FFMAX(decoder->output[0]->buffer_num_min, decoder->output[0]->buffer_num_recommended) + ctx->extra_buffers;
304 ctx->pool_out->pool = mmal_pool_create(decoder->output[0]->buffer_num,
305 decoder->output[0]->buffer_size);
306 if (!ctx->pool_out->pool) {
307 ret = AVERROR(ENOMEM);
314 return ret < 0 ? ret : AVERROR_UNKNOWN;
317 static av_cold int ffmmal_init_decoder(AVCodecContext *avctx)
319 MMALDecodeContext *ctx = avctx->priv_data;
320 MMAL_STATUS_T status;
321 MMAL_ES_FORMAT_T *format_in;
322 MMAL_COMPONENT_T *decoder;
327 if (mmal_vc_init()) {
328 av_log(avctx, AV_LOG_ERROR, "Cannot initialize MMAL VC driver!\n");
329 return AVERROR(ENOSYS);
332 if ((ret = ff_get_format(avctx, avctx->codec->pix_fmts)) < 0)
335 avctx->pix_fmt = ret;
337 if ((status = mmal_component_create(MMAL_COMPONENT_DEFAULT_VIDEO_DECODER, &ctx->decoder)))
340 decoder = ctx->decoder;
342 format_in = decoder->input[0]->format;
343 format_in->type = MMAL_ES_TYPE_VIDEO;
344 format_in->encoding = MMAL_ENCODING_H264;
345 format_in->es->video.width = FFALIGN(avctx->width, 32);
346 format_in->es->video.height = FFALIGN(avctx->height, 16);
347 format_in->es->video.crop.width = avctx->width;
348 format_in->es->video.crop.height = avctx->height;
349 format_in->es->video.frame_rate.num = 24000;
350 format_in->es->video.frame_rate.den = 1001;
351 format_in->es->video.par.num = avctx->sample_aspect_ratio.num;
352 format_in->es->video.par.den = avctx->sample_aspect_ratio.den;
353 format_in->flags = MMAL_ES_FORMAT_FLAG_FRAMED;
355 if (avctx->codec->id == AV_CODEC_ID_H264 && avctx->extradata && avctx->extradata[0] == 1) {
358 ctx->bsfc = av_bitstream_filter_init("h264_mp4toannexb");
360 av_log(avctx, AV_LOG_ERROR, "Cannot open the h264_mp4toannexb BSF!\n");
361 ret = AVERROR(ENOSYS);
364 av_bitstream_filter_filter(ctx->bsfc, avctx, NULL, &dummy_p, &dummy_int, NULL, 0, 0);
367 if (avctx->extradata_size) {
368 if ((status = mmal_format_extradata_alloc(format_in, avctx->extradata_size)))
370 format_in->extradata_size = avctx->extradata_size;
371 memcpy(format_in->extradata, avctx->extradata, format_in->extradata_size);
374 if ((status = mmal_port_format_commit(decoder->input[0])))
377 decoder->input[0]->buffer_num =
378 FFMAX(decoder->input[0]->buffer_num_min, 20);
379 decoder->input[0]->buffer_size =
380 FFMAX(decoder->input[0]->buffer_size_min, 512 * 1024);
381 ctx->pool_in = mmal_pool_create(decoder->input[0]->buffer_num, 0);
383 ret = AVERROR(ENOMEM);
387 if ((ret = ffmal_update_format(avctx)) < 0)
390 ctx->queue_decoded_frames = mmal_queue_create();
391 if (!ctx->queue_decoded_frames)
394 decoder->input[0]->userdata = (void*)avctx;
395 decoder->output[0]->userdata = (void*)avctx;
396 decoder->control->userdata = (void*)avctx;
398 if ((status = mmal_port_enable(decoder->control, control_port_cb)))
400 if ((status = mmal_port_enable(decoder->input[0], input_callback)))
402 if ((status = mmal_port_enable(decoder->output[0], output_callback)))
405 if ((status = mmal_component_enable(decoder)))
411 ffmmal_close_decoder(avctx);
412 return ret < 0 ? ret : AVERROR_UNKNOWN;
415 static void ffmmal_flush(AVCodecContext *avctx)
417 MMALDecodeContext *ctx = avctx->priv_data;
418 MMAL_COMPONENT_T *decoder = ctx->decoder;
419 MMAL_STATUS_T status;
421 ffmmal_stop_decoder(avctx);
423 if ((status = mmal_port_enable(decoder->control, control_port_cb)))
425 if ((status = mmal_port_enable(decoder->input[0], input_callback)))
427 if ((status = mmal_port_enable(decoder->output[0], output_callback)))
433 av_log(avctx, AV_LOG_ERROR, "MMAL flush error: %i\n", (int)status);
436 // Split packets and add them to the waiting_buffers list. We don't queue them
437 // immediately, because it can happen that the decoder is temporarily blocked
438 // (due to us not reading/returning enough output buffers) and won't accept
439 // new input. (This wouldn't be an issue if MMAL input buffers always were
440 // complete frames - then the input buffer just would have to be big enough.)
441 static int ffmmal_add_packet(AVCodecContext *avctx, AVPacket *avpkt)
443 MMALDecodeContext *ctx = avctx->priv_data;
444 AVBufferRef *buf = NULL;
446 uint8_t *data = (uint8_t *)"";
456 if ((ret = av_bitstream_filter_filter(ctx->bsfc, avctx, NULL,
457 &tmp_data, &tmp_size,
458 avpkt->data, avpkt->size,
459 avpkt->flags & AV_PKT_FLAG_KEY)) < 0)
461 buf = av_buffer_create(tmp_data, tmp_size, NULL, NULL, 0);
464 buf = av_buffer_ref(avpkt->buf);
466 buf = av_buffer_alloc(avpkt->size);
468 memcpy(buf->data, avpkt->data, avpkt->size);
472 ret = AVERROR(ENOMEM);
482 FFBufferEntry *buffer = av_mallocz(sizeof(*buffer));
484 ret = AVERROR(ENOMEM);
489 buffer->length = FFMIN(size, ctx->decoder->input[0]->buffer_size);
492 buffer->flags |= MMAL_BUFFER_HEADER_FLAG_FRAME_START;
494 data += buffer->length;
495 size -= buffer->length;
497 buffer->pts = avpkt->pts == AV_NOPTS_VALUE ? MMAL_TIME_UNKNOWN : avpkt->pts;
498 buffer->dts = avpkt->dts == AV_NOPTS_VALUE ? MMAL_TIME_UNKNOWN : avpkt->dts;
501 buffer->flags |= MMAL_BUFFER_HEADER_FLAG_FRAME_END;
503 if (!buffer->length) {
504 buffer->flags |= MMAL_BUFFER_HEADER_FLAG_EOS;
509 buffer->ref = av_buffer_ref(buf);
512 ret = AVERROR(ENOMEM);
517 // Insert at end of the list
518 if (!ctx->waiting_buffers)
519 ctx->waiting_buffers = buffer;
520 if (ctx->waiting_buffers_tail)
521 ctx->waiting_buffers_tail->next = buffer;
522 ctx->waiting_buffers_tail = buffer;
526 av_buffer_unref(&buf);
530 // Move prepared/split packets from waiting_buffers to the MMAL decoder.
531 static int ffmmal_fill_input_port(AVCodecContext *avctx)
533 MMALDecodeContext *ctx = avctx->priv_data;
535 while (ctx->waiting_buffers) {
536 MMAL_BUFFER_HEADER_T *mbuffer;
537 FFBufferEntry *buffer;
538 MMAL_STATUS_T status;
540 mbuffer = mmal_queue_get(ctx->pool_in->queue);
544 buffer = ctx->waiting_buffers;
546 mmal_buffer_header_reset(mbuffer);
548 mbuffer->pts = buffer->pts;
549 mbuffer->dts = buffer->dts;
550 mbuffer->flags = buffer->flags;
551 mbuffer->data = buffer->data;
552 mbuffer->length = buffer->length;
553 mbuffer->user_data = buffer->ref;
554 mbuffer->alloc_size = ctx->decoder->input[0]->buffer_size;
556 if ((status = mmal_port_send_buffer(ctx->decoder->input[0], mbuffer))) {
557 mmal_buffer_header_release(mbuffer);
558 av_buffer_unref(&buffer->ref);
561 // Remove from start of the list
562 ctx->waiting_buffers = buffer->next;
563 if (ctx->waiting_buffers_tail == buffer)
564 ctx->waiting_buffers_tail = NULL;
568 av_log(avctx, AV_LOG_ERROR, "MMAL error %d when sending input\n", (int)status);
569 return AVERROR_UNKNOWN;
576 static int ffmal_copy_frame(AVCodecContext *avctx, AVFrame *frame,
577 MMAL_BUFFER_HEADER_T *buffer)
579 MMALDecodeContext *ctx = avctx->priv_data;
582 if (avctx->pix_fmt == AV_PIX_FMT_MMAL) {
584 return AVERROR_UNKNOWN; // format change code failed with OOM previously
586 if ((ret = ff_decode_frame_props(avctx, frame)) < 0)
589 if ((ret = ffmmal_set_ref(frame, ctx->pool_out, buffer)) < 0)
592 int w = FFALIGN(avctx->width, 32);
593 int h = FFALIGN(avctx->height, 16);
598 if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
601 ptr = buffer->data + buffer->type->video.offset[0];
602 for (i = 0; i < avctx->height; i++)
603 memcpy(frame->data[0] + frame->linesize[0] * i, ptr + w * i, avctx->width);
607 for (plane = 1; plane < 3; plane++) {
608 for (i = 0; i < avctx->height / 2; i++)
609 memcpy(frame->data[plane] + frame->linesize[plane] * i, ptr + w / 2 * i, (avctx->width + 1) / 2);
610 ptr += w / 2 * h / 2;
614 if (buffer->pts != MMAL_TIME_UNKNOWN) {
615 frame->pkt_pts = buffer->pts;
616 frame->pts = buffer->pts;
623 // Fetch a decoded buffer and place it into the frame parameter.
624 static int ffmmal_read_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame)
626 MMALDecodeContext *ctx = avctx->priv_data;
627 MMAL_BUFFER_HEADER_T *buffer = NULL;
628 MMAL_STATUS_T status = 0;
631 if (ctx->eos_received)
635 // To ensure decoding in lockstep with a constant delay between fed packets
636 // and output frames, we always wait until an output buffer is available.
637 // Except during start we don't know after how many input packets the decoder
638 // is going to return the first buffer, and we can't distinguish decoder
639 // being busy from decoder waiting for input. So just poll at the start and
640 // keep feeding new data to the buffer.
641 // We are pretty sure the decoder will produce output if we sent more input
642 // frames than what a h264 decoder could logically delay. This avoids too
643 // excessive buffering.
644 // We also wait if we sent eos, but didn't receive it yet (think of decoding
645 // stream with a very low number of frames).
646 if (ctx->frames_output || ctx->packets_sent > MAX_DELAYED_FRAMES || ctx->eos_sent) {
647 buffer = mmal_queue_wait(ctx->queue_decoded_frames);
649 buffer = mmal_queue_get(ctx->queue_decoded_frames);
654 ctx->eos_received |= !!(buffer->flags & MMAL_BUFFER_HEADER_FLAG_EOS);
655 if (ctx->eos_received)
658 if (buffer->cmd == MMAL_EVENT_FORMAT_CHANGED) {
659 MMAL_COMPONENT_T *decoder = ctx->decoder;
660 MMAL_EVENT_FORMAT_CHANGED_T *ev = mmal_event_format_changed_get(buffer);
661 MMAL_BUFFER_HEADER_T *stale_buffer;
663 av_log(avctx, AV_LOG_INFO, "Changing output format.\n");
665 if ((status = mmal_port_disable(decoder->output[0])))
668 while ((stale_buffer = mmal_queue_get(ctx->queue_decoded_frames)))
669 mmal_buffer_header_release(stale_buffer);
671 mmal_format_copy(decoder->output[0]->format, ev->format);
673 if ((ret = ffmal_update_format(avctx)) < 0)
676 if ((status = mmal_port_enable(decoder->output[0], output_callback)))
679 if ((ret = ffmmal_fill_output_port(avctx)) < 0)
682 if ((ret = ffmmal_fill_input_port(avctx)) < 0)
685 mmal_buffer_header_release(buffer);
687 } else if (buffer->cmd) {
689 av_get_codec_tag_string(s, sizeof(s), buffer->cmd);
690 av_log(avctx, AV_LOG_WARNING, "Unknown MMAL event %s on output port\n", s);
692 } else if (buffer->length == 0) {
693 // Unused output buffer that got drained after format change.
694 mmal_buffer_header_release(buffer);
698 ctx->frames_output++;
700 if ((ret = ffmal_copy_frame(avctx, frame, buffer)) < 0)
709 mmal_buffer_header_release(buffer);
710 if (status && ret >= 0)
711 ret = AVERROR_UNKNOWN;
715 static int ffmmal_decode(AVCodecContext *avctx, void *data, int *got_frame,
718 AVFrame *frame = data;
721 if ((ret = ffmmal_add_packet(avctx, avpkt)) < 0)
724 if ((ret = ffmmal_fill_input_port(avctx)) < 0)
727 if ((ret = ffmmal_fill_output_port(avctx)) < 0)
730 if ((ret = ffmmal_read_frame(avctx, frame, got_frame)) < 0)
733 // ffmmal_read_frame() can block for a while. Since the decoder is
734 // asynchronous, it's a good idea to fill the ports again.
736 if ((ret = ffmmal_fill_output_port(avctx)) < 0)
739 if ((ret = ffmmal_fill_input_port(avctx)) < 0)
745 AVHWAccel ff_h264_mmal_hwaccel = {
747 .type = AVMEDIA_TYPE_VIDEO,
748 .id = AV_CODEC_ID_H264,
749 .pix_fmt = AV_PIX_FMT_MMAL,
752 static const AVOption options[]={
753 {"extra_buffers", "extra buffers", offsetof(MMALDecodeContext, extra_buffers), AV_OPT_TYPE_INT, {.i64 = 10}, 0, 256, 0},
757 static const AVClass ffmmaldec_class = {
758 .class_name = "mmaldec",
760 .version = LIBAVUTIL_VERSION_INT,
763 AVCodec ff_h264_mmal_decoder = {
765 .long_name = NULL_IF_CONFIG_SMALL("h264 (mmal)"),
766 .type = AVMEDIA_TYPE_VIDEO,
767 .id = AV_CODEC_ID_H264,
768 .priv_data_size = sizeof(MMALDecodeContext),
769 .init = ffmmal_init_decoder,
770 .close = ffmmal_close_decoder,
771 .decode = ffmmal_decode,
772 .flush = ffmmal_flush,
773 .priv_class = &ffmmaldec_class,
774 .capabilities = AV_CODEC_CAP_DELAY,
775 .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_MMAL,