]> git.sesse.net Git - ffmpeg/blob - libavcodec/mediacodecdec_common.h
lavf/segment: fix writing separate header with auto BSF
[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 <sys/types.h>
28
29 #include "libavutil/frame.h"
30 #include "libavutil/pixfmt.h"
31
32 #include "avcodec.h"
33 #include "mediacodec_wrapper.h"
34
35 typedef struct MediaCodecDecContext {
36
37     volatile int refcount;
38
39     char *codec_name;
40
41     FFAMediaCodec *codec;
42     FFAMediaFormat *format;
43
44     void *surface;
45
46     int started;
47     int draining;
48     int flushing;
49     int eos;
50
51     int width;
52     int height;
53     int stride;
54     int slice_height;
55     int color_format;
56     enum AVPixelFormat pix_fmt;
57     int crop_top;
58     int crop_bottom;
59     int crop_left;
60     int crop_right;
61
62     uint64_t output_buffer_count;
63
64 } MediaCodecDecContext;
65
66 int ff_mediacodec_dec_init(AVCodecContext *avctx,
67                            MediaCodecDecContext *s,
68                            const char *mime,
69                            FFAMediaFormat *format);
70
71 int ff_mediacodec_dec_decode(AVCodecContext *avctx,
72                              MediaCodecDecContext *s,
73                              AVFrame *frame,
74                              int *got_frame,
75                              AVPacket *pkt);
76
77 int ff_mediacodec_dec_flush(AVCodecContext *avctx,
78                             MediaCodecDecContext *s);
79
80 int ff_mediacodec_dec_close(AVCodecContext *avctx,
81                             MediaCodecDecContext *s);
82
83 int ff_mediacodec_dec_is_flushing(AVCodecContext *avctx,
84                                   MediaCodecDecContext *s);
85
86 typedef struct MediaCodecBuffer {
87
88     MediaCodecDecContext *ctx;
89     ssize_t index;
90     int64_t pts;
91     volatile int released;
92
93 } MediaCodecBuffer;
94
95 #endif /* AVCODEC_MEDIACODECDEC_COMMON_H */