FFmpeg
vf_transpose.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2010 Stefano Sabatini
3  * Copyright (c) 2008 Vitor Sessak
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 /**
23  * @file
24  * transposition filter
25  * Based on MPlayer libmpcodecs/vf_rotate.c.
26  */
27 
28 #include <stdio.h>
29 
30 #include "libavutil/avassert.h"
31 #include "libavutil/imgutils.h"
32 #include "libavutil/internal.h"
33 #include "libavutil/intreadwrite.h"
34 #include "libavutil/opt.h"
35 #include "libavutil/pixdesc.h"
36 
37 #include "avfilter.h"
38 #include "formats.h"
39 #include "internal.h"
40 #include "video.h"
41 #include "transpose.h"
42 
43 typedef struct TransVtable {
44  void (*transpose_8x8)(uint8_t *src, ptrdiff_t src_linesize,
45  uint8_t *dst, ptrdiff_t dst_linesize);
46  void (*transpose_block)(uint8_t *src, ptrdiff_t src_linesize,
47  uint8_t *dst, ptrdiff_t dst_linesize,
48  int w, int h);
49 } TransVtable;
50 
51 typedef struct TransContext {
52  const AVClass *class;
53  int hsub, vsub;
54  int planes;
55  int pixsteps[4];
56 
57  int passthrough; ///< PassthroughType, landscape passthrough mode enabled
58  int dir; ///< TransposeDir
59 
61 } TransContext;
62 
64 {
66  int fmt, ret;
67 
68  for (fmt = 0; av_pix_fmt_desc_get(fmt); fmt++) {
70  if (!(desc->flags & AV_PIX_FMT_FLAG_PAL ||
71  desc->flags & AV_PIX_FMT_FLAG_HWACCEL ||
73  desc->log2_chroma_w != desc->log2_chroma_h) &&
74  (ret = ff_add_format(&pix_fmts, fmt)) < 0)
75  return ret;
76  }
77 
78 
80 }
81 
82 static inline void transpose_block_8_c(uint8_t *src, ptrdiff_t src_linesize,
83  uint8_t *dst, ptrdiff_t dst_linesize,
84  int w, int h)
85 {
86  int x, y;
87  for (y = 0; y < h; y++, dst += dst_linesize, src++)
88  for (x = 0; x < w; x++)
89  dst[x] = src[x*src_linesize];
90 }
91 
92 static void transpose_8x8_8_c(uint8_t *src, ptrdiff_t src_linesize,
93  uint8_t *dst, ptrdiff_t dst_linesize)
94 {
95  transpose_block_8_c(src, src_linesize, dst, dst_linesize, 8, 8);
96 }
97 
98 static inline void transpose_block_16_c(uint8_t *src, ptrdiff_t src_linesize,
99  uint8_t *dst, ptrdiff_t dst_linesize,
100  int w, int h)
101 {
102  int x, y;
103  for (y = 0; y < h; y++, dst += dst_linesize, src += 2)
104  for (x = 0; x < w; x++)
105  *((uint16_t *)(dst + 2*x)) = *((uint16_t *)(src + x*src_linesize));
106 }
107 
108 static void transpose_8x8_16_c(uint8_t *src, ptrdiff_t src_linesize,
109  uint8_t *dst, ptrdiff_t dst_linesize)
110 {
111  transpose_block_16_c(src, src_linesize, dst, dst_linesize, 8, 8);
112 }
113 
114 static inline void transpose_block_24_c(uint8_t *src, ptrdiff_t src_linesize,
115  uint8_t *dst, ptrdiff_t dst_linesize,
116  int w, int h)
117 {
118  int x, y;
119  for (y = 0; y < h; y++, dst += dst_linesize) {
120  for (x = 0; x < w; x++) {
121  int32_t v = AV_RB24(src + x*src_linesize + y*3);
122  AV_WB24(dst + 3*x, v);
123  }
124  }
125 }
126 
127 static void transpose_8x8_24_c(uint8_t *src, ptrdiff_t src_linesize,
128  uint8_t *dst, ptrdiff_t dst_linesize)
129 {
130  transpose_block_24_c(src, src_linesize, dst, dst_linesize, 8, 8);
131 }
132 
133 static inline void transpose_block_32_c(uint8_t *src, ptrdiff_t src_linesize,
134  uint8_t *dst, ptrdiff_t dst_linesize,
135  int w, int h)
136 {
137  int x, y;
138  for (y = 0; y < h; y++, dst += dst_linesize, src += 4) {
139  for (x = 0; x < w; x++)
140  *((uint32_t *)(dst + 4*x)) = *((uint32_t *)(src + x*src_linesize));
141  }
142 }
143 
144 static void transpose_8x8_32_c(uint8_t *src, ptrdiff_t src_linesize,
145  uint8_t *dst, ptrdiff_t dst_linesize)
146 {
147  transpose_block_32_c(src, src_linesize, dst, dst_linesize, 8, 8);
148 }
149 
150 static inline void transpose_block_48_c(uint8_t *src, ptrdiff_t src_linesize,
151  uint8_t *dst, ptrdiff_t dst_linesize,
152  int w, int h)
153 {
154  int x, y;
155  for (y = 0; y < h; y++, dst += dst_linesize, src += 6) {
156  for (x = 0; x < w; x++) {
157  int64_t v = AV_RB48(src + x*src_linesize);
158  AV_WB48(dst + 6*x, v);
159  }
160  }
161 }
162 
163 static void transpose_8x8_48_c(uint8_t *src, ptrdiff_t src_linesize,
164  uint8_t *dst, ptrdiff_t dst_linesize)
165 {
166  transpose_block_48_c(src, src_linesize, dst, dst_linesize, 8, 8);
167 }
168 
169 static inline void transpose_block_64_c(uint8_t *src, ptrdiff_t src_linesize,
170  uint8_t *dst, ptrdiff_t dst_linesize,
171  int w, int h)
172 {
173  int x, y;
174  for (y = 0; y < h; y++, dst += dst_linesize, src += 8)
175  for (x = 0; x < w; x++)
176  *((uint64_t *)(dst + 8*x)) = *((uint64_t *)(src + x*src_linesize));
177 }
178 
179 static void transpose_8x8_64_c(uint8_t *src, ptrdiff_t src_linesize,
180  uint8_t *dst, ptrdiff_t dst_linesize)
181 {
182  transpose_block_64_c(src, src_linesize, dst, dst_linesize, 8, 8);
183 }
184 
185 static int config_props_output(AVFilterLink *outlink)
186 {
187  AVFilterContext *ctx = outlink->src;
188  TransContext *s = ctx->priv;
189  AVFilterLink *inlink = ctx->inputs[0];
190  const AVPixFmtDescriptor *desc_out = av_pix_fmt_desc_get(outlink->format);
191  const AVPixFmtDescriptor *desc_in = av_pix_fmt_desc_get(inlink->format);
192 
193  if (s->dir&4) {
195  "dir values greater than 3 are deprecated, use the passthrough option instead\n");
196  s->dir &= 3;
197  s->passthrough = TRANSPOSE_PT_TYPE_LANDSCAPE;
198  }
199 
200  if ((inlink->w >= inlink->h && s->passthrough == TRANSPOSE_PT_TYPE_LANDSCAPE) ||
201  (inlink->w <= inlink->h && s->passthrough == TRANSPOSE_PT_TYPE_PORTRAIT)) {
203  "w:%d h:%d -> w:%d h:%d (passthrough mode)\n",
204  inlink->w, inlink->h, inlink->w, inlink->h);
205  return 0;
206  } else {
207  s->passthrough = TRANSPOSE_PT_TYPE_NONE;
208  }
209 
210  s->hsub = desc_in->log2_chroma_w;
211  s->vsub = desc_in->log2_chroma_h;
212  s->planes = av_pix_fmt_count_planes(outlink->format);
213 
214  av_assert0(desc_in->nb_components == desc_out->nb_components);
215 
216 
217  av_image_fill_max_pixsteps(s->pixsteps, NULL, desc_out);
218 
219  outlink->w = inlink->h;
220  outlink->h = inlink->w;
221 
222  if (inlink->sample_aspect_ratio.num)
223  outlink->sample_aspect_ratio = av_div_q((AVRational) { 1, 1 },
224  inlink->sample_aspect_ratio);
225  else
226  outlink->sample_aspect_ratio = inlink->sample_aspect_ratio;
227 
228  for (int i = 0; i < 4; i++) {
229  TransVtable *v = &s->vtables[i];
230  switch (s->pixsteps[i]) {
232  v->transpose_8x8 = transpose_8x8_8_c; break;
234  v->transpose_8x8 = transpose_8x8_16_c; break;
236  v->transpose_8x8 = transpose_8x8_24_c; break;
238  v->transpose_8x8 = transpose_8x8_32_c; break;
240  v->transpose_8x8 = transpose_8x8_48_c; break;
242  v->transpose_8x8 = transpose_8x8_64_c; break;
243  }
244  }
245 
247  "w:%d h:%d dir:%d -> w:%d h:%d rotation:%s vflip:%d\n",
248  inlink->w, inlink->h, s->dir, outlink->w, outlink->h,
249  s->dir == 1 || s->dir == 3 ? "clockwise" : "counterclockwise",
250  s->dir == 0 || s->dir == 3);
251  return 0;
252 }
253 
255 {
256  TransContext *s = inlink->dst->priv;
257 
258  return s->passthrough ?
261 }
262 
263 typedef struct ThreadData {
264  AVFrame *in, *out;
265 } ThreadData;
266 
267 static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr,
268  int nb_jobs)
269 {
270  TransContext *s = ctx->priv;
271  ThreadData *td = arg;
272  AVFrame *out = td->out;
273  AVFrame *in = td->in;
274  int plane;
275 
276  for (plane = 0; plane < s->planes; plane++) {
277  int hsub = plane == 1 || plane == 2 ? s->hsub : 0;
278  int vsub = plane == 1 || plane == 2 ? s->vsub : 0;
279  int pixstep = s->pixsteps[plane];
280  int inh = AV_CEIL_RSHIFT(in->height, vsub);
281  int outw = AV_CEIL_RSHIFT(out->width, hsub);
282  int outh = AV_CEIL_RSHIFT(out->height, vsub);
283  int start = (outh * jobnr ) / nb_jobs;
284  int end = (outh * (jobnr+1)) / nb_jobs;
285  uint8_t *dst, *src;
286  int dstlinesize, srclinesize;
287  int x, y;
288  TransVtable *v = &s->vtables[plane];
289 
290  dstlinesize = out->linesize[plane];
291  dst = out->data[plane] + start * dstlinesize;
292  src = in->data[plane];
293  srclinesize = in->linesize[plane];
294 
295  if (s->dir & 1) {
296  src += in->linesize[plane] * (inh - 1);
297  srclinesize *= -1;
298  }
299 
300  if (s->dir & 2) {
301  dst = out->data[plane] + dstlinesize * (outh - start - 1);
302  dstlinesize *= -1;
303  }
304 
305  for (y = start; y < end - 7; y += 8) {
306  for (x = 0; x < outw - 7; x += 8) {
307  v->transpose_8x8(src + x * srclinesize + y * pixstep,
308  srclinesize,
309  dst + (y - start) * dstlinesize + x * pixstep,
310  dstlinesize);
311  }
312  if (outw - x > 0 && end - y > 0)
313  v->transpose_block(src + x * srclinesize + y * pixstep,
314  srclinesize,
315  dst + (y - start) * dstlinesize + x * pixstep,
316  dstlinesize, outw - x, end - y);
317  }
318 
319  if (end - y > 0)
320  v->transpose_block(src + 0 * srclinesize + y * pixstep,
321  srclinesize,
322  dst + (y - start) * dstlinesize + 0 * pixstep,
323  dstlinesize, outw, end - y);
324  }
325 
326  return 0;
327 }
328 
330 {
331  AVFilterContext *ctx = inlink->dst;
332  TransContext *s = ctx->priv;
333  AVFilterLink *outlink = ctx->outputs[0];
334  ThreadData td;
335  AVFrame *out;
336 
337  if (s->passthrough)
338  return ff_filter_frame(outlink, in);
339 
340  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
341  if (!out) {
342  av_frame_free(&in);
343  return AVERROR(ENOMEM);
344  }
346 
347  if (in->sample_aspect_ratio.num == 0) {
348  out->sample_aspect_ratio = in->sample_aspect_ratio;
349  } else {
350  out->sample_aspect_ratio.num = in->sample_aspect_ratio.den;
351  out->sample_aspect_ratio.den = in->sample_aspect_ratio.num;
352  }
353 
354  td.in = in, td.out = out;
355  ctx->internal->execute(ctx, filter_slice, &td, NULL, FFMIN(outlink->h, ff_filter_get_nb_threads(ctx)));
356  av_frame_free(&in);
357  return ff_filter_frame(outlink, out);
358 }
359 
360 #define OFFSET(x) offsetof(TransContext, x)
361 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
362 
363 static const AVOption transpose_options[] = {
364  { "dir", "set transpose direction", OFFSET(dir), AV_OPT_TYPE_INT, { .i64 = TRANSPOSE_CCLOCK_FLIP }, 0, 7, FLAGS, "dir" },
365  { "cclock_flip", "rotate counter-clockwise with vertical flip", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK_FLIP }, .flags=FLAGS, .unit = "dir" },
366  { "clock", "rotate clockwise", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK }, .flags=FLAGS, .unit = "dir" },
367  { "cclock", "rotate counter-clockwise", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CCLOCK }, .flags=FLAGS, .unit = "dir" },
368  { "clock_flip", "rotate clockwise with vertical flip", 0, AV_OPT_TYPE_CONST, { .i64 = TRANSPOSE_CLOCK_FLIP }, .flags=FLAGS, .unit = "dir" },
369 
370  { "passthrough", "do not apply transposition if the input matches the specified geometry",
371  OFFSET(passthrough), AV_OPT_TYPE_INT, {.i64=TRANSPOSE_PT_TYPE_NONE}, 0, INT_MAX, FLAGS, "passthrough" },
372  { "none", "always apply transposition", 0, AV_OPT_TYPE_CONST, {.i64=TRANSPOSE_PT_TYPE_NONE}, INT_MIN, INT_MAX, FLAGS, "passthrough" },
373  { "portrait", "preserve portrait geometry", 0, AV_OPT_TYPE_CONST, {.i64=TRANSPOSE_PT_TYPE_PORTRAIT}, INT_MIN, INT_MAX, FLAGS, "passthrough" },
374  { "landscape", "preserve landscape geometry", 0, AV_OPT_TYPE_CONST, {.i64=TRANSPOSE_PT_TYPE_LANDSCAPE}, INT_MIN, INT_MAX, FLAGS, "passthrough" },
375 
376  { NULL }
377 };
378 
380 
382  {
383  .name = "default",
384  .type = AVMEDIA_TYPE_VIDEO,
385  .get_video_buffer = get_video_buffer,
386  .filter_frame = filter_frame,
387  },
388  { NULL }
389 };
390 
392  {
393  .name = "default",
394  .config_props = config_props_output,
395  .type = AVMEDIA_TYPE_VIDEO,
396  },
397  { NULL }
398 };
399 
401  .name = "transpose",
402  .description = NULL_IF_CONFIG_SMALL("Transpose input video."),
403  .priv_size = sizeof(TransContext),
404  .priv_class = &transpose_class,
409 };
ff_get_video_buffer
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:99
transpose_8x8_24_c
static void transpose_8x8_24_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize)
Definition: vf_transpose.c:127
transpose_8x8_16_c
static void transpose_8x8_16_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize)
Definition: vf_transpose.c:108
AV_LOG_WARNING
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
td
#define td
Definition: regdef.h:70
TransVtable::transpose_block
void(* transpose_block)(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize, int w, int h)
Definition: vf_transpose.c:46
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
AV_RB48
#define AV_RB48(x)
Definition: intreadwrite.h:472
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(transpose)
out
FILE * out
Definition: movenc.c:54
avfilter_vf_transpose_outputs
static const AVFilterPad avfilter_vf_transpose_outputs[]
Definition: vf_transpose.c:391
TransContext::planes
int planes
Definition: vf_transpose.c:54
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1080
TransContext
Definition: vf_transpose.c:51
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2522
av_div_q
AVRational av_div_q(AVRational b, AVRational c)
Divide one rational by another.
Definition: rational.c:88
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:202
end
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:295
pixdesc.h
w
uint8_t w
Definition: llviddspenc.c:38
transpose_8x8_32_c
static void transpose_8x8_32_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize)
Definition: vf_transpose.c:144
AVOption
AVOption.
Definition: opt.h:246
transpose_block_32_c
static void transpose_block_32_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize, int w, int h)
Definition: vf_transpose.c:133
TransContext::pixsteps
int pixsteps[4]
Definition: vf_transpose.c:55
AV_LOG_VERBOSE
#define AV_LOG_VERBOSE
Detailed information.
Definition: log.h:192
TransContext::dir
int dir
TransposeDir.
Definition: vf_transpose.c:58
TRANSPOSE_CLOCK_FLIP
@ TRANSPOSE_CLOCK_FLIP
Definition: transpose.h:31
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:148
ThreadData::out
AVFrame * out
Definition: af_adeclick.c:488
video.h
AVFormatContext::internal
AVFormatInternal * internal
An opaque field for libavformat internal usage.
Definition: avformat.h:1795
transpose_block_24_c
static void transpose_block_24_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize, int w, int h)
Definition: vf_transpose.c:114
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
formats.h
transpose_block_48_c
static void transpose_block_48_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize, int w, int h)
Definition: vf_transpose.c:150
TRANSPOSE_CCLOCK
@ TRANSPOSE_CCLOCK
Definition: transpose.h:30
ff_default_get_video_buffer
AVFrame * ff_default_get_video_buffer(AVFilterLink *link, int w, int h)
Definition: video.c:44
ff_vf_transpose
AVFilter ff_vf_transpose
Definition: vf_transpose.c:400
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2562
fmt
const char * fmt
Definition: avisynth_c.h:861
start
void INT64 start
Definition: avisynth_c.h:767
AV_PIX_FMT_FLAG_HWACCEL
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
Definition: pixdesc.h:140
plane
int plane
Definition: avisynth_c.h:384
TransContext::vsub
int vsub
Definition: vf_transpose.c:53
src
#define src
Definition: vp8dsp.c:254
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:54
transpose_8x8_48_c
static void transpose_8x8_48_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize)
Definition: vf_transpose.c:163
avassert.h
TransVtable
Definition: vf_transpose.c:43
ff_set_common_formats
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:568
transpose_block_16_c
static void transpose_block_16_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize, int w, int h)
Definition: vf_transpose.c:98
intreadwrite.h
s
#define s(width, name)
Definition: cbs_vp9.c:257
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_transpose.c:63
av_assert0
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:275
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AVPixFmtDescriptor::log2_chroma_w
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:92
int32_t
int32_t
Definition: audio_convert.c:194
arg
const char * arg
Definition: jacosubdec.c:66
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
NULL
#define NULL
Definition: coverity.c:32
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:654
AVPixFmtDescriptor::nb_components
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:83
AVRational
Rational number (pair of numerator and denominator).
Definition: rational.h:58
transpose_block_64_c
static void transpose_block_64_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize, int w, int h)
Definition: vf_transpose.c:169
ff_add_format
int ff_add_format(AVFilterFormats **avff, int64_t fmt)
Add fmt to the list of media formats contained in *avff.
Definition: formats.c:337
FLAGS
#define FLAGS
Definition: vf_transpose.c:361
TransContext::vtables
TransVtable vtables[4]
Definition: vf_transpose.c:60
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
transpose_options
static const AVOption transpose_options[]
Definition: vf_transpose.c:363
TRANSPOSE_PT_TYPE_PORTRAIT
@ TRANSPOSE_PT_TYPE_PORTRAIT
Definition: transpose.h:24
desc
const char * desc
Definition: nvenc.c:68
transpose_8x8_64_c
static void transpose_8x8_64_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize)
Definition: vf_transpose.c:179
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:188
TRANSPOSE_PT_TYPE_NONE
@ TRANSPOSE_PT_TYPE_NONE
Definition: transpose.h:22
transpose_block_8_c
static void transpose_block_8_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize, int w, int h)
Definition: vf_transpose.c:82
AV_PIX_FMT_FLAG_BITSTREAM
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
Definition: pixdesc.h:136
AV_WB24
#define AV_WB24(p, d)
Definition: intreadwrite.h:450
FFMIN
#define FFMIN(a, b)
Definition: common.h:96
ff_null_get_video_buffer
AVFrame * ff_null_get_video_buffer(AVFilterLink *link, int w, int h)
Definition: video.c:39
internal.h
in
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(const uint8_t *) pi - 0x80) *(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(const int16_t *) pi >> 8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t, *(const int16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(const int32_t *) pi >> 24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t, *(const int32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(const float *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(const float *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(const float *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(const double *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(const double *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(const double *) pi *(1U<< 31)))) #define SET_CONV_FUNC_GROUP(ofmt, ifmt) static void set_generic_function(AudioConvert *ac) { } void ff_audio_convert_free(AudioConvert **ac) { if(! *ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);} AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enum AVSampleFormat out_fmt, enum AVSampleFormat in_fmt, int channels, int sample_rate, int apply_map) { AudioConvert *ac;int in_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) return NULL;ac->avr=avr;ac->out_fmt=out_fmt;ac->in_fmt=in_fmt;ac->channels=channels;ac->apply_map=apply_map;if(avr->dither_method !=AV_RESAMPLE_DITHER_NONE &&av_get_packed_sample_fmt(out_fmt)==AV_SAMPLE_FMT_S16 &&av_get_bytes_per_sample(in_fmt) > 2) { ac->dc=ff_dither_alloc(avr, out_fmt, in_fmt, channels, sample_rate, apply_map);if(!ac->dc) { av_free(ac);return NULL;} return ac;} in_planar=ff_sample_fmt_is_planar(in_fmt, channels);out_planar=ff_sample_fmt_is_planar(out_fmt, channels);if(in_planar==out_planar) { ac->func_type=CONV_FUNC_TYPE_FLAT;ac->planes=in_planar ? ac->channels :1;} else if(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;else ac->func_type=CONV_FUNC_TYPE_DEINTERLEAVE;set_generic_function(ac);if(ARCH_AARCH64) ff_audio_convert_init_aarch64(ac);if(ARCH_ARM) ff_audio_convert_init_arm(ac);if(ARCH_X86) ff_audio_convert_init_x86(ac);return ac;} int ff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in) { int use_generic=1;int len=in->nb_samples;int p;if(ac->dc) { av_log(ac->avr, AV_LOG_TRACE, "%d samples - audio_convert: %s to %s (dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));return ff_convert_dither(ac-> in
Definition: audio_convert.c:326
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
internal.h
ff_filter_get_nb_threads
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:802
ThreadData
Used for passing data between threads.
Definition: af_adeclick.c:487
uint8_t
uint8_t
Definition: audio_convert.c:194
TRANSPOSE_CLOCK
@ TRANSPOSE_CLOCK
Definition: transpose.h:29
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:60
AV_WB48
#define AV_WB48(p, darg)
Definition: intreadwrite.h:481
filter_slice
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_transpose.c:267
TransContext::hsub
int hsub
Definition: vf_transpose.c:53
AVFilter
Filter definition.
Definition: avfilter.h:144
ret
ret
Definition: filter_design.txt:187
get_video_buffer
static AVFrame * get_video_buffer(AVFilterLink *inlink, int w, int h)
Definition: vf_transpose.c:254
TRANSPOSE_CCLOCK_FLIP
@ TRANSPOSE_CCLOCK_FLIP
Definition: transpose.h:28
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:223
avfilter.h
OFFSET
#define OFFSET(x)
Definition: vf_transpose.c:360
avfilter_vf_transpose_inputs
static const AVFilterPad avfilter_vf_transpose_inputs[]
Definition: vf_transpose.c:381
transpose.h
av_image_fill_max_pixsteps
void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], const AVPixFmtDescriptor *pixdesc)
Compute the max pixel step for each plane of an image with a format described by pixdesc.
Definition: imgutils.c:35
AVFilterContext
An instance of a filter.
Definition: avfilter.h:338
TRANSPOSE_PT_TYPE_LANDSCAPE
@ TRANSPOSE_PT_TYPE_LANDSCAPE
Definition: transpose.h:23
AVFILTER_FLAG_SLICE_THREADS
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:116
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
ThreadData::in
AVFrame * in
Definition: af_afftdn.c:1082
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
imgutils.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:565
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
config_props_output
static int config_props_output(AVFilterLink *outlink)
Definition: vf_transpose.c:185
h
h
Definition: vp9dsp_template.c:2038
transpose
#define transpose(x)
TransContext::passthrough
int passthrough
PassthroughType, landscape passthrough mode enabled.
Definition: vf_transpose.c:57
AV_RB24
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_WB32 unsigned int_TMPL AV_RB24
Definition: bytestream.h:93
AV_PIX_FMT_FLAG_PAL
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
Definition: pixdesc.h:132
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:232
TransVtable::transpose_8x8
void(* transpose_8x8)(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize)
Definition: vf_transpose.c:44
transpose_8x8_8_c
static void transpose_8x8_8_c(uint8_t *src, ptrdiff_t src_linesize, uint8_t *dst, ptrdiff_t dst_linesize)
Definition: vf_transpose.c:92
AVPixFmtDescriptor::log2_chroma_h
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:101
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_transpose.c:329