vaapi_decode.h 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. /*
  2. * This file is part of FFmpeg.
  3. *
  4. * FFmpeg is free software; you can redistribute it and/or
  5. * modify it under the terms of the GNU Lesser General Public
  6. * License as published by the Free Software Foundation; either
  7. * version 2.1 of the License, or (at your option) any later version.
  8. *
  9. * FFmpeg is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  12. * Lesser General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU Lesser General Public
  15. * License along with FFmpeg; if not, write to the Free Software
  16. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  17. */
  18. #ifndef AVCODEC_VAAPI_DECODE_H
  19. #define AVCODEC_VAAPI_DECODE_H
  20. #include <va/va.h>
  21. #include "libavutil/frame.h"
  22. #include "libavutil/hwcontext.h"
  23. #include "libavutil/hwcontext_vaapi.h"
  24. #include "avcodec.h"
  25. #include "version.h"
  26. #if FF_API_STRUCT_VAAPI_CONTEXT
  27. #include "vaapi.h"
  28. #endif
  29. static inline VASurfaceID ff_vaapi_get_surface_id(AVFrame *pic)
  30. {
  31. return (uintptr_t)pic->data[3];
  32. }
  33. enum {
  34. MAX_PARAM_BUFFERS = 16,
  35. };
  36. typedef struct VAAPIDecodePicture {
  37. VASurfaceID output_surface;
  38. int nb_param_buffers;
  39. VABufferID param_buffers[MAX_PARAM_BUFFERS];
  40. int nb_slices;
  41. VABufferID *slice_buffers;
  42. int slices_allocated;
  43. } VAAPIDecodePicture;
  44. typedef struct VAAPIDecodeContext {
  45. VAConfigID va_config;
  46. VAContextID va_context;
  47. #if FF_API_STRUCT_VAAPI_CONTEXT
  48. FF_DISABLE_DEPRECATION_WARNINGS
  49. int have_old_context;
  50. struct vaapi_context *old_context;
  51. AVBufferRef *device_ref;
  52. FF_ENABLE_DEPRECATION_WARNINGS
  53. #endif
  54. AVHWDeviceContext *device;
  55. AVVAAPIDeviceContext *hwctx;
  56. AVHWFramesContext *frames;
  57. AVVAAPIFramesContext *hwfc;
  58. enum AVPixelFormat surface_format;
  59. int surface_count;
  60. VASurfaceAttrib pixel_format_attribute;
  61. } VAAPIDecodeContext;
  62. int ff_vaapi_decode_make_param_buffer(AVCodecContext *avctx,
  63. VAAPIDecodePicture *pic,
  64. int type,
  65. const void *data,
  66. size_t size);
  67. int ff_vaapi_decode_make_slice_buffer(AVCodecContext *avctx,
  68. VAAPIDecodePicture *pic,
  69. const void *params_data,
  70. size_t params_size,
  71. const void *slice_data,
  72. size_t slice_size);
  73. int ff_vaapi_decode_issue(AVCodecContext *avctx,
  74. VAAPIDecodePicture *pic);
  75. int ff_vaapi_decode_cancel(AVCodecContext *avctx,
  76. VAAPIDecodePicture *pic);
  77. int ff_vaapi_decode_init(AVCodecContext *avctx);
  78. int ff_vaapi_decode_uninit(AVCodecContext *avctx);
  79. int ff_vaapi_common_frame_params(AVCodecContext *avctx,
  80. AVBufferRef *hw_frames_ctx);
  81. #endif /* AVCODEC_VAAPI_DECODE_H */