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.

103 lines
3.8KB

  1. /*
  2. * Video Acceleration API (video decoding)
  3. * HW decode acceleration for MPEG-2, MPEG-4, H.264 and VC-1
  4. *
  5. * Copyright (C) 2008-2009 Splitted-Desktop Systems
  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_VAAPI_INTERNAL_H
  24. #define AVCODEC_VAAPI_INTERNAL_H
  25. #include <va/va.h>
  26. #include "vaapi.h"
  27. #include "avcodec.h"
  28. #include "internal.h"
  29. /**
  30. * @addtogroup VAAPI_Decoding
  31. *
  32. * @{
  33. */
  34. typedef struct {
  35. VADisplay display; ///< Windowing system dependent handle
  36. VAConfigID config_id; ///< Configuration ID
  37. VAContextID context_id; ///< Context ID (video decode pipeline)
  38. VABufferID pic_param_buf_id; ///< Picture parameter buffer
  39. VABufferID iq_matrix_buf_id; ///< Inverse quantiser matrix buffer
  40. VABufferID bitplane_buf_id; ///< Bitplane buffer (for VC-1 decoding)
  41. VABufferID *slice_buf_ids; ///< Slice parameter/data buffers
  42. unsigned int n_slice_buf_ids; ///< Number of effective slice buffers
  43. unsigned int slice_buf_ids_alloc; ///< Number of allocated slice buffers
  44. void *slice_params; ///< Pointer to slice parameter buffers
  45. unsigned int slice_param_size; ///< Size of a slice parameter element
  46. unsigned int slice_params_alloc; ///< Number of allocated slice parameters
  47. unsigned int slice_count; ///< Number of slices currently filled in
  48. const uint8_t *slice_data; ///< Pointer to slice data buffer base
  49. unsigned int slice_data_size; ///< Current size of slice data
  50. } FFVAContext;
  51. /** Extract vaapi_context from an AVCodecContext */
  52. static inline FFVAContext *ff_vaapi_get_context(AVCodecContext *avctx)
  53. {
  54. return avctx->internal->hwaccel_priv_data;
  55. }
  56. /** Extract VASurfaceID from an AVFrame */
  57. static inline VASurfaceID ff_vaapi_get_surface_id(AVFrame *pic)
  58. {
  59. return (uintptr_t)pic->data[3];
  60. }
  61. /** Common AVHWAccel.init() implementation */
  62. int ff_vaapi_context_init(AVCodecContext *avctx);
  63. /** Common AVHWAccel.uninit() implementation */
  64. int ff_vaapi_context_fini(AVCodecContext *avctx);
  65. /** Common AVHWAccel.end_frame() implementation */
  66. void ff_vaapi_common_end_frame(AVCodecContext *avctx);
  67. /** Allocate a new picture parameter buffer */
  68. void *ff_vaapi_alloc_pic_param(FFVAContext *vactx, unsigned int size);
  69. /** Allocate a new IQ matrix buffer */
  70. void *ff_vaapi_alloc_iq_matrix(FFVAContext *vactx, unsigned int size);
  71. /** Allocate a new bit-plane buffer */
  72. uint8_t *ff_vaapi_alloc_bitplane(FFVAContext *vactx, uint32_t size);
  73. /**
  74. * Allocate a new slice descriptor for the input slice.
  75. *
  76. * @param vactx the VA API context
  77. * @param buffer the slice data buffer base
  78. * @param size the size of the slice in bytes
  79. * @return the newly allocated slice parameter
  80. */
  81. VASliceParameterBufferBase *ff_vaapi_alloc_slice(FFVAContext *vactx, const uint8_t *buffer, uint32_t size);
  82. int ff_vaapi_mpeg_end_frame(AVCodecContext *avctx);
  83. int ff_vaapi_commit_slices(FFVAContext *vactx);
  84. int ff_vaapi_render_picture(FFVAContext *vactx, VASurfaceID surface);
  85. /* @} */
  86. #endif /* AVCODEC_VAAPI_INTERNAL_H */