]> git.sesse.net Git - ffmpeg/blob - libavcodec/mediacodecdec_common.h
Merge commit '0e4c166cdd6446522a085dd9731967d09ac71f72'
[ffmpeg] / libavcodec / mediacodecdec_common.h
1 /*
2  * Android MediaCodec decoder
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 #ifndef AVCODEC_MEDIACODECDEC_COMMON_H
24 #define AVCODEC_MEDIACODECDEC_COMMON_H
25
26 #include <stdint.h>
27 #include <stdatomic.h>
28 #include <stdbool.h>
29 #include <sys/types.h>
30
31 #include "libavutil/frame.h"
32 #include "libavutil/pixfmt.h"
33
34 #include "avcodec.h"
35 #include "mediacodec_wrapper.h"
36
37 typedef struct MediaCodecDecContext {
38
39     atomic_int refcount;
40
41     char *codec_name;
42
43     FFAMediaCodec *codec;
44     FFAMediaFormat *format;
45
46     void *surface;
47
48     int started;
49     int draining;
50     int flushing;
51     int eos;
52
53     int width;
54     int height;
55     int stride;
56     int slice_height;
57     int color_format;
58     enum AVPixelFormat pix_fmt;
59     int crop_top;
60     int crop_bottom;
61     int crop_left;
62     int crop_right;
63
64     uint64_t output_buffer_count;
65
66 } MediaCodecDecContext;
67
68 int ff_mediacodec_dec_init(AVCodecContext *avctx,
69                            MediaCodecDecContext *s,
70                            const char *mime,
71                            FFAMediaFormat *format);
72
73 int ff_mediacodec_dec_send(AVCodecContext *avctx,
74                            MediaCodecDecContext *s,
75                            AVPacket *pkt);
76
77 int ff_mediacodec_dec_receive(AVCodecContext *avctx,
78                               MediaCodecDecContext *s,
79                               AVFrame *frame,
80                               bool wait);
81
82 int ff_mediacodec_dec_flush(AVCodecContext *avctx,
83                             MediaCodecDecContext *s);
84
85 int ff_mediacodec_dec_close(AVCodecContext *avctx,
86                             MediaCodecDecContext *s);
87
88 int ff_mediacodec_dec_is_flushing(AVCodecContext *avctx,
89                                   MediaCodecDecContext *s);
90
91 typedef struct MediaCodecBuffer {
92
93     MediaCodecDecContext *ctx;
94     ssize_t index;
95     int64_t pts;
96     atomic_int released;
97
98 } MediaCodecBuffer;
99
100 #endif /* AVCODEC_MEDIACODECDEC_COMMON_H */