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.

110 lines
3.8KB

  1. /*
  2. * Intel MediaSDK QSV public API
  3. *
  4. * This file is part of FFmpeg.
  5. *
  6. * FFmpeg is free software; you can redistribute it and/or
  7. * modify it under the terms of the GNU Lesser General Public
  8. * License as published by the Free Software Foundation; either
  9. * version 2.1 of the License, or (at your option) any later version.
  10. *
  11. * FFmpeg is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  14. * Lesser General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU Lesser General Public
  17. * License along with FFmpeg; if not, write to the Free Software
  18. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  19. */
  20. #ifndef AVCODEC_QSV_H
  21. #define AVCODEC_QSV_H
  22. #include <mfxvideo.h>
  23. #include "libavutil/buffer.h"
  24. /**
  25. * This struct is used for communicating QSV parameters between libavcodec and
  26. * the caller. It is managed by the caller and must be assigned to
  27. * AVCodecContext.hwaccel_context.
  28. * - decoding: hwaccel_context must be set on return from the get_format()
  29. * callback
  30. * - encoding: hwaccel_context must be set before avcodec_open2()
  31. */
  32. typedef struct AVQSVContext {
  33. /**
  34. * If non-NULL, the session to use for encoding or decoding.
  35. * Otherwise, libavcodec will try to create an internal session.
  36. */
  37. mfxSession session;
  38. /**
  39. * The IO pattern to use.
  40. */
  41. int iopattern;
  42. /**
  43. * Extra buffers to pass to encoder or decoder initialization.
  44. */
  45. mfxExtBuffer **ext_buffers;
  46. int nb_ext_buffers;
  47. /**
  48. * Encoding only. If this field is set to non-zero by the caller, libavcodec
  49. * will create an mfxExtOpaqueSurfaceAlloc extended buffer and pass it to
  50. * the encoder initialization. This only makes sense if iopattern is also
  51. * set to MFX_IOPATTERN_IN_OPAQUE_MEMORY.
  52. *
  53. * The number of allocated opaque surfaces will be the sum of the number
  54. * required by the encoder and the user-provided value nb_opaque_surfaces.
  55. * The array of the opaque surfaces will be exported to the caller through
  56. * the opaque_surfaces field.
  57. *
  58. * The caller must set this field to zero for oneVPL (MFX_VERSION >= 2.0)
  59. */
  60. int opaque_alloc;
  61. /**
  62. * Encoding only, and only if opaque_alloc is set to non-zero. Before
  63. * calling avcodec_open2(), the caller should set this field to the number
  64. * of extra opaque surfaces to allocate beyond what is required by the
  65. * encoder.
  66. *
  67. * On return from avcodec_open2(), this field will be set by libavcodec to
  68. * the total number of allocated opaque surfaces.
  69. */
  70. int nb_opaque_surfaces;
  71. /**
  72. * Encoding only, and only if opaque_alloc is set to non-zero. On return
  73. * from avcodec_open2(), this field will be used by libavcodec to export the
  74. * array of the allocated opaque surfaces to the caller, so they can be
  75. * passed to other parts of the pipeline.
  76. *
  77. * The buffer reference exported here is owned and managed by libavcodec,
  78. * the callers should make their own reference with av_buffer_ref() and free
  79. * it with av_buffer_unref() when it is no longer needed.
  80. *
  81. * The buffer data is an nb_opaque_surfaces-sized array of mfxFrameSurface1.
  82. */
  83. AVBufferRef *opaque_surfaces;
  84. /**
  85. * Encoding only, and only if opaque_alloc is set to non-zero. On return
  86. * from avcodec_open2(), this field will be set to the surface type used in
  87. * the opaque allocation request.
  88. */
  89. int opaque_alloc_type;
  90. } AVQSVContext;
  91. /**
  92. * Allocate a new context.
  93. *
  94. * It must be freed by the caller with av_free().
  95. */
  96. AVQSVContext *av_qsv_alloc_context(void);
  97. #endif /* AVCODEC_QSV_H */