FFmpeg
vf_transpose_npp.c
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 #include <nppi.h>
20 #include <stdio.h>
21 #include <string.h>
22 
23 #include "libavutil/common.h"
24 #include "libavutil/hwcontext.h"
26 #include "libavutil/cuda_check.h"
27 #include "libavutil/internal.h"
28 #include "libavutil/opt.h"
29 #include "libavutil/pixdesc.h"
30 
31 #include "avfilter.h"
32 #include "filters.h"
33 #include "formats.h"
34 #include "video.h"
35 
36 #define CHECK_CU(x) FF_CUDA_CHECK_DL(ctx, device_hwctx->internal->cuda_dl, x)
37 
38 static const enum AVPixelFormat supported_formats[] = {
41 };
42 
47 };
48 
49 enum Transpose {
54 };
55 
60 };
61 
62 typedef struct NPPTransposeStageContext {
66  struct {
67  int width;
68  int height;
69  } planes_in[3], planes_out[3];
73 
74 typedef struct NPPTransposeContext {
75  const AVClass *class;
78 
79  int passthrough; ///< PassthroughType, landscape passthrough mode enabled
80  int dir; ///< TransposeDir
82 
84 {
85  NPPTransposeContext *s = ctx->priv;
86  int i;
87 
88  av_log(ctx, AV_LOG_WARNING, "The libnpp based filters are deprecated.\n");
89 
90  for (i = 0; i < FF_ARRAY_ELEMS(s->stages); i++) {
91  s->stages[i].frame = av_frame_alloc();
92  if (!s->stages[i].frame)
93  return AVERROR(ENOMEM);
94  }
95 
96  s->tmp_frame = av_frame_alloc();
97  if (!s->tmp_frame)
98  return AVERROR(ENOMEM);
99 
100  return 0;
101 }
102 
104 {
105  NPPTransposeContext *s = ctx->priv;
106  int i;
107 
108  for (i = 0; i < FF_ARRAY_ELEMS(s->stages); i++) {
109  av_frame_free(&s->stages[i].frame);
110  av_buffer_unref(&s->stages[i].frames_ctx);
111  }
112 
113  av_frame_free(&s->tmp_frame);
114 }
115 
116 static int init_stage(NPPTransposeStageContext *stage, AVBufferRef *device_ctx)
117 {
118  AVBufferRef *out_ref = NULL;
119  AVHWFramesContext *out_ctx;
120  int in_sw, in_sh, out_sw, out_sh;
121  int ret, i;
122 
123  av_pix_fmt_get_chroma_sub_sample(stage->in_fmt, &in_sw, &in_sh);
124  av_pix_fmt_get_chroma_sub_sample(stage->out_fmt, &out_sw, &out_sh);
125 
126  if (!stage->planes_out[0].width) {
127  stage->planes_out[0].width = stage->planes_in[0].width;
128  stage->planes_out[0].height = stage->planes_in[0].height;
129  }
130 
131  for (i = 1; i < FF_ARRAY_ELEMS(stage->planes_in); i++) {
132  stage->planes_in[i].width = stage->planes_in[0].width >> in_sw;
133  stage->planes_in[i].height = stage->planes_in[0].height >> in_sh;
134  stage->planes_out[i].width = stage->planes_out[0].width >> out_sw;
135  stage->planes_out[i].height = stage->planes_out[0].height >> out_sh;
136  }
137 
138  out_ref = av_hwframe_ctx_alloc(device_ctx);
139  if (!out_ref)
140  return AVERROR(ENOMEM);
141  out_ctx = (AVHWFramesContext*)out_ref->data;
142 
143  out_ctx->format = AV_PIX_FMT_CUDA;
144  out_ctx->sw_format = stage->out_fmt;
145  out_ctx->width = FFALIGN(stage->planes_out[0].width, 32);
146  out_ctx->height = FFALIGN(stage->planes_out[0].height, 32);
147 
148  ret = av_hwframe_ctx_init(out_ref);
149  if (ret < 0)
150  goto fail;
151 
152  av_frame_unref(stage->frame);
153  ret = av_hwframe_get_buffer(out_ref, stage->frame, 0);
154  if (ret < 0)
155  goto fail;
156 
157  stage->frame->width = stage->planes_out[0].width;
158  stage->frame->height = stage->planes_out[0].height;
159  av_buffer_unref(&stage->frames_ctx);
160  stage->frames_ctx = out_ref;
161 
162  return 0;
163 
164 fail:
165  av_buffer_unref(&out_ref);
166  return ret;
167 }
168 
169 static int format_is_supported(enum AVPixelFormat fmt)
170 {
171  int i;
172 
173  for (i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++)
174  if (supported_formats[i] == fmt)
175  return 1;
176 
177  return 0;
178 }
179 
180 static int init_processing_chain(AVFilterContext *ctx, int in_width, int in_height,
181  int out_width, int out_height)
182 {
183  FilterLink *inl = ff_filter_link(ctx->inputs[0]);
184  FilterLink *outl = ff_filter_link(ctx->outputs[0]);
185  NPPTransposeContext *s = ctx->priv;
186  AVHWFramesContext *in_frames_ctx;
187  enum AVPixelFormat format;
188  int i, ret, last_stage = -1;
189  int rot_width = out_width, rot_height = out_height;
190 
191  /* check that we have a hw context */
192  if (!inl->hw_frames_ctx) {
193  av_log(ctx, AV_LOG_ERROR, "No hw context provided on input\n");
194  return AVERROR(EINVAL);
195  }
196 
197  in_frames_ctx = (AVHWFramesContext*)inl->hw_frames_ctx->data;
198  format = in_frames_ctx->sw_format;
199 
201  av_log(ctx, AV_LOG_ERROR, "Unsupported input format: %s\n",
203  return AVERROR(ENOSYS);
204  }
205 
206  if (s->dir != NPP_TRANSPOSE_CCLOCK_FLIP) {
207  s->stages[STAGE_ROTATE].stage_needed = 1;
208  }
209 
210  if (s->dir == NPP_TRANSPOSE_CCLOCK_FLIP || s->dir == NPP_TRANSPOSE_CLOCK_FLIP) {
211  s->stages[STAGE_TRANSPOSE].stage_needed = 1;
212 
213  /* Rotating by 180° in case of clock_flip, or not at all for cclock_flip, so width/height unchanged by rotation */
214  rot_width = in_width;
215  rot_height = in_height;
216  }
217 
218  s->stages[STAGE_ROTATE].in_fmt = format;
219  s->stages[STAGE_ROTATE].out_fmt = format;
220  s->stages[STAGE_ROTATE].planes_in[0].width = in_width;
221  s->stages[STAGE_ROTATE].planes_in[0].height = in_height;
222  s->stages[STAGE_ROTATE].planes_out[0].width = rot_width;
223  s->stages[STAGE_ROTATE].planes_out[0].height = rot_height;
224  s->stages[STAGE_TRANSPOSE].in_fmt = format;
225  s->stages[STAGE_TRANSPOSE].out_fmt = format;
226  s->stages[STAGE_TRANSPOSE].planes_in[0].width = rot_width;
227  s->stages[STAGE_TRANSPOSE].planes_in[0].height = rot_height;
228  s->stages[STAGE_TRANSPOSE].planes_out[0].width = out_width;
229  s->stages[STAGE_TRANSPOSE].planes_out[0].height = out_height;
230 
231  /* init the hardware contexts */
232  for (i = 0; i < FF_ARRAY_ELEMS(s->stages); i++) {
233  if (!s->stages[i].stage_needed)
234  continue;
235  ret = init_stage(&s->stages[i], in_frames_ctx->device_ref);
236  if (ret < 0)
237  return ret;
238  last_stage = i;
239  }
240 
241  if (last_stage >= 0) {
242  outl->hw_frames_ctx = av_buffer_ref(s->stages[last_stage].frames_ctx);
243  } else {
245  s->passthrough = 1;
246  }
247 
248  if (!outl->hw_frames_ctx)
249  return AVERROR(ENOMEM);
250 
251  return 0;
252 }
253 
255 {
256  FilterLink *outl = ff_filter_link(outlink);
257  AVFilterContext *ctx = outlink->src;
258  AVFilterLink *inlink = ctx->inputs[0];
260  NPPTransposeContext *s = ctx->priv;
261  int ret;
262 
263  if ((inlink->w >= inlink->h && s->passthrough == NPP_TRANSPOSE_PT_TYPE_LANDSCAPE) ||
264  (inlink->w <= inlink->h && s->passthrough == NPP_TRANSPOSE_PT_TYPE_PORTRAIT))
265  {
266  if (inl->hw_frames_ctx) {
268  if (!outl->hw_frames_ctx)
269  return AVERROR(ENOMEM);
270  }
271 
273  "w:%d h:%d -> w:%d h:%d (passthrough mode)\n",
274  inlink->w, inlink->h, inlink->w, inlink->h);
275  return 0;
276  } else {
277  s->passthrough = NPP_TRANSPOSE_PT_TYPE_NONE;
278  }
279 
280  outlink->w = inlink->h;
281  outlink->h = inlink->w;
282  outlink->sample_aspect_ratio = (AVRational){inlink->sample_aspect_ratio.den, inlink->sample_aspect_ratio.num};
283 
284  ret = init_processing_chain(ctx, inlink->w, inlink->h, outlink->w, outlink->h);
285  if (ret < 0)
286  return ret;
287 
288  av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d -transpose-> w:%d h:%d\n",
289  inlink->w, inlink->h, outlink->w, outlink->h);
290 
291  return 0;
292 }
293 
295  AVFrame *out, AVFrame *in)
296 {
297  NPPTransposeContext *s = ctx->priv;
298  NppStatus err;
299  int i;
300 
301  for (i = 0; i < FF_ARRAY_ELEMS(stage->planes_in) && i < FF_ARRAY_ELEMS(in->data) && in->data[i]; i++) {
302  int iw = stage->planes_in[i].width;
303  int ih = stage->planes_in[i].height;
304  int ow = stage->planes_out[i].width;
305  int oh = stage->planes_out[i].height;
306 
307  // nppRotate uses 0,0 as the rotation point
308  // need to shift the image accordingly after rotation
309  // need to subtract 1 to get the correct coordinates
310  double angle = s->dir == NPP_TRANSPOSE_CLOCK ? -90.0 : s->dir == NPP_TRANSPOSE_CCLOCK ? 90.0 : 180.0;
311  int shiftw = (s->dir == NPP_TRANSPOSE_CLOCK || s->dir == NPP_TRANSPOSE_CLOCK_FLIP) ? ow - 1 : 0;
312  int shifth = (s->dir == NPP_TRANSPOSE_CCLOCK || s->dir == NPP_TRANSPOSE_CLOCK_FLIP) ? oh - 1 : 0;
313 
314  err = nppiRotate_8u_C1R(in->data[i], (NppiSize){ iw, ih },
315  in->linesize[i], (NppiRect){ 0, 0, iw, ih },
316  out->data[i], out->linesize[i],
317  (NppiRect){ 0, 0, ow, oh },
318  angle, shiftw, shifth, NPPI_INTER_NN);
319  if (err != NPP_SUCCESS) {
320  av_log(ctx, AV_LOG_ERROR, "NPP rotate error: %d\n", err);
321  return AVERROR_UNKNOWN;
322  }
323  }
324 
325  return 0;
326 }
327 
329  AVFrame *out, AVFrame *in)
330 {
331  NppStatus err;
332  int i;
333 
334  for (i = 0; i < FF_ARRAY_ELEMS(stage->planes_in) && i < FF_ARRAY_ELEMS(in->data) && in->data[i]; i++) {
335  int iw = stage->planes_in[i].width;
336  int ih = stage->planes_in[i].height;
337 
338  err = nppiTranspose_8u_C1R(in->data[i], in->linesize[i],
339  out->data[i], out->linesize[i],
340  (NppiSize){ iw, ih });
341  if (err != NPP_SUCCESS) {
342  av_log(ctx, AV_LOG_ERROR, "NPP transpose error: %d\n", err);
343  return AVERROR_UNKNOWN;
344  }
345  }
346 
347  return 0;
348 }
349 
351  AVFrame *out, AVFrame *in) = {
354 };
355 
357 {
358  NPPTransposeContext *s = ctx->priv;
359  AVFrame *src = in;
360  int i, ret, last_stage = -1;
361 
362  for (i = 0; i < FF_ARRAY_ELEMS(s->stages); i++) {
363  if (!s->stages[i].stage_needed)
364  continue;
365 
366  ret = npptranspose_process[i](ctx, &s->stages[i], s->stages[i].frame, src);
367  if (ret < 0)
368  return ret;
369 
370  src = s->stages[i].frame;
371  last_stage = i;
372  }
373 
374  if (last_stage < 0)
375  return AVERROR_BUG;
376 
377  ret = av_hwframe_get_buffer(src->hw_frames_ctx, s->tmp_frame, 0);
378  if (ret < 0)
379  return ret;
380 
382  av_frame_move_ref(src, s->tmp_frame);
383 
384  ret = av_frame_copy_props(out, in);
385  if (ret < 0)
386  return ret;
387 
388  return 0;
389 }
390 
392 {
393  AVFilterContext *ctx = link->dst;
394  NPPTransposeContext *s = ctx->priv;
395  AVFilterLink *outlink = ctx->outputs[0];
396  FilterLink *outl = ff_filter_link(outlink);
397  AVHWFramesContext *frames_ctx = (AVHWFramesContext*)outl->hw_frames_ctx->data;
398  AVCUDADeviceContext *device_hwctx = frames_ctx->device_ctx->hwctx;
399  AVFrame *out = NULL;
400  CUcontext dummy;
401  int ret = 0;
402 
403  if (s->passthrough)
404  return ff_filter_frame(outlink, in);
405 
406  out = av_frame_alloc();
407  if (!out) {
408  ret = AVERROR(ENOMEM);
409  goto fail;
410  }
411 
412  ret = CHECK_CU(device_hwctx->internal->cuda_dl->cuCtxPushCurrent(device_hwctx->cuda_ctx));
413  if (ret < 0)
414  goto fail;
415 
416  ret = npptranspose_filter(ctx, out, in);
417 
418  CHECK_CU(device_hwctx->internal->cuda_dl->cuCtxPopCurrent(&dummy));
419  if (ret < 0)
420  goto fail;
421 
422  av_frame_free(&in);
423 
424  return ff_filter_frame(outlink, out);
425 
426 fail:
427  av_frame_free(&in);
428  av_frame_free(&out);
429  return ret;
430 }
431 
432 #define OFFSET(x) offsetof(NPPTransposeContext, x)
433 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
434 
435 static const AVOption options[] = {
436  { "dir", "set transpose direction", OFFSET(dir), AV_OPT_TYPE_INT, { .i64 = NPP_TRANSPOSE_CCLOCK_FLIP }, 0, 3, FLAGS, .unit = "dir" },
437  { "cclock_flip", "rotate counter-clockwise with vertical flip", 0, AV_OPT_TYPE_CONST, { .i64 = NPP_TRANSPOSE_CCLOCK_FLIP }, 0, 0, FLAGS, .unit = "dir" },
438  { "clock", "rotate clockwise", 0, AV_OPT_TYPE_CONST, { .i64 = NPP_TRANSPOSE_CLOCK }, 0, 0, FLAGS, .unit = "dir" },
439  { "cclock", "rotate counter-clockwise", 0, AV_OPT_TYPE_CONST, { .i64 = NPP_TRANSPOSE_CCLOCK }, 0, 0, FLAGS, .unit = "dir" },
440  { "clock_flip", "rotate clockwise with vertical flip", 0, AV_OPT_TYPE_CONST, { .i64 = NPP_TRANSPOSE_CLOCK_FLIP }, 0, 0, FLAGS, .unit = "dir" },
441  { "passthrough", "do not apply transposition if the input matches the specified geometry", OFFSET(passthrough), AV_OPT_TYPE_INT, { .i64 = NPP_TRANSPOSE_PT_TYPE_NONE }, 0, 2, FLAGS, .unit = "passthrough" },
442  { "none", "always apply transposition", 0, AV_OPT_TYPE_CONST, { .i64 = NPP_TRANSPOSE_PT_TYPE_NONE }, 0, 0, FLAGS, .unit = "passthrough" },
443  { "landscape", "preserve landscape geometry", 0, AV_OPT_TYPE_CONST, { .i64 = NPP_TRANSPOSE_PT_TYPE_LANDSCAPE }, 0, 0, FLAGS, .unit = "passthrough" },
444  { "portrait", "preserve portrait geometry", 0, AV_OPT_TYPE_CONST, { .i64 = NPP_TRANSPOSE_PT_TYPE_PORTRAIT }, 0, 0, FLAGS, .unit = "passthrough" },
445  { NULL },
446 };
447 
448 static const AVClass npptranspose_class = {
449  .class_name = "npptranspose",
450  .item_name = av_default_item_name,
451  .option = options,
452  .version = LIBAVUTIL_VERSION_INT,
453 };
454 
456  {
457  .name = "default",
458  .type = AVMEDIA_TYPE_VIDEO,
459  .filter_frame = npptranspose_filter_frame,
460  },
461 };
462 
464  {
465  .name = "default",
466  .type = AVMEDIA_TYPE_VIDEO,
467  .config_props = npptranspose_config_props,
468  },
469 };
470 
472  .p.name = "transpose_npp",
473  .p.description = NULL_IF_CONFIG_SMALL("NVIDIA Performance Primitives video transpose"),
474  .p.priv_class = &npptranspose_class,
475  .init = npptranspose_init,
476  .uninit = npptranspose_uninit,
477  .priv_size = sizeof(NPPTransposeContext),
481  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
482 };
AVHWDeviceContext::hwctx
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
Definition: hwcontext.h:88
NPPTransposeStageContext::planes_out
struct NPPTransposeStageContext::@401 planes_out[3]
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:216
AV_PIX_FMT_CUDA
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
Definition: pixfmt.h:260
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:71
init_processing_chain
static int init_processing_chain(AVFilterContext *ctx, int in_width, int in_height, int out_width, int out_height)
Definition: vf_transpose_npp.c:180
AVERROR
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
opt.h
npptranspose_filter
static int npptranspose_filter(AVFilterContext *ctx, AVFrame *out, AVFrame *in)
Definition: vf_transpose_npp.c:356
hwcontext_cuda_internal.h
npptranspose_init
static int npptranspose_init(AVFilterContext *ctx)
Definition: vf_transpose_npp.c:83
out
FILE * out
Definition: movenc.c:55
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1067
npptranspose_class
static const AVClass npptranspose_class
Definition: vf_transpose_npp.c:448
AVBufferRef::data
uint8_t * data
The data buffer.
Definition: buffer.h:90
AVHWFramesContext::format
enum AVPixelFormat format
The pixel format identifying the underlying HW surface type.
Definition: hwcontext.h:200
supported_formats
static enum AVPixelFormat supported_formats[]
Definition: vf_transpose_npp.c:38
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
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:64
av_hwframe_ctx_init
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
Definition: hwcontext.c:337
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:263
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:427
pixdesc.h
AVFrame::width
int width
Definition: frame.h:499
av_hwframe_ctx_alloc
AVBufferRef * av_hwframe_ctx_alloc(AVBufferRef *device_ref_in)
Allocate an AVHWFramesContext tied to a given device context.
Definition: hwcontext.c:263
AVOption
AVOption.
Definition: opt.h:429
NPPTransposeStageContext::frame
AVFrame * frame
Definition: vf_transpose_npp.c:71
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:226
av_buffer_ref
AVBufferRef * av_buffer_ref(const AVBufferRef *buf)
Create a new reference to an AVBuffer.
Definition: buffer.c:103
Passthrough
Passthrough
Definition: vf_transpose_npp.c:56
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:220
options
static const AVOption options[]
Definition: vf_transpose_npp.c:435
AVERROR_UNKNOWN
#define AVERROR_UNKNOWN
Unknown error, typically from an external library.
Definition: error.h:73
AVHWFramesContext::width
int width
The allocated dimensions of the frames in this pool.
Definition: hwcontext.h:220
video.h
ff_vf_transpose_npp
const FFFilter ff_vf_transpose_npp
Definition: vf_transpose_npp.c:471
init_stage
static int init_stage(NPPTransposeStageContext *stage, AVBufferRef *device_ctx)
Definition: vf_transpose_npp.c:116
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:448
NPPTransposeContext::dir
int dir
TransposeDir.
Definition: vf_transpose_npp.c:80
formats.h
NPPTransposeContext::tmp_frame
AVFrame * tmp_frame
Definition: vf_transpose_npp.c:77
npptranspose_config_props
static int npptranspose_config_props(AVFilterLink *outlink)
Definition: vf_transpose_npp.c:254
fail
#define fail()
Definition: checkasm.h:206
TransposeStage
TransposeStage
Definition: vf_transpose_npp.c:43
dummy
int dummy
Definition: motion.c:66
av_pix_fmt_get_chroma_sub_sample
int av_pix_fmt_get_chroma_sub_sample(enum AVPixelFormat pix_fmt, int *h_shift, int *v_shift)
Utility function to access log2_chroma_w log2_chroma_h from the pixel format AVPixFmtDescriptor.
Definition: pixdesc.c:3475
AVFilterPad
A filter pad used for either input or output.
Definition: filters.h:39
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:52
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:210
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
AVHWFramesContext::height
int height
Definition: hwcontext.h:220
FFFilter
Definition: filters.h:266
OFFSET
#define OFFSET(x)
Definition: vf_transpose_npp.c:432
NPP_TRANSPOSE_CLOCK
@ NPP_TRANSPOSE_CLOCK
Definition: vf_transpose_npp.c:51
s
#define s(width, name)
Definition: cbs_vp9.c:198
npptranspose_rotate
static int npptranspose_rotate(AVFilterContext *ctx, NPPTransposeStageContext *stage, AVFrame *out, AVFrame *in)
Definition: vf_transpose_npp.c:294
filters.h
ctx
AVFormatContext * ctx
Definition: movenc.c:49
format_is_supported
static int format_is_supported(enum AVPixelFormat fmt)
Definition: vf_transpose_npp.c:169
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:73
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:264
link
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 link
Definition: filter_design.txt:23
if
if(ret)
Definition: filter_design.txt:179
LIBAVUTIL_VERSION_INT
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:76
NULL
#define NULL
Definition: coverity.c:32
AVHWFramesContext::sw_format
enum AVPixelFormat sw_format
The pixel format identifying the actual data layout of the hardware frames.
Definition: hwcontext.h:213
av_frame_copy_props
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:599
format
New swscale design to change SwsGraph is what coordinates multiple passes These can include cascaded scaling error diffusion and so on Or we could have separate passes for the vertical and horizontal scaling In between each SwsPass lies a fully allocated image buffer Graph passes may have different levels of e g we can have a single threaded error diffusion pass following a multi threaded scaling pass SwsGraph is internally recreated whenever the image format
Definition: swscale-v2.txt:14
av_buffer_unref
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
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
AVHWFramesContext::device_ref
AVBufferRef * device_ref
A reference to the parent AVHWDeviceContext.
Definition: hwcontext.h:129
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:241
options
Definition: swscale.c:43
Transpose
Transpose
Definition: vf_transpose_npp.c:49
npptranspose_process
static int(*const npptranspose_process[])(AVFilterContext *ctx, NPPTransposeStageContext *stage, AVFrame *out, AVFrame *in)
Definition: vf_transpose_npp.c:350
NPPTransposeStageContext::stage_needed
int stage_needed
Definition: vf_transpose_npp.c:63
ff_filter_link
static FilterLink * ff_filter_link(AVFilterLink *link)
Definition: filters.h:198
NPPTransposeContext
Definition: vf_transpose_npp.c:74
NPPTransposeStageContext::height
int height
Definition: vf_transpose_npp.c:68
FF_FILTER_FLAG_HWFRAME_AWARE
#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:207
NPP_TRANSPOSE_PT_TYPE_PORTRAIT
@ NPP_TRANSPOSE_PT_TYPE_PORTRAIT
Definition: vf_transpose_npp.c:59
NPP_TRANSPOSE_CCLOCK
@ NPP_TRANSPOSE_CCLOCK
Definition: vf_transpose_npp.c:52
CHECK_CU
#define CHECK_CU(x)
Definition: vf_transpose_npp.c:36
NPP_TRANSPOSE_PT_TYPE_LANDSCAPE
@ NPP_TRANSPOSE_PT_TYPE_LANDSCAPE
Definition: vf_transpose_npp.c:58
npptranspose_uninit
static void npptranspose_uninit(AVFilterContext *ctx)
Definition: vf_transpose_npp.c:103
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:94
NPPTransposeStageContext::out_fmt
enum AVPixelFormat out_fmt
Definition: vf_transpose_npp.c:65
NPPTransposeStageContext::in_fmt
enum AVPixelFormat in_fmt
Definition: vf_transpose_npp.c:64
NPPTransposeStageContext::planes_in
struct NPPTransposeStageContext::@401 planes_in[3]
NPP_TRANSPOSE_CLOCK_FLIP
@ NPP_TRANSPOSE_CLOCK_FLIP
Definition: vf_transpose_npp.c:53
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
NPPTransposeContext::passthrough
int passthrough
PassthroughType, landscape passthrough mode enabled.
Definition: vf_transpose_npp.c:79
NPPTransposeContext::stages
NPPTransposeStageContext stages[STAGE_NB]
Definition: vf_transpose_npp.c:76
internal.h
common.h
npptranspose_outputs
static const AVFilterPad npptranspose_outputs[]
Definition: vf_transpose_npp.c:463
av_frame_move_ref
void av_frame_move_ref(AVFrame *dst, AVFrame *src)
Move everything contained in src to dst and reset src.
Definition: frame.c:523
av_frame_unref
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:496
AVFilterPad::name
const char * name
Pad name.
Definition: filters.h:45
npptranspose_transpose
static int npptranspose_transpose(AVFilterContext *ctx, NPPTransposeStageContext *stage, AVFrame *out, AVFrame *in)
Definition: vf_transpose_npp.c:328
FLAGS
#define FLAGS
Definition: vf_transpose_npp.c:433
NPPTransposeStageContext
Definition: vf_transpose_npp.c:62
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:118
AVCUDADeviceContext
This struct is allocated as AVHWDeviceContext.hwctx.
Definition: hwcontext_cuda.h:42
ret
ret
Definition: filter_design.txt:187
AVClass::class_name
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:81
AVHWFramesContext::device_ctx
AVHWDeviceContext * device_ctx
The parent AVHWDeviceContext.
Definition: hwcontext.h:137
cuda_check.h
AVFrame::height
int height
Definition: frame.h:499
NPPTransposeStageContext::width
int width
Definition: vf_transpose_npp.c:67
npptranspose_filter_frame
static int npptranspose_filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_transpose_npp.c:391
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
avfilter.h
STAGE_NB
@ STAGE_NB
Definition: vf_transpose_npp.c:46
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:78
NPP_TRANSPOSE_PT_TYPE_NONE
@ NPP_TRANSPOSE_PT_TYPE_NONE
Definition: vf_transpose_npp.c:57
AVFilterContext
An instance of a filter.
Definition: avfilter.h:274
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:200
FFFilter::p
AVFilter p
The public AVFilter.
Definition: filters.h:270
AVBufferRef
A reference to a data buffer.
Definition: buffer.h:82
NPPTransposeStageContext::frames_ctx
AVBufferRef * frames_ctx
Definition: vf_transpose_npp.c:70
FFALIGN
#define FFALIGN(x, a)
Definition: macros.h:78
STAGE_TRANSPOSE
@ STAGE_TRANSPOSE
Definition: vf_transpose_npp.c:45
hwcontext.h
AVERROR_BUG
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:52
AVFrame::linesize
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:472
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:27
NPP_TRANSPOSE_CCLOCK_FLIP
@ NPP_TRANSPOSE_CCLOCK_FLIP
Definition: vf_transpose_npp.c:50
npptranspose_inputs
static const AVFilterPad npptranspose_inputs[]
Definition: vf_transpose_npp.c:455
av_hwframe_get_buffer
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
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
FILTER_SINGLE_PIXFMT
#define FILTER_SINGLE_PIXFMT(pix_fmt_)
Definition: filters.h:253
src
#define src
Definition: vp8dsp.c:248
av_get_pix_fmt_name
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:3367
STAGE_ROTATE
@ STAGE_ROTATE
Definition: vf_transpose_npp.c:44