tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

mediacodecdec_common.h (2946B)


      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    AVCodecContext *avctx;
     40    atomic_int refcount;
     41    atomic_int hw_buffer_count;
     42 
     43    char *codec_name;
     44 
     45    FFAMediaCodec *codec;
     46    FFAMediaFormat *format;
     47 
     48    void *surface;
     49 
     50    int started;
     51    int draining;
     52    int flushing;
     53    int eos;
     54 
     55    int width;
     56    int height;
     57    int stride;
     58    int slice_height;
     59    int color_format;
     60    int crop_top;
     61    int crop_bottom;
     62    int crop_left;
     63    int crop_right;
     64    int display_width;
     65    int display_height;
     66 
     67    uint64_t output_buffer_count;
     68    ssize_t current_input_buffer;
     69 
     70    bool delay_flush;
     71    atomic_int serial;
     72 
     73    bool use_ndk_codec;
     74 } MediaCodecDecContext;
     75 
     76 int ff_mediacodec_dec_init(AVCodecContext *avctx,
     77                           MediaCodecDecContext *s,
     78                           const char *mime,
     79                           FFAMediaFormat *format);
     80 
     81 int ff_mediacodec_dec_send(AVCodecContext *avctx,
     82                           MediaCodecDecContext *s,
     83                           AVPacket *pkt,
     84                           bool wait);
     85 
     86 int ff_mediacodec_dec_receive(AVCodecContext *avctx,
     87                              MediaCodecDecContext *s,
     88                              AVFrame *frame,
     89                              bool wait);
     90 
     91 int ff_mediacodec_dec_flush(AVCodecContext *avctx,
     92                            MediaCodecDecContext *s);
     93 
     94 int ff_mediacodec_dec_close(AVCodecContext *avctx,
     95                            MediaCodecDecContext *s);
     96 
     97 int ff_mediacodec_dec_is_flushing(AVCodecContext *avctx,
     98                                  MediaCodecDecContext *s);
     99 
    100 typedef struct MediaCodecBuffer {
    101 
    102    MediaCodecDecContext *ctx;
    103    ssize_t index;
    104    int64_t pts;
    105    atomic_int released;
    106    int serial;
    107 
    108 } MediaCodecBuffer;
    109 
    110 #endif /* AVCODEC_MEDIACODECDEC_COMMON_H */