vdpau_internal.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. /*
  2. * Video Decode and Presentation API for UNIX (VDPAU) is used for
  3. * HW decode acceleration for MPEG-1/2, H.264 and VC-1.
  4. *
  5. * Copyright (C) 2008 NVIDIA
  6. *
  7. * This file is part of FFmpeg.
  8. *
  9. * FFmpeg is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation; either
  12. * version 2.1 of the License, or (at your option) any later version.
  13. *
  14. * FFmpeg is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with FFmpeg; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. */
  23. #ifndef AVCODEC_VDPAU_INTERNAL_H
  24. #define AVCODEC_VDPAU_INTERNAL_H
  25. #include <stdint.h>
  26. #include <vdpau/vdpau.h>
  27. #include "libavutil/frame.h"
  28. #include "libavutil/hwcontext.h"
  29. #include "libavutil/hwcontext_vdpau.h"
  30. #include "avcodec.h"
  31. #include "vdpau.h"
  32. /** Extract VdpVideoSurface from an AVFrame */
  33. static inline uintptr_t ff_vdpau_get_surface_id(AVFrame *pic)
  34. {
  35. return (uintptr_t)pic->data[3];
  36. }
  37. union VDPAUPictureInfo {
  38. VdpPictureInfoH264 h264;
  39. VdpPictureInfoMPEG1Or2 mpeg;
  40. VdpPictureInfoVC1 vc1;
  41. VdpPictureInfoMPEG4Part2 mpeg4;
  42. #ifdef VDP_DECODER_PROFILE_H264_HIGH_444_PREDICTIVE
  43. VdpPictureInfoH264Predictive h264_predictive;
  44. #endif
  45. #ifdef VDP_DECODER_PROFILE_HEVC_MAIN
  46. VdpPictureInfoHEVC hevc;
  47. #endif
  48. #ifdef VDP_YCBCR_FORMAT_Y_U_V_444
  49. VdpPictureInfoHEVC444 hevc_444;
  50. #endif
  51. #ifdef VDP_DECODER_PROFILE_VP9_PROFILE_0
  52. VdpPictureInfoVP9 vp9;
  53. #endif
  54. };
  55. typedef struct VDPAUHWContext {
  56. AVVDPAUContext context;
  57. VdpDevice device;
  58. VdpGetProcAddress *get_proc_address;
  59. char reset;
  60. unsigned char flags;
  61. } VDPAUHWContext;
  62. typedef struct VDPAUContext {
  63. /**
  64. * VDPAU device handle
  65. */
  66. VdpDevice device;
  67. /**
  68. * VDPAU decoder handle
  69. */
  70. VdpDecoder decoder;
  71. /**
  72. * VDPAU device driver
  73. */
  74. VdpGetProcAddress *get_proc_address;
  75. /**
  76. * VDPAU decoder render callback
  77. */
  78. VdpDecoderRender *render;
  79. uint32_t width;
  80. uint32_t height;
  81. } VDPAUContext;
  82. struct vdpau_picture_context {
  83. /**
  84. * VDPAU picture information.
  85. */
  86. union VDPAUPictureInfo info;
  87. /**
  88. * Allocated size of the bitstream_buffers table.
  89. */
  90. int bitstream_buffers_allocated;
  91. /**
  92. * Useful bitstream buffers in the bitstream buffers table.
  93. */
  94. int bitstream_buffers_used;
  95. /**
  96. * Table of bitstream buffers.
  97. */
  98. VdpBitstreamBuffer *bitstream_buffers;
  99. };
  100. int ff_vdpau_common_init(AVCodecContext *avctx, VdpDecoderProfile profile,
  101. int level);
  102. int ff_vdpau_common_uninit(AVCodecContext *avctx);
  103. int ff_vdpau_common_start_frame(struct vdpau_picture_context *pic,
  104. const uint8_t *buffer, uint32_t size);
  105. int ff_vdpau_common_end_frame(AVCodecContext *avctx, AVFrame *frame,
  106. struct vdpau_picture_context *pic);
  107. int ff_vdpau_mpeg_end_frame(AVCodecContext *avctx);
  108. int ff_vdpau_add_buffer(struct vdpau_picture_context *pic, const uint8_t *buf,
  109. uint32_t buf_size);
  110. int ff_vdpau_common_frame_params(AVCodecContext *avctx,
  111. AVBufferRef *hw_frames_ctx);
  112. #endif /* AVCODEC_VDPAU_INTERNAL_H */