FFmpeg: libavfilter/vf_transpose_vaapi.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 #include <string.h>
19
22
28
31 int passthrough;
// PassthroughType, landscape passthrough mode enabled
32 int dir;
// TransposeDir
33
37
39 {
42 VAStatus vas;
43 int support_flag;
44 VAProcPipelineCaps pipeline_caps;
45
46 memset(&pipeline_caps, 0, sizeof(pipeline_caps));
47 vas = vaQueryVideoProcPipelineCaps(vpp_ctx->
hwctx->
display,
50 &pipeline_caps);
51 if (vas != VA_STATUS_SUCCESS) {
53 "caps: %d (%s).\n", vas, vaErrorStr(vas));
55 }
56
57 if (!pipeline_caps.rotation_flags) {
60 }
61
64 ctx->rotation_state = VA_ROTATION_270;
65 ctx->mirror_state = VA_MIRROR_VERTICAL;
66 break;
68 ctx->rotation_state = VA_ROTATION_90;
69 ctx->mirror_state = VA_MIRROR_NONE;
70 break;
72 ctx->rotation_state = VA_ROTATION_270;
73 ctx->mirror_state = VA_MIRROR_NONE;
74 break;
76 ctx->rotation_state = VA_ROTATION_90;
77 ctx->mirror_state = VA_MIRROR_VERTICAL;
78 break;
80 ctx->rotation_state = VA_ROTATION_180;
81 ctx->mirror_state = VA_MIRROR_NONE;
82 break;
84 ctx->rotation_state = VA_ROTATION_NONE;
85 ctx->mirror_state = VA_MIRROR_HORIZONTAL;
86 break;
88 ctx->rotation_state = VA_ROTATION_NONE;
89 ctx->mirror_state = VA_MIRROR_VERTICAL;
90 break;
91 default:
94 }
95
96 if (VA_ROTATION_NONE !=
ctx->rotation_state) {
97 support_flag = pipeline_caps.rotation_flags & (1 <<
ctx->rotation_state);
98 if (!support_flag) {
100 ctx->rotation_state);
102 }
103 }
104
105 if (VA_MIRROR_NONE !=
ctx->mirror_state) {
106 support_flag = pipeline_caps.mirror_flags &
ctx->mirror_state;
107 if (!support_flag) {
111 }
112 }
113
114 return 0;
115 }
116
118 {
124 VAProcPipelineParameterBuffer params;
125 int err;
126
127 if (
ctx->passthrough)
129
133
136
142 }
143
145 if (err < 0)
147
150 if (err < 0)
152
153 params.rotation_state =
ctx->rotation_state;
154 params.mirror_state =
ctx->mirror_state;
155
157 if (err < 0)
159
161
165
167
171 return err;
172 }
173
175 {
177
182
183 return 0;
184 }
185
187 {
192
199 "w:%d h:%d -> w:%d h:%d (passthrough mode)\n",
201 return 0;
202 }
203
205
214 break;
215 default:
216 break;
217 }
218
220 }
221
223 {
225
226 return ctx->passthrough ?
229 }
230
231 #define OFFSET(x) offsetof(TransposeVAAPIContext, x)
232 #define FLAGS (AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM)
242
243 { "passthrough", "do not apply transposition if the input matches the specified geometry",
248
250 };
251
252
254
256 {
262 },
263 };
264
266 {
270 },
271 };
272
274 .
name =
"transpose_vaapi",
282 .priv_class = &transpose_vaapi_class,
284 };
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
void ff_vaapi_vpp_pipeline_uninit(AVFilterContext *avctx)
void ff_vaapi_vpp_ctx_init(AVFilterContext *avctx)
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
int ff_vaapi_vpp_render_picture(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, AVFrame *output_frame)
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
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
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
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).
#define FILTER_QUERY_FUNC(func)
#define AV_LOG_VERBOSE
Detailed information.
VADisplay display
The VADisplay handle, to be filled by the user.
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
const char * name
Filter name.
A link between two filters.
static const AVFilterPad transpose_vaapi_inputs[]
int(* build_filter_params)(AVFilterContext *avctx)
AVFrame * ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
void * priv
private data for use by the filter
A filter pad used for either input or output.
static int transpose_vaapi_filter_frame(AVFilterLink *inlink, AVFrame *input_frame)
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
enum AVPixelFormat output_format
AVVAAPIDeviceContext * hwctx
#define FILTER_INPUTS(array)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
AVFilterLink ** inputs
array of pointers to input links
int ff_vaapi_vpp_config_input(AVFilterLink *inlink)
void ff_vaapi_vpp_ctx_uninit(AVFilterContext *avctx)
int ff_vaapi_vpp_query_formats(AVFilterContext *avctx)
@ TRANSPOSE_PT_TYPE_PORTRAIT
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
AVFilterContext * src
source filter
static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
AVFrame * ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
int w
agreed upon image width
AVBufferRef * hw_frames_ctx
For hwaccel pixel formats, this should be a reference to the AVHWFramesContext describing the frames.
const char * name
Pad name.
static const AVFilterPad transpose_vaapi_outputs[]
static int transpose_vaapi_build_filter_params(AVFilterContext *avctx)
int ff_vaapi_vpp_config_output(AVFilterLink *outlink)
int h
agreed upon image height
static av_cold int transpose_vaapi_init(AVFilterContext *avctx)
void(* pipeline_uninit)(AVFilterContext *avctx)
@ TRANSPOSE_PT_TYPE_LANDSCAPE
static AVFrame * get_video_buffer(AVFilterLink *inlink, int w, int h)
static const AVOption transpose_vaapi_options[]
#define FILTER_OUTPUTS(array)
AVFILTER_DEFINE_CLASS(transpose_vaapi)
static av_cold int uninit(AVCodecContext *avctx)
static int transpose_vaapi_vpp_config_output(AVFilterLink *outlink)
const AVFilter ff_vf_transpose_vaapi
const char * av_get_pix_fmt_name(enum AVPixelFormat pix_fmt)
Return the short name for a pixel format, NULL in case pix_fmt is unknown.
int ff_vaapi_vpp_init_params(AVFilterContext *avctx, VAProcPipelineParameterBuffer *params, const AVFrame *input_frame, AVFrame *output_frame)
AVFilterLink ** outputs
array of pointers to output links
Generated on Wed Aug 24 2022 21:42:10 for FFmpeg by
doxygen
1.8.17