mediacodecdec_common.h 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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 <stdbool.h>
  27. #include <sys/types.h>
  28. #include "libavutil/frame.h"
  29. #include "libavutil/pixfmt.h"
  30. #include "avcodec.h"
  31. #include "mediacodec_wrapper.h"
  32. typedef struct MediaCodecDecContext {
  33. AVCodecContext *avctx;
  34. atomic_int refcount;
  35. atomic_int hw_buffer_count;
  36. char *codec_name;
  37. FFAMediaCodec *codec;
  38. FFAMediaFormat *format;
  39. void *surface;
  40. int started;
  41. int draining;
  42. int flushing;
  43. int eos;
  44. int width;
  45. int height;
  46. int stride;
  47. int slice_height;
  48. int color_format;
  49. int crop_top;
  50. int crop_bottom;
  51. int crop_left;
  52. int crop_right;
  53. int display_width;
  54. int display_height;
  55. uint64_t output_buffer_count;
  56. ssize_t current_input_buffer;
  57. bool delay_flush;
  58. atomic_int serial;
  59. } MediaCodecDecContext;
  60. int ff_mediacodec_dec_init(AVCodecContext *avctx,
  61. MediaCodecDecContext *s,
  62. const char *mime,
  63. FFAMediaFormat *format);
  64. int ff_mediacodec_dec_send(AVCodecContext *avctx,
  65. MediaCodecDecContext *s,
  66. AVPacket *pkt,
  67. bool wait);
  68. int ff_mediacodec_dec_receive(AVCodecContext *avctx,
  69. MediaCodecDecContext *s,
  70. AVFrame *frame,
  71. bool wait);
  72. int ff_mediacodec_dec_flush(AVCodecContext *avctx,
  73. MediaCodecDecContext *s);
  74. int ff_mediacodec_dec_close(AVCodecContext *avctx,
  75. MediaCodecDecContext *s);
  76. int ff_mediacodec_dec_is_flushing(AVCodecContext *avctx,
  77. MediaCodecDecContext *s);
  78. typedef struct MediaCodecBuffer {
  79. MediaCodecDecContext *ctx;
  80. ssize_t index;
  81. int64_t pts;
  82. atomic_int released;
  83. int serial;
  84. } MediaCodecBuffer;
  85. #endif /* AVCODEC_MEDIACODECDEC_COMMON_H */