FFmpeg
Loading...
Searching...
No Matches
vf_transpose_cuda.c
Go to the documentation of this file.
1/*
2 * Copyright (C) 2026 NyanMisaka
3 *
4 * This file is part of FFmpeg.
5 *
6 * FFmpeg is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
10 *
11 * FFmpeg is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
15 *
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with FFmpeg; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
21#include "libavutil/avassert.h"
22#include "libavutil/common.h"
23#include "libavutil/hwcontext.h"
26#include "libavutil/internal.h"
27#include "libavutil/opt.h"
28#include "libavutil/pixdesc.h"
29
30#include "avfilter.h"
31#include "filters.h"
32#include "transpose.h"
33#include "video.h"
34
35#include "cuda/load_helper.h"
36
37#define DIV_UP(a, b) ( ((a) + (b) - 1) / (b) )
38#define BLOCK_X 32
39#define BLOCK_Y 16
40
41#define CHECK_CU(x) FF_CUDA_CHECK_DL(ctx, s->hwctx->internal->cuda_dl, x)
42
66
67typedef struct TransposeCUDAContext {
68 const AVClass *class;
69
74
76
77 CUcontext cu_ctx;
78 CUmodule cu_module;
79 CUfunction cu_func_uchar;
80 CUfunction cu_func_ushort;
81 CUfunction cu_func_uchar2;
82 CUfunction cu_func_ushort2;
83 CUfunction cu_func_uchar4;
84 CUstream cu_stream;
85
87 int passthrough; ///< PassthroughType, landscape passthrough mode enabled
88 int dir; ///< TransposeDir
90
92{
93 TransposeCUDAContext *s = ctx->priv;
94
95 s->frame = av_frame_alloc();
96 if (!s->frame)
97 return AVERROR(ENOMEM);
98
99 s->tmp_frame = av_frame_alloc();
100 if (!s->tmp_frame)
101 return AVERROR(ENOMEM);
102
103 return 0;
104}
105
107{
108 TransposeCUDAContext *s = ctx->priv;
109
110 if (s->hwctx && s->cu_module) {
111 CUcontext dummy;
112 CudaFunctions *cu = s->hwctx->internal->cuda_dl;
113 CHECK_CU(cu->cuCtxPushCurrent(s->cu_ctx));
114 CHECK_CU(cu->cuModuleUnload(s->cu_module));
115 CHECK_CU(cu->cuCtxPopCurrent(&dummy));
116 }
117
118 av_frame_free(&s->frame);
119 av_buffer_unref(&s->frames_ctx);
120 av_frame_free(&s->tmp_frame);
121}
122
124 AVBufferRef *device_ctx,
125 int width, int height,
126 enum AVPixelFormat sw_format)
127{
128 AVBufferRef *out_ref = NULL;
129 AVHWFramesContext *out_ctx;
130 int ret;
131
132 out_ref = av_hwframe_ctx_alloc(device_ctx);
133 if (!out_ref)
134 return AVERROR(ENOMEM);
135 out_ctx = (AVHWFramesContext*)out_ref->data;
136
137 out_ctx->format = AV_PIX_FMT_CUDA;
138 out_ctx->sw_format = sw_format;
139 out_ctx->width = FFALIGN(width, 32);
140 out_ctx->height = FFALIGN(height, 32);
141
142 ret = av_hwframe_ctx_init(out_ref);
143 if (ret < 0)
144 goto fail;
145
146 av_frame_unref(s->frame);
147 ret = av_hwframe_get_buffer(out_ref, s->frame, 0);
148 if (ret < 0)
149 goto fail;
150
151 s->frame->width = width;
152 s->frame->height = height;
153
154 av_buffer_unref(&s->frames_ctx);
155 s->frames_ctx = out_ref;
156
157 return 0;
158fail:
159 av_buffer_unref(&out_ref);
160 return ret;
161}
162
164{
165 for (int i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++)
166 if (supported_formats[i] == fmt)
167 return 1;
168 return 0;
169}
170
172 int out_width, int out_height)
173{
174 FilterLink *inl = ff_filter_link(ctx->inputs[0]);
175 FilterLink *outl = ff_filter_link(ctx->outputs[0]);
176 TransposeCUDAContext *s = ctx->priv;
177 AVHWFramesContext *in_frames_ctx;
179 int ret;
180
181 /* check that we have a hw context */
182 if (!inl->hw_frames_ctx) {
183 av_log(ctx, AV_LOG_ERROR, "No hw context provided on input\n");
184 return AVERROR(EINVAL);
185 }
186
187 in_frames_ctx = (AVHWFramesContext*)inl->hw_frames_ctx->data;
188 format = in_frames_ctx->sw_format;
189 s->pix_desc = av_pix_fmt_desc_get(format);
190
192 av_log(ctx, AV_LOG_ERROR, "Unsupported input format: %s\n",
194 return AVERROR(ENOSYS);
195 }
196
197 ret = init_hwframe_ctx(s, in_frames_ctx->device_ref,
198 out_width, out_height, format);
199 if (ret < 0)
200 return ret;
201
202 s->hwctx = in_frames_ctx->device_ctx->hwctx;
203 s->cu_stream = s->hwctx->stream;
204
205 outl->hw_frames_ctx = av_buffer_ref(s->frames_ctx);
206 if (!outl->hw_frames_ctx)
207 return AVERROR(ENOMEM);
208
209 return 0;
210}
211
213{
214 extern const unsigned char ff_vf_transpose_cuda_ptx_data[];
215 extern const unsigned int ff_vf_transpose_cuda_ptx_len;
216 FilterLink *outl = ff_filter_link(outlink);
217 AVFilterContext *ctx = outlink->src;
218 AVFilterLink *inlink = ctx->inputs[0];
219 FilterLink *inl = ff_filter_link(inlink);
220 TransposeCUDAContext *s = ctx->priv;
221 CUcontext dummy, cuda_ctx;
222 CudaFunctions *cu;
223 int ret = 0;
224
225 if ((inlink->w >= inlink->h && s->passthrough == TRANSPOSE_PT_TYPE_LANDSCAPE) ||
226 (inlink->w <= inlink->h && s->passthrough == TRANSPOSE_PT_TYPE_PORTRAIT)) {
227 if (inl->hw_frames_ctx) {
229 if (!outl->hw_frames_ctx)
230 return AVERROR(ENOMEM);
231 }
232
234 "w:%d h:%d -> w:%d h:%d (passthrough mode)\n",
235 inlink->w, inlink->h, inlink->w, inlink->h);
236 return 0;
237 } else {
238 s->passthrough = TRANSPOSE_PT_TYPE_NONE;
239 }
240
241 switch (s->dir) {
243 case TRANSPOSE_CCLOCK:
244 case TRANSPOSE_CLOCK:
246 outlink->w = inlink->h;
247 outlink->h = inlink->w;
248 s->flip_wh = 1;
249 break;
250 default:
251 outlink->w = inlink->w;
252 outlink->h = inlink->h;
253 s->flip_wh = 0;
254 break;
255 }
256
257 if (s->flip_wh && inlink->sample_aspect_ratio.num)
259 else
260 outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
261
262 ret = init_processing_chain(ctx, outlink->w, outlink->h);
263 if (ret < 0)
264 return ret;
265
266 cuda_ctx = s->cu_ctx = s->hwctx->cuda_ctx;
267 cu = s->hwctx->internal->cuda_dl;
268
269 ret = CHECK_CU(cu->cuCtxPushCurrent(cuda_ctx));
270 if (ret < 0)
271 return ret;
272
273 ret = ff_cuda_load_module(ctx, s->hwctx, &s->cu_module,
274 ff_vf_transpose_cuda_ptx_data, ff_vf_transpose_cuda_ptx_len);
275 if (ret < 0)
276 goto exit;
277
278 ret = CHECK_CU(cu->cuModuleGetFunction(&s->cu_func_uchar, s->cu_module, "Transpose_Cuda_uchar"));
279 if (ret < 0)
280 goto exit;
281
282 ret = CHECK_CU(cu->cuModuleGetFunction(&s->cu_func_ushort, s->cu_module, "Transpose_Cuda_ushort"));
283 if (ret < 0)
284 goto exit;
285
286 ret = CHECK_CU(cu->cuModuleGetFunction(&s->cu_func_uchar2, s->cu_module, "Transpose_Cuda_uchar2"));
287 if (ret < 0)
288 goto exit;
289
290 ret = CHECK_CU(cu->cuModuleGetFunction(&s->cu_func_ushort2, s->cu_module, "Transpose_Cuda_ushort2"));
291 if (ret < 0)
292 goto exit;
293
294 ret = CHECK_CU(cu->cuModuleGetFunction(&s->cu_func_uchar4, s->cu_module, "Transpose_Cuda_uchar4"));
295 if (ret < 0)
296 goto exit;
297
299 "w:%d h:%d dir:%d -> w:%d h:%d\n",
300 inlink->w, inlink->h, s->dir, outlink->w, outlink->h);
301exit:
302 CHECK_CU(cu->cuCtxPopCurrent(&dummy));
303
304 return ret;
305}
306
308 CUfunction cu_func,
309 CUarray_format cu_format,
310 int channels,
311 int is_422_uv, // Dst* & Src* are 4:2:2 UV planes
312 CUdeviceptr dst0,
313 CUdeviceptr dst1, // Dst1 is for fully planar V, optional
314 int dst_width, // Width is pixels per channel
315 int dst_height, // Height is pixels per channel
316 int dst_pitch, // Pitch is elements per channel
317 CUdeviceptr src0,
318 CUdeviceptr src1, // Src1 is for fully planar V, optional
319 int src_width, // Width is pixels per channel
320 int src_height, // Height is pixels per channel
321 int src_pitch)
322{
323 TransposeCUDAContext *s = ctx->priv;
324 CudaFunctions *cu = s->hwctx->internal->cuda_dl;
325 CUtexObject src0_tex = 0, src1_tex = 0;
326 int ret;
327
328 void *kernel_args[] = {
329 &dst0, &dst1, &dst_width, &dst_height, &dst_pitch,
330 &src0_tex, &src1_tex, &s->dir,
331 };
332
333 CUDA_TEXTURE_DESC tex_desc = {
334 .addressMode = { CU_TR_ADDRESS_MODE_CLAMP,
335 CU_TR_ADDRESS_MODE_CLAMP },
336 .filterMode = is_422_uv ? CU_TR_FILTER_MODE_LINEAR
337 : CU_TR_FILTER_MODE_POINT,
338 .flags = 2 /* CU_TRSF_NORMALIZED_COORDINATES */
339 };
340 CUDA_RESOURCE_DESC res_desc = {
341 .resType = CU_RESOURCE_TYPE_PITCH2D,
342 .res.pitch2D.format = cu_format,
343 .res.pitch2D.numChannels = channels,
344 .res.pitch2D.pitchInBytes = src_pitch,
345 .res.pitch2D.width = src_width,
346 .res.pitch2D.height = src_height
347 };
348
349 res_desc.res.pitch2D.devPtr = (CUdeviceptr)src0;
350 ret = CHECK_CU(cu->cuTexObjectCreate(&src0_tex, &res_desc, &tex_desc, NULL));
351 if (ret < 0)
352 goto exit;
353
354 if (src1) {
355 res_desc.res.pitch2D.devPtr = (CUdeviceptr)src1;
356 ret = CHECK_CU(cu->cuTexObjectCreate(&src1_tex, &res_desc, &tex_desc, NULL));
357 if (ret < 0)
358 goto exit;
359 }
360
361 ret = CHECK_CU(cu->cuLaunchKernel(cu_func,
362 DIV_UP(dst_width, BLOCK_X), DIV_UP(dst_height, BLOCK_Y), 1,
363 BLOCK_X, BLOCK_Y, 1, 0, s->cu_stream, kernel_args, NULL));
364exit:
365 if (src0_tex)
366 CHECK_CU(cu->cuTexObjectDestroy(src0_tex));
367 if (src1_tex)
368 CHECK_CU(cu->cuTexObjectDestroy(src1_tex));
369
370 return ret;
371}
372
374 AVFrame *out, AVFrame *in)
375{
376 TransposeCUDAContext *s = ctx->priv;
377 int ret;
378
379 for (int c = 0; c < s->pix_desc->nb_components; c++) {
380 const AVComponentDescriptor *comp = &s->pix_desc->comp[c];
381 const int p = comp->plane;
382 int pix_size, channels;
383 int is_planar_u, is_planar_v, is_422_uv;
384 CUfunction func;
385 CUarray_format format;
386
387 pix_size = (comp->depth + 7) / 8;
388 channels = comp->step / pix_size;
389 if (pix_size > 2 || channels > 4)
390 av_unreachable("Unsupported pixel format!");
391
392 is_planar_u = p == 1 && channels == 1;
393 is_planar_v = p == 2 && channels == 1;
394 is_422_uv = p && s->pix_desc->log2_chroma_w == 1 && !s->pix_desc->log2_chroma_h;
395
396 if (comp->plane < c || is_planar_v) {
397 // We process planes as a whole, so don't reprocess
398 // them for additional components
399 continue;
400 }
401
402 switch (pix_size) {
403 case 1:
404 func = channels == 4 ? s->cu_func_uchar4 :
405 channels == 2 ? s->cu_func_uchar2 : s->cu_func_uchar;
406 format = CU_AD_FORMAT_UNSIGNED_INT8;
407 break;
408 case 2:
409 func = channels == 2 ? s->cu_func_ushort2 : s->cu_func_ushort;
410 format = CU_AD_FORMAT_UNSIGNED_INT16;
411 break;
412 default:
413 av_unreachable("Unsupported pixel format!");
414 }
415
416 ret = call_kernel(ctx, func, format, channels, is_422_uv,
417 (CUdeviceptr)out->data[p],
418 (CUdeviceptr)(is_planar_u ? out->data[p+1] : NULL),
419 AV_CEIL_RSHIFT(out->width, p ? s->pix_desc->log2_chroma_w : 0),
420 AV_CEIL_RSHIFT(out->height, p ? s->pix_desc->log2_chroma_h : 0),
421 out->linesize[p] / comp->step,
422 (CUdeviceptr)in->data[p],
423 (CUdeviceptr)(is_planar_u ? in->data[p+1] : NULL),
424 AV_CEIL_RSHIFT(in->width, p ? s->pix_desc->log2_chroma_w : 0),
425 AV_CEIL_RSHIFT(in->height, p ? s->pix_desc->log2_chroma_h : 0),
426 in->linesize[p]);
427 if (ret < 0)
428 return ret;
429 }
430
431 return 0;
432}
433
435 AVFrame *out, AVFrame *in)
436{
437 TransposeCUDAContext *s = ctx->priv;
438 AVFilterLink *outlink = ctx->outputs[0];
439 int ret;
440
441 ret = cudatranspose_rotate(ctx, s->frame, in);
442 if (ret < 0)
443 return ret;
444
445 ret = av_hwframe_get_buffer(s->frame->hw_frames_ctx, s->tmp_frame, 0);
446 if (ret < 0)
447 return ret;
448
449 av_frame_move_ref(out, s->frame);
450 av_frame_move_ref(s->frame, s->tmp_frame);
451
452 s->frame->width = outlink->w;
453 s->frame->height = outlink->h;
454
455 ret = av_frame_copy_props(out, in);
456 if (ret < 0)
457 return ret;
458
459 if (s->flip_wh && in->sample_aspect_ratio.num)
460 out->sample_aspect_ratio = av_inv_q(in->sample_aspect_ratio);
461 else
462 out->sample_aspect_ratio = in->sample_aspect_ratio;
463
464 return 0;
465}
466
468{
469 AVFilterContext *ctx = link->dst;
470 TransposeCUDAContext *s = ctx->priv;
471 AVFilterLink *outlink = ctx->outputs[0];
472 CudaFunctions *cu;
473 AVFrame *out = NULL;
474 CUcontext dummy;
475 int ret = 0;
476
477 if (s->passthrough)
478 return ff_filter_frame(outlink, in);
479
481 if (!out) {
482 ret = AVERROR(ENOMEM);
483 goto fail;
484 }
485
486 cu = s->hwctx->internal->cuda_dl;
487
488 ret = CHECK_CU(cu->cuCtxPushCurrent(s->cu_ctx));
489 if (ret < 0)
490 goto fail;
491
492 ret = cudatranspose_transpose(ctx, out, in);
493
494 CHECK_CU(cu->cuCtxPopCurrent(&dummy));
495 if (ret < 0)
496 goto fail;
497
498 av_frame_free(&in);
499
500 return ff_filter_frame(outlink, out);
501
502fail:
503 av_frame_free(&in);
505 return ret;
506}
507
509{
510 TransposeCUDAContext *s = inlink->dst->priv;
511
512 return s->passthrough ?
513 ff_null_get_video_buffer (inlink, w, h) :
515}
516
517#define OFFSET(x) offsetof(TransposeCUDAContext, x)
518#define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
519
521 { "dir", "set transpose direction", OFFSET(dir), AV_OPT_TYPE_INT, { .i64 = TRANSPOSE_CCLOCK_FLIP }, 0, 6, FLAGS, .unit = "dir" },
522 { "cclock_flip", "rotate counter-clockwise with vertical flip", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK_FLIP }, 0, 0, FLAGS, .unit = "dir" },
523 { "clock", "rotate clockwise", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK }, 0, 0, FLAGS, .unit = "dir" },
524 { "cclock", "rotate counter-clockwise", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK }, 0, 0, FLAGS, .unit = "dir" },
525 { "clock_flip", "rotate clockwise with vertical flip", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK_FLIP }, 0, 0, FLAGS, .unit = "dir" },
526 { "reversal", "rotate by half-turn", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_REVERSAL }, 0, 0, FLAGS, .unit = "dir" },
527 { "hflip", "flip horizontally", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_HFLIP }, 0, 0, FLAGS, .unit = "dir" },
528 { "vflip", "flip vertically", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_VFLIP }, 0, 0, FLAGS, .unit = "dir" },
529
530 { "passthrough", "do not apply transposition if the input matches the specified geometry", OFFSET(passthrough), AV_OPT_TYPE_INT, { .i64 = TRANSPOSE_PT_TYPE_NONE }, 0, 2, FLAGS, .unit = "passthrough" },
531 { "none", "always apply transposition", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_PT_TYPE_NONE }, 0, 0, FLAGS, .unit = "passthrough" },
532 { "landscape", "preserve landscape geometry", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_PT_TYPE_LANDSCAPE }, 0, 0, FLAGS, .unit = "passthrough" },
533 { "portrait", "preserve portrait geometry", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_PT_TYPE_PORTRAIT }, 0, 0, FLAGS, .unit = "passthrough" },
534
535 { NULL },
536};
537
539
541 {
542 .name = "default",
543 .type = AVMEDIA_TYPE_VIDEO,
544 .filter_frame = cudatranspose_filter_frame,
545 .get_buffer.video = cudatranspose_get_video_buffer,
546 },
547};
548
550 {
551 .name = "default",
552 .type = AVMEDIA_TYPE_VIDEO,
553 .config_props = cudatranspose_config_props,
554 },
555};
556
558 .p.name = "transpose_cuda",
559 .p.description = NULL_IF_CONFIG_SMALL("Transpose input video using CUDA"),
560 .p.priv_class = &cudatranspose_class,
561 .init = cudatranspose_init,
562 .uninit = cudatranspose_uninit,
563 .priv_size = sizeof(TransposeCUDAContext),
567 .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
568};
static const char *const format[]
Definition af_aiir.c:444
const FFFilter ff_vf_transpose_cuda
channels
Definition aptx.h:31
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_unreachable(msg)
Asserts that are used as compiler optimization hints depending upon ASSERT_LEVEL and NBDEBUG.
Definition avassert.h:109
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition avfilter.c:1068
Main libavfilter public API header.
#define i(width, name, range_min, range_max)
Definition cbs_h264.c:63
#define s(width, name)
Definition cbs_vp9.c:198
#define FLAGS
Definition cmdutils.c:598
common internal and external API header
#define AV_CEIL_RSHIFT(a, b)
Definition common.h:60
#define NULL
Definition coverity.c:32
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
Definition eamad.c:79
static int dummy
Definition ffplay.c:3754
#define fail
Definition test.h:479
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
void av_buffer_unref(AVBufferRef **buf)
Free a given reference and automatically free the buffer if there are no more references to it.
Definition buffer.c:139
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition buffer.c:103
#define AVERROR(e)
Definition error.h:45
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition frame.c:496
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
Definition frame.c:523
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition frame.c:64
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition frame.c:599
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition frame.c:52
#define AV_LOG_VERBOSE
Detailed information.
Definition log.h:226
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition log.h:210
static av_always_inline AVRational av_inv_q(AVRational q)
Invert a rational.
Definition rational.h:159
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
Definition hwcontext.c:337
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
Definition hwcontext.c:263
int av_hwframe_get_buffer(AVBufferRef *hwframe_ref, AVFrame *frame, int flags)
Allocate a new frame attached to the given AVHWFramesContext.
Definition hwcontext.c:506
FFmpeg internal API for CUDA.
int(* func)(AVBPrint *dst, const char *in, const char *arg)
Definition jacosubdec.c:66
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FF_FILTER_FLAG_HWFRAME_AWARE
The filter is aware of hardware frames, and any hardware frame context should not be automatically pr...
Definition filters.h:208
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition filters.h:199
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition filters.h:254
#define AVFILTER_DEFINE_CLASS(fname)
Definition filters.h:478
#define av_cold
Definition attributes.h:117
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
uint8_t w
Definition llvidencdsp.c:39
int ff_cuda_load_module(void *avctx, AVCUDADeviceContext *hwctx, CUmodule *cu_module, const unsigned char *data, const unsigned int length)
Loads a CUDA module and applies any decompression, if necessary.
Definition load_helper.c:34
#define FFALIGN(x, a)
Definition macros.h:78
AVOptions.
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.
Definition pixdesc.c:3380
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition pixdesc.c:3460
#define AV_PIX_FMT_0RGB32
Definition pixfmt.h:521
#define AV_PIX_FMT_P212
Definition pixfmt.h:624
#define AV_PIX_FMT_YUV420P10
Definition pixfmt.h:545
#define AV_PIX_FMT_P210
Definition pixfmt.h:622
#define AV_PIX_FMT_P012
Definition pixfmt.h:609
#define AV_PIX_FMT_P216
Definition pixfmt.h:626
#define AV_PIX_FMT_P010
Definition pixfmt.h:608
#define AV_PIX_FMT_P016
Definition pixfmt.h:610
#define AV_PIX_FMT_YUV422P10
Definition pixfmt.h:546
#define AV_PIX_FMT_YUV444P12MSB
Definition pixfmt.h:561
#define AV_PIX_FMT_BGR32
Definition pixfmt.h:519
AVPixelFormat
Pixel format.
Definition pixfmt.h:71
@ 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...
Definition pixfmt.h:96
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition pixfmt.h:73
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition pixfmt.h:77
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
Definition pixfmt.h:260
@ AV_PIX_FMT_NV16
interleaved chroma YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition pixfmt.h:198
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78
#define AV_PIX_FMT_YUV444P16
Definition pixfmt.h:558
#define AV_PIX_FMT_YUV444P10MSB
Definition pixfmt.h:560
#define AV_PIX_FMT_0BGR32
Definition pixfmt.h:522
#define AV_PIX_FMT_RGB32
Definition pixfmt.h:517
#define AV_PIX_FMT_YUV444P10
Definition pixfmt.h:548
#define FF_ARRAY_ELEMS(a)
A reference to a data buffer.
Definition buffer.h:82
uint8_t * data
The data buffer.
Definition buffer.h:90
This struct is allocated as AVHWDeviceContext.hwctx.
Describe the class of an AVClass context structure.
Definition log.h:76
An instance of a filter.
Definition avfilter.h:273
void * priv
private data for use by the filter
Definition avfilter.h:288
A filter pad used for either input or output.
Definition filters.h:40
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition frame.h:493
int width
Definition frame.h:544
int height
Definition frame.h:544
AVRational sample_aspect_ratio
Sample aspect ratio for the video frame, 0/1 if unknown/unspecified.
Definition frame.h:569
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition frame.h:517
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
Definition hwcontext.h:88
This struct describes a set or pool of "hardware" frames (i.e.
Definition hwcontext.h:118
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
Definition hwcontext.h:200
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
Definition hwcontext.h:129
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition hwcontext.h:213
int width
The allocated dimensions of the frames in this pool.
Definition hwcontext.h:220
AVHWDeviceContext * device_ctx
The parent AVHWDeviceContext.
Definition hwcontext.h:137
AVOption.
Definition opt.h:428
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition pixdesc.h:69
int num
Numerator.
Definition rational.h:59
int passthrough
PassthroughType, landscape passthrough mode enabled.
const AVPixFmtDescriptor * pix_desc
AVCUDADeviceContext * hwctx
#define av_log(a,...)
#define src1
Definition h264pred.c:141
#define src0
Definition h264pred.c:140
static FILE * out
Definition movenc.c:55
static AVFormatContext * ctx
Definition movenc.c:49
#define height
Definition dsp.h:89
#define width
Definition dsp.h:89
@ TRANSPOSE_CLOCK_FLIP
Definition transpose.h:34
@ TRANSPOSE_HFLIP
Definition transpose.h:36
@ TRANSPOSE_CCLOCK
Definition transpose.h:33
@ TRANSPOSE_CCLOCK_FLIP
Definition transpose.h:31
@ TRANSPOSE_VFLIP
Definition transpose.h:37
@ TRANSPOSE_REVERSAL
Definition transpose.h:35
@ TRANSPOSE_CLOCK
Definition transpose.h:32
@ TRANSPOSE_PT_TYPE_NONE
Definition transpose.h:25
@ TRANSPOSE_PT_TYPE_PORTRAIT
Definition transpose.h:27
@ TRANSPOSE_PT_TYPE_LANDSCAPE
Definition transpose.h:26
static enum AVPixelFormat supported_formats[]
#define DIV_UP(a, b)
static av_cold int init_hwframe_ctx(TransposeCUDAContext *s, AVBufferRef *device_ctx, int width, int height, enum AVPixelFormat sw_format)
static AVFrame * cudatranspose_get_video_buffer(AVFilterLink *inlink, int w, int h)
static av_cold void cudatranspose_uninit(AVFilterContext *ctx)
static int cudatranspose_transpose(AVFilterContext *ctx, AVFrame *out, AVFrame *in)
static const AVOption cudatranspose_options[]
#define DIV_UP(a, b)
static int cudatranspose_rotate(AVFilterContext *ctx, AVFrame *out, AVFrame *in)
static CUresult call_kernel(AVFilterContext *ctx, CUfunction cu_func, CUarray_format cu_format, int channels, int is_422_uv, CUdeviceptr dst0, CUdeviceptr dst1, int dst_width, int dst_height, int dst_pitch, CUdeviceptr src0, CUdeviceptr src1, int src_width, int src_height, int src_pitch)
static av_cold int cudatranspose_init(AVFilterContext *ctx)
static int cudatranspose_filter_frame(AVFilterLink *link, AVFrame *in)
static int init_processing_chain(AVFilterContext *ctx, int out_width, int out_height)
static int format_is_supported(enum AVPixelFormat fmt)
#define CHECK_CU(x)
static const AVFilterPad cudatranspose_inputs[]
#define OFFSET(x)
static int cudatranspose_config_props(AVFilterLink *outlink)
static const AVFilterPad cudatranspose_outputs[]
AVFrame * ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
Definition video.c:44
AVFrame * ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
Definition video.c:84
#define BLOCK_X
Definition vp3.c:640
#define BLOCK_Y
Definition vp3.c:641
static double c[64]