2 * This file is part of FFmpeg.
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.
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.
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
21 * Intel Quick Sync Video VPP base function
24 #ifndef AVFILTER_QSVVPP_H
25 #define AVFILTER_QSVVPP_H
27 #include <mfx/mfxvideo.h>
30 #include "libavutil/fifo.h"
32 #define FF_INLINK_IDX(link) ((int)((link)->dstpad - (link)->dst->input_pads))
33 #define FF_OUTLINK_IDX(link) ((int)((link)->srcpad - (link)->src->output_pads))
35 #define QSV_VERSION_ATLEAST(MAJOR, MINOR) \
36 (MFX_VERSION_MAJOR > (MAJOR) || \
37 MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))
39 #define QSV_RUNTIME_VERSION_ATLEAST(MFX_VERSION, MAJOR, MINOR) \
40 ((MFX_VERSION.Major > (MAJOR)) || \
41 (MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR)))
43 typedef struct QSVFrame {
45 mfxFrameSurface1 surface;
46 struct QSVFrame *next;
50 typedef struct QSVVPPContext {
52 int (*filter_frame) (AVFilterLink *outlink, AVFrame *frame); /**< callback */
53 enum AVPixelFormat out_sw_format; /**< Real output format */
54 mfxVideoParam vpp_param;
55 mfxFrameInfo *frame_infos; /**< frame info for each input */
57 /** members related to the input/output surface */
60 QSVFrame *in_frame_list;
61 QSVFrame *out_frame_list;
62 int nb_surface_ptrs_in;
63 int nb_surface_ptrs_out;
64 mfxFrameSurface1 **surface_ptrs_in;
65 mfxFrameSurface1 **surface_ptrs_out;
67 /** MFXVPP extern parameters */
68 mfxExtOpaqueSurfaceAlloc opaque_alloc;
69 mfxExtBuffer **ext_buffers;
75 /** order with frame_out, sync */
76 AVFifoBuffer *async_fifo;
79 typedef struct QSVVPPCrop {
80 int in_idx; ///< Input index
81 int x, y, w, h; ///< Crop rectangle
84 typedef struct QSVVPPParam {
85 /* default is ff_filter_frame */
86 int (*filter_frame)(AVFilterLink *outlink, AVFrame *frame);
88 /* To fill with MFX enhanced filter configurations */
90 mfxExtBuffer **ext_buf;
92 /* Real output format */
93 enum AVPixelFormat out_sw_format;
95 /* Crop information for each input, if needed */
102 /* create and initialize the QSV session */
103 int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam *param);
105 /* release the resources (eg.surfaces) */
106 int ff_qsvvpp_free(QSVVPPContext **vpp);
108 /* vpp filter frame and call the cb if needed */
109 int ff_qsvvpp_filter_frame(QSVVPPContext *vpp, AVFilterLink *inlink, AVFrame *frame);
111 int ff_qsvvpp_print_iopattern(void *log_ctx, int mfx_iopattern,
112 const char *extra_string);
114 int ff_qsvvpp_print_error(void *log_ctx, mfxStatus err,
115 const char *error_string);
117 int ff_qsvvpp_print_warning(void *log_ctx, mfxStatus err,
118 const char *warning_string);
120 #endif /* AVFILTER_QSVVPP_H */