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.

121 lines
3.8KB

  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. /**
  19. * @file
  20. * Intel Quick Sync Video VPP base function
  21. */
  22. #ifndef AVFILTER_QSVVPP_H
  23. #define AVFILTER_QSVVPP_H
  24. #include <mfx/mfxvideo.h>
  25. #include "avfilter.h"
  26. #include "libavutil/fifo.h"
  27. #define FF_INLINK_IDX(link) ((int)((link)->dstpad - (link)->dst->input_pads))
  28. #define FF_OUTLINK_IDX(link) ((int)((link)->srcpad - (link)->src->output_pads))
  29. #define QSV_VERSION_ATLEAST(MAJOR, MINOR) \
  30. (MFX_VERSION_MAJOR > (MAJOR) || \
  31. MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))
  32. #define QSV_RUNTIME_VERSION_ATLEAST(MFX_VERSION, MAJOR, MINOR) \
  33. ((MFX_VERSION.Major > (MAJOR)) || \
  34. (MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR)))
  35. typedef struct QSVFrame {
  36. AVFrame *frame;
  37. mfxFrameSurface1 surface;
  38. struct QSVFrame *next;
  39. int queued;
  40. } QSVFrame;
  41. typedef struct QSVVPPContext {
  42. mfxSession session;
  43. int (*filter_frame) (AVFilterLink *outlink, AVFrame *frame); /**< callback */
  44. enum AVPixelFormat out_sw_format; /**< Real output format */
  45. mfxVideoParam vpp_param;
  46. mfxFrameInfo *frame_infos; /**< frame info for each input */
  47. /** members related to the input/output surface */
  48. int in_mem_mode;
  49. int out_mem_mode;
  50. QSVFrame *in_frame_list;
  51. QSVFrame *out_frame_list;
  52. int nb_surface_ptrs_in;
  53. int nb_surface_ptrs_out;
  54. mfxFrameSurface1 **surface_ptrs_in;
  55. mfxFrameSurface1 **surface_ptrs_out;
  56. /** MFXVPP extern parameters */
  57. mfxExtOpaqueSurfaceAlloc opaque_alloc;
  58. mfxExtBuffer **ext_buffers;
  59. int nb_ext_buffers;
  60. int got_frame;
  61. int async_depth;
  62. int eof;
  63. /** order with frame_out, sync */
  64. AVFifoBuffer *async_fifo;
  65. } QSVVPPContext;
  66. typedef struct QSVVPPCrop {
  67. int in_idx; ///< Input index
  68. int x, y, w, h; ///< Crop rectangle
  69. } QSVVPPCrop;
  70. typedef struct QSVVPPParam {
  71. /* default is ff_filter_frame */
  72. int (*filter_frame)(AVFilterLink *outlink, AVFrame *frame);
  73. /* To fill with MFX enhanced filter configurations */
  74. int num_ext_buf;
  75. mfxExtBuffer **ext_buf;
  76. /* Real output format */
  77. enum AVPixelFormat out_sw_format;
  78. /* Crop information for each input, if needed */
  79. int num_crop;
  80. QSVVPPCrop *crop;
  81. int async_depth;
  82. } QSVVPPParam;
  83. /* create and initialize the QSV session */
  84. int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam *param);
  85. /* release the resources (eg.surfaces) */
  86. int ff_qsvvpp_free(QSVVPPContext **vpp);
  87. /* vpp filter frame and call the cb if needed */
  88. int ff_qsvvpp_filter_frame(QSVVPPContext *vpp, AVFilterLink *inlink, AVFrame *frame);
  89. int ff_qsvvpp_print_iopattern(void *log_ctx, int mfx_iopattern,
  90. const char *extra_string);
  91. int ff_qsvvpp_print_error(void *log_ctx, mfxStatus err,
  92. const char *error_string);
  93. int ff_qsvvpp_print_warning(void *log_ctx, mfxStatus err,
  94. const char *warning_string);
  95. #endif /* AVFILTER_QSVVPP_H */