2 * Android MediaCodec decoder
4 * Copyright (c) 2015-2016 Matthieu Bouron <matthieu.bouron stupeflix.com>
6 * This file is part of FFmpeg.
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.
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.
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
24 #include <sys/types.h>
26 #include "libavutil/atomic.h"
27 #include "libavutil/common.h"
28 #include "libavutil/mem.h"
29 #include "libavutil/log.h"
30 #include "libavutil/pixfmt.h"
31 #include "libavutil/time.h"
32 #include "libavutil/timestamp.h"
37 #include "mediacodec.h"
38 #include "mediacodec_surface.h"
39 #include "mediacodec_sw_buffer.h"
40 #include "mediacodec_wrapper.h"
41 #include "mediacodecdec.h"
44 * OMX.k3.video.decoder.avc, OMX.NVIDIA.* OMX.SEC.avc.dec and OMX.google
45 * codec workarounds used in various place are taken from the Gstreamer
48 * Gstreamer references:
49 * https://cgit.freedesktop.org/gstreamer/gst-plugins-bad/tree/sys/androidmedia/
51 * Gstreamer copyright notice:
53 * Copyright (C) 2012, Collabora Ltd.
54 * Author: Sebastian Dröge <sebastian.droege@collabora.co.uk>
56 * Copyright (C) 2012, Rafaël Carré <funman@videolanorg>
58 * Copyright (C) 2015, Sebastian Dröge <sebastian@centricular.com>
60 * Copyright (C) 2014-2015, Collabora Ltd.
61 * Author: Matthieu Bouron <matthieu.bouron@gcollabora.com>
63 * Copyright (C) 2015, Edward Hervey
64 * Author: Edward Hervey <bilboed@gmail.com>
66 * Copyright (C) 2015, Matthew Waters <matthew@centricular.com>
68 * This library is free software; you can redistribute it and/or
69 * modify it under the terms of the GNU Lesser General Public
70 * License as published by the Free Software Foundation
71 * version 2.1 of the License.
73 * This library is distributed in the hope that it will be useful,
74 * but WITHOUT ANY WARRANTY; without even the implied warranty of
75 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
76 * Lesser General Public License for more details.
78 * You should have received a copy of the GNU Lesser General Public
79 * License along with this library; if not, write to the Free Software
80 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
84 #define INPUT_DEQUEUE_TIMEOUT_US 8000
85 #define OUTPUT_DEQUEUE_TIMEOUT_US 8000
86 #define OUTPUT_DEQUEUE_BLOCK_TIMEOUT_US 1000000
89 COLOR_FormatYUV420Planar = 0x13,
90 COLOR_FormatYUV420SemiPlanar = 0x15,
91 COLOR_FormatYCbYCr = 0x19,
92 COLOR_FormatAndroidOpaque = 0x7F000789,
93 COLOR_QCOM_FormatYUV420SemiPlanar = 0x7fa30c00,
94 COLOR_QCOM_FormatYUV420SemiPlanar32m = 0x7fa30c04,
95 COLOR_QCOM_FormatYUV420PackedSemiPlanar64x32Tile2m8ka = 0x7fa30c03,
96 COLOR_TI_FormatYUV420PackedSemiPlanar = 0x7f000100,
97 COLOR_TI_FormatYUV420PackedSemiPlanarInterlaced = 0x7f000001,
100 static const struct {
103 enum AVPixelFormat pix_fmt;
105 } color_formats[] = {
107 { COLOR_FormatYUV420Planar, AV_PIX_FMT_YUV420P },
108 { COLOR_FormatYUV420SemiPlanar, AV_PIX_FMT_NV12 },
109 { COLOR_QCOM_FormatYUV420SemiPlanar, AV_PIX_FMT_NV12 },
110 { COLOR_QCOM_FormatYUV420SemiPlanar32m, AV_PIX_FMT_NV12 },
111 { COLOR_QCOM_FormatYUV420PackedSemiPlanar64x32Tile2m8ka, AV_PIX_FMT_NV12 },
112 { COLOR_TI_FormatYUV420PackedSemiPlanar, AV_PIX_FMT_NV12 },
113 { COLOR_TI_FormatYUV420PackedSemiPlanarInterlaced, AV_PIX_FMT_NV12 },
117 static enum AVPixelFormat mcdec_map_color_format(AVCodecContext *avctx,
118 MediaCodecDecContext *s,
122 enum AVPixelFormat ret = AV_PIX_FMT_NONE;
125 return AV_PIX_FMT_MEDIACODEC;
128 if (!strcmp(s->codec_name, "OMX.k3.video.decoder.avc") && color_format == COLOR_FormatYCbYCr) {
129 s->color_format = color_format = COLOR_TI_FormatYUV420PackedSemiPlanar;
132 for (i = 0; i < FF_ARRAY_ELEMS(color_formats); i++) {
133 if (color_formats[i].color_format == color_format) {
134 return color_formats[i].pix_fmt;
138 av_log(avctx, AV_LOG_ERROR, "Output color format 0x%x (value=%d) is not supported\n",
139 color_format, color_format);
144 static void ff_mediacodec_dec_ref(MediaCodecDecContext *s)
146 avpriv_atomic_int_add_and_fetch(&s->refcount, 1);
149 static void ff_mediacodec_dec_unref(MediaCodecDecContext *s)
154 if (!avpriv_atomic_int_add_and_fetch(&s->refcount, -1)) {
156 ff_AMediaCodec_delete(s->codec);
161 ff_AMediaFormat_delete(s->format);
166 ff_mediacodec_surface_unref(s->surface, NULL);
170 av_freep(&s->codec_name);
175 static void mediacodec_buffer_release(void *opaque, uint8_t *data)
177 AVMediaCodecBuffer *buffer = opaque;
178 MediaCodecDecContext *ctx = buffer->ctx;
179 int released = avpriv_atomic_int_get(&buffer->released);
182 ff_AMediaCodec_releaseOutputBuffer(ctx->codec, buffer->index, 0);
185 ff_mediacodec_dec_unref(ctx);
189 static int mediacodec_wrap_hw_buffer(AVCodecContext *avctx,
190 MediaCodecDecContext *s,
192 FFAMediaCodecBufferInfo *info,
197 AVMediaCodecBuffer *buffer = NULL;
199 frame->buf[0] = NULL;
200 frame->width = avctx->width;
201 frame->height = avctx->height;
202 frame->format = avctx->pix_fmt;
204 if (avctx->pkt_timebase.num && avctx->pkt_timebase.den) {
205 frame->pts = av_rescale_q(info->presentationTimeUs,
206 av_make_q(1, 1000000),
207 avctx->pkt_timebase);
209 frame->pts = info->presentationTimeUs;
212 FF_DISABLE_DEPRECATION_WARNINGS
213 frame->pkt_pts = frame->pts;
214 FF_ENABLE_DEPRECATION_WARNINGS
216 frame->pkt_dts = AV_NOPTS_VALUE;
218 buffer = av_mallocz(sizeof(AVMediaCodecBuffer));
220 ret = AVERROR(ENOMEM);
224 buffer->released = 0;
226 frame->buf[0] = av_buffer_create(NULL,
228 mediacodec_buffer_release,
230 AV_BUFFER_FLAG_READONLY);
232 if (!frame->buf[0]) {
233 ret = AVERROR(ENOMEM);
239 ff_mediacodec_dec_ref(s);
241 buffer->index = index;
242 buffer->pts = info->presentationTimeUs;
244 frame->data[3] = (uint8_t *)buffer;
249 av_buffer_unref(&frame->buf[0]);
250 status = ff_AMediaCodec_releaseOutputBuffer(s->codec, index, 0);
252 av_log(avctx, AV_LOG_ERROR, "Failed to release output buffer\n");
253 ret = AVERROR_EXTERNAL;
259 static int mediacodec_wrap_sw_buffer(AVCodecContext *avctx,
260 MediaCodecDecContext *s,
264 FFAMediaCodecBufferInfo *info,
270 frame->width = avctx->width;
271 frame->height = avctx->height;
272 frame->format = avctx->pix_fmt;
274 /* MediaCodec buffers needs to be copied to our own refcounted buffers
275 * because the flush command invalidates all input and output buffers.
277 if ((ret = ff_get_buffer(avctx, frame, 0)) < 0) {
278 av_log(avctx, AV_LOG_ERROR, "Could not allocate buffer\n");
282 /* Override frame->pkt_pts as ff_get_buffer will override its value based
283 * on the last avpacket received which is not in sync with the frame:
284 * * N avpackets can be pushed before 1 frame is actually returned
285 * * 0-sized avpackets are pushed to flush remaining frames at EOS */
286 frame->pts = info->presentationTimeUs;
288 FF_DISABLE_DEPRECATION_WARNINGS
289 frame->pkt_pts = info->presentationTimeUs;
290 FF_ENABLE_DEPRECATION_WARNINGS
292 frame->pkt_dts = AV_NOPTS_VALUE;
294 av_log(avctx, AV_LOG_DEBUG,
295 "Frame: width=%d stride=%d height=%d slice-height=%d "
296 "crop-top=%d crop-bottom=%d crop-left=%d crop-right=%d encoder=%s\n"
297 "destination linesizes=%d,%d,%d\n" ,
298 avctx->width, s->stride, avctx->height, s->slice_height,
299 s->crop_top, s->crop_bottom, s->crop_left, s->crop_right, s->codec_name,
300 frame->linesize[0], frame->linesize[1], frame->linesize[2]);
302 switch (s->color_format) {
303 case COLOR_FormatYUV420Planar:
304 ff_mediacodec_sw_buffer_copy_yuv420_planar(avctx, s, data, size, info, frame);
306 case COLOR_FormatYUV420SemiPlanar:
307 case COLOR_QCOM_FormatYUV420SemiPlanar:
308 case COLOR_QCOM_FormatYUV420SemiPlanar32m:
309 ff_mediacodec_sw_buffer_copy_yuv420_semi_planar(avctx, s, data, size, info, frame);
311 case COLOR_TI_FormatYUV420PackedSemiPlanar:
312 case COLOR_TI_FormatYUV420PackedSemiPlanarInterlaced:
313 ff_mediacodec_sw_buffer_copy_yuv420_packed_semi_planar(avctx, s, data, size, info, frame);
315 case COLOR_QCOM_FormatYUV420PackedSemiPlanar64x32Tile2m8ka:
316 ff_mediacodec_sw_buffer_copy_yuv420_packed_semi_planar_64x32Tile2m8ka(avctx, s, data, size, info, frame);
319 av_log(avctx, AV_LOG_ERROR, "Unsupported color format 0x%x (value=%d)\n",
320 s->color_format, s->color_format);
321 ret = AVERROR(EINVAL);
327 status = ff_AMediaCodec_releaseOutputBuffer(s->codec, index, 0);
329 av_log(avctx, AV_LOG_ERROR, "Failed to release output buffer\n");
330 ret = AVERROR_EXTERNAL;
336 static int mediacodec_dec_parse_format(AVCodecContext *avctx, MediaCodecDecContext *s)
344 av_log(avctx, AV_LOG_ERROR, "Output MediaFormat is not set\n");
345 return AVERROR(EINVAL);
348 format = ff_AMediaFormat_toString(s->format);
350 return AVERROR_EXTERNAL;
352 av_log(avctx, AV_LOG_DEBUG, "Parsing MediaFormat %s\n", format);
355 /* Mandatory fields */
356 if (!ff_AMediaFormat_getInt32(s->format, "width", &value)) {
357 format = ff_AMediaFormat_toString(s->format);
358 av_log(avctx, AV_LOG_ERROR, "Could not get %s from format %s\n", "width", format);
360 return AVERROR_EXTERNAL;
364 if (!ff_AMediaFormat_getInt32(s->format, "height", &value)) {
365 format = ff_AMediaFormat_toString(s->format);
366 av_log(avctx, AV_LOG_ERROR, "Could not get %s from format %s\n", "height", format);
368 return AVERROR_EXTERNAL;
372 if (!ff_AMediaFormat_getInt32(s->format, "stride", &value)) {
373 format = ff_AMediaFormat_toString(s->format);
374 av_log(avctx, AV_LOG_ERROR, "Could not get %s from format %s\n", "stride", format);
376 return AVERROR_EXTERNAL;
378 s->stride = value > 0 ? value : s->width;
380 if (!ff_AMediaFormat_getInt32(s->format, "slice-height", &value)) {
381 format = ff_AMediaFormat_toString(s->format);
382 av_log(avctx, AV_LOG_ERROR, "Could not get %s from format %s\n", "slice-height", format);
384 return AVERROR_EXTERNAL;
386 s->slice_height = value > 0 ? value : s->height;
388 if (strstr(s->codec_name, "OMX.Nvidia.")) {
389 s->slice_height = FFALIGN(s->height, 16);
390 } else if (strstr(s->codec_name, "OMX.SEC.avc.dec")) {
391 s->slice_height = avctx->height;
392 s->stride = avctx->width;
395 if (!ff_AMediaFormat_getInt32(s->format, "color-format", &value)) {
396 format = ff_AMediaFormat_toString(s->format);
397 av_log(avctx, AV_LOG_ERROR, "Could not get %s from format %s\n", "color-format", format);
399 return AVERROR_EXTERNAL;
401 s->color_format = value;
403 s->pix_fmt = avctx->pix_fmt = mcdec_map_color_format(avctx, s, value);
404 if (avctx->pix_fmt == AV_PIX_FMT_NONE) {
405 av_log(avctx, AV_LOG_ERROR, "Output color format is not supported\n");
406 return AVERROR(EINVAL);
409 /* Optional fields */
410 if (ff_AMediaFormat_getInt32(s->format, "crop-top", &value))
413 if (ff_AMediaFormat_getInt32(s->format, "crop-bottom", &value))
414 s->crop_bottom = value;
416 if (ff_AMediaFormat_getInt32(s->format, "crop-left", &value))
417 s->crop_left = value;
419 if (ff_AMediaFormat_getInt32(s->format, "crop-right", &value))
420 s->crop_right = value;
422 width = s->crop_right + 1 - s->crop_left;
423 height = s->crop_bottom + 1 - s->crop_top;
425 av_log(avctx, AV_LOG_INFO,
426 "Output crop parameters top=%d bottom=%d left=%d right=%d, "
427 "resulting dimensions width=%d height=%d\n",
428 s->crop_top, s->crop_bottom, s->crop_left, s->crop_right,
431 return ff_set_dimensions(avctx, width, height);
435 static int mediacodec_dec_flush_codec(AVCodecContext *avctx, MediaCodecDecContext *s)
437 FFAMediaCodec *codec = s->codec;
440 s->dequeued_buffer_nb = 0;
446 status = ff_AMediaCodec_flush(codec);
448 av_log(avctx, AV_LOG_ERROR, "Failed to flush codec\n");
449 return AVERROR_EXTERNAL;
453 s->first_buffer_at = av_gettime();
458 int ff_mediacodec_dec_init(AVCodecContext *avctx, MediaCodecDecContext *s,
459 const char *mime, FFAMediaFormat *format)
465 enum AVPixelFormat pix_fmt;
466 static const enum AVPixelFormat pix_fmts[] = {
467 AV_PIX_FMT_MEDIACODEC,
471 s->first_buffer_at = av_gettime();
474 pix_fmt = ff_get_format(avctx, pix_fmts);
475 if (pix_fmt == AV_PIX_FMT_MEDIACODEC) {
476 AVMediaCodecContext *user_ctx = avctx->hwaccel_context;
478 if (user_ctx && user_ctx->surface) {
479 s->surface = ff_mediacodec_surface_ref(user_ctx->surface, avctx);
480 av_log(avctx, AV_LOG_INFO, "Using surface %p\n", s->surface);
484 profile = ff_AMediaCodecProfile_getProfileFromAVCodecContext(avctx);
486 av_log(avctx, AV_LOG_WARNING, "Unsupported or unknown profile");
489 s->codec_name = ff_AMediaCodecList_getCodecNameByType(mime, profile, 0, avctx);
490 if (!s->codec_name) {
491 ret = AVERROR_EXTERNAL;
495 av_log(avctx, AV_LOG_DEBUG, "Found decoder %s\n", s->codec_name);
496 s->codec = ff_AMediaCodec_createCodecByName(s->codec_name);
498 av_log(avctx, AV_LOG_ERROR, "Failed to create media decoder for type %s and name %s\n", mime, s->codec_name);
499 ret = AVERROR_EXTERNAL;
503 status = ff_AMediaCodec_configure(s->codec, format, s->surface, NULL, 0);
505 char *desc = ff_AMediaFormat_toString(format);
506 av_log(avctx, AV_LOG_ERROR,
507 "Failed to configure codec (status = %d) with format %s\n",
511 ret = AVERROR_EXTERNAL;
515 status = ff_AMediaCodec_start(s->codec);
517 char *desc = ff_AMediaFormat_toString(format);
518 av_log(avctx, AV_LOG_ERROR,
519 "Failed to start codec (status = %d) with format %s\n",
522 ret = AVERROR_EXTERNAL;
526 s->format = ff_AMediaCodec_getOutputFormat(s->codec);
528 if ((ret = mediacodec_dec_parse_format(avctx, s)) < 0) {
529 av_log(avctx, AV_LOG_ERROR,
530 "Failed to configure context\n");
535 av_log(avctx, AV_LOG_DEBUG, "MediaCodec %p started successfully\n", s->codec);
540 av_log(avctx, AV_LOG_ERROR, "MediaCodec %p failed to start\n", s->codec);
541 ff_mediacodec_dec_close(avctx, s);
545 int ff_mediacodec_dec_decode(AVCodecContext *avctx, MediaCodecDecContext *s,
546 AVFrame *frame, int *got_frame,
551 int need_draining = 0;
555 FFAMediaCodec *codec = s->codec;
556 FFAMediaCodecBufferInfo info = { 0 };
560 int64_t input_dequeue_timeout_us = INPUT_DEQUEUE_TIMEOUT_US;
561 int64_t output_dequeue_timeout_us = OUTPUT_DEQUEUE_TIMEOUT_US;
564 av_log(avctx, AV_LOG_ERROR, "Decoder is flushing and cannot accept new buffer "
565 "until all output buffers have been released\n");
566 return AVERROR_EXTERNAL;
569 if (pkt->size == 0) {
573 if (s->draining && s->eos) {
577 while (offset < pkt->size || (need_draining && !s->draining)) {
579 index = ff_AMediaCodec_dequeueInputBuffer(codec, input_dequeue_timeout_us);
580 if (ff_AMediaCodec_infoTryAgainLater(codec, index)) {
585 av_log(avctx, AV_LOG_ERROR, "Failed to dequeue input buffer (status=%zd)\n", index);
586 return AVERROR_EXTERNAL;
589 data = ff_AMediaCodec_getInputBuffer(codec, index, &size);
591 av_log(avctx, AV_LOG_ERROR, "Failed to get input buffer\n");
592 return AVERROR_EXTERNAL;
596 int64_t pts = pkt->pts;
597 uint32_t flags = ff_AMediaCodec_getBufferFlagEndOfStream(codec);
600 pts = av_rescale_q(pts, avctx->pkt_timebase, av_make_q(1, 1000000));
603 av_log(avctx, AV_LOG_DEBUG, "Sending End Of Stream signal\n");
605 status = ff_AMediaCodec_queueInputBuffer(codec, index, 0, 0, pts, flags);
607 av_log(avctx, AV_LOG_ERROR, "Failed to queue input empty buffer (status = %d)\n", status);
608 return AVERROR_EXTERNAL;
614 int64_t pts = pkt->pts;
616 size = FFMIN(pkt->size - offset, size);
618 memcpy(data, pkt->data + offset, size);
621 if (s->surface && avctx->pkt_timebase.num && avctx->pkt_timebase.den) {
622 pts = av_rescale_q(pts, avctx->pkt_timebase, av_make_q(1, 1000000));
625 status = ff_AMediaCodec_queueInputBuffer(codec, index, 0, size, pts, 0);
627 av_log(avctx, AV_LOG_ERROR, "Failed to queue input buffer (status = %d)\n", status);
628 return AVERROR_EXTERNAL;
633 if (need_draining || s->draining) {
634 /* If the codec is flushing or need to be flushed, block for a fair
635 * amount of time to ensure we got a frame */
636 output_dequeue_timeout_us = OUTPUT_DEQUEUE_BLOCK_TIMEOUT_US;
637 } else if (s->dequeued_buffer_nb == 0) {
638 /* If the codec hasn't produced any frames, do not block so we
639 * can push data to it as fast as possible, and get the first
641 output_dequeue_timeout_us = 0;
644 index = ff_AMediaCodec_dequeueOutputBuffer(codec, &info, output_dequeue_timeout_us);
648 if (!s->first_buffer++) {
649 av_log(avctx, AV_LOG_DEBUG, "Got first buffer after %fms\n", (av_gettime() - s->first_buffer_at) / 1000);
652 av_log(avctx, AV_LOG_DEBUG, "Got output buffer %zd"
653 " offset=%" PRIi32 " size=%" PRIi32 " ts=%" PRIi64
654 " flags=%" PRIu32 "\n", index, info.offset, info.size,
655 info.presentationTimeUs, info.flags);
657 if (info.flags & ff_AMediaCodec_getBufferFlagEndOfStream(codec)) {
663 if ((ret = mediacodec_wrap_hw_buffer(avctx, s, index, &info, frame)) < 0) {
664 av_log(avctx, AV_LOG_ERROR, "Failed to wrap MediaCodec buffer\n");
668 data = ff_AMediaCodec_getOutputBuffer(codec, index, &size);
670 av_log(avctx, AV_LOG_ERROR, "Failed to get output buffer\n");
671 return AVERROR_EXTERNAL;
674 if ((ret = mediacodec_wrap_sw_buffer(avctx, s, data, size, index, &info, frame)) < 0) {
675 av_log(avctx, AV_LOG_ERROR, "Failed to wrap MediaCodec buffer\n");
681 s->dequeued_buffer_nb++;
683 status = ff_AMediaCodec_releaseOutputBuffer(codec, index, 0);
685 av_log(avctx, AV_LOG_ERROR, "Failed to release output buffer\n");
689 } else if (ff_AMediaCodec_infoOutputFormatChanged(codec, index)) {
693 status = ff_AMediaFormat_delete(s->format);
695 av_log(avctx, AV_LOG_ERROR, "Failed to delete MediaFormat %p\n", s->format);
699 s->format = ff_AMediaCodec_getOutputFormat(codec);
701 av_log(avctx, AV_LOG_ERROR, "Failed to get output format\n");
702 return AVERROR_EXTERNAL;
705 format = ff_AMediaFormat_toString(s->format);
707 return AVERROR_EXTERNAL;
709 av_log(avctx, AV_LOG_INFO, "Output MediaFormat changed to %s\n", format);
712 if ((ret = mediacodec_dec_parse_format(avctx, s)) < 0) {
716 } else if (ff_AMediaCodec_infoOutputBuffersChanged(codec, index)) {
717 ff_AMediaCodec_cleanOutputBuffers(codec);
718 } else if (ff_AMediaCodec_infoTryAgainLater(codec, index)) {
720 av_log(avctx, AV_LOG_ERROR, "Failed to dequeue output buffer within %" PRIi64 "ms "
721 "while draining remaining frames, output will probably lack frames\n",
722 output_dequeue_timeout_us / 1000);
724 av_log(avctx, AV_LOG_DEBUG, "No output buffer available, try again later\n");
727 av_log(avctx, AV_LOG_ERROR, "Failed to dequeue output buffer (status=%zd)\n", index);
728 return AVERROR_EXTERNAL;
734 int ff_mediacodec_dec_flush(AVCodecContext *avctx, MediaCodecDecContext *s)
736 if (!s->surface || avpriv_atomic_int_get(&s->refcount) == 1) {
739 /* No frames (holding a reference to the codec) are retained by the
740 * user, thus we can flush the codec and returns accordingly */
741 if ((ret = mediacodec_dec_flush_codec(avctx, s)) < 0) {
752 int ff_mediacodec_dec_close(AVCodecContext *avctx, MediaCodecDecContext *s)
754 ff_mediacodec_dec_unref(s);
759 int ff_mediacodec_dec_is_flushing(AVCodecContext *avctx, MediaCodecDecContext *s)
764 AVHWAccel ff_h264_mediacodec_hwaccel = {
765 .name = "mediacodec",
766 .type = AVMEDIA_TYPE_VIDEO,
767 .id = AV_CODEC_ID_H264,
768 .pix_fmt = AV_PIX_FMT_MEDIACODEC,
771 AVHWAccel ff_hevc_mediacodec_hwaccel = {
772 .name = "mediacodec",
773 .type = AVMEDIA_TYPE_VIDEO,
774 .id = AV_CODEC_ID_HEVC,
775 .pix_fmt = AV_PIX_FMT_MEDIACODEC,