]> git.sesse.net Git - ffmpeg/blob - libavcodec/mediacodecdec.c
lavc/mediacodecdec: switch to new decoding API
[ffmpeg] / libavcodec / mediacodecdec.c
1 /*
2  * Android MediaCodec MPEG-2 / H.264 / H.265 / MPEG-4 / VP8 / VP9 decoders
3  *
4  * Copyright (c) 2015-2016 Matthieu Bouron <matthieu.bouron stupeflix.com>
5  *
6  * This file is part of FFmpeg.
7  *
8  * FFmpeg is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12  *
13  * FFmpeg is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with FFmpeg; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21  */
22
23 #include <stdint.h>
24 #include <string.h>
25
26 #include "libavutil/avassert.h"
27 #include "libavutil/common.h"
28 #include "libavutil/fifo.h"
29 #include "libavutil/opt.h"
30 #include "libavutil/intreadwrite.h"
31 #include "libavutil/pixfmt.h"
32
33 #include "avcodec.h"
34 #include "decode.h"
35 #include "h264_parse.h"
36 #include "hevc_parse.h"
37 #include "hwaccel.h"
38 #include "internal.h"
39 #include "mediacodec_wrapper.h"
40 #include "mediacodecdec_common.h"
41
42 typedef struct MediaCodecH264DecContext {
43
44     MediaCodecDecContext *ctx;
45
46     AVFifoBuffer *fifo;
47
48     AVPacket buffered_pkt;
49
50 } MediaCodecH264DecContext;
51
52 static av_cold int mediacodec_decode_close(AVCodecContext *avctx)
53 {
54     MediaCodecH264DecContext *s = avctx->priv_data;
55
56     ff_mediacodec_dec_close(avctx, s->ctx);
57     s->ctx = NULL;
58
59     av_fifo_free(s->fifo);
60
61     av_packet_unref(&s->buffered_pkt);
62
63     return 0;
64 }
65
66 #if CONFIG_H264_MEDIACODEC_DECODER || CONFIG_HEVC_MEDIACODEC_DECODER
67 static int h2645_ps_to_nalu(const uint8_t *src, int src_size, uint8_t **out, int *out_size)
68 {
69     int i;
70     int ret = 0;
71     uint8_t *p = NULL;
72     static const uint8_t nalu_header[] = { 0x00, 0x00, 0x00, 0x01 };
73
74     if (!out || !out_size) {
75         return AVERROR(EINVAL);
76     }
77
78     p = av_malloc(sizeof(nalu_header) + src_size);
79     if (!p) {
80         return AVERROR(ENOMEM);
81     }
82
83     *out = p;
84     *out_size = sizeof(nalu_header) + src_size;
85
86     memcpy(p, nalu_header, sizeof(nalu_header));
87     memcpy(p + sizeof(nalu_header), src, src_size);
88
89     /* Escape 0x00, 0x00, 0x0{0-3} pattern */
90     for (i = 4; i < *out_size; i++) {
91         if (i < *out_size - 3 &&
92             p[i + 0] == 0 &&
93             p[i + 1] == 0 &&
94             p[i + 2] <= 3) {
95             uint8_t *new;
96
97             *out_size += 1;
98             new = av_realloc(*out, *out_size);
99             if (!new) {
100                 ret = AVERROR(ENOMEM);
101                 goto done;
102             }
103             *out = p = new;
104
105             i = i + 2;
106             memmove(p + i + 1, p + i, *out_size - (i + 1));
107             p[i] = 0x03;
108         }
109     }
110 done:
111     if (ret < 0) {
112         av_freep(out);
113         *out_size = 0;
114     }
115
116     return ret;
117 }
118 #endif
119
120 #if CONFIG_H264_MEDIACODEC_DECODER
121 static int h264_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
122 {
123     int i;
124     int ret;
125
126     H264ParamSets ps;
127     const PPS *pps = NULL;
128     const SPS *sps = NULL;
129     int is_avc = 0;
130     int nal_length_size = 0;
131
132     memset(&ps, 0, sizeof(ps));
133
134     ret = ff_h264_decode_extradata(avctx->extradata, avctx->extradata_size,
135                                    &ps, &is_avc, &nal_length_size, 0, avctx);
136     if (ret < 0) {
137         goto done;
138     }
139
140     for (i = 0; i < MAX_PPS_COUNT; i++) {
141         if (ps.pps_list[i]) {
142             pps = (const PPS*)ps.pps_list[i]->data;
143             break;
144         }
145     }
146
147     if (pps) {
148         if (ps.sps_list[pps->sps_id]) {
149             sps = (const SPS*)ps.sps_list[pps->sps_id]->data;
150         }
151     }
152
153     if (pps && sps) {
154         uint8_t *data = NULL;
155         int data_size = 0;
156
157         if ((ret = h2645_ps_to_nalu(sps->data, sps->data_size, &data, &data_size)) < 0) {
158             goto done;
159         }
160         ff_AMediaFormat_setBuffer(format, "csd-0", (void*)data, data_size);
161         av_freep(&data);
162
163         if ((ret = h2645_ps_to_nalu(pps->data, pps->data_size, &data, &data_size)) < 0) {
164             goto done;
165         }
166         ff_AMediaFormat_setBuffer(format, "csd-1", (void*)data, data_size);
167         av_freep(&data);
168     } else {
169         av_log(avctx, AV_LOG_ERROR, "Could not extract PPS/SPS from extradata");
170         ret = AVERROR_INVALIDDATA;
171     }
172
173 done:
174     ff_h264_ps_uninit(&ps);
175
176     return ret;
177 }
178 #endif
179
180 #if CONFIG_HEVC_MEDIACODEC_DECODER
181 static int hevc_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
182 {
183     int i;
184     int ret;
185
186     HEVCParamSets ps;
187     HEVCSEI sei;
188
189     const HEVCVPS *vps = NULL;
190     const HEVCPPS *pps = NULL;
191     const HEVCSPS *sps = NULL;
192     int is_nalff = 0;
193     int nal_length_size = 0;
194
195     uint8_t *vps_data = NULL;
196     uint8_t *sps_data = NULL;
197     uint8_t *pps_data = NULL;
198     int vps_data_size = 0;
199     int sps_data_size = 0;
200     int pps_data_size = 0;
201
202     memset(&ps, 0, sizeof(ps));
203     memset(&sei, 0, sizeof(sei));
204
205     ret = ff_hevc_decode_extradata(avctx->extradata, avctx->extradata_size,
206                                    &ps, &sei, &is_nalff, &nal_length_size, 0, 1, avctx);
207     if (ret < 0) {
208         goto done;
209     }
210
211     for (i = 0; i < HEVC_MAX_VPS_COUNT; i++) {
212         if (ps.vps_list[i]) {
213             vps = (const HEVCVPS*)ps.vps_list[i]->data;
214             break;
215         }
216     }
217
218     for (i = 0; i < HEVC_MAX_PPS_COUNT; i++) {
219         if (ps.pps_list[i]) {
220             pps = (const HEVCPPS*)ps.pps_list[i]->data;
221             break;
222         }
223     }
224
225     if (pps) {
226         if (ps.sps_list[pps->sps_id]) {
227             sps = (const HEVCSPS*)ps.sps_list[pps->sps_id]->data;
228         }
229     }
230
231     if (vps && pps && sps) {
232         uint8_t *data;
233         int data_size;
234
235         if ((ret = h2645_ps_to_nalu(vps->data, vps->data_size, &vps_data, &vps_data_size)) < 0 ||
236             (ret = h2645_ps_to_nalu(sps->data, sps->data_size, &sps_data, &sps_data_size)) < 0 ||
237             (ret = h2645_ps_to_nalu(pps->data, pps->data_size, &pps_data, &pps_data_size)) < 0) {
238             goto done;
239         }
240
241         data_size = vps_data_size + sps_data_size + pps_data_size;
242         data = av_mallocz(data_size);
243         if (!data) {
244             ret = AVERROR(ENOMEM);
245             goto done;
246         }
247
248         memcpy(data                                , vps_data, vps_data_size);
249         memcpy(data + vps_data_size                , sps_data, sps_data_size);
250         memcpy(data + vps_data_size + sps_data_size, pps_data, pps_data_size);
251
252         ff_AMediaFormat_setBuffer(format, "csd-0", data, data_size);
253
254         av_freep(&data);
255     } else {
256         av_log(avctx, AV_LOG_ERROR, "Could not extract VPS/PPS/SPS from extradata");
257         ret = AVERROR_INVALIDDATA;
258     }
259
260 done:
261     av_freep(&vps_data);
262     av_freep(&sps_data);
263     av_freep(&pps_data);
264
265     return ret;
266 }
267 #endif
268
269 #if CONFIG_MPEG2_MEDIACODEC_DECODER
270 static int mpeg2_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
271 {
272     int ret = 0;
273
274     if (avctx->extradata) {
275         ff_AMediaFormat_setBuffer(format, "csd-0", avctx->extradata, avctx->extradata_size);
276     }
277
278     return ret;
279 }
280 #endif
281
282 #if CONFIG_MPEG4_MEDIACODEC_DECODER
283 static int mpeg4_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
284 {
285     int ret = 0;
286
287     if (avctx->extradata) {
288         ff_AMediaFormat_setBuffer(format, "csd-0", avctx->extradata, avctx->extradata_size);
289     }
290
291     return ret;
292 }
293 #endif
294
295 #if CONFIG_VP8_MEDIACODEC_DECODER || CONFIG_VP9_MEDIACODEC_DECODER
296 static int vpx_set_extradata(AVCodecContext *avctx, FFAMediaFormat *format)
297 {
298     int ret = 0;
299
300     if (avctx->extradata) {
301         ff_AMediaFormat_setBuffer(format, "csd-0", avctx->extradata, avctx->extradata_size);
302     }
303
304     return ret;
305 }
306 #endif
307
308 static av_cold int mediacodec_decode_init(AVCodecContext *avctx)
309 {
310     int ret;
311
312     const char *codec_mime = NULL;
313
314     FFAMediaFormat *format = NULL;
315     MediaCodecH264DecContext *s = avctx->priv_data;
316
317     format = ff_AMediaFormat_new();
318     if (!format) {
319         av_log(avctx, AV_LOG_ERROR, "Failed to create media format\n");
320         ret = AVERROR_EXTERNAL;
321         goto done;
322     }
323
324     switch (avctx->codec_id) {
325 #if CONFIG_H264_MEDIACODEC_DECODER
326     case AV_CODEC_ID_H264:
327         codec_mime = "video/avc";
328
329         ret = h264_set_extradata(avctx, format);
330         if (ret < 0)
331             goto done;
332         break;
333 #endif
334 #if CONFIG_HEVC_MEDIACODEC_DECODER
335     case AV_CODEC_ID_HEVC:
336         codec_mime = "video/hevc";
337
338         ret = hevc_set_extradata(avctx, format);
339         if (ret < 0)
340             goto done;
341         break;
342 #endif
343 #if CONFIG_MPEG2_MEDIACODEC_DECODER
344     case AV_CODEC_ID_MPEG2VIDEO:
345         codec_mime = "video/mpeg2";
346
347         ret = mpeg2_set_extradata(avctx, format);
348         if (ret < 0)
349             goto done;
350         break;
351 #endif
352 #if CONFIG_MPEG4_MEDIACODEC_DECODER
353     case AV_CODEC_ID_MPEG4:
354         codec_mime = "video/mp4v-es",
355
356         ret = mpeg4_set_extradata(avctx, format);
357         if (ret < 0)
358             goto done;
359         break;
360 #endif
361 #if CONFIG_VP8_MEDIACODEC_DECODER
362     case AV_CODEC_ID_VP8:
363         codec_mime = "video/x-vnd.on2.vp8";
364
365         ret = vpx_set_extradata(avctx, format);
366         if (ret < 0)
367             goto done;
368         break;
369 #endif
370 #if CONFIG_VP9_MEDIACODEC_DECODER
371     case AV_CODEC_ID_VP9:
372         codec_mime = "video/x-vnd.on2.vp9";
373
374         ret = vpx_set_extradata(avctx, format);
375         if (ret < 0)
376             goto done;
377         break;
378 #endif
379     default:
380         av_assert0(0);
381     }
382
383     ff_AMediaFormat_setString(format, "mime", codec_mime);
384     ff_AMediaFormat_setInt32(format, "width", avctx->width);
385     ff_AMediaFormat_setInt32(format, "height", avctx->height);
386
387     s->ctx = av_mallocz(sizeof(*s->ctx));
388     if (!s->ctx) {
389         av_log(avctx, AV_LOG_ERROR, "Failed to allocate MediaCodecDecContext\n");
390         ret = AVERROR(ENOMEM);
391         goto done;
392     }
393
394     if ((ret = ff_mediacodec_dec_init(avctx, s->ctx, codec_mime, format)) < 0) {
395         s->ctx = NULL;
396         goto done;
397     }
398
399     av_log(avctx, AV_LOG_INFO, "MediaCodec started successfully, ret = %d\n", ret);
400
401     s->fifo = av_fifo_alloc(sizeof(AVPacket));
402     if (!s->fifo) {
403         ret = AVERROR(ENOMEM);
404         goto done;
405     }
406
407 done:
408     if (format) {
409         ff_AMediaFormat_delete(format);
410     }
411
412     if (ret < 0) {
413         mediacodec_decode_close(avctx);
414     }
415
416     return ret;
417 }
418
419
420 static int mediacodec_process_data(AVCodecContext *avctx, AVFrame *frame,
421                                    int *got_frame, AVPacket *pkt)
422 {
423     MediaCodecH264DecContext *s = avctx->priv_data;
424
425     return ff_mediacodec_dec_decode(avctx, s->ctx, frame, got_frame, pkt);
426 }
427
428 static int mediacodec_receive_frame(AVCodecContext *avctx, AVFrame *frame)
429 {
430     MediaCodecH264DecContext *s = avctx->priv_data;
431     int ret;
432     int got_frame = 0;
433     int is_eof = 0;
434     AVPacket pkt = { 0 };
435
436     /*
437      * MediaCodec.flush() discards both input and output buffers, thus we
438      * need to delay the call to this function until the user has released or
439      * renderered the frames he retains.
440      *
441      * After we have buffered an input packet, check if the codec is in the
442      * flushing state. If it is, we need to call ff_mediacodec_dec_flush.
443      *
444      * ff_mediacodec_dec_flush returns 0 if the flush cannot be performed on
445      * the codec (because the user retains frames). The codec stays in the
446      * flushing state.
447      *
448      * ff_mediacodec_dec_flush returns 1 if the flush can actually be
449      * performed on the codec. The codec leaves the flushing state and can
450      * process again packets.
451      *
452      * ff_mediacodec_dec_flush returns a negative value if an error has
453      * occurred.
454      *
455      */
456     if (ff_mediacodec_dec_is_flushing(avctx, s->ctx)) {
457         if (!ff_mediacodec_dec_flush(avctx, s->ctx)) {
458             return AVERROR(EAGAIN);
459         }
460     }
461
462     ret = ff_decode_get_packet(avctx, &pkt);
463     if (ret == AVERROR_EOF)
464         is_eof = 1;
465     else if (ret == AVERROR(EAGAIN))
466         ; /* no input packet, but fallthrough to check for pending frames */
467     else if (ret < 0)
468         return ret;
469
470     /* buffer the input packet */
471     if (pkt.size) {
472         if (av_fifo_space(s->fifo) < sizeof(pkt)) {
473             ret = av_fifo_realloc2(s->fifo,
474                                    av_fifo_size(s->fifo) + sizeof(pkt));
475             if (ret < 0) {
476                 av_packet_unref(&pkt);
477                 return ret;
478             }
479         }
480         av_fifo_generic_write(s->fifo, &pkt, sizeof(pkt), NULL);
481     }
482
483     /* process buffered data */
484     while (!got_frame) {
485         /* prepare the input data */
486         if (s->buffered_pkt.size <= 0) {
487             av_packet_unref(&s->buffered_pkt);
488
489             /* no more data */
490             if (av_fifo_size(s->fifo) < sizeof(AVPacket)) {
491                 AVPacket null_pkt = { 0 };
492                 if (is_eof) {
493                     ret = ff_mediacodec_dec_decode(avctx, s->ctx, frame,
494                                                    &got_frame, &null_pkt);
495                     if (ret < 0)
496                         return ret;
497                     else if (got_frame)
498                         return 0;
499                     else
500                         return AVERROR_EOF;
501                 }
502                 return AVERROR(EAGAIN);
503             }
504
505             av_fifo_generic_read(s->fifo, &s->buffered_pkt, sizeof(s->buffered_pkt), NULL);
506         }
507
508         ret = mediacodec_process_data(avctx, frame, &got_frame, &s->buffered_pkt);
509         if (ret < 0)
510             return ret;
511
512         s->buffered_pkt.size -= ret;
513         s->buffered_pkt.data += ret;
514     }
515
516     return 0;
517 }
518
519 static void mediacodec_decode_flush(AVCodecContext *avctx)
520 {
521     MediaCodecH264DecContext *s = avctx->priv_data;
522
523     while (av_fifo_size(s->fifo)) {
524         AVPacket pkt;
525         av_fifo_generic_read(s->fifo, &pkt, sizeof(pkt), NULL);
526         av_packet_unref(&pkt);
527     }
528     av_fifo_reset(s->fifo);
529
530     av_packet_unref(&s->buffered_pkt);
531
532     ff_mediacodec_dec_flush(avctx, s->ctx);
533 }
534
535 static const AVCodecHWConfigInternal *mediacodec_hw_configs[] = {
536     &(const AVCodecHWConfigInternal) {
537         .public          = {
538             .pix_fmt     = AV_PIX_FMT_MEDIACODEC,
539             .methods     = AV_CODEC_HW_CONFIG_METHOD_AD_HOC |
540                            AV_CODEC_HW_CONFIG_METHOD_HW_DEVICE_CTX,
541             .device_type = AV_HWDEVICE_TYPE_MEDIACODEC,
542         },
543         .hwaccel         = NULL,
544     },
545     NULL
546 };
547
548 #if CONFIG_H264_MEDIACODEC_DECODER
549 AVCodec ff_h264_mediacodec_decoder = {
550     .name           = "h264_mediacodec",
551     .long_name      = NULL_IF_CONFIG_SMALL("H.264 Android MediaCodec decoder"),
552     .type           = AVMEDIA_TYPE_VIDEO,
553     .id             = AV_CODEC_ID_H264,
554     .priv_data_size = sizeof(MediaCodecH264DecContext),
555     .init           = mediacodec_decode_init,
556     .receive_frame  = mediacodec_receive_frame,
557     .flush          = mediacodec_decode_flush,
558     .close          = mediacodec_decode_close,
559     .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE,
560     .caps_internal  = FF_CODEC_CAP_SETS_PKT_DTS,
561     .bsfs           = "h264_mp4toannexb",
562     .hw_configs     = mediacodec_hw_configs,
563     .wrapper_name   = "mediacodec",
564 };
565 #endif
566
567 #if CONFIG_HEVC_MEDIACODEC_DECODER
568 AVCodec ff_hevc_mediacodec_decoder = {
569     .name           = "hevc_mediacodec",
570     .long_name      = NULL_IF_CONFIG_SMALL("H.265 Android MediaCodec decoder"),
571     .type           = AVMEDIA_TYPE_VIDEO,
572     .id             = AV_CODEC_ID_HEVC,
573     .priv_data_size = sizeof(MediaCodecH264DecContext),
574     .init           = mediacodec_decode_init,
575     .receive_frame  = mediacodec_receive_frame,
576     .flush          = mediacodec_decode_flush,
577     .close          = mediacodec_decode_close,
578     .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE,
579     .caps_internal  = FF_CODEC_CAP_SETS_PKT_DTS,
580     .bsfs           = "hevc_mp4toannexb",
581     .hw_configs     = mediacodec_hw_configs,
582     .wrapper_name   = "mediacodec",
583 };
584 #endif
585
586 #if CONFIG_MPEG2_MEDIACODEC_DECODER
587 AVCodec ff_mpeg2_mediacodec_decoder = {
588     .name           = "mpeg2_mediacodec",
589     .long_name      = NULL_IF_CONFIG_SMALL("MPEG-2 Android MediaCodec decoder"),
590     .type           = AVMEDIA_TYPE_VIDEO,
591     .id             = AV_CODEC_ID_MPEG2VIDEO,
592     .priv_data_size = sizeof(MediaCodecH264DecContext),
593     .init           = mediacodec_decode_init,
594     .receive_frame  = mediacodec_receive_frame,
595     .flush          = mediacodec_decode_flush,
596     .close          = mediacodec_decode_close,
597     .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE,
598     .caps_internal  = FF_CODEC_CAP_SETS_PKT_DTS,
599     .hw_configs     = mediacodec_hw_configs,
600     .wrapper_name   = "mediacodec",
601 };
602 #endif
603
604 #if CONFIG_MPEG4_MEDIACODEC_DECODER
605 AVCodec ff_mpeg4_mediacodec_decoder = {
606     .name           = "mpeg4_mediacodec",
607     .long_name      = NULL_IF_CONFIG_SMALL("MPEG-4 Android MediaCodec decoder"),
608     .type           = AVMEDIA_TYPE_VIDEO,
609     .id             = AV_CODEC_ID_MPEG4,
610     .priv_data_size = sizeof(MediaCodecH264DecContext),
611     .init           = mediacodec_decode_init,
612     .receive_frame  = mediacodec_receive_frame,
613     .flush          = mediacodec_decode_flush,
614     .close          = mediacodec_decode_close,
615     .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE,
616     .caps_internal  = FF_CODEC_CAP_SETS_PKT_DTS,
617     .hw_configs     = mediacodec_hw_configs,
618     .wrapper_name   = "mediacodec",
619 };
620 #endif
621
622 #if CONFIG_VP8_MEDIACODEC_DECODER
623 AVCodec ff_vp8_mediacodec_decoder = {
624     .name           = "vp8_mediacodec",
625     .long_name      = NULL_IF_CONFIG_SMALL("VP8 Android MediaCodec decoder"),
626     .type           = AVMEDIA_TYPE_VIDEO,
627     .id             = AV_CODEC_ID_VP8,
628     .priv_data_size = sizeof(MediaCodecH264DecContext),
629     .init           = mediacodec_decode_init,
630     .receive_frame  = mediacodec_receive_frame,
631     .flush          = mediacodec_decode_flush,
632     .close          = mediacodec_decode_close,
633     .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE,
634     .caps_internal  = FF_CODEC_CAP_SETS_PKT_DTS,
635     .hw_configs     = mediacodec_hw_configs,
636     .wrapper_name   = "mediacodec",
637 };
638 #endif
639
640 #if CONFIG_VP9_MEDIACODEC_DECODER
641 AVCodec ff_vp9_mediacodec_decoder = {
642     .name           = "vp9_mediacodec",
643     .long_name      = NULL_IF_CONFIG_SMALL("VP9 Android MediaCodec decoder"),
644     .type           = AVMEDIA_TYPE_VIDEO,
645     .id             = AV_CODEC_ID_VP9,
646     .priv_data_size = sizeof(MediaCodecH264DecContext),
647     .init           = mediacodec_decode_init,
648     .receive_frame  = mediacodec_receive_frame,
649     .flush          = mediacodec_decode_flush,
650     .close          = mediacodec_decode_close,
651     .capabilities   = AV_CODEC_CAP_DELAY | AV_CODEC_CAP_AVOID_PROBING | AV_CODEC_CAP_HARDWARE,
652     .caps_internal  = FF_CODEC_CAP_SETS_PKT_DTS,
653     .hw_configs     = mediacodec_hw_configs,
654     .wrapper_name   = "mediacodec",
655 };
656 #endif