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  const AVClass *class;
57 
58  mfxSession session;
59  int (*filter_frame) (AVFilterLink *outlink, AVFrame *frame); /**< callback */
60  enum AVPixelFormat out_sw_format; /**< Real output format */
61  mfxVideoParam vpp_param;
62  mfxFrameInfo *frame_infos; /**< frame info for each input */
63 
64  /** members related to the input/output surface */
71  mfxFrameSurface1 **surface_ptrs_in;
72  mfxFrameSurface1 **surface_ptrs_out;
73 
74 #if QSV_HAVE_OPAQUE
75  /** MFXVPP extern parameters */
76  mfxExtOpaqueSurfaceAlloc opaque_alloc;
77  mfxExtBuffer **ext_buffers;
79 #endif
80 
81  int got_frame;
83  int eof;
84  /** order with frame_out, sync */
87 
88 typedef struct QSVVPPCrop {
89  int in_idx; ///< Input index
90  int x, y, w, h; ///< Crop rectangle
91 } QSVVPPCrop;
92 
93 typedef struct QSVVPPParam {
94  /* default is ff_filter_frame */
96 
97  /* To fill with MFX enhanced filter configurations */
99  mfxExtBuffer **ext_buf;
100 
101  /* Real output format */
103 
104  /* Crop information for each input, if needed */
105  int num_crop;
107 } QSVVPPParam;
108 
109 /* create and initialize the QSV session */
110 int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param);
111 
112 /* release the resources (eg.surfaces) */
113 int ff_qsvvpp_close(AVFilterContext *avctx);
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 
131 #endif /* AVFILTER_QSVVPP_H */
QSVVPPCrop::in_idx
int in_idx
Input index.
Definition: qsvvpp.h:89
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
QSVVPPContext::nb_surface_ptrs_in
int nb_surface_ptrs_in
Definition: qsvvpp.h:69
QSVVPPParam::crop
QSVVPPCrop * crop
Definition: qsvvpp.h:106
QSVVPPParam::out_sw_format
enum AVPixelFormat out_sw_format
Definition: qsvvpp.h:102
ff_qsvvpp_filter_frame
int ff_qsvvpp_filter_frame(QSVVPPContext *vpp, AVFilterLink *inlink, AVFrame *frame)
Definition: qsvvpp.c:847
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:58
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:330
w
uint8_t w
Definition: llviddspenc.c:38
QSVFrame::frame
AVFrame * frame
Definition: qsv_internal.h:81
QSVVPPContext::out_mem_mode
int out_mem_mode
Definition: qsvvpp.h:66
QSVVPPContext::surface_ptrs_in
mfxFrameSurface1 ** surface_ptrs_in
Definition: qsvvpp.h:71
fifo.h
QSVVPPContext::frame_infos
mfxFrameInfo * frame_infos
frame info for each input
Definition: qsvvpp.h:62
QSVVPPContext::in_frame_list
QSVFrame * in_frame_list
Definition: qsvvpp.h:67
QSVVPPContext::out_sw_format
enum AVPixelFormat out_sw_format
Real output format.
Definition: qsvvpp.h:60
QSVVPPContext::async_fifo
AVFifo * async_fifo
order with frame_out, sync
Definition: qsvvpp.h:85
QSVVPPCrop::w
int w
Definition: qsvvpp.h:90
ff_qsvvpp_create_mfx_session
int ff_qsvvpp_create_mfx_session(void *ctx, void *loader, mfxIMPL implementation, mfxVersion *pver, mfxSession *psession)
Definition: qsvvpp.c:998
QSVVPPContext::vpp_param
mfxVideoParam vpp_param
Definition: qsvvpp.h:61
ctx
AVFormatContext * ctx
Definition: movenc.c:48
QSVFrame
Definition: qsv_internal.h:80
QSVVPPContext::async_depth
int async_depth
Definition: qsvvpp.h:82
QSVVPPContext
Definition: qsvvpp.h:55
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:66
QSVVPPParam::num_crop
int num_crop
Definition: qsvvpp.h:105
QSVVPPParam
Definition: qsvvpp.h:93
QSVVPPCrop::x
int x
Definition: qsvvpp.h:90
QSVFrame::surface
mfxFrameSurface1 surface
Definition: qsv_internal.h:82
ff_qsvvpp_get_video_buffer
AVFrame * ff_qsvvpp_get_video_buffer(AVFilterLink *inlink, int w, int h)
Definition: qsvvpp.c:1029
QSVVPPContext::got_frame
int got_frame
Definition: qsvvpp.h:81
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:823
QSVVPPContext::nb_ext_buffers
int nb_ext_buffers
Definition: qsvvpp.h:78
mfx_iopattern
int mfx_iopattern
Definition: qsv.c:85
QSVVPPContext::eof
int eof
Definition: qsvvpp.h:83
hwcontext_qsv.h
QSVVPPContext::filter_frame
int(* filter_frame)(AVFilterLink *outlink, AVFrame *frame)
callback
Definition: qsvvpp.h:59
QSVVPPParam::num_ext_buf
int num_ext_buf
Definition: qsvvpp.h:98
QSVVPPParam::filter_frame
int(* filter_frame)(AVFilterLink *outlink, AVFrame *frame)
Definition: qsvvpp.h:95
QSVVPPContext::surface_ptrs_out
mfxFrameSurface1 ** surface_ptrs_out
Definition: qsvvpp.h:72
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:90
QSVVPPCrop::y
int y
Definition: qsvvpp.h:90
QSVVPPContext::ext_buffers
mfxExtBuffer ** ext_buffers
Definition: qsvvpp.h:77
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:392
ff_qsvvpp_init
int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param)
Definition: qsvvpp.c:702
QSVVPPContext::in_mem_mode
int in_mem_mode
members related to the input/output surface
Definition: qsvvpp.h:65
hwcontext.h
QSVVPPContext::out_frame_list
QSVFrame * out_frame_list
Definition: qsvvpp.h:68
h
h
Definition: vp9dsp_template.c:2038
QSVVPPCrop
Definition: qsvvpp.h:88
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:70
QSVVPPParam::ext_buf
mfxExtBuffer ** ext_buf
Definition: qsvvpp.h:99
QSVVPPContext::opaque_alloc
mfxExtOpaqueSurfaceAlloc opaque_alloc
MFXVPP extern parameters.
Definition: qsvvpp.h:76