2016-01-21 10:29:39 +02:00
|
|
|
/*
|
|
|
|
* Android MediaCodec decoder
|
|
|
|
*
|
|
|
|
* Copyright (c) 2015-2016 Matthieu Bouron <matthieu.bouron stupeflix.com>
|
|
|
|
*
|
|
|
|
* This file is part of FFmpeg.
|
|
|
|
*
|
|
|
|
* FFmpeg is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* FFmpeg is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with FFmpeg; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
|
|
|
*/
|
|
|
|
|
2016-10-12 14:44:08 +02:00
|
|
|
#ifndef AVCODEC_MEDIACODECDEC_COMMON_H
|
|
|
|
#define AVCODEC_MEDIACODECDEC_COMMON_H
|
2016-01-21 10:29:39 +02:00
|
|
|
|
|
|
|
#include <stdint.h>
|
2017-03-22 20:27:30 +02:00
|
|
|
#include <stdatomic.h>
|
2018-02-16 05:52:14 +02:00
|
|
|
#include <stdbool.h>
|
2016-01-21 10:29:39 +02:00
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
#include "libavutil/frame.h"
|
|
|
|
#include "libavutil/pixfmt.h"
|
|
|
|
|
|
|
|
#include "avcodec.h"
|
|
|
|
#include "mediacodec_wrapper.h"
|
|
|
|
|
|
|
|
typedef struct MediaCodecDecContext {
|
|
|
|
|
2018-03-06 23:14:51 +02:00
|
|
|
AVCodecContext *avctx;
|
2017-03-22 20:27:30 +02:00
|
|
|
atomic_int refcount;
|
2018-03-11 09:43:42 +02:00
|
|
|
atomic_int hw_buffer_count;
|
2016-03-11 18:21:04 +02:00
|
|
|
|
2016-03-14 20:27:14 +02:00
|
|
|
char *codec_name;
|
2016-01-21 10:29:39 +02:00
|
|
|
|
|
|
|
FFAMediaCodec *codec;
|
|
|
|
FFAMediaFormat *format;
|
|
|
|
|
2016-03-11 18:21:04 +02:00
|
|
|
void *surface;
|
|
|
|
|
2016-01-21 10:29:39 +02:00
|
|
|
int started;
|
2016-03-11 18:21:04 +02:00
|
|
|
int draining;
|
2016-01-21 10:29:39 +02:00
|
|
|
int flushing;
|
2016-06-20 16:41:21 +02:00
|
|
|
int eos;
|
2016-01-21 10:29:39 +02:00
|
|
|
|
|
|
|
int width;
|
|
|
|
int height;
|
|
|
|
int stride;
|
|
|
|
int slice_height;
|
|
|
|
int color_format;
|
|
|
|
int crop_top;
|
|
|
|
int crop_bottom;
|
|
|
|
int crop_left;
|
|
|
|
int crop_right;
|
2018-03-20 01:29:45 +02:00
|
|
|
int display_width;
|
|
|
|
int display_height;
|
2016-01-21 10:29:39 +02:00
|
|
|
|
2016-10-06 11:56:24 +02:00
|
|
|
uint64_t output_buffer_count;
|
2016-01-21 10:29:39 +02:00
|
|
|
|
2018-03-06 23:07:32 +02:00
|
|
|
bool delay_flush;
|
|
|
|
atomic_int serial;
|
|
|
|
|
2016-01-21 10:29:39 +02:00
|
|
|
} MediaCodecDecContext;
|
|
|
|
|
|
|
|
int ff_mediacodec_dec_init(AVCodecContext *avctx,
|
|
|
|
MediaCodecDecContext *s,
|
|
|
|
const char *mime,
|
|
|
|
FFAMediaFormat *format);
|
|
|
|
|
2018-02-16 05:52:14 +02:00
|
|
|
int ff_mediacodec_dec_send(AVCodecContext *avctx,
|
|
|
|
MediaCodecDecContext *s,
|
|
|
|
AVPacket *pkt);
|
|
|
|
|
|
|
|
int ff_mediacodec_dec_receive(AVCodecContext *avctx,
|
|
|
|
MediaCodecDecContext *s,
|
|
|
|
AVFrame *frame,
|
|
|
|
bool wait);
|
2016-01-21 10:29:39 +02:00
|
|
|
|
|
|
|
int ff_mediacodec_dec_flush(AVCodecContext *avctx,
|
|
|
|
MediaCodecDecContext *s);
|
|
|
|
|
|
|
|
int ff_mediacodec_dec_close(AVCodecContext *avctx,
|
|
|
|
MediaCodecDecContext *s);
|
|
|
|
|
2016-03-11 18:21:04 +02:00
|
|
|
int ff_mediacodec_dec_is_flushing(AVCodecContext *avctx,
|
|
|
|
MediaCodecDecContext *s);
|
|
|
|
|
|
|
|
typedef struct MediaCodecBuffer {
|
|
|
|
|
|
|
|
MediaCodecDecContext *ctx;
|
|
|
|
ssize_t index;
|
|
|
|
int64_t pts;
|
2017-03-22 20:27:30 +02:00
|
|
|
atomic_int released;
|
2018-03-06 23:07:32 +02:00
|
|
|
int serial;
|
2016-03-11 18:21:04 +02:00
|
|
|
|
|
|
|
} MediaCodecBuffer;
|
|
|
|
|
2016-10-12 14:44:08 +02:00
|
|
|
#endif /* AVCODEC_MEDIACODECDEC_COMMON_H */
|