You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

96 lines
2.5KB

  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. #ifndef AVCODEC_MEDIACODECDEC_H
  23. #define AVCODEC_MEDIACODECDEC_H
  24. #include <stdint.h>
  25. #include <sys/types.h>
  26. #include "libavutil/frame.h"
  27. #include "libavutil/pixfmt.h"
  28. #include "avcodec.h"
  29. #include "mediacodec_wrapper.h"
  30. typedef struct MediaCodecDecContext {
  31. volatile int refcount;
  32. char *codec_name;
  33. FFAMediaCodec *codec;
  34. FFAMediaFormat *format;
  35. void *surface;
  36. int started;
  37. int draining;
  38. int flushing;
  39. int eos;
  40. int width;
  41. int height;
  42. int stride;
  43. int slice_height;
  44. int color_format;
  45. enum AVPixelFormat pix_fmt;
  46. int crop_top;
  47. int crop_bottom;
  48. int crop_left;
  49. int crop_right;
  50. uint64_t output_buffer_count;
  51. } MediaCodecDecContext;
  52. int ff_mediacodec_dec_init(AVCodecContext *avctx,
  53. MediaCodecDecContext *s,
  54. const char *mime,
  55. FFAMediaFormat *format);
  56. int ff_mediacodec_dec_decode(AVCodecContext *avctx,
  57. MediaCodecDecContext *s,
  58. AVFrame *frame,
  59. int *got_frame,
  60. AVPacket *pkt);
  61. int ff_mediacodec_dec_flush(AVCodecContext *avctx,
  62. MediaCodecDecContext *s);
  63. int ff_mediacodec_dec_close(AVCodecContext *avctx,
  64. MediaCodecDecContext *s);
  65. int ff_mediacodec_dec_is_flushing(AVCodecContext *avctx,
  66. MediaCodecDecContext *s);
  67. typedef struct MediaCodecBuffer {
  68. MediaCodecDecContext *ctx;
  69. ssize_t index;
  70. int64_t pts;
  71. volatile int released;
  72. } MediaCodecBuffer;
  73. #endif /* AVCODEC_MEDIACODECDEC_H */