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.

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