FFmpeg
qsvvpp.h
Go to the documentation of this file.
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 /**
20  * @file
21  * Intel Quick Sync Video VPP base function
22  */
23 
24 #ifndef AVFILTER_QSVVPP_H
25 #define AVFILTER_QSVVPP_H
26 
27 #include <mfxvideo.h>
28 
29 #include "avfilter.h"
30 #include "libavutil/fifo.h"
31 #include "libavutil/hwcontext.h"
33 
34 #define FF_INLINK_IDX(link) ((int)((link)->dstpad - (link)->dst->input_pads))
35 #define FF_OUTLINK_IDX(link) ((int)((link)->srcpad - (link)->src->output_pads))
36 
37 #define QSV_VERSION_ATLEAST(MAJOR, MINOR) \
38  (MFX_VERSION_MAJOR > (MAJOR) || \
39  MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))
40 
41 #define QSV_RUNTIME_VERSION_ATLEAST(MFX_VERSION, MAJOR, MINOR) \
42  ((MFX_VERSION.Major > (MAJOR)) || \
43  (MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR)))
44 
45 #define QSV_ONEVPL QSV_VERSION_ATLEAST(2, 0)
46 #define QSV_HAVE_OPAQUE !QSV_ONEVPL
47 
48 typedef struct QSVFrame {
49  AVFrame *frame;
50  mfxFrameSurface1 surface;
51  struct QSVFrame *next;
52  int queued;
53 } QSVFrame;
54 
55 #define QSVVPP_MAX_FRAME_EXTBUFS 8
56 
57 typedef struct QSVVPPFrameParam {
58  /* To fill with MFX enhanced filter configurations */
60  mfxExtBuffer **ext_buf;
62 
63 typedef struct QSVVPPContext {
64  const AVClass *class;
65 
66  mfxSession session;
67  int (*filter_frame) (AVFilterLink *outlink, AVFrame *frame); /**< callback */
69  enum AVPixelFormat out_sw_format; /**< Real output format */
70  mfxVideoParam vpp_param;
71  mfxFrameInfo *frame_infos; /**< frame info for each input */
72 
73  /** members related to the input/output surface */
80  mfxFrameSurface1 **surface_ptrs_in;
81  mfxFrameSurface1 **surface_ptrs_out;
82 
83 #if QSV_HAVE_OPAQUE
84  /** MFXVPP extern parameters */
85  mfxExtOpaqueSurfaceAlloc opaque_alloc;
86 #endif
87  /** store sequence parameters */
88  mfxExtBuffer **seq_buffers;
90 
91  /** store all parameters for vpp execution, including parameters per frame */
92  mfxExtBuffer **ext_buffers;
94 
95  int got_frame;
97  int eof;
98  /** order with frame_out, sync */
100 
101  mfxVersion ver;
103 } QSVVPPContext;
104 
105 typedef struct QSVVPPCrop {
106  int in_idx; ///< Input index
107  int x, y, w, h; ///< Crop rectangle
108 } QSVVPPCrop;
109 
110 typedef struct QSVVPPParam {
111  /* default is ff_filter_frame */
114 
115  /* To fill with MFX enhanced filter configurations */
117  mfxExtBuffer **ext_buf;
118 
119  /* Real output format */
121 
122  /* Crop information for each input, if needed */
123  int num_crop;
125 } QSVVPPParam;
126 
127 /* create and initialize the QSV session */
128 int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param);
129 
130 /* release the resources (eg.surfaces) */
131 int ff_qsvvpp_close(AVFilterContext *avctx);
132 
133 /* vpp filter frame and call the cb if needed */
135 
136 int ff_qsvvpp_print_iopattern(void *log_ctx, int mfx_iopattern,
137  const char *extra_string);
138 
139 int ff_qsvvpp_print_error(void *log_ctx, mfxStatus err,
140  const char *error_string);
141 
142 int ff_qsvvpp_print_warning(void *log_ctx, mfxStatus err,
143  const char *warning_string);
144 
145 int ff_qsvvpp_create_mfx_session(void *ctx, void *loader, mfxIMPL implementation,
146  mfxVersion *pver, mfxSession *psession);
147 
149 #endif /* AVFILTER_QSVVPP_H */
QSVVPPCrop::in_idx
int in_idx
Input index.
Definition: qsvvpp.h:106
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
QSVVPPContext::nb_surface_ptrs_in
int nb_surface_ptrs_in
Definition: qsvvpp.h:78
out
FILE * out
Definition: movenc.c:54
QSVVPPParam::crop
QSVVPPCrop * crop
Definition: qsvvpp.h:124
QSVVPPParam::out_sw_format
enum AVPixelFormat out_sw_format
Definition: qsvvpp.h:120
ff_qsvvpp_filter_frame
int ff_qsvvpp_filter_frame(QSVVPPContext *vpp, AVFilterLink *inlink, AVFrame *frame)
Definition: qsvvpp.c:960
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
QSVVPPContext::session
mfxSession session
Definition: qsvvpp.h:66
QSVVPPContext::ver
mfxVersion ver
Definition: qsvvpp.h:101
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:344
w
uint8_t w
Definition: llviddspenc.c:38
QSVFrame::frame
AVFrame * frame
Definition: qsv_internal.h:80
QSVVPPContext::out_mem_mode
int out_mem_mode
Definition: qsvvpp.h:75
QSVVPPContext::surface_ptrs_in
mfxFrameSurface1 ** surface_ptrs_in
Definition: qsvvpp.h:80
fifo.h
QSVVPPContext::seq_buffers
mfxExtBuffer ** seq_buffers
store sequence parameters
Definition: qsvvpp.h:88
QSVVPPContext::frame_infos
mfxFrameInfo * frame_infos
frame info for each input
Definition: qsvvpp.h:71
QSVVPPContext::in_frame_list
QSVFrame * in_frame_list
Definition: qsvvpp.h:76
QSVVPPContext::out_sw_format
enum AVPixelFormat out_sw_format
Real output format.
Definition: qsvvpp.h:69
QSVVPPContext::async_fifo
AVFifo * async_fifo
order with frame_out, sync
Definition: qsvvpp.h:99
QSVVPPCrop::w
int w
Definition: qsvvpp.h:107
ff_qsvvpp_create_mfx_session
int ff_qsvvpp_create_mfx_session(void *ctx, void *loader, mfxIMPL implementation, mfxVersion *pver, mfxSession *psession)
Definition: qsvvpp.c:1115
QSVVPPContext::vpp_param
mfxVideoParam vpp_param
Definition: qsvvpp.h:70
ctx
AVFormatContext * ctx
Definition: movenc.c:48
frame
static AVFrame * frame
Definition: demux_decode.c:54
QSVFrame
Definition: qsv_internal.h:79
QSVVPPContext::async_depth
int async_depth
Definition: qsvvpp.h:96
QSVVPPContext
Definition: qsvvpp.h:63
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
QSVVPPParam::num_crop
int num_crop
Definition: qsvvpp.h:123
QSVVPPParam
Definition: qsvvpp.h:110
QSVVPPCrop::x
int x
Definition: qsvvpp.h:107
QSVVPPContext::vpp_initted
int vpp_initted
Definition: qsvvpp.h:102
QSVFrame::surface
mfxFrameSurface1 surface
Definition: qsv_internal.h:81
ff_qsvvpp_get_video_buffer
AVFrame * ff_qsvvpp_get_video_buffer(AVFilterLink *inlink, int w, int h)
Definition: qsvvpp.c:1146
fp
#define fp
Definition: regdef.h:44
QSVVPPContext::got_frame
int got_frame
Definition: qsvvpp.h:95
ff_qsvvpp_print_error
int ff_qsvvpp_print_error(void *log_ctx, mfxStatus err, const char *error_string)
Definition: qsvvpp.c:154
ff_qsvvpp_print_iopattern
int ff_qsvvpp_print_iopattern(void *log_ctx, int mfx_iopattern, const char *extra_string)
Definition: qsvvpp.c:72
AVFifo
Definition: fifo.c:35
ff_qsvvpp_close
int ff_qsvvpp_close(AVFilterContext *avctx)
Definition: qsvvpp.c:936
QSVVPPContext::nb_ext_buffers
int nb_ext_buffers
Definition: qsvvpp.h:93
mfx_iopattern
int mfx_iopattern
Definition: qsv.c:85
QSVVPPContext::eof
int eof
Definition: qsvvpp.h:97
hwcontext_qsv.h
QSVVPPFrameParam::num_ext_buf
int num_ext_buf
Definition: qsvvpp.h:59
QSVVPPContext::filter_frame
int(* filter_frame)(AVFilterLink *outlink, AVFrame *frame)
callback
Definition: qsvvpp.h:67
QSVVPPParam::num_ext_buf
int num_ext_buf
Definition: qsvvpp.h:116
QSVVPPParam::filter_frame
int(* filter_frame)(AVFilterLink *outlink, AVFrame *frame)
Definition: qsvvpp.h:112
QSVVPPContext::surface_ptrs_out
mfxFrameSurface1 ** surface_ptrs_out
Definition: qsvvpp.h:81
QSVVPPContext::set_frame_ext_params
int(* set_frame_ext_params)(AVFilterContext *ctx, const AVFrame *in, AVFrame *out, QSVVPPFrameParam *fp)
callbak
Definition: qsvvpp.h:68
QSVFrame::queued
int queued
Definition: qsv_internal.h:99
QSVVPPCrop::h
int h
Crop rectangle.
Definition: qsvvpp.h:107
QSVVPPCrop::y
int y
Definition: qsvvpp.h:107
QSVVPPContext::ext_buffers
mfxExtBuffer ** ext_buffers
store all parameters for vpp execution, including parameters per frame
Definition: qsvvpp.h:92
avfilter.h
ff_qsvvpp_print_warning
int ff_qsvvpp_print_warning(void *log_ctx, mfxStatus err, const char *warning_string)
Definition: qsvvpp.c:164
AVFilterContext
An instance of a filter.
Definition: avfilter.h:407
ff_qsvvpp_init
int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param)
Definition: qsvvpp.c:744
QSVVPPFrameParam::ext_buf
mfxExtBuffer ** ext_buf
Definition: qsvvpp.h:60
QSVVPPContext::in_mem_mode
int in_mem_mode
members related to the input/output surface
Definition: qsvvpp.h:74
hwcontext.h
QSVVPPContext::out_frame_list
QSVFrame * out_frame_list
Definition: qsvvpp.h:77
h
h
Definition: vp9dsp_template.c:2038
QSVVPPContext::nb_seq_buffers
int nb_seq_buffers
Definition: qsvvpp.h:89
QSVVPPCrop
Definition: qsvvpp.h:105
QSVFrame::next
struct QSVFrame * next
Definition: qsv_internal.h:102
int
int
Definition: ffmpeg_filter.c:409
QSVVPPParam::set_frame_ext_params
int(* set_frame_ext_params)(AVFilterContext *ctx, const AVFrame *in, AVFrame *out, QSVVPPFrameParam *fp)
callbak
Definition: qsvvpp.h:113
QSVVPPContext::nb_surface_ptrs_out
int nb_surface_ptrs_out
Definition: qsvvpp.h:79
QSVVPPFrameParam
Definition: qsvvpp.h:57
QSVVPPParam::ext_buf
mfxExtBuffer ** ext_buf
Definition: qsvvpp.h:117
QSVVPPContext::opaque_alloc
mfxExtOpaqueSurfaceAlloc opaque_alloc
MFXVPP extern parameters.
Definition: qsvvpp.h:85