mediacodecdec_common.h 2.51 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
/*
 * 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
 */

23 24
#ifndef AVCODEC_MEDIACODECDEC_COMMON_H
#define AVCODEC_MEDIACODECDEC_COMMON_H
25 26 27 28 29 30 31 32 33 34 35 36

#include <stdint.h>
#include <sys/types.h>

#include "libavutil/frame.h"
#include "libavutil/pixfmt.h"

#include "avcodec.h"
#include "mediacodec_wrapper.h"

typedef struct MediaCodecDecContext {

37 38
    volatile int refcount;

39
    char *codec_name;
40 41 42 43

    FFAMediaCodec *codec;
    FFAMediaFormat *format;

44 45
    void *surface;

46
    int started;
47
    int draining;
48
    int flushing;
49
    int eos;
50 51 52 53 54 55 56 57 58 59 60 61

    int width;
    int height;
    int stride;
    int slice_height;
    int color_format;
    enum AVPixelFormat pix_fmt;
    int crop_top;
    int crop_bottom;
    int crop_left;
    int crop_right;

62
    uint64_t output_buffer_count;
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82

} MediaCodecDecContext;

int ff_mediacodec_dec_init(AVCodecContext *avctx,
                           MediaCodecDecContext *s,
                           const char *mime,
                           FFAMediaFormat *format);

int ff_mediacodec_dec_decode(AVCodecContext *avctx,
                             MediaCodecDecContext *s,
                             AVFrame *frame,
                             int *got_frame,
                             AVPacket *pkt);

int ff_mediacodec_dec_flush(AVCodecContext *avctx,
                            MediaCodecDecContext *s);

int ff_mediacodec_dec_close(AVCodecContext *avctx,
                            MediaCodecDecContext *s);

83 84 85 86 87 88 89 90 91 92 93 94
int ff_mediacodec_dec_is_flushing(AVCodecContext *avctx,
                                  MediaCodecDecContext *s);

typedef struct MediaCodecBuffer {

    MediaCodecDecContext *ctx;
    ssize_t index;
    int64_t pts;
    volatile int released;

} MediaCodecBuffer;

95
#endif /* AVCODEC_MEDIACODECDEC_COMMON_H */