qsv.h 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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 <mfx/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. int opaque_alloc;
  59. /**
  60. * Encoding only, and only if opaque_alloc is set to non-zero. Before
  61. * calling avcodec_open2(), the caller should set this field to the number
  62. * of extra opaque surfaces to allocate beyond what is required by the
  63. * encoder.
  64. *
  65. * On return from avcodec_open2(), this field will be set by libavcodec to
  66. * the total number of allocated opaque surfaces.
  67. */
  68. int nb_opaque_surfaces;
  69. /**
  70. * Encoding only, and only if opaque_alloc is set to non-zero. On return
  71. * from avcodec_open2(), this field will be used by libavcodec to export the
  72. * array of the allocated opaque surfaces to the caller, so they can be
  73. * passed to other parts of the pipeline.
  74. *
  75. * The buffer reference exported here is owned and managed by libavcodec,
  76. * the callers should make their own reference with av_buffer_ref() and free
  77. * it with av_buffer_unref() when it is no longer needed.
  78. *
  79. * The buffer data is an nb_opaque_surfaces-sized array of mfxFrameSurface1.
  80. */
  81. AVBufferRef *opaque_surfaces;
  82. /**
  83. * Encoding only, and only if opaque_alloc is set to non-zero. On return
  84. * from avcodec_open2(), this field will be set to the surface type used in
  85. * the opaque allocation request.
  86. */
  87. int opaque_alloc_type;
  88. } AVQSVContext;
  89. /**
  90. * Allocate a new context.
  91. *
  92. * It must be freed by the caller with av_free().
  93. */
  94. AVQSVContext *av_qsv_alloc_context(void);
  95. #endif /* AVCODEC_QSV_H */