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/mmal_parameters_video.h>
30 #include <interface/mmal/util/mmal_util.h>
31 #include <interface/mmal/util/mmal_util_params.h>
32 #include <interface/mmal/util/mmal_default_components.h>
33 #include <interface/mmal/vc/mmal_vc_api.h>
37 #include "libavutil/atomic.h"
38 #include "libavutil/avassert.h"
39 #include "libavutil/buffer.h"
40 #include "libavutil/common.h"
41 #include "libavutil/opt.h"
42 #include "libavutil/log.h"
44 typedef struct FFBufferEntry {
50 struct FFBufferEntry *next;
53 // MMAL_POOL_T destroys all of its MMAL_BUFFER_HEADER_Ts. If we want correct
54 // refcounting for AVFrames, we can free the MMAL_POOL_T only after all AVFrames
55 // have been unreferenced.
56 typedef struct FFPoolRef {
57 volatile int refcount;
61 typedef struct FFBufferRef {
62 MMAL_BUFFER_HEADER_T *buffer;
66 typedef struct MMALDecodeContext {
70 MMAL_COMPONENT_T *decoder;
71 MMAL_QUEUE_T *queue_decoded_frames;
75 // Waiting input packets. Because the libavcodec API requires decoding and
76 // returning packets in lockstep, it can happen that queue_decoded_frames
77 // contains almost all surfaces - then the decoder input queue can quickly
78 // fill up and won't accept new input either. Without consuming input, the
79 // libavcodec API can't return new frames, and we have a logical deadlock.
80 // This is avoided by queuing such buffers here.
81 FFBufferEntry *waiting_buffers, *waiting_buffers_tail;
84 volatile int packets_buffered;
85 int64_t frames_output;
91 // Assume decoder is guaranteed to produce output after at least this many
92 // packets (where each packet contains 1 frame).
93 #define MAX_DELAYED_FRAMES 16
95 static void ffmmal_poolref_unref(FFPoolRef *ref)
97 if (ref && avpriv_atomic_int_add_and_fetch(&ref->refcount, -1) == 0) {
98 mmal_pool_destroy(ref->pool);
103 static void ffmmal_release_frame(void *opaque, uint8_t *data)
105 FFBufferRef *ref = (void *)data;
107 mmal_buffer_header_release(ref->buffer);
108 ffmmal_poolref_unref(ref->pool);
113 // Setup frame with a new reference to buffer. The buffer must have been
114 // allocated from the given pool.
115 static int ffmmal_set_ref(AVFrame *frame, FFPoolRef *pool,
116 MMAL_BUFFER_HEADER_T *buffer)
118 FFBufferRef *ref = av_mallocz(sizeof(*ref));
120 return AVERROR(ENOMEM);
123 ref->buffer = buffer;
125 frame->buf[0] = av_buffer_create((void *)ref, sizeof(*ref),
126 ffmmal_release_frame, NULL,
127 AV_BUFFER_FLAG_READONLY);
128 if (!frame->buf[0]) {
130 return AVERROR(ENOMEM);
133 avpriv_atomic_int_add_and_fetch(&ref->pool->refcount, 1);
134 mmal_buffer_header_acquire(buffer);
136 frame->format = AV_PIX_FMT_MMAL;
137 frame->data[3] = (uint8_t *)ref->buffer;
141 static void ffmmal_stop_decoder(AVCodecContext *avctx)
143 MMALDecodeContext *ctx = avctx->priv_data;
144 MMAL_COMPONENT_T *decoder = ctx->decoder;
145 MMAL_BUFFER_HEADER_T *buffer;
147 mmal_port_disable(decoder->input[0]);
148 mmal_port_disable(decoder->output[0]);
149 mmal_port_disable(decoder->control);
151 mmal_port_flush(decoder->input[0]);
152 mmal_port_flush(decoder->output[0]);
153 mmal_port_flush(decoder->control);
155 while ((buffer = mmal_queue_get(ctx->queue_decoded_frames)))
156 mmal_buffer_header_release(buffer);
158 while (ctx->waiting_buffers) {
159 FFBufferEntry *buffer = ctx->waiting_buffers;
161 ctx->waiting_buffers = buffer->next;
163 av_buffer_unref(&buffer->ref);
166 ctx->waiting_buffers_tail = NULL;
168 assert(avpriv_atomic_get(&ctx->packets_buffered) == 0);
170 ctx->frames_output = ctx->eos_received = ctx->eos_sent = ctx->packets_sent = ctx->extradata_sent = 0;
173 static av_cold int ffmmal_close_decoder(AVCodecContext *avctx)
175 MMALDecodeContext *ctx = avctx->priv_data;
178 ffmmal_stop_decoder(avctx);
180 mmal_component_destroy(ctx->decoder);
182 mmal_queue_destroy(ctx->queue_decoded_frames);
183 mmal_pool_destroy(ctx->pool_in);
184 ffmmal_poolref_unref(ctx->pool_out);
191 static void input_callback(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer)
193 AVCodecContext *avctx = (AVCodecContext*)port->userdata;
194 MMALDecodeContext *ctx = avctx->priv_data;
197 FFBufferEntry *entry = buffer->user_data;
198 av_buffer_unref(&entry->ref);
199 if (entry->flags & MMAL_BUFFER_HEADER_FLAG_FRAME_END)
200 avpriv_atomic_int_add_and_fetch(&ctx->packets_buffered, -1);
203 mmal_buffer_header_release(buffer);
206 static void output_callback(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer)
208 AVCodecContext *avctx = (AVCodecContext*)port->userdata;
209 MMALDecodeContext *ctx = avctx->priv_data;
211 mmal_queue_put(ctx->queue_decoded_frames, buffer);
214 static void control_port_cb(MMAL_PORT_T *port, MMAL_BUFFER_HEADER_T *buffer)
216 AVCodecContext *avctx = (AVCodecContext*)port->userdata;
217 MMAL_STATUS_T status;
219 if (buffer->cmd == MMAL_EVENT_ERROR) {
220 status = *(uint32_t *)buffer->data;
221 av_log(avctx, AV_LOG_ERROR, "MMAL error %d on control port\n", (int)status);
224 av_get_codec_tag_string(s, sizeof(s), buffer->cmd);
225 av_log(avctx, AV_LOG_WARNING, "Unknown MMAL event %s on control port\n", s);
228 mmal_buffer_header_release(buffer);
231 // Feed free output buffers to the decoder.
232 static int ffmmal_fill_output_port(AVCodecContext *avctx)
234 MMALDecodeContext *ctx = avctx->priv_data;
235 MMAL_BUFFER_HEADER_T *buffer;
236 MMAL_STATUS_T status;
239 return AVERROR_UNKNOWN; // format change code failed with OOM previously
241 while ((buffer = mmal_queue_get(ctx->pool_out->pool->queue))) {
242 if ((status = mmal_port_send_buffer(ctx->decoder->output[0], buffer))) {
243 mmal_buffer_header_release(buffer);
244 av_log(avctx, AV_LOG_ERROR, "MMAL error %d when sending output buffer.\n", (int)status);
245 return AVERROR_UNKNOWN;
252 static enum AVColorSpace ffmmal_csp_to_av_csp(MMAL_FOURCC_T fourcc)
255 case MMAL_COLOR_SPACE_BT470_2_BG:
256 case MMAL_COLOR_SPACE_BT470_2_M:
257 case MMAL_COLOR_SPACE_ITUR_BT601: return AVCOL_SPC_BT470BG;
258 case MMAL_COLOR_SPACE_ITUR_BT709: return AVCOL_SPC_BT709;
259 case MMAL_COLOR_SPACE_FCC: return AVCOL_SPC_FCC;
260 case MMAL_COLOR_SPACE_SMPTE240M: return AVCOL_SPC_SMPTE240M;
261 default: return AVCOL_SPC_UNSPECIFIED;
265 static int ffmal_update_format(AVCodecContext *avctx)
267 MMALDecodeContext *ctx = avctx->priv_data;
268 MMAL_STATUS_T status;
270 MMAL_COMPONENT_T *decoder = ctx->decoder;
271 MMAL_ES_FORMAT_T *format_out = decoder->output[0]->format;
273 ffmmal_poolref_unref(ctx->pool_out);
274 if (!(ctx->pool_out = av_mallocz(sizeof(*ctx->pool_out)))) {
275 ret = AVERROR(ENOMEM);
278 ctx->pool_out->refcount = 1;
283 if ((status = mmal_port_parameter_set_uint32(decoder->output[0], MMAL_PARAMETER_EXTRA_BUFFERS, ctx->extra_buffers)))
286 if ((status = mmal_port_parameter_set_boolean(decoder->output[0], MMAL_PARAMETER_VIDEO_INTERPOLATE_TIMESTAMPS, 0)))
289 if (avctx->pix_fmt == AV_PIX_FMT_MMAL) {
290 format_out->encoding = MMAL_ENCODING_OPAQUE;
292 format_out->encoding_variant = format_out->encoding = MMAL_ENCODING_I420;
295 if ((status = mmal_port_format_commit(decoder->output[0])))
298 if ((ret = ff_set_dimensions(avctx, format_out->es->video.crop.x + format_out->es->video.crop.width,
299 format_out->es->video.crop.y + format_out->es->video.crop.height)) < 0)
302 if (format_out->es->video.par.num && format_out->es->video.par.den) {
303 avctx->sample_aspect_ratio.num = format_out->es->video.par.num;
304 avctx->sample_aspect_ratio.den = format_out->es->video.par.den;
307 avctx->colorspace = ffmmal_csp_to_av_csp(format_out->es->video.color_space);
309 decoder->output[0]->buffer_size =
310 FFMAX(decoder->output[0]->buffer_size_min, decoder->output[0]->buffer_size_recommended);
311 decoder->output[0]->buffer_num =
312 FFMAX(decoder->output[0]->buffer_num_min, decoder->output[0]->buffer_num_recommended) + ctx->extra_buffers;
313 ctx->pool_out->pool = mmal_pool_create(decoder->output[0]->buffer_num,
314 decoder->output[0]->buffer_size);
315 if (!ctx->pool_out->pool) {
316 ret = AVERROR(ENOMEM);
323 return ret < 0 ? ret : AVERROR_UNKNOWN;
326 static av_cold int ffmmal_init_decoder(AVCodecContext *avctx)
328 MMALDecodeContext *ctx = avctx->priv_data;
329 MMAL_STATUS_T status;
330 MMAL_ES_FORMAT_T *format_in;
331 MMAL_COMPONENT_T *decoder;
336 if (mmal_vc_init()) {
337 av_log(avctx, AV_LOG_ERROR, "Cannot initialize MMAL VC driver!\n");
338 return AVERROR(ENOSYS);
341 if ((ret = ff_get_format(avctx, avctx->codec->pix_fmts)) < 0)
344 avctx->pix_fmt = ret;
346 if ((status = mmal_component_create(MMAL_COMPONENT_DEFAULT_VIDEO_DECODER, &ctx->decoder)))
349 decoder = ctx->decoder;
351 format_in = decoder->input[0]->format;
352 format_in->type = MMAL_ES_TYPE_VIDEO;
353 format_in->encoding = MMAL_ENCODING_H264;
354 format_in->es->video.width = FFALIGN(avctx->width, 32);
355 format_in->es->video.height = FFALIGN(avctx->height, 16);
356 format_in->es->video.crop.width = avctx->width;
357 format_in->es->video.crop.height = avctx->height;
358 format_in->es->video.frame_rate.num = 24000;
359 format_in->es->video.frame_rate.den = 1001;
360 format_in->es->video.par.num = avctx->sample_aspect_ratio.num;
361 format_in->es->video.par.den = avctx->sample_aspect_ratio.den;
362 format_in->flags = MMAL_ES_FORMAT_FLAG_FRAMED;
364 if ((status = mmal_port_format_commit(decoder->input[0])))
367 decoder->input[0]->buffer_num =
368 FFMAX(decoder->input[0]->buffer_num_min, 20);
369 decoder->input[0]->buffer_size =
370 FFMAX(decoder->input[0]->buffer_size_min, 512 * 1024);
371 ctx->pool_in = mmal_pool_create(decoder->input[0]->buffer_num, 0);
373 ret = AVERROR(ENOMEM);
377 if ((ret = ffmal_update_format(avctx)) < 0)
380 ctx->queue_decoded_frames = mmal_queue_create();
381 if (!ctx->queue_decoded_frames)
384 decoder->input[0]->userdata = (void*)avctx;
385 decoder->output[0]->userdata = (void*)avctx;
386 decoder->control->userdata = (void*)avctx;
388 if ((status = mmal_port_enable(decoder->control, control_port_cb)))
390 if ((status = mmal_port_enable(decoder->input[0], input_callback)))
392 if ((status = mmal_port_enable(decoder->output[0], output_callback)))
395 if ((status = mmal_component_enable(decoder)))
401 ffmmal_close_decoder(avctx);
402 return ret < 0 ? ret : AVERROR_UNKNOWN;
405 static void ffmmal_flush(AVCodecContext *avctx)
407 MMALDecodeContext *ctx = avctx->priv_data;
408 MMAL_COMPONENT_T *decoder = ctx->decoder;
409 MMAL_STATUS_T status;
411 ffmmal_stop_decoder(avctx);
413 if ((status = mmal_port_enable(decoder->control, control_port_cb)))
415 if ((status = mmal_port_enable(decoder->input[0], input_callback)))
417 if ((status = mmal_port_enable(decoder->output[0], output_callback)))
423 av_log(avctx, AV_LOG_ERROR, "MMAL flush error: %i\n", (int)status);
426 // Split packets and add them to the waiting_buffers list. We don't queue them
427 // immediately, because it can happen that the decoder is temporarily blocked
428 // (due to us not reading/returning enough output buffers) and won't accept
429 // new input. (This wouldn't be an issue if MMAL input buffers always were
430 // complete frames - then the input buffer just would have to be big enough.)
431 // If is_extradata is set, send it as MMAL_BUFFER_HEADER_FLAG_CONFIG.
432 static int ffmmal_add_packet(AVCodecContext *avctx, AVPacket *avpkt,
435 MMALDecodeContext *ctx = avctx->priv_data;
436 AVBufferRef *buf = NULL;
438 uint8_t *data = (uint8_t *)"";
444 buf = av_buffer_ref(avpkt->buf);
448 buf = av_buffer_alloc(avpkt->size);
450 memcpy(buf->data, avpkt->data, avpkt->size);
456 ret = AVERROR(ENOMEM);
462 if (!ctx->packets_sent) {
463 // Short-cut the flush logic to avoid upsetting MMAL.
465 ctx->eos_received = 1;
473 FFBufferEntry *buffer = av_mallocz(sizeof(*buffer));
475 ret = AVERROR(ENOMEM);
480 buffer->length = FFMIN(size, ctx->decoder->input[0]->buffer_size);
483 buffer->flags |= MMAL_BUFFER_HEADER_FLAG_CONFIG;
486 buffer->flags |= MMAL_BUFFER_HEADER_FLAG_FRAME_START;
488 data += buffer->length;
489 size -= buffer->length;
491 buffer->pts = avpkt->pts == AV_NOPTS_VALUE ? MMAL_TIME_UNKNOWN : avpkt->pts;
492 buffer->dts = avpkt->dts == AV_NOPTS_VALUE ? MMAL_TIME_UNKNOWN : avpkt->dts;
495 buffer->flags |= MMAL_BUFFER_HEADER_FLAG_FRAME_END;
496 avpriv_atomic_int_add_and_fetch(&ctx->packets_buffered, 1);
499 if (!buffer->length) {
500 buffer->flags |= MMAL_BUFFER_HEADER_FLAG_EOS;
505 buffer->ref = av_buffer_ref(buf);
508 ret = AVERROR(ENOMEM);
513 // Insert at end of the list
514 if (!ctx->waiting_buffers)
515 ctx->waiting_buffers = buffer;
516 if (ctx->waiting_buffers_tail)
517 ctx->waiting_buffers_tail->next = buffer;
518 ctx->waiting_buffers_tail = buffer;
522 av_buffer_unref(&buf);
526 // Move prepared/split packets from waiting_buffers to the MMAL decoder.
527 static int ffmmal_fill_input_port(AVCodecContext *avctx)
529 MMALDecodeContext *ctx = avctx->priv_data;
531 while (ctx->waiting_buffers) {
532 MMAL_BUFFER_HEADER_T *mbuffer;
533 FFBufferEntry *buffer;
534 MMAL_STATUS_T status;
536 mbuffer = mmal_queue_get(ctx->pool_in->queue);
540 buffer = ctx->waiting_buffers;
542 mmal_buffer_header_reset(mbuffer);
544 mbuffer->pts = buffer->pts;
545 mbuffer->dts = buffer->dts;
546 mbuffer->flags = buffer->flags;
547 mbuffer->data = buffer->data;
548 mbuffer->length = buffer->length;
549 mbuffer->user_data = buffer;
550 mbuffer->alloc_size = ctx->decoder->input[0]->buffer_size;
552 // Remove from start of the list
553 ctx->waiting_buffers = buffer->next;
554 if (ctx->waiting_buffers_tail == buffer)
555 ctx->waiting_buffers_tail = NULL;
557 if ((status = mmal_port_send_buffer(ctx->decoder->input[0], mbuffer))) {
558 mmal_buffer_header_release(mbuffer);
559 av_buffer_unref(&buffer->ref);
560 if (buffer->flags & MMAL_BUFFER_HEADER_FLAG_FRAME_END)
561 avpriv_atomic_int_add_and_fetch(&ctx->packets_buffered, -1);
566 av_log(avctx, AV_LOG_ERROR, "MMAL error %d when sending input\n", (int)status);
567 return AVERROR_UNKNOWN;
574 static int ffmal_copy_frame(AVCodecContext *avctx, AVFrame *frame,
575 MMAL_BUFFER_HEADER_T *buffer)
577 MMALDecodeContext *ctx = avctx->priv_data;
580 if (avctx->pix_fmt == AV_PIX_FMT_MMAL) {
582 return AVERROR_UNKNOWN; // format change code failed with OOM previously
584 if ((ret = ff_decode_frame_props(avctx, frame)) < 0)
587 if ((ret = ffmmal_set_ref(frame, ctx->pool_out, buffer)) < 0)
590 int w = FFALIGN(avctx->width, 32);
591 int h = FFALIGN(avctx->height, 16);
596 if ((ret = ff_get_buffer(avctx, frame, 0)) < 0)
599 ptr = buffer->data + buffer->type->video.offset[0];
600 for (i = 0; i < avctx->height; i++)
601 memcpy(frame->data[0] + frame->linesize[0] * i, ptr + w * i, avctx->width);
605 for (plane = 1; plane < 3; plane++) {
606 for (i = 0; i < avctx->height / 2; i++)
607 memcpy(frame->data[plane] + frame->linesize[plane] * i, ptr + w / 2 * i, (avctx->width + 1) / 2);
608 ptr += w / 2 * h / 2;
612 frame->pkt_pts = buffer->pts == MMAL_TIME_UNKNOWN ? AV_NOPTS_VALUE : buffer->pts;
613 frame->pkt_dts = AV_NOPTS_VALUE;
619 // Fetch a decoded buffer and place it into the frame parameter.
620 static int ffmmal_read_frame(AVCodecContext *avctx, AVFrame *frame, int *got_frame)
622 MMALDecodeContext *ctx = avctx->priv_data;
623 MMAL_BUFFER_HEADER_T *buffer = NULL;
624 MMAL_STATUS_T status = 0;
627 if (ctx->eos_received)
631 // To ensure decoding in lockstep with a constant delay between fed packets
632 // and output frames, we always wait until an output buffer is available.
633 // Except during start we don't know after how many input packets the decoder
634 // is going to return the first buffer, and we can't distinguish decoder
635 // being busy from decoder waiting for input. So just poll at the start and
636 // keep feeding new data to the buffer.
637 // We are pretty sure the decoder will produce output if we sent more input
638 // frames than what a h264 decoder could logically delay. This avoids too
639 // excessive buffering.
640 // We also wait if we sent eos, but didn't receive it yet (think of decoding
641 // stream with a very low number of frames).
642 if (avpriv_atomic_int_get(&ctx->packets_buffered) > MAX_DELAYED_FRAMES ||
643 (ctx->packets_sent && ctx->eos_sent)) {
644 // MMAL will ignore broken input packets, which means the frame we
645 // expect here may never arrive. Dealing with this correctly is
646 // complicated, so here's a hack to avoid that it freezes forever
647 // in this unlikely situation.
648 buffer = mmal_queue_timedwait(ctx->queue_decoded_frames, 100);
650 av_log(avctx, AV_LOG_ERROR, "Did not get output frame from MMAL.\n");
651 ret = AVERROR_UNKNOWN;
655 buffer = mmal_queue_get(ctx->queue_decoded_frames);
660 ctx->eos_received |= !!(buffer->flags & MMAL_BUFFER_HEADER_FLAG_EOS);
661 if (ctx->eos_received)
664 if (buffer->cmd == MMAL_EVENT_FORMAT_CHANGED) {
665 MMAL_COMPONENT_T *decoder = ctx->decoder;
666 MMAL_EVENT_FORMAT_CHANGED_T *ev = mmal_event_format_changed_get(buffer);
667 MMAL_BUFFER_HEADER_T *stale_buffer;
669 av_log(avctx, AV_LOG_INFO, "Changing output format.\n");
671 if ((status = mmal_port_disable(decoder->output[0])))
674 while ((stale_buffer = mmal_queue_get(ctx->queue_decoded_frames)))
675 mmal_buffer_header_release(stale_buffer);
677 mmal_format_copy(decoder->output[0]->format, ev->format);
679 if ((ret = ffmal_update_format(avctx)) < 0)
682 if ((status = mmal_port_enable(decoder->output[0], output_callback)))
685 if ((ret = ffmmal_fill_output_port(avctx)) < 0)
688 if ((ret = ffmmal_fill_input_port(avctx)) < 0)
691 mmal_buffer_header_release(buffer);
693 } else if (buffer->cmd) {
695 av_get_codec_tag_string(s, sizeof(s), buffer->cmd);
696 av_log(avctx, AV_LOG_WARNING, "Unknown MMAL event %s on output port\n", s);
698 } else if (buffer->length == 0) {
699 // Unused output buffer that got drained after format change.
700 mmal_buffer_header_release(buffer);
704 ctx->frames_output++;
706 if ((ret = ffmal_copy_frame(avctx, frame, buffer)) < 0)
715 mmal_buffer_header_release(buffer);
716 if (status && ret >= 0)
717 ret = AVERROR_UNKNOWN;
721 static int ffmmal_decode(AVCodecContext *avctx, void *data, int *got_frame,
724 MMALDecodeContext *ctx = avctx->priv_data;
725 AVFrame *frame = data;
728 if (avctx->extradata_size && !ctx->extradata_sent) {
730 av_init_packet(&pkt);
731 pkt.data = avctx->extradata;
732 pkt.size = avctx->extradata_size;
733 ctx->extradata_sent = 1;
734 if ((ret = ffmmal_add_packet(avctx, &pkt, 1)) < 0)
738 if ((ret = ffmmal_add_packet(avctx, avpkt, 0)) < 0)
741 if ((ret = ffmmal_fill_input_port(avctx)) < 0)
744 if ((ret = ffmmal_fill_output_port(avctx)) < 0)
747 if ((ret = ffmmal_read_frame(avctx, frame, got_frame)) < 0)
750 // ffmmal_read_frame() can block for a while. Since the decoder is
751 // asynchronous, it's a good idea to fill the ports again.
753 if ((ret = ffmmal_fill_output_port(avctx)) < 0)
756 if ((ret = ffmmal_fill_input_port(avctx)) < 0)
762 AVHWAccel ff_h264_mmal_hwaccel = {
764 .type = AVMEDIA_TYPE_VIDEO,
765 .id = AV_CODEC_ID_H264,
766 .pix_fmt = AV_PIX_FMT_MMAL,
769 static const AVOption options[]={
770 {"extra_buffers", "extra buffers", offsetof(MMALDecodeContext, extra_buffers), AV_OPT_TYPE_INT, {.i64 = 10}, 0, 256, 0},
774 static const AVClass ffmmaldec_class = {
775 .class_name = "mmaldec",
777 .version = LIBAVUTIL_VERSION_INT,
780 AVCodec ff_h264_mmal_decoder = {
782 .long_name = NULL_IF_CONFIG_SMALL("h264 (mmal)"),
783 .type = AVMEDIA_TYPE_VIDEO,
784 .id = AV_CODEC_ID_H264,
785 .priv_data_size = sizeof(MMALDecodeContext),
786 .init = ffmmal_init_decoder,
787 .close = ffmmal_close_decoder,
788 .decode = ffmmal_decode,
789 .flush = ffmmal_flush,
790 .priv_class = &ffmmaldec_class,
791 .capabilities = AV_CODEC_CAP_DELAY,
792 .caps_internal = FF_CODEC_CAP_SETS_PKT_DTS,
793 .pix_fmts = (const enum AVPixelFormat[]) { AV_PIX_FMT_MMAL,