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 typedef struct QSVVPPContext {
56  mfxSession session;
57  int (*filter_frame) (AVFilterLink *outlink, AVFrame *frame); /**< callback */
58  enum AVPixelFormat out_sw_format; /**< Real output format */
59  mfxVideoParam vpp_param;
60  mfxFrameInfo *frame_infos; /**< frame info for each input */
61 
62  /** members related to the input/output surface */
69  mfxFrameSurface1 **surface_ptrs_in;
70  mfxFrameSurface1 **surface_ptrs_out;
71 
72 #if QSV_HAVE_OPAQUE
73  /** MFXVPP extern parameters */
74  mfxExtOpaqueSurfaceAlloc opaque_alloc;
75  mfxExtBuffer **ext_buffers;
77 #endif
78 
79  int got_frame;
81  int eof;
82  /** order with frame_out, sync */
85 
86 typedef struct QSVVPPCrop {
87  int in_idx; ///< Input index
88  int x, y, w, h; ///< Crop rectangle
89 } QSVVPPCrop;
90 
91 typedef struct QSVVPPParam {
92  /* default is ff_filter_frame */
94 
95  /* To fill with MFX enhanced filter configurations */
97  mfxExtBuffer **ext_buf;
98 
99  /* Real output format */
101 
102  /* Crop information for each input, if needed */
103  int num_crop;
105 
107 } QSVVPPParam;
108 
109 /* create and initialize the QSV session */
110 int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam *param);
111 
112 /* release the resources (eg.surfaces) */
113 int ff_qsvvpp_free(QSVVPPContext **vpp);
114 
115 /* vpp filter frame and call the cb if needed */
117 
118 int ff_qsvvpp_print_iopattern(void *log_ctx, int mfx_iopattern,
119  const char *extra_string);
120 
121 int ff_qsvvpp_print_error(void *log_ctx, mfxStatus err,
122  const char *error_string);
123 
124 int ff_qsvvpp_print_warning(void *log_ctx, mfxStatus err,
125  const char *warning_string);
126 
127 int ff_qsvvpp_create_mfx_session(void *ctx, void *loader, mfxIMPL implementation,
128  mfxVersion *pver, mfxSession *psession);
129 
130 #endif /* AVFILTER_QSVVPP_H */
QSVVPPCrop::in_idx
int in_idx
Input index.
Definition: qsvvpp.h:87
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
QSVVPPContext::nb_surface_ptrs_in
int nb_surface_ptrs_in
Definition: qsvvpp.h:67
QSVVPPParam::crop
QSVVPPCrop * crop
Definition: qsvvpp.h:104
QSVVPPParam::out_sw_format
enum AVPixelFormat out_sw_format
Definition: qsvvpp.h:100
ff_qsvvpp_filter_frame
int ff_qsvvpp_filter_frame(QSVVPPContext *vpp, AVFilterLink *inlink, AVFrame *frame)
Definition: qsvvpp.c:837
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:56
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:325
ff_qsvvpp_free
int ff_qsvvpp_free(QSVVPPContext **vpp)
Definition: qsvvpp.c:810
QSVFrame::frame
AVFrame * frame
Definition: qsv_internal.h:81
QSVVPPContext::out_mem_mode
int out_mem_mode
Definition: qsvvpp.h:64
ff_qsvvpp_create
int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam *param)
Definition: qsvvpp.c:683
QSVVPPContext::surface_ptrs_in
mfxFrameSurface1 ** surface_ptrs_in
Definition: qsvvpp.h:69
fifo.h
QSVVPPContext::frame_infos
mfxFrameInfo * frame_infos
frame info for each input
Definition: qsvvpp.h:60
QSVVPPContext::in_frame_list
QSVFrame * in_frame_list
Definition: qsvvpp.h:65
QSVVPPContext::out_sw_format
enum AVPixelFormat out_sw_format
Real output format.
Definition: qsvvpp.h:58
QSVVPPContext::async_fifo
AVFifo * async_fifo
order with frame_out, sync
Definition: qsvvpp.h:83
QSVVPPCrop::w
int w
Definition: qsvvpp.h:88
ff_qsvvpp_create_mfx_session
int ff_qsvvpp_create_mfx_session(void *ctx, void *loader, mfxIMPL implementation, mfxVersion *pver, mfxSession *psession)
Definition: qsvvpp.c:988
QSVVPPContext::vpp_param
mfxVideoParam vpp_param
Definition: qsvvpp.h:59
ctx
AVFormatContext * ctx
Definition: movenc.c:48
QSVVPPParam::async_depth
int async_depth
Definition: qsvvpp.h:106
QSVFrame
Definition: qsv_internal.h:80
QSVVPPContext::async_depth
int async_depth
Definition: qsvvpp.h:80
QSVVPPContext
Definition: qsvvpp.h:55
QSVVPPParam::num_crop
int num_crop
Definition: qsvvpp.h:103
QSVVPPParam
Definition: qsvvpp.h:91
QSVVPPCrop::x
int x
Definition: qsvvpp.h:88
QSVFrame::surface
mfxFrameSurface1 surface
Definition: qsv_internal.h:82
QSVVPPContext::got_frame
int got_frame
Definition: qsvvpp.h:79
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
QSVVPPContext::nb_ext_buffers
int nb_ext_buffers
Definition: qsvvpp.h:76
mfx_iopattern
int mfx_iopattern
Definition: qsv.c:85
QSVVPPContext::eof
int eof
Definition: qsvvpp.h:81
hwcontext_qsv.h
QSVVPPContext::filter_frame
int(* filter_frame)(AVFilterLink *outlink, AVFrame *frame)
callback
Definition: qsvvpp.h:57
QSVVPPParam::num_ext_buf
int num_ext_buf
Definition: qsvvpp.h:96
QSVVPPParam::filter_frame
int(* filter_frame)(AVFilterLink *outlink, AVFrame *frame)
Definition: qsvvpp.h:93
QSVVPPContext::surface_ptrs_out
mfxFrameSurface1 ** surface_ptrs_out
Definition: qsvvpp.h:70
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
QSVFrame::queued
int queued
Definition: qsv_internal.h:100
QSVVPPCrop::h
int h
Crop rectangle.
Definition: qsvvpp.h:88
QSVVPPCrop::y
int y
Definition: qsvvpp.h:88
QSVVPPContext::ext_buffers
mfxExtBuffer ** ext_buffers
Definition: qsvvpp.h:75
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:415
QSVVPPContext::in_mem_mode
int in_mem_mode
members related to the input/output surface
Definition: qsvvpp.h:63
hwcontext.h
QSVVPPContext::out_frame_list
QSVFrame * out_frame_list
Definition: qsvvpp.h:66
QSVVPPCrop
Definition: qsvvpp.h:86
QSVFrame::next
struct QSVFrame * next
Definition: qsv_internal.h:103
int
int
Definition: ffmpeg_filter.c:156
QSVVPPContext::nb_surface_ptrs_out
int nb_surface_ptrs_out
Definition: qsvvpp.h:68
QSVVPPParam::ext_buf
mfxExtBuffer ** ext_buf
Definition: qsvvpp.h:97
QSVVPPContext::opaque_alloc
mfxExtOpaqueSurfaceAlloc opaque_alloc
MFXVPP extern parameters.
Definition: qsvvpp.h:74