nvdec.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. /*
  2. * HW decode acceleration through NVDEC
  3. *
  4. * Copyright (c) 2016 Anton Khirnov
  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_NVDEC_H
  23. #define AVCODEC_NVDEC_H
  24. #include "compat/cuda/dynlink_loader.h"
  25. #include <stdint.h>
  26. #include "libavutil/buffer.h"
  27. #include "libavutil/frame.h"
  28. #include "avcodec.h"
  29. #if defined(NVDECAPI_MAJOR_VERSION) && defined(NVDECAPI_MINOR_VERSION)
  30. # define NVDECAPI_CHECK_VERSION(major, minor) \
  31. ((major) < NVDECAPI_MAJOR_VERSION || ((major) == NVDECAPI_MAJOR_VERSION && (minor) <= NVDECAPI_MINOR_VERSION))
  32. #else
  33. /* version macros were added in SDK 8.1 ffnvcodec */
  34. # define NVDECAPI_CHECK_VERSION(major, minor) \
  35. ((major) < 8 || ((major) == 8 && (minor) <= 0))
  36. #endif
  37. typedef struct NVDECFrame {
  38. unsigned int idx;
  39. AVBufferRef *idx_ref;
  40. AVBufferRef *decoder_ref;
  41. } NVDECFrame;
  42. typedef struct NVDECContext {
  43. CUVIDPICPARAMS pic_params;
  44. AVBufferPool *decoder_pool;
  45. AVBufferRef *decoder_ref;
  46. uint8_t *bitstream;
  47. int bitstream_len;
  48. unsigned int bitstream_allocated;
  49. unsigned *slice_offsets;
  50. int nb_slices;
  51. unsigned int slice_offsets_allocated;
  52. int supports_444;
  53. } NVDECContext;
  54. int ff_nvdec_decode_init(AVCodecContext *avctx);
  55. int ff_nvdec_decode_uninit(AVCodecContext *avctx);
  56. int ff_nvdec_start_frame(AVCodecContext *avctx, AVFrame *frame);
  57. int ff_nvdec_end_frame(AVCodecContext *avctx);
  58. int ff_nvdec_simple_end_frame(AVCodecContext *avctx);
  59. int ff_nvdec_simple_decode_slice(AVCodecContext *avctx, const uint8_t *buffer,
  60. uint32_t size);
  61. int ff_nvdec_frame_params(AVCodecContext *avctx,
  62. AVBufferRef *hw_frames_ctx,
  63. int dpb_size,
  64. int supports_444);
  65. int ff_nvdec_get_ref_idx(AVFrame *frame);
  66. #endif /* AVCODEC_NVDEC_H */