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 <mfx/mfxvideo.h>
28 
29 #include "avfilter.h"
30 #include "libavutil/fifo.h"
31 
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))
34 
35 #define QSV_VERSION_ATLEAST(MAJOR, MINOR) \
36  (MFX_VERSION_MAJOR > (MAJOR) || \
37  MFX_VERSION_MAJOR == (MAJOR) && MFX_VERSION_MINOR >= (MINOR))
38 
39 #define QSV_RUNTIME_VERSION_ATLEAST(MFX_VERSION, MAJOR, MINOR) \
40  ((MFX_VERSION.Major > (MAJOR)) || \
41  (MFX_VERSION.Major == (MAJOR) && MFX_VERSION.Minor >= (MINOR)))
42 
43 typedef struct QSVFrame {
44  AVFrame *frame;
45  mfxFrameSurface1 surface;
46  struct QSVFrame *next;
47  int queued;
48 } QSVFrame;
49 
50 typedef struct QSVVPPContext {
51  mfxSession session;
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 */
56 
57  /** members related to the input/output surface */
64  mfxFrameSurface1 **surface_ptrs_in;
65  mfxFrameSurface1 **surface_ptrs_out;
66 
67  /** MFXVPP extern parameters */
68  mfxExtOpaqueSurfaceAlloc opaque_alloc;
69  mfxExtBuffer **ext_buffers;
71 
72  int got_frame;
74  int eof;
75  /** order with frame_out, sync */
78 
79 typedef struct QSVVPPCrop {
80  int in_idx; ///< Input index
81  int x, y, w, h; ///< Crop rectangle
82 } QSVVPPCrop;
83 
84 typedef struct QSVVPPParam {
85  /* default is ff_filter_frame */
87 
88  /* To fill with MFX enhanced filter configurations */
90  mfxExtBuffer **ext_buf;
91 
92  /* Real output format */
94 
95  /* Crop information for each input, if needed */
96  int num_crop;
98 
100 } QSVVPPParam;
101 
102 /* create and initialize the QSV session */
103 int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam *param);
104 
105 /* release the resources (eg.surfaces) */
106 int ff_qsvvpp_free(QSVVPPContext **vpp);
107 
108 /* vpp filter frame and call the cb if needed */
110 
111 int ff_qsvvpp_print_iopattern(void *log_ctx, int mfx_iopattern,
112  const char *extra_string);
113 
114 int ff_qsvvpp_print_error(void *log_ctx, mfxStatus err,
115  const char *error_string);
116 
117 int ff_qsvvpp_print_warning(void *log_ctx, mfxStatus err,
118  const char *warning_string);
119 
120 #endif /* AVFILTER_QSVVPP_H */
QSVVPPCrop::in_idx
int in_idx
Input index.
Definition: qsvvpp.h:80
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
QSVVPPContext::nb_surface_ptrs_in
int nb_surface_ptrs_in
Definition: qsvvpp.h:62
QSVVPPParam::crop
QSVVPPCrop * crop
Definition: qsvvpp.h:97
QSVVPPParam::out_sw_format
enum AVPixelFormat out_sw_format
Definition: qsvvpp.h:93
ff_qsvvpp_filter_frame
int ff_qsvvpp_filter_frame(QSVVPPContext *vpp, AVFilterLink *inlink, AVFrame *frame)
Definition: qsvvpp.c:798
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:51
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:317
ff_qsvvpp_free
int ff_qsvvpp_free(QSVVPPContext **vpp)
Definition: qsvvpp.c:773
QSVFrame::frame
AVFrame * frame
Definition: qsv_internal.h:73
QSVVPPContext::out_mem_mode
int out_mem_mode
Definition: qsvvpp.h:59
AVFifoBuffer
Definition: fifo.h:31
ff_qsvvpp_create
int ff_qsvvpp_create(AVFilterContext *avctx, QSVVPPContext **vpp, QSVVPPParam *param)
Definition: qsvvpp.c:655
QSVVPPContext::surface_ptrs_in
mfxFrameSurface1 ** surface_ptrs_in
Definition: qsvvpp.h:64
fifo.h
QSVVPPContext::frame_infos
mfxFrameInfo * frame_infos
frame info for each input
Definition: qsvvpp.h:55
QSVVPPContext::in_frame_list
QSVFrame * in_frame_list
Definition: qsvvpp.h:60
QSVVPPContext::out_sw_format
enum AVPixelFormat out_sw_format
Real output format.
Definition: qsvvpp.h:53
QSVVPPContext::async_fifo
AVFifoBuffer * async_fifo
order with frame_out, sync
Definition: qsvvpp.h:76
QSVVPPCrop::w
int w
Definition: qsvvpp.h:81
QSVVPPContext::vpp_param
mfxVideoParam vpp_param
Definition: qsvvpp.h:54
QSVVPPParam::async_depth
int async_depth
Definition: qsvvpp.h:99
QSVFrame
Definition: qsv_internal.h:72
QSVVPPContext::async_depth
int async_depth
Definition: qsvvpp.h:73
QSVVPPContext
Definition: qsvvpp.h:50
QSVVPPParam::num_crop
int num_crop
Definition: qsvvpp.h:96
QSVVPPParam
Definition: qsvvpp.h:84
QSVVPPCrop::x
int x
Definition: qsvvpp.h:81
QSVFrame::surface
mfxFrameSurface1 surface
Definition: qsv_internal.h:74
QSVVPPContext::got_frame
int got_frame
Definition: qsvvpp.h:72
ff_qsvvpp_print_error
int ff_qsvvpp_print_error(void *log_ctx, mfxStatus err, const char *error_string)
Definition: qsvvpp.c:127
ff_qsvvpp_print_iopattern
int ff_qsvvpp_print_iopattern(void *log_ctx, int mfx_iopattern, const char *extra_string)
Definition: qsvvpp.c:55
QSVVPPContext::nb_ext_buffers
int nb_ext_buffers
Definition: qsvvpp.h:70
mfx_iopattern
int mfx_iopattern
Definition: qsv.c:82
QSVVPPContext::eof
int eof
Definition: qsvvpp.h:74
QSVVPPContext::filter_frame
int(* filter_frame)(AVFilterLink *outlink, AVFrame *frame)
callback
Definition: qsvvpp.h:52
QSVVPPParam::num_ext_buf
int num_ext_buf
Definition: qsvvpp.h:89
QSVVPPParam::filter_frame
int(* filter_frame)(AVFilterLink *outlink, AVFrame *frame)
Definition: qsvvpp.h:86
QSVVPPContext::surface_ptrs_out
mfxFrameSurface1 ** surface_ptrs_out
Definition: qsvvpp.h:65
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:81
QSVVPPCrop::h
int h
Crop rectangle.
Definition: qsvvpp.h:81
QSVVPPCrop::y
int y
Definition: qsvvpp.h:81
QSVVPPContext::ext_buffers
mfxExtBuffer ** ext_buffers
Definition: qsvvpp.h:69
avfilter.h
ff_qsvvpp_print_warning
int ff_qsvvpp_print_warning(void *log_ctx, mfxStatus err, const char *warning_string)
Definition: qsvvpp.c:137
AVFilterContext
An instance of a filter.
Definition: avfilter.h:402
QSVVPPContext::in_mem_mode
int in_mem_mode
members related to the input/output surface
Definition: qsvvpp.h:58
QSVVPPContext::out_frame_list
QSVFrame * out_frame_list
Definition: qsvvpp.h:61
QSVVPPCrop
Definition: qsvvpp.h:79
QSVFrame::next
struct QSVFrame * next
Definition: qsv_internal.h:84
int
int
Definition: ffmpeg_filter.c:153
QSVVPPContext::nb_surface_ptrs_out
int nb_surface_ptrs_out
Definition: qsvvpp.h:63
QSVVPPParam::ext_buf
mfxExtBuffer ** ext_buf
Definition: qsvvpp.h:90
QSVVPPContext::opaque_alloc
mfxExtOpaqueSurfaceAlloc opaque_alloc
MFXVPP extern parameters.
Definition: qsvvpp.h:68