FFmpeg: libavfilter/vf_stack_qsv.c Source File
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 * Hardware accelerated hstack, vstack and xstack filters based on Intel Quick Sync Video VPP
22 */
23
24 #include "config_components.h"
25
36
41
44
45 #define HSTACK_NAME "hstack_qsv"
46 #define VSTACK_NAME "vstack_qsv"
47 #define XSTACK_NAME "xstack_qsv"
48 #define HWContext QSVVPPContext
49 #define StackHWContext StackQSVContext
51
54
58
59 static void rgb2yuv(
float r,
float g,
float b,
int *y,
int *
u,
int *v,
int depth)
60 {
61 *y = ((0.21260*219.0/255.0) *
r + (0.71520*219.0/255.0) *
g +
62 (0.07220*219.0/255.0) *
b) * ((1 << depth) - 1);
63 *
u = (-(0.11457*224.0/255.0) *
r - (0.38543*224.0/255.0) *
g +
64 (0.50000*224.0/255.0) *
b + 0.5) * ((1 << depth) - 1);
65 *v = ((0.50000*224.0/255.0) *
r - (0.45415*224.0/255.0) *
g -
66 (0.04585*224.0/255.0) *
b + 0.5) * ((1 << depth) - 1);
67 }
68
70 {
75
76 for (
int i = 0;
i <
ctx->nb_inputs;
i++) {
81 break;
82 }
83
85 for (
int i = 0;
i <
ctx->nb_inputs;
i++)
87
89 }
90
92 }
93
95 {
101 mfxVPPCompInputStream *
is = sctx->
comp_conf.InputStream;
102
106
108 } else
109 in_format = inlink0->
format;
110
112
115
119
122
124 }
else if (hwfc0->
device_ctx != hwfc->device_ctx) {
126
128 }
129 }
130 }
131
133 depth = 10;
134
137
143 }
144
148
154 is[
i].GlobalAlpha = 255;
155 is[
i].GlobalAlphaEnable = 0;
156 is[
i].PixelAlphaEnable = 0;
157 }
158
160 }
161
162 /*
163 * Callback for qsvvpp
164 * @Note: qsvvpp composition does not generate PTS for result frame.
165 * so we assign the PTS from framesync to the output frame.
166 */
167
169 {
171
175 }
176
177
179 {
182
186
187 /* fill composite config */
188 sctx->
comp_conf.Header.BufferId = MFX_EXTBUFF_VPP_COMPOSITE;
195
196 /* initialize QSVVPP params */
199
202
206
207 return 0;
208 }
209
211 {
213
215
219 }
220
222 {
228 };
229
231 }
232
234
235 #if CONFIG_HSTACK_QSV_FILTER
236
239
240 #endif
241
242 #if CONFIG_VSTACK_QSV_FILTER
243
246
247 #endif
248
249 #if CONFIG_XSTACK_QSV_FILTER
250
253
254 #endif
static av_cold void qsv_stack_uninit(AVFilterContext *ctx)
static int qsv_stack_query_formats(AVFilterContext *ctx)
AVPixelFormat
Pixel format.
Filter the word "frame" indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
The official guide to swscale for confused that is
#define u(width, name, range_min, range_max)
enum AVPixelFormat out_sw_format
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
uint8_t * data
The data buffer.
int ff_framesync_get_frame(FFFrameSync *fs, unsigned in, AVFrame **rframe, unsigned get)
Get the current frame in an input.
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
AVRational time_base
Time base for the output events.
This structure describes decoded (raw) audio or video data.
int64_t pts
Presentation timestamp in time_base units (time when frame should be shown to user).
static int process_frame(FFFrameSync *fs)
A link between two filters.
static int config_output(AVFilterLink *outlink)
void * priv
private data for use by the filter
#define DEFINE_STACK_FILTER(category, api, capi, filter_flags)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
static av_cold void stack_uninit(AVFilterContext *avctx)
#define DEFINE_HSTACK_OPTIONS(api)
int64_t av_rescale_q(int64_t a, AVRational bq, AVRational cq)
Rescale a 64-bit integer by 2 rational numbers.
static enum AVPixelFormat pixel_formats[]
int ff_qsvvpp_close(AVFilterContext *avctx)
#define fs(width, name, subs,...)
#define DEFINE_XSTACK_OPTIONS(api)
@ AV_PIX_FMT_QSV
HW acceleration through QSV, data[3] contains a pointer to the mfxFrameSurface1 structure.
int64_t pts
Timestamp of the current event.
#define AVFILTER_FLAG_HWDEVICE
The filter can create hardware frames using AVFilterContext.hw_device_ctx.
int format
agreed upon media format
#define DEFINE_VSTACK_OPTIONS(api)
AVFilterContext * src
source filter
FF_FILTER_FORWARD_WANTED(outlink, inlink)
StackItemRegion * regions
#define i(width, name, range_min, range_max)
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
static int config_comm_output(AVFilterLink *outlink)
void * av_mallocz(size_t size)
Allocate a memory block with alignment suitable for all memory accesses (including vectors if availab...
int(* filter_frame)(AVFilterLink *outlink, AVFrame *frame)
int ff_qsvvpp_init(AVFilterContext *avctx, QSVVPPParam *param)
void * av_calloc(size_t nmemb, size_t size)
This struct describes a set or pool of "hardware" frames (i.e.
static int filter_callback(AVFilterLink *outlink, AVFrame *frame)
@ AV_PIX_FMT_NV12
planar YUV 4:2:0, 12bpp, 1 plane for Y and 1 plane for the UV components, which are interleaved (firs...
AVHWDeviceContext * device_ctx
The parent AVHWDeviceContext.
static void rgb2yuv(float r, float g, float b, int *y, int *u, int *v, int depth)
int ff_qsvvpp_filter_frame(QSVVPPContext *s, AVFilterLink *inlink, AVFrame *picref)
static int stack_init(AVFilterContext *avctx)
AVRational time_base
Define the time base used by the PTS of the frames/samples which will pass through this link.
static int qsv_stack_init(AVFilterContext *ctx)
mfxExtVPPComposite comp_conf
Generated on Thu Sep 26 2024 23:15:40 for FFmpeg by
doxygen
1.8.17