FFmpeg
vf_shufflepixels.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2020 Paul B Mahol
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/avstring.h"
23 #include "libavutil/common.h"
24 #include "libavutil/internal.h"
25 #include "libavutil/imgutils.h"
26 #include "libavutil/lfg.h"
27 #include "libavutil/opt.h"
28 #include "libavutil/pixdesc.h"
29 #include "libavutil/random_seed.h"
30 
31 #include "avfilter.h"
32 #include "internal.h"
33 #include "video.h"
34 
35 typedef struct ShufflePixelsContext {
36  const AVClass *class;
37 
39  int mode;
40  int direction;
41  int64_t seed;
42 
43  int depth;
44  int nb_planes;
45  int linesize[4];
46  int planewidth[4];
47  int planeheight[4];
48 
49  int nb_blocks;
50 
53 
55 
56  int (*shuffle_pixels)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
58 
60 {
61  static const enum AVPixelFormat pix_fmts[] = {
70  };
72  if (!fmts_list)
73  return AVERROR(ENOMEM);
74  return ff_set_common_formats(ctx, fmts_list);
75 }
76 
78 {
79  ShufflePixelsContext *s = ctx->priv;
80  const int nb_blocks = s->nb_blocks;
81  AVLFG *c = &s->c;
82  uint8_t *used = s->used;
83  int32_t *map = s->map;
84 
85  for (int x = 0; x < s->planewidth[0];) {
86  int rand = av_lfg_get(c) % nb_blocks;
87 
88  if (used[rand] == 0) {
89  int width;
90 
91  if (s->direction) {
92  width = FFMIN(s->block_w, s->planewidth[0] - x);
93  map[rand * s->block_w] = x;
94  } else {
95  width = FFMIN(s->block_w, s->planewidth[0] - rand * s->block_w);
96  map[x] = rand * s->block_w;
97  }
98  used[rand] = 1;
99 
100  if (s->direction) {
101  for (int i = 1; i < width; i++) {
102  map[rand * s->block_w + i] = map[rand * s->block_w] + i;
103  }
104  } else {
105  for (int i = 1; i < width; i++) {
106  map[x + i] = map[x] + i;
107  }
108  }
109 
110  x += width;
111  }
112  }
113 }
114 
116 {
117  ShufflePixelsContext *s = ctx->priv;
118  const int nb_blocks = s->nb_blocks;
119  AVLFG *c = &s->c;
120  uint8_t *used = s->used;
121  int32_t *map = s->map;
122 
123  for (int y = 0; y < s->planeheight[0];) {
124  int rand = av_lfg_get(c) % nb_blocks;
125 
126  if (used[rand] == 0) {
127  int height;
128 
129  if (s->direction) {
130  height = FFMIN(s->block_h, s->planeheight[0] - y);
131  map[rand * s->block_h] = y;
132  } else {
133  height = FFMIN(s->block_h, s->planeheight[0] - rand * s->block_h);
134  map[y] = rand * s->block_h;
135  }
136  used[rand] = 1;
137 
138  if (s->direction) {
139  for (int i = 1; i < height; i++) {
140  map[rand * s->block_h + i] = map[rand * s->block_h] + i;
141  }
142  } else {
143  for (int i = 1; i < height; i++) {
144  map[y + i] = map[y] + i;
145  }
146  }
147 
148  y += height;
149  }
150  }
151 }
152 
154 {
155  ShufflePixelsContext *s = ctx->priv;
156  const int nb_blocks = s->nb_blocks;
157  int nb_blocks_w = s->planewidth[0] / s->block_w;
158  AVLFG *c = &s->c;
159  uint8_t *used = s->used;
160  int32_t *map = s->map;
161 
162  for (int i = 0; i < nb_blocks;) {
163  int rand = av_lfg_get(c) % nb_blocks;
164 
165  if (used[rand] == 0) {
166  int yin = i / nb_blocks_w;
167  int xin = i % nb_blocks_w;
168  int in = yin * s->block_h * s->planewidth[0] + xin * s->block_w;
169  int yout = rand / nb_blocks_w;
170  int xout = rand % nb_blocks_w;
171  int out = yout * s->block_h * s->planewidth[0] + xout * s->block_w;
172 
173  if (s->direction) {
174  map[out] = in;
175  } else {
176  map[in] = out;
177  }
178  used[rand] = 1;
179 
180  if (s->direction) {
181  for (int y = 0; y < s->block_h; y++) {
182  for (int x = 0; x < s->block_w; x++) {
183  map[out + y * s->planewidth[0] + x] = map[out] + x + y * s->planewidth[0];
184  }
185  }
186  } else {
187  for (int y = 0; y < s->block_h; y++) {
188  for (int x = 0; x < s->block_w; x++) {
189  map[in + y * s->planewidth[0] + x] = map[in] + x + y * s->planewidth[0];
190  }
191  }
192  }
193 
194  i++;
195  }
196  }
197 }
198 
199 typedef struct ThreadData {
200  AVFrame *in, *out;
201 } ThreadData;
202 
203 
204 #define SHUFFLE_HORIZONTAL(name, type) \
205 static int shuffle_horizontal## name(AVFilterContext *ctx, void *arg, \
206  int jobnr, int nb_jobs) \
207 { \
208  ShufflePixelsContext *s = ctx->priv; \
209  ThreadData *td = arg; \
210  AVFrame *in = td->in; \
211  AVFrame *out = td->out; \
212  \
213  for (int p = 0; p < s->nb_planes; p++) { \
214  const int slice_start = (s->planeheight[p] * jobnr) / nb_jobs; \
215  const int slice_end = (s->planeheight[p] * (jobnr+1)) / nb_jobs; \
216  type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
217  const type *src = (const type *)(in->data[p] + \
218  slice_start * in->linesize[p]); \
219  const int32_t *map = s->map; \
220  \
221  for (int y = slice_start; y < slice_end; y++) { \
222  for (int x = 0; x < s->planewidth[p]; x++) { \
223  dst[x] = src[map[x]]; \
224  } \
225  \
226  dst += out->linesize[p] / sizeof(type); \
227  src += in->linesize[p] / sizeof(type); \
228  } \
229  } \
230  \
231  return 0; \
232 }
233 
235 SHUFFLE_HORIZONTAL(16, uint16_t)
236 
237 #define SHUFFLE_VERTICAL(name, type) \
238 static int shuffle_vertical## name(AVFilterContext *ctx, void *arg, \
239  int jobnr, int nb_jobs) \
240 { \
241  ShufflePixelsContext *s = ctx->priv; \
242  ThreadData *td = arg; \
243  AVFrame *in = td->in; \
244  AVFrame *out = td->out; \
245  \
246  for (int p = 0; p < s->nb_planes; p++) { \
247  const int slice_start = (s->planeheight[p] * jobnr) / nb_jobs; \
248  const int slice_end = (s->planeheight[p] * (jobnr+1)) / nb_jobs; \
249  type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
250  const int32_t *map = s->map; \
251  \
252  for (int y = slice_start; y < slice_end; y++) { \
253  const type *src = (const type *)(in->data[p] + \
254  map[y] * in->linesize[p]); \
255  \
256  memcpy(dst, src, s->linesize[p]); \
257  dst += out->linesize[p] / sizeof(type); \
258  } \
259  } \
260  \
261  return 0; \
262 }
263 
265 SHUFFLE_VERTICAL(16, uint16_t)
266 
267 #define SHUFFLE_BLOCK(name, type) \
268 static int shuffle_block## name(AVFilterContext *ctx, void *arg, \
269  int jobnr, int nb_jobs) \
270 { \
271  ShufflePixelsContext *s = ctx->priv; \
272  ThreadData *td = arg; \
273  AVFrame *in = td->in; \
274  AVFrame *out = td->out; \
275  \
276  for (int p = 0; p < s->nb_planes; p++) { \
277  const int slice_start = (s->planeheight[p] * jobnr) / nb_jobs; \
278  const int slice_end = (s->planeheight[p] * (jobnr+1)) / nb_jobs; \
279  type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
280  const type *src = (const type *)in->data[p]; \
281  const int32_t *map = s->map + slice_start * s->planewidth[p]; \
282  \
283  for (int y = slice_start; y < slice_end; y++) { \
284  for (int x = 0; x < s->planewidth[p]; x++) { \
285  int ymap = map[x] / s->planewidth[p]; \
286  int xmap = map[x] % s->planewidth[p]; \
287  \
288  dst[x] = src[xmap + ymap * in->linesize[p] / sizeof(type)]; \
289  } \
290  \
291  dst += out->linesize[p] / sizeof(type); \
292  map += s->planewidth[p]; \
293  } \
294  } \
295  \
296  return 0; \
297 }
298 
300 SHUFFLE_BLOCK(16, uint16_t)
301 
302 static int config_output(AVFilterLink *outlink)
303 {
304  AVFilterContext *ctx = outlink->src;
305  ShufflePixelsContext *s = ctx->priv;
306  AVFilterLink *inlink = ctx->inputs[0];
307  const AVPixFmtDescriptor *desc;
308  int ret;
309 
310  if (s->seed == -1)
311  s->seed = av_get_random_seed();
312  av_lfg_init(&s->c, s->seed);
313 
314  desc = av_pix_fmt_desc_get(outlink->format);
315  if (!desc)
316  return AVERROR_BUG;
317  s->nb_planes = av_pix_fmt_count_planes(outlink->format);
318  s->depth = desc->comp[0].depth;
319 
320  if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
321  return ret;
322 
323  s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
324  s->planewidth[0] = s->planewidth[3] = inlink->w;
325 
326  s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
327  s->planeheight[0] = s->planeheight[3] = inlink->h;
328 
329  s->map = av_calloc(inlink->w * inlink->h, sizeof(*s->map));
330  if (!s->map)
331  return AVERROR(ENOMEM);
332 
333  switch (s->mode) {
334  case 0:
335  s->shuffle_pixels = s->depth <= 8 ? shuffle_horizontal8 : shuffle_horizontal16;
336  s->nb_blocks = (s->planewidth[0] + s->block_w - 1) / s->block_w;
337  break;
338  case 1:
339  s->shuffle_pixels = s->depth <= 8 ? shuffle_vertical8 : shuffle_vertical16;
340  s->nb_blocks = (s->planeheight[0] + s->block_h - 1) / s->block_h;
341  break;
342  case 2:
343  s->shuffle_pixels = s->depth <= 8 ? shuffle_block8 : shuffle_block16;
344  s->nb_blocks = (s->planeheight[0] / s->block_h) *
345  (s->planewidth[0] / s->block_w);
346  break;
347  default:
348  av_assert0(0);
349  }
350 
351  s->used = av_calloc(s->nb_blocks, sizeof(*s->used));
352  if (!s->used)
353  return AVERROR(ENOMEM);
354 
355  switch (s->mode) {
356  case 0:
358  break;
359  case 1:
361  break;
362  case 2:
364  break;
365  default:
366  av_assert0(0);
367  }
368 
369  return 0;
370 }
371 
373 {
374  AVFilterContext *ctx = inlink->dst;
375  ShufflePixelsContext *s = ctx->priv;
376  AVFrame *out = ff_get_video_buffer(ctx->outputs[0], in->width, in->height);
377  ThreadData td;
378  int ret;
379 
381  if (ret < 0) {
382  av_frame_free(&out);
383  goto fail;
384  }
385 
386  td.out = out;
387  td.in = in;
388  ctx->internal->execute(ctx, s->shuffle_pixels, &td, NULL, FFMIN(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
389 
390  av_frame_free(&in);
391  return ff_filter_frame(ctx->outputs[0], out);
392 fail:
393  av_frame_free(&in);
394  return ret;
395 }
396 
398 {
399  ShufflePixelsContext *s = ctx->priv;
400 
401  av_freep(&s->map);
402  av_freep(&s->used);
403 }
404 
405 #define OFFSET(x) offsetof(ShufflePixelsContext, x)
406 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
407 static const AVOption shufflepixels_options[] = {
408  { "direction", "set shuffle direction", OFFSET(direction), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "dir" },
409  { "d", "set shuffle direction", OFFSET(direction), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "dir" },
410  { "forward", 0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "dir" },
411  { "inverse", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "dir" },
412  { "mode", "set shuffle mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, FLAGS, "mode" },
413  { "m", "set shuffle mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, FLAGS, "mode" },
414  { "horizontal", 0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "mode" },
415  { "vertical", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "mode" },
416  { "block", 0, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "mode" },
417  { "width", "set block width", OFFSET(block_w), AV_OPT_TYPE_INT, {.i64=10}, 1, 8000, FLAGS },
418  { "w", "set block width", OFFSET(block_w), AV_OPT_TYPE_INT, {.i64=10}, 1, 8000, FLAGS },
419  { "height", "set block height", OFFSET(block_h), AV_OPT_TYPE_INT, {.i64=10}, 1, 8000, FLAGS },
420  { "h", "set block height", OFFSET(block_h), AV_OPT_TYPE_INT, {.i64=10}, 1, 8000, FLAGS },
421  { "seed", "set random seed", OFFSET(seed), AV_OPT_TYPE_INT64, {.i64=-1}, -1, UINT_MAX, FLAGS },
422  { "s", "set random seed", OFFSET(seed), AV_OPT_TYPE_INT64, {.i64=-1}, -1, UINT_MAX, FLAGS },
423  { NULL },
424 };
425 
426 AVFILTER_DEFINE_CLASS(shufflepixels);
427 
429  {
430  .name = "default",
431  .type = AVMEDIA_TYPE_VIDEO,
432  .filter_frame = filter_frame,
433  },
434  { NULL },
435 };
436 
438  {
439  .name = "default",
440  .type = AVMEDIA_TYPE_VIDEO,
441  .config_props = config_output,
442  },
443  { NULL },
444 };
445 
447  .name = "shufflepixels",
448  .description = NULL_IF_CONFIG_SMALL("Shuffle video pixels."),
449  .priv_size = sizeof(ShufflePixelsContext),
450  .priv_class = &shufflepixels_class,
452  .uninit = uninit,
456 };
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
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(shufflepixels)
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:421
td
#define td
Definition: regdef.h:70
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
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
ff_make_format_list
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:286
out
FILE * out
Definition: movenc.c:54
av_lfg_init
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
Definition: lfg.c:32
SHUFFLE_BLOCK
#define SHUFFLE_BLOCK(name, type)
Definition: vf_shufflepixels.c:267
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1096
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2573
ShufflePixelsContext::depth
int depth
Definition: vf_shufflepixels.c:43
ShufflePixelsContext::used
uint8_t * used
Definition: vf_shufflepixels.c:51
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
FLAGS
#define FLAGS
Definition: vf_shufflepixels.c:406
SHUFFLE_HORIZONTAL
#define SHUFFLE_HORIZONTAL(name, type)
Definition: vf_shufflepixels.c:204
av_frame_free
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:203
make_horizontal_map
static void make_horizontal_map(AVFilterContext *ctx)
Definition: vf_shufflepixels.c:77
shufflepixels_inputs
static const AVFilterPad shufflepixels_inputs[]
Definition: vf_shufflepixels.c:428
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
pixdesc.h
AVOption
AVOption.
Definition: opt.h:248
ff_vf_shufflepixels
AVFilter ff_vf_shufflepixels
Definition: vf_shufflepixels.c:446
ShufflePixelsContext::nb_blocks
int nb_blocks
Definition: vf_shufflepixels.c:49
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:149
ThreadData::out
AVFrame * out
Definition: af_adeclick.c:502
ShufflePixelsContext::planeheight
int planeheight[4]
Definition: vf_shufflepixels.c:47
video.h
AVFormatContext::internal
AVFormatInternal * internal
An opaque field for libavformat internal usage.
Definition: avformat.h:1699
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:379
av_get_random_seed
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
Definition: random_seed.c:120
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:65
ShufflePixelsContext::block_w
int block_w
Definition: vf_shufflepixels.c:38
av_pix_fmt_count_planes
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2613
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:417
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:215
OFFSET
#define OFFSET(x)
Definition: vf_shufflepixels.c:405
ShufflePixelsContext::mode
int mode
Definition: vf_shufflepixels.c:39
fail
#define fail()
Definition: checkasm.h:133
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:415
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:443
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:383
shufflepixels_options
static const AVOption shufflepixels_options[]
Definition: vf_shufflepixels.c:407
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:54
shufflepixels_outputs
static const AVFilterPad shufflepixels_outputs[]
Definition: vf_shufflepixels.c:437
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:402
avassert.h
av_cold
#define av_cold
Definition: attributes.h:90
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:587
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:419
width
#define width
av_image_fill_linesizes
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
Definition: imgutils.c:89
s
#define s(width, name)
Definition: cbs_vp9.c:257
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:420
av_lfg_get
static unsigned int av_lfg_get(AVLFG *c)
Get the next random unsigned 32-bit number using an ALFG.
Definition: lfg.h:53
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:412
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
lfg.h
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_shufflepixels.c:59
AV_OPT_TYPE_INT64
@ AV_OPT_TYPE_INT64
Definition: opt.h:226
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:309
ctx
AVFormatContext * ctx
Definition: movenc.c:48
make_vertical_map
static void make_vertical_map(AVFilterContext *ctx)
Definition: vf_shufflepixels.c:115
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:382
int32_t
int32_t
Definition: audio_convert.c:194
arg
const char * arg
Definition: jacosubdec.c:66
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:380
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:418
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:658
ShufflePixelsContext::block_h
int block_h
Definition: vf_shufflepixels.c:38
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
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:414
seed
static unsigned int seed
Definition: videogen.c:78
c
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
Definition: undefined.txt:32
AVLFG
Context structure for the Lagged Fibonacci PRNG.
Definition: lfg.h:33
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
ShufflePixelsContext::map
int32_t * map
Definition: vf_shufflepixels.c:52
ShufflePixelsContext::nb_planes
int nb_planes
Definition: vf_shufflepixels.c:44
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:406
ShufflePixelsContext
Definition: vf_shufflepixels.c:35
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_shufflepixels.c:397
height
#define height
FFMIN
#define FFMIN(a, b)
Definition: common.h:105
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:177
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:438
internal.h
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition: avfilter.h:126
ShufflePixelsContext::c
AVLFG c
Definition: vf_shufflepixels.c:54
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
int i
Definition: input.c:407
internal.h
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:416
common.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
ShufflePixelsContext::linesize
int linesize[4]
Definition: vf_shufflepixels.c:45
ThreadData
Used for passing data between threads.
Definition: dsddec.c:67
uint8_t
uint8_t
Definition: audio_convert.c:194
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:60
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:398
ShufflePixelsContext::planewidth
int planewidth[4]
Definition: vf_shufflepixels.c:46
AVFilter
Filter definition.
Definition: avfilter.h:145
ret
ret
Definition: filter_design.txt:187
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:435
random_seed.h
av_calloc
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
Definition: mem.c:245
mode
mode
Definition: ebur128.h:83
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
avfilter.h
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_shufflepixels.c:302
ShufflePixelsContext::shuffle_pixels
int(* shuffle_pixels)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_shufflepixels.c:56
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
AVFilterContext
An instance of a filter.
Definition: avfilter.h:341
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:168
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:117
desc
const char * desc
Definition: libsvtav1.c:79
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
ThreadData::in
AVFrame * in
Definition: af_adenorm.c:223
ShufflePixelsContext::seed
int64_t seed
Definition: vf_shufflepixels.c:41
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
map
const VDPAUPixFmtMap * map
Definition: hwcontext_vdpau.c:71
av_freep
#define av_freep(p)
Definition: tableprint_vlc.h:35
imgutils.h
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
ShufflePixelsContext::direction
int direction
Definition: vf_shufflepixels.c:40
AVERROR_BUG
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:50
SHUFFLE_VERTICAL
#define SHUFFLE_VERTICAL(name, type)
Definition: vf_shufflepixels.c:237
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_shufflepixels.c:372
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:409
avstring.h
make_block_map
static void make_block_map(AVFilterContext *ctx)
Definition: vf_shufflepixels.c:153
int
int
Definition: ffmpeg_filter.c:170
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234