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 "formats.h"
33 #include "internal.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  for (i = 0; i < FF_ARRAY_ELEMS(s->stages); i++) {
89  s->stages[i].frame = av_frame_alloc();
90  if (!s->stages[i].frame)
91  return AVERROR(ENOMEM);
92  }
93 
94  s->tmp_frame = av_frame_alloc();
95  if (!s->tmp_frame)
96  return AVERROR(ENOMEM);
97 
98  return 0;
99 }
100 
102 {
103  NPPTransposeContext *s = ctx->priv;
104  int i;
105 
106  for (i = 0; i < FF_ARRAY_ELEMS(s->stages); i++) {
107  av_frame_free(&s->stages[i].frame);
108  av_buffer_unref(&s->stages[i].frames_ctx);
109  }
110 
111  av_frame_free(&s->tmp_frame);
112 }
113 
115 {
116  static const enum AVPixelFormat pixel_formats[] = {
118  };
119 
120  return ff_set_common_formats_from_list(ctx, pixel_formats);
121 }
122 
123 static int init_stage(NPPTransposeStageContext *stage, AVBufferRef *device_ctx)
124 {
125  AVBufferRef *out_ref = NULL;
126  AVHWFramesContext *out_ctx;
127  int in_sw, in_sh, out_sw, out_sh;
128  int ret, i;
129 
130  av_pix_fmt_get_chroma_sub_sample(stage->in_fmt, &in_sw, &in_sh);
131  av_pix_fmt_get_chroma_sub_sample(stage->out_fmt, &out_sw, &out_sh);
132 
133  if (!stage->planes_out[0].width) {
134  stage->planes_out[0].width = stage->planes_in[0].width;
135  stage->planes_out[0].height = stage->planes_in[0].height;
136  }
137 
138  for (i = 1; i < FF_ARRAY_ELEMS(stage->planes_in); i++) {
139  stage->planes_in[i].width = stage->planes_in[0].width >> in_sw;
140  stage->planes_in[i].height = stage->planes_in[0].height >> in_sh;
141  stage->planes_out[i].width = stage->planes_out[0].width >> out_sw;
142  stage->planes_out[i].height = stage->planes_out[0].height >> out_sh;
143  }
144 
145  out_ref = av_hwframe_ctx_alloc(device_ctx);
146  if (!out_ref)
147  return AVERROR(ENOMEM);
148  out_ctx = (AVHWFramesContext*)out_ref->data;
149 
150  out_ctx->format = AV_PIX_FMT_CUDA;
151  out_ctx->sw_format = stage->out_fmt;
152  out_ctx->width = FFALIGN(stage->planes_out[0].width, 32);
153  out_ctx->height = FFALIGN(stage->planes_out[0].height, 32);
154 
155  ret = av_hwframe_ctx_init(out_ref);
156  if (ret < 0)
157  goto fail;
158 
159  av_frame_unref(stage->frame);
160  ret = av_hwframe_get_buffer(out_ref, stage->frame, 0);
161  if (ret < 0)
162  goto fail;
163 
164  stage->frame->width = stage->planes_out[0].width;
165  stage->frame->height = stage->planes_out[0].height;
166  av_buffer_unref(&stage->frames_ctx);
167  stage->frames_ctx = out_ref;
168 
169  return 0;
170 
171 fail:
172  av_buffer_unref(&out_ref);
173  return ret;
174 }
175 
176 static int format_is_supported(enum AVPixelFormat fmt)
177 {
178  int i;
179 
180  for (i = 0; i < FF_ARRAY_ELEMS(supported_formats); i++)
181  if (supported_formats[i] == fmt)
182  return 1;
183 
184  return 0;
185 }
186 
187 static int init_processing_chain(AVFilterContext *ctx, int in_width, int in_height,
188  int out_width, int out_height)
189 {
190  NPPTransposeContext *s = ctx->priv;
191  AVHWFramesContext *in_frames_ctx;
192  enum AVPixelFormat format;
193  int i, ret, last_stage = -1;
194  int rot_width = out_width, rot_height = out_height;
195 
196  /* check that we have a hw context */
197  if (!ctx->inputs[0]->hw_frames_ctx) {
198  av_log(ctx, AV_LOG_ERROR, "No hw context provided on input\n");
199  return AVERROR(EINVAL);
200  }
201 
202  in_frames_ctx = (AVHWFramesContext*)ctx->inputs[0]->hw_frames_ctx->data;
203  format = in_frames_ctx->sw_format;
204 
206  av_log(ctx, AV_LOG_ERROR, "Unsupported input format: %s\n",
208  return AVERROR(ENOSYS);
209  }
210 
211  if (s->dir != NPP_TRANSPOSE_CCLOCK_FLIP) {
212  s->stages[STAGE_ROTATE].stage_needed = 1;
213  }
214 
215  if (s->dir == NPP_TRANSPOSE_CCLOCK_FLIP || s->dir == NPP_TRANSPOSE_CLOCK_FLIP) {
216  s->stages[STAGE_TRANSPOSE].stage_needed = 1;
217 
218  /* Rotating by 180° in case of clock_flip, or not at all for cclock_flip, so width/height unchanged by rotation */
219  rot_width = in_width;
220  rot_height = in_height;
221  }
222 
223  s->stages[STAGE_ROTATE].in_fmt = format;
224  s->stages[STAGE_ROTATE].out_fmt = format;
225  s->stages[STAGE_ROTATE].planes_in[0].width = in_width;
226  s->stages[STAGE_ROTATE].planes_in[0].height = in_height;
227  s->stages[STAGE_ROTATE].planes_out[0].width = rot_width;
228  s->stages[STAGE_ROTATE].planes_out[0].height = rot_height;
229  s->stages[STAGE_TRANSPOSE].in_fmt = format;
230  s->stages[STAGE_TRANSPOSE].out_fmt = format;
231  s->stages[STAGE_TRANSPOSE].planes_in[0].width = rot_width;
232  s->stages[STAGE_TRANSPOSE].planes_in[0].height = rot_height;
233  s->stages[STAGE_TRANSPOSE].planes_out[0].width = out_width;
234  s->stages[STAGE_TRANSPOSE].planes_out[0].height = out_height;
235 
236  /* init the hardware contexts */
237  for (i = 0; i < FF_ARRAY_ELEMS(s->stages); i++) {
238  if (!s->stages[i].stage_needed)
239  continue;
240  ret = init_stage(&s->stages[i], in_frames_ctx->device_ref);
241  if (ret < 0)
242  return ret;
243  last_stage = i;
244  }
245 
246  if (last_stage >= 0) {
247  ctx->outputs[0]->hw_frames_ctx = av_buffer_ref(s->stages[last_stage].frames_ctx);
248  } else {
249  ctx->outputs[0]->hw_frames_ctx = av_buffer_ref(ctx->inputs[0]->hw_frames_ctx);
250  s->passthrough = 1;
251  }
252 
253  if (!ctx->outputs[0]->hw_frames_ctx)
254  return AVERROR(ENOMEM);
255 
256  return 0;
257 }
258 
260 {
261  AVFilterContext *ctx = outlink->src;
262  AVFilterLink *inlink = ctx->inputs[0];
263  NPPTransposeContext *s = ctx->priv;
264  int ret;
265 
266  if ((inlink->w >= inlink->h && s->passthrough == NPP_TRANSPOSE_PT_TYPE_LANDSCAPE) ||
267  (inlink->w <= inlink->h && s->passthrough == NPP_TRANSPOSE_PT_TYPE_PORTRAIT))
268  {
269  if (inlink->hw_frames_ctx) {
270  outlink->hw_frames_ctx = av_buffer_ref(inlink->hw_frames_ctx);
271  if (!outlink->hw_frames_ctx)
272  return AVERROR(ENOMEM);
273  }
274 
276  "w:%d h:%d -> w:%d h:%d (passthrough mode)\n",
277  inlink->w, inlink->h, inlink->w, inlink->h);
278  return 0;
279  } else {
280  s->passthrough = NPP_TRANSPOSE_PT_TYPE_NONE;
281  }
282 
283  outlink->w = inlink->h;
284  outlink->h = inlink->w;
285  outlink->sample_aspect_ratio = (AVRational){inlink->sample_aspect_ratio.den, inlink->sample_aspect_ratio.num};
286 
287  ret = init_processing_chain(ctx, inlink->w, inlink->h, outlink->w, outlink->h);
288  if (ret < 0)
289  return ret;
290 
291  av_log(ctx, AV_LOG_VERBOSE, "w:%d h:%d -transpose-> w:%d h:%d\n",
292  inlink->w, inlink->h, outlink->w, outlink->h);
293 
294  return 0;
295 }
296 
298  AVFrame *out, AVFrame *in)
299 {
300  NPPTransposeContext *s = ctx->priv;
301  NppStatus err;
302  int i;
303 
304  for (i = 0; i < FF_ARRAY_ELEMS(stage->planes_in) && i < FF_ARRAY_ELEMS(in->data) && in->data[i]; i++) {
305  int iw = stage->planes_in[i].width;
306  int ih = stage->planes_in[i].height;
307  int ow = stage->planes_out[i].width;
308  int oh = stage->planes_out[i].height;
309 
310  // nppRotate uses 0,0 as the rotation point
311  // need to shift the image accordingly after rotation
312  // need to substract 1 to get the correct coordinates
313  double angle = s->dir == NPP_TRANSPOSE_CLOCK ? -90.0 : s->dir == NPP_TRANSPOSE_CCLOCK ? 90.0 : 180.0;
314  int shiftw = (s->dir == NPP_TRANSPOSE_CLOCK || s->dir == NPP_TRANSPOSE_CLOCK_FLIP) ? ow - 1 : 0;
315  int shifth = (s->dir == NPP_TRANSPOSE_CCLOCK || s->dir == NPP_TRANSPOSE_CLOCK_FLIP) ? oh - 1 : 0;
316 
317  err = nppiRotate_8u_C1R(in->data[i], (NppiSize){ iw, ih },
318  in->linesize[i], (NppiRect){ 0, 0, iw, ih },
319  out->data[i], out->linesize[i],
320  (NppiRect){ 0, 0, ow, oh },
321  angle, shiftw, shifth, NPPI_INTER_NN);
322  if (err != NPP_SUCCESS) {
323  av_log(ctx, AV_LOG_ERROR, "NPP rotate error: %d\n", err);
324  return AVERROR_UNKNOWN;
325  }
326  }
327 
328  return 0;
329 }
330 
332  AVFrame *out, AVFrame *in)
333 {
334  NppStatus err;
335  int i;
336 
337  for (i = 0; i < FF_ARRAY_ELEMS(stage->planes_in) && i < FF_ARRAY_ELEMS(in->data) && in->data[i]; i++) {
338  int iw = stage->planes_in[i].width;
339  int ih = stage->planes_in[i].height;
340 
341  err = nppiTranspose_8u_C1R(in->data[i], in->linesize[i],
342  out->data[i], out->linesize[i],
343  (NppiSize){ iw, ih });
344  if (err != NPP_SUCCESS) {
345  av_log(ctx, AV_LOG_ERROR, "NPP transpose error: %d\n", err);
346  return AVERROR_UNKNOWN;
347  }
348  }
349 
350  return 0;
351 }
352 
354  AVFrame *out, AVFrame *in) = {
357 };
358 
360 {
361  NPPTransposeContext *s = ctx->priv;
362  AVFrame *src = in;
363  int i, ret, last_stage = -1;
364 
365  for (i = 0; i < FF_ARRAY_ELEMS(s->stages); i++) {
366  if (!s->stages[i].stage_needed)
367  continue;
368 
369  ret = npptranspose_process[i](ctx, &s->stages[i], s->stages[i].frame, src);
370  if (ret < 0)
371  return ret;
372 
373  src = s->stages[i].frame;
374  last_stage = i;
375  }
376 
377  if (last_stage < 0)
378  return AVERROR_BUG;
379 
380  ret = av_hwframe_get_buffer(src->hw_frames_ctx, s->tmp_frame, 0);
381  if (ret < 0)
382  return ret;
383 
385  av_frame_move_ref(src, s->tmp_frame);
386 
387  ret = av_frame_copy_props(out, in);
388  if (ret < 0)
389  return ret;
390 
391  return 0;
392 }
393 
395 {
396  AVFilterContext *ctx = link->dst;
397  NPPTransposeContext *s = ctx->priv;
398  AVFilterLink *outlink = ctx->outputs[0];
399  AVHWFramesContext *frames_ctx = (AVHWFramesContext*)outlink->hw_frames_ctx->data;
400  AVCUDADeviceContext *device_hwctx = frames_ctx->device_ctx->hwctx;
401  AVFrame *out = NULL;
402  CUcontext dummy;
403  int ret = 0;
404 
405  if (s->passthrough)
406  return ff_filter_frame(outlink, in);
407 
408  out = av_frame_alloc();
409  if (!out) {
410  ret = AVERROR(ENOMEM);
411  goto fail;
412  }
413 
414  ret = CHECK_CU(device_hwctx->internal->cuda_dl->cuCtxPushCurrent(device_hwctx->cuda_ctx));
415  if (ret < 0)
416  goto fail;
417 
418  ret = npptranspose_filter(ctx, out, in);
419 
420  CHECK_CU(device_hwctx->internal->cuda_dl->cuCtxPopCurrent(&dummy));
421  if (ret < 0)
422  goto fail;
423 
424  av_frame_free(&in);
425 
426  return ff_filter_frame(outlink, out);
427 
428 fail:
429  av_frame_free(&in);
430  av_frame_free(&out);
431  return ret;
432 }
433 
434 #define OFFSET(x) offsetof(NPPTransposeContext, x)
435 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM)
436 
437 static const AVOption options[] = {
438  { "dir", "set transpose direction", OFFSET(dir), AV_OPT_TYPE_INT, { .i64 = NPP_TRANSPOSE_CCLOCK_FLIP }, 0, 3, FLAGS, "dir" },
439  { "cclock_flip", "rotate counter-clockwise with vertical flip", 0, AV_OPT_TYPE_CONST, { .i64 = NPP_TRANSPOSE_CCLOCK_FLIP }, 0, 0, FLAGS, "dir" },
440  { "clock", "rotate clockwise", 0, AV_OPT_TYPE_CONST, { .i64 = NPP_TRANSPOSE_CLOCK }, 0, 0, FLAGS, "dir" },
441  { "cclock", "rotate counter-clockwise", 0, AV_OPT_TYPE_CONST, { .i64 = NPP_TRANSPOSE_CCLOCK }, 0, 0, FLAGS, "dir" },
442  { "clock_flip", "rotate clockwise with vertical flip", 0, AV_OPT_TYPE_CONST, { .i64 = NPP_TRANSPOSE_CLOCK_FLIP }, 0, 0, FLAGS, "dir" },
443  { "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, "passthrough" },
444  { "none", "always apply transposition", 0, AV_OPT_TYPE_CONST, { .i64 = NPP_TRANSPOSE_PT_TYPE_NONE }, 0, 0, FLAGS, "passthrough" },
445  { "landscape", "preserve landscape geometry", 0, AV_OPT_TYPE_CONST, { .i64 = NPP_TRANSPOSE_PT_TYPE_LANDSCAPE }, 0, 0, FLAGS, "passthrough" },
446  { "portrait", "preserve portrait geometry", 0, AV_OPT_TYPE_CONST, { .i64 = NPP_TRANSPOSE_PT_TYPE_PORTRAIT }, 0, 0, FLAGS, "passthrough" },
447  { NULL },
448 };
449 
450 static const AVClass npptranspose_class = {
451  .class_name = "npptranspose",
452  .item_name = av_default_item_name,
453  .option = options,
454  .version = LIBAVUTIL_VERSION_INT,
455 };
456 
458  {
459  .name = "default",
460  .type = AVMEDIA_TYPE_VIDEO,
461  .filter_frame = npptranspose_filter_frame,
462  },
463 };
464 
466  {
467  .name = "default",
468  .type = AVMEDIA_TYPE_VIDEO,
469  .config_props = npptranspose_config_props,
470  },
471 };
472 
474  .name = "transpose_npp",
475  .description = NULL_IF_CONFIG_SMALL("NVIDIA Performance Primitives video transpose"),
476  .init = npptranspose_init,
477  .uninit = npptranspose_uninit,
478  .query_formats = npptranspose_query_formats,
479  .priv_size = sizeof(NPPTransposeContext),
480  .priv_class = &npptranspose_class,
483  .flags_internal = FF_FILTER_FLAG_HWFRAME_AWARE,
484 };
AVHWDeviceContext::hwctx
void * hwctx
The format-specific data, allocated and freed by libavutil along with this context.
Definition: hwcontext.h:92
AV_PIX_FMT_CUDA
@ AV_PIX_FMT_CUDA
HW acceleration through CUDA.
Definition: pixfmt.h:225
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
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:187
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:359
hwcontext_cuda_internal.h
npptranspose_init
static int npptranspose_init(AVFilterContext *ctx)
Definition: vf_transpose_npp.c:83
out
FILE * out
Definition: movenc.c:54
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: internal.h:334
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1019
npptranspose_class
static const AVClass npptranspose_class
Definition: vf_transpose_npp.c:450
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:209
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:112
av_hwframe_ctx_init
int av_hwframe_ctx_init(AVBufferRef *ref)
Finalize the context before use.
Definition: hwcontext.c:333
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:303
pixdesc.h
AVFrame::width
int width
Definition: frame.h:361
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:247
AVOption
AVOption.
Definition: opt.h:247
NPPTransposeStageContext::frame
AVFrame * frame
Definition: vf_transpose_npp.c:71
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:196
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:153
options
static const AVOption options[]
Definition: vf_transpose_npp.c:437
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:229
video.h
init_stage
static int init_stage(NPPTransposeStageContext *stage, AVBufferRef *device_ctx)
Definition: vf_transpose_npp.c:123
AVFrame::data
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:317
NPPTransposeContext::dir
int dir
TransposeDir.
Definition: vf_transpose_npp.c:80
ff_vf_transpose_npp
const AVFilter ff_vf_transpose_npp
Definition: vf_transpose_npp.c:473
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:259
fail
#define fail()
Definition: checkasm.h:127
TransposeStage
TransposeStage
Definition: vf_transpose_npp.c:43
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:2568
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:50
av_frame_alloc
AVFrame * av_frame_alloc(void)
Allocate an AVFrame and set its fields to default values.
Definition: frame.c:99
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:180
FF_ARRAY_ELEMS
#define FF_ARRAY_ELEMS(a)
Definition: sinewin_tablegen.c:29
AVHWFramesContext::height
int height
Definition: hwcontext.h:229
NPPTransposeStageContext::planes_out
struct NPPTransposeStageContext::@234 planes_out[3]
npptranspose_query_formats
static int npptranspose_query_formats(AVFilterContext *ctx)
Definition: vf_transpose_npp.c:114
OFFSET
#define OFFSET(x)
Definition: vf_transpose_npp.c:434
NPP_TRANSPOSE_CLOCK
@ NPP_TRANSPOSE_CLOCK
Definition: vf_transpose_npp.c:51
s
#define s(width, name)
Definition: cbs_vp9.c:257
npptranspose_rotate
static int npptranspose_rotate(AVFilterContext *ctx, NPPTransposeStageContext *stage, AVFrame *out, AVFrame *in)
Definition: vf_transpose_npp.c:297
ff_set_common_formats_from_list
int ff_set_common_formats_from_list(AVFilterContext *ctx, const int *fmts)
Equivalent to ff_set_common_formats(ctx, ff_make_format_list(fmts))
Definition: formats.c:703
ctx
AVFormatContext * ctx
Definition: movenc.c:48
format_is_supported
static int format_is_supported(enum AVPixelFormat fmt)
Definition: vf_transpose_npp.c:176
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:66
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:152
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:66
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:222
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:537
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:141
av_default_item_name
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:235
src
#define src
Definition: vp8dsp.c:255
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:353
NPPTransposeStageContext::stage_needed
int stage_needed
Definition: vf_transpose_npp.c:63
NPPTransposeContext
Definition: vf_transpose_npp.c:74
NPPTransposeStageContext::height
int height
Definition: vf_transpose_npp.c:68
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:101
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:117
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
internal.h
NPP_TRANSPOSE_CLOCK_FLIP
@ NPP_TRANSPOSE_CLOCK_FLIP
Definition: vf_transpose_npp.c:53
i
int i
Definition: input.c:406
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:465
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:461
av_frame_unref
void av_frame_unref(AVFrame *frame)
Unreference all the buffers referenced by frame and reset the frame fields.
Definition: frame.c:437
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:56
npptranspose_transpose
static int npptranspose_transpose(AVFilterContext *ctx, NPPTransposeStageContext *stage, AVFrame *out, AVFrame *in)
Definition: vf_transpose_npp.c:331
FLAGS
#define FLAGS
Definition: vf_transpose_npp.c:435
NPPTransposeStageContext
Definition: vf_transpose_npp.c:62
AVFilter
Filter definition.
Definition: avfilter.h:149
AVHWFramesContext
This struct describes a set or pool of "hardware" frames (i.e.
Definition: hwcontext.h:124
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:71
AVHWFramesContext::device_ctx
AVHWDeviceContext * device_ctx
The parent AVHWDeviceContext.
Definition: hwcontext.h:149
cuda_check.h
AVFrame::height
int height
Definition: frame.h:361
NPPTransposeStageContext::width
int width
Definition: vf_transpose_npp.c:67
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
dummy
int dummy
Definition: motion.c:65
npptranspose_filter_frame
static int npptranspose_filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_transpose_npp.c:394
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
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:71
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:346
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
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
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:153
STAGE_TRANSPOSE
@ STAGE_TRANSPOSE
Definition: vf_transpose_npp.c:45
format
fg outputs[0] format
Definition: ffmpeg_filter.c:175
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, size in bytes of each picture line.
Definition: frame.h:334
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
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:457
NPPTransposeStageContext::planes_in
struct NPPTransposeStageContext::@234 planes_in[3]
int
int
Definition: ffmpeg_filter.c:156
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:502
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233
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:2460
STAGE_ROTATE
@ STAGE_ROTATE
Definition: vf_transpose_npp.c:44