FFmpeg  4.4.8
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 "filters.h"
33 #include "internal.h"
34 #include "video.h"
35 
36 typedef struct ShufflePixelsContext {
37  const AVClass *class;
38 
40  int mode;
41  int direction;
43 
44  int depth;
45  int nb_planes;
46  int linesize[4];
47  int planewidth[4];
48  int planeheight[4];
49 
50  int nb_blocks;
51 
54 
56 
57  int (*shuffle_pixels)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs);
59 
61 {
62  static const enum AVPixelFormat pix_fmts[] = {
71  };
73  if (!fmts_list)
74  return AVERROR(ENOMEM);
75  return ff_set_common_formats(ctx, fmts_list);
76 }
77 
79 {
80  ShufflePixelsContext *s = ctx->priv;
81  const int nb_blocks = s->nb_blocks;
82  AVLFG *c = &s->c;
83  uint8_t *used = s->used;
84  int32_t *map = s->map;
85 
86  for (int x = 0; x < s->planewidth[0];) {
87  int rand = av_lfg_get(c) % nb_blocks;
88 
89  if (used[rand] == 0) {
90  int width;
91 
92  if (s->direction) {
93  width = FFMIN(s->block_w, s->planewidth[0] - x);
94  map[rand * s->block_w] = x;
95  } else {
96  width = FFMIN(s->block_w, s->planewidth[0] - rand * s->block_w);
97  map[x] = rand * s->block_w;
98  }
99  used[rand] = 1;
100 
101  if (s->direction) {
102  for (int i = 1; i < width; i++) {
103  map[rand * s->block_w + i] = map[rand * s->block_w] + i;
104  }
105  } else {
106  for (int i = 1; i < width; i++) {
107  map[x + i] = map[x] + i;
108  }
109  }
110 
111  x += width;
112  }
113  }
114 }
115 
117 {
118  ShufflePixelsContext *s = ctx->priv;
119  const int nb_blocks = s->nb_blocks;
120  AVLFG *c = &s->c;
121  uint8_t *used = s->used;
122  int32_t *map = s->map;
123 
124  for (int y = 0; y < s->planeheight[0];) {
125  int rand = av_lfg_get(c) % nb_blocks;
126 
127  if (used[rand] == 0) {
128  int height;
129 
130  if (s->direction) {
131  height = FFMIN(s->block_h, s->planeheight[0] - y);
132  map[rand * s->block_h] = y;
133  } else {
134  height = FFMIN(s->block_h, s->planeheight[0] - rand * s->block_h);
135  map[y] = rand * s->block_h;
136  }
137  used[rand] = 1;
138 
139  if (s->direction) {
140  for (int i = 1; i < height; i++) {
141  map[rand * s->block_h + i] = map[rand * s->block_h] + i;
142  }
143  } else {
144  for (int i = 1; i < height; i++) {
145  map[y + i] = map[y] + i;
146  }
147  }
148 
149  y += height;
150  }
151  }
152 }
153 
155 {
156  ShufflePixelsContext *s = ctx->priv;
157  const int nb_blocks = s->nb_blocks;
158  int nb_blocks_w = s->planewidth[0] / s->block_w;
159  AVLFG *c = &s->c;
160  uint8_t *used = s->used;
161  int32_t *map = s->map;
162 
163  for (int i = 0; i < nb_blocks;) {
164  int rand = av_lfg_get(c) % nb_blocks;
165 
166  if (used[rand] == 0) {
167  int yin = i / nb_blocks_w;
168  int xin = i % nb_blocks_w;
169  int in = yin * s->block_h * s->planewidth[0] + xin * s->block_w;
170  int yout = rand / nb_blocks_w;
171  int xout = rand % nb_blocks_w;
172  int out = yout * s->block_h * s->planewidth[0] + xout * s->block_w;
173 
174  if (s->direction) {
175  map[out] = in;
176  } else {
177  map[in] = out;
178  }
179  used[rand] = 1;
180 
181  if (s->direction) {
182  for (int y = 0; y < s->block_h; y++) {
183  for (int x = 0; x < s->block_w; x++) {
184  map[out + y * s->planewidth[0] + x] = map[out] + x + y * s->planewidth[0];
185  }
186  }
187  } else {
188  for (int y = 0; y < s->block_h; y++) {
189  for (int x = 0; x < s->block_w; x++) {
190  map[in + y * s->planewidth[0] + x] = map[in] + x + y * s->planewidth[0];
191  }
192  }
193  }
194 
195  i++;
196  }
197  }
198 }
199 
200 typedef struct ThreadData {
201  AVFrame *in, *out;
202 } ThreadData;
203 
204 
205 #define SHUFFLE_HORIZONTAL(name, type) \
206 static int shuffle_horizontal## name(AVFilterContext *ctx, void *arg, \
207  int jobnr, int nb_jobs) \
208 { \
209  ShufflePixelsContext *s = ctx->priv; \
210  ThreadData *td = arg; \
211  AVFrame *in = td->in; \
212  AVFrame *out = td->out; \
213  \
214  for (int p = 0; p < s->nb_planes; p++) { \
215  const int slice_start = ff_slice_pos(s->planeheight[p], jobnr, nb_jobs); \
216  const int slice_end = ff_slice_pos(s->planeheight[p], jobnr + 1, nb_jobs); \
217  type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
218  const type *src = (const type *)(in->data[p] + \
219  slice_start * in->linesize[p]); \
220  const int32_t *map = s->map; \
221  \
222  for (int y = slice_start; y < slice_end; y++) { \
223  for (int x = 0; x < s->planewidth[p]; x++) { \
224  dst[x] = src[map[x]]; \
225  } \
226  \
227  dst += out->linesize[p] / sizeof(type); \
228  src += in->linesize[p] / sizeof(type); \
229  } \
230  } \
231  \
232  return 0; \
233 }
234 
236 SHUFFLE_HORIZONTAL(16, uint16_t)
237 
238 #define SHUFFLE_VERTICAL(name, type) \
239 static int shuffle_vertical## name(AVFilterContext *ctx, void *arg, \
240  int jobnr, int nb_jobs) \
241 { \
242  ShufflePixelsContext *s = ctx->priv; \
243  ThreadData *td = arg; \
244  AVFrame *in = td->in; \
245  AVFrame *out = td->out; \
246  \
247  for (int p = 0; p < s->nb_planes; p++) { \
248  const int slice_start = ff_slice_pos(s->planeheight[p], jobnr, nb_jobs); \
249  const int slice_end = ff_slice_pos(s->planeheight[p], jobnr + 1, nb_jobs); \
250  type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
251  const int32_t *map = s->map; \
252  \
253  for (int y = slice_start; y < slice_end; y++) { \
254  const type *src = (const type *)(in->data[p] + \
255  map[y] * in->linesize[p]); \
256  \
257  memcpy(dst, src, s->linesize[p]); \
258  dst += out->linesize[p] / sizeof(type); \
259  } \
260  } \
261  \
262  return 0; \
263 }
264 
266 SHUFFLE_VERTICAL(16, uint16_t)
267 
268 #define SHUFFLE_BLOCK(name, type) \
269 static int shuffle_block## name(AVFilterContext *ctx, void *arg, \
270  int jobnr, int nb_jobs) \
271 { \
272  ShufflePixelsContext *s = ctx->priv; \
273  ThreadData *td = arg; \
274  AVFrame *in = td->in; \
275  AVFrame *out = td->out; \
276  \
277  for (int p = 0; p < s->nb_planes; p++) { \
278  const int slice_start = ff_slice_pos(s->planeheight[p], jobnr, nb_jobs); \
279  const int slice_end = ff_slice_pos(s->planeheight[p], jobnr + 1, nb_jobs); \
280  type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
281  const type *src = (const type *)in->data[p]; \
282  const int32_t *map = s->map + slice_start * s->planewidth[p]; \
283  \
284  for (int y = slice_start; y < slice_end; y++) { \
285  for (int x = 0; x < s->planewidth[p]; x++) { \
286  int ymap = map[x] / s->planewidth[p]; \
287  int xmap = map[x] % s->planewidth[p]; \
288  \
289  dst[x] = src[xmap + ymap * in->linesize[p] / sizeof(type)]; \
290  } \
291  \
292  dst += out->linesize[p] / sizeof(type); \
293  map += s->planewidth[p]; \
294  } \
295  } \
296  \
297  return 0; \
298 }
299 
301 SHUFFLE_BLOCK(16, uint16_t)
302 
303 static int config_output(AVFilterLink *outlink)
304 {
305  AVFilterContext *ctx = outlink->src;
306  ShufflePixelsContext *s = ctx->priv;
307  AVFilterLink *inlink = ctx->inputs[0];
308  const AVPixFmtDescriptor *desc;
309  int ret;
310 
311  if (s->seed == -1)
312  s->seed = av_get_random_seed();
313  av_lfg_init(&s->c, s->seed);
314 
315  desc = av_pix_fmt_desc_get(outlink->format);
316  if (!desc)
317  return AVERROR_BUG;
318  s->nb_planes = av_pix_fmt_count_planes(outlink->format);
319  s->depth = desc->comp[0].depth;
320 
321  if ((ret = av_image_fill_linesizes(s->linesize, inlink->format, inlink->w)) < 0)
322  return ret;
323 
324  s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
325  s->planewidth[0] = s->planewidth[3] = inlink->w;
326 
327  s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
328  s->planeheight[0] = s->planeheight[3] = inlink->h;
329 
330  s->map = av_calloc(inlink->w * inlink->h, sizeof(*s->map));
331  if (!s->map)
332  return AVERROR(ENOMEM);
333 
334  switch (s->mode) {
335  case 0:
336  s->shuffle_pixels = s->depth <= 8 ? shuffle_horizontal8 : shuffle_horizontal16;
337  s->nb_blocks = (s->planewidth[0] + s->block_w - 1) / s->block_w;
338  break;
339  case 1:
340  s->shuffle_pixels = s->depth <= 8 ? shuffle_vertical8 : shuffle_vertical16;
341  s->nb_blocks = (s->planeheight[0] + s->block_h - 1) / s->block_h;
342  break;
343  case 2:
344  s->shuffle_pixels = s->depth <= 8 ? shuffle_block8 : shuffle_block16;
345  s->nb_blocks = (s->planeheight[0] / s->block_h) *
346  (s->planewidth[0] / s->block_w);
347  break;
348  default:
349  av_assert0(0);
350  }
351 
352  s->used = av_calloc(s->nb_blocks, sizeof(*s->used));
353  if (!s->used)
354  return AVERROR(ENOMEM);
355 
356  switch (s->mode) {
357  case 0:
359  break;
360  case 1:
362  break;
363  case 2:
365  break;
366  default:
367  av_assert0(0);
368  }
369 
370  return 0;
371 }
372 
373 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
374 {
375  AVFilterContext *ctx = inlink->dst;
376  ShufflePixelsContext *s = ctx->priv;
377  AVFrame *out = ff_get_video_buffer(ctx->outputs[0], in->width, in->height);
378  ThreadData td;
379  int ret;
380 
381  ret = av_frame_copy_props(out, in);
382  if (ret < 0) {
383  av_frame_free(&out);
384  goto fail;
385  }
386 
387  td.out = out;
388  td.in = in;
389  ctx->internal->execute(ctx, s->shuffle_pixels, &td, NULL, FFMIN(s->planeheight[1], ff_filter_get_nb_threads(ctx)));
390 
391  av_frame_free(&in);
392  return ff_filter_frame(ctx->outputs[0], out);
393 fail:
394  av_frame_free(&in);
395  return ret;
396 }
397 
399 {
400  ShufflePixelsContext *s = ctx->priv;
401 
402  av_freep(&s->map);
403  av_freep(&s->used);
404 }
405 
406 #define OFFSET(x) offsetof(ShufflePixelsContext, x)
407 #define FLAGS (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
408 static const AVOption shufflepixels_options[] = {
409  { "direction", "set shuffle direction", OFFSET(direction), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "dir" },
410  { "d", "set shuffle direction", OFFSET(direction), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "dir" },
411  { "forward", 0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "dir" },
412  { "inverse", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "dir" },
413  { "mode", "set shuffle mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, FLAGS, "mode" },
414  { "m", "set shuffle mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, FLAGS, "mode" },
415  { "horizontal", 0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "mode" },
416  { "vertical", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "mode" },
417  { "block", 0, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "mode" },
418  { "width", "set block width", OFFSET(block_w), AV_OPT_TYPE_INT, {.i64=10}, 1, 8000, FLAGS },
419  { "w", "set block width", OFFSET(block_w), AV_OPT_TYPE_INT, {.i64=10}, 1, 8000, FLAGS },
420  { "height", "set block height", OFFSET(block_h), AV_OPT_TYPE_INT, {.i64=10}, 1, 8000, FLAGS },
421  { "h", "set block height", OFFSET(block_h), AV_OPT_TYPE_INT, {.i64=10}, 1, 8000, FLAGS },
422  { "seed", "set random seed", OFFSET(seed), AV_OPT_TYPE_INT64, {.i64=-1}, -1, UINT_MAX, FLAGS },
423  { "s", "set random seed", OFFSET(seed), AV_OPT_TYPE_INT64, {.i64=-1}, -1, UINT_MAX, FLAGS },
424  { NULL },
425 };
426 
427 AVFILTER_DEFINE_CLASS(shufflepixels);
428 
430  {
431  .name = "default",
432  .type = AVMEDIA_TYPE_VIDEO,
433  .filter_frame = filter_frame,
434  },
435  { NULL },
436 };
437 
439  {
440  .name = "default",
441  .type = AVMEDIA_TYPE_VIDEO,
442  .config_props = config_output,
443  },
444  { NULL },
445 };
446 
448  .name = "shufflepixels",
449  .description = NULL_IF_CONFIG_SMALL("Shuffle video pixels."),
450  .priv_size = sizeof(ShufflePixelsContext),
451  .priv_class = &shufflepixels_class,
453  .uninit = uninit,
457 };
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
#define av_cold
Definition: attributes.h:88
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
uint8_t
int32_t
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert0(cond)
assert() equivalent, that is always enabled.
Definition: avassert.h:37
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1096
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:802
Main libavfilter public API header.
#define flags(name, subs,...)
Definition: cbs_av1.c:572
#define s(width, name)
Definition: cbs_vp9.c:257
#define fail()
Definition: checkasm.h:133
common internal and external API header
#define FFMIN(a, b)
Definition: common.h:105
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
#define NULL
Definition: coverity.c:32
long long int64_t
Definition: coverity.c:34
mode
Use these values in ebur128_init (or'ed).
Definition: ebur128.h:83
int
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
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:286
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
@ AV_OPT_TYPE_INT64
Definition: opt.h:226
@ AV_OPT_TYPE_INT
Definition: opt.h:225
#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
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition: avfilter.h:117
uint32_t av_get_random_seed(void)
Get a seed to use in conjunction with random functions.
Definition: random_seed.c:120
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:50
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:203
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:658
void * av_calloc(size_t nmemb, size_t size)
Non-inlined equivalent of av_mallocz_array().
Definition: mem.c:245
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
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
const VDPAUPixFmtMap * map
misc image utilities
int i
Definition: input.c:407
av_cold void av_lfg_init(AVLFG *c, unsigned int seed)
Definition: lfg.c:32
static unsigned int av_lfg_get(AVLFG *c)
Get the next random unsigned 32-bit number using an ALFG.
Definition: lfg.h:53
const char * arg
Definition: jacosubdec.c:66
common internal API header
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:117
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:309
const char * desc
Definition: libsvtav1.c:79
AVOptions.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2613
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2573
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:420
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:406
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:398
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:379
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:421
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:414
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:438
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:415
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:416
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
@ 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_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:215
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:168
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:380
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:382
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:383
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:419
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:443
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:418
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:409
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:435
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:417
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:412
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:402
#define td
Definition: regdef.h:70
Describe the class of an AVClass context structure.
Definition: log.h:67
An instance of a filter.
Definition: avfilter.h:341
A list of supported formats for one end of a filter link.
Definition: formats.h:65
A filter pad used for either input or output.
Definition: internal.h:54
const char * name
Pad name.
Definition: internal.h:60
Filter definition.
Definition: avfilter.h:145
const char * name
Filter name.
Definition: avfilter.h:149
AVFormatInternal * internal
An opaque field for libavformat internal usage.
Definition: avformat.h:1699
This structure describes decoded (raw) audio or video data.
Definition: frame.h:318
Context structure for the Lagged Fibonacci PRNG.
Definition: lfg.h:33
AVOption.
Definition: opt.h:248
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
int(* shuffle_pixels)(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Used for passing data between threads.
Definition: dsddec.c:67
AVFrame * out
Definition: af_adeclick.c:502
AVFrame * in
Definition: af_adenorm.c:223
#define av_freep(p)
FILE * out
Definition: movenc.c:54
AVFormatContext * ctx
Definition: movenc.c:48
#define height
#define width
AVFILTER_DEFINE_CLASS(shufflepixels)
static void make_block_map(AVFilterContext *ctx)
static void make_horizontal_map(AVFilterContext *ctx)
AVFilter ff_vf_shufflepixels
static const AVFilterPad shufflepixels_inputs[]
static const AVFilterPad shufflepixels_outputs[]
static int query_formats(AVFilterContext *ctx)
static const AVOption shufflepixels_options[]
#define FLAGS
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
#define SHUFFLE_BLOCK(name, type)
static av_cold void uninit(AVFilterContext *ctx)
static void make_vertical_map(AVFilterContext *ctx)
#define OFFSET(x)
static int config_output(AVFilterLink *outlink)
#define SHUFFLE_VERTICAL(name, type)
#define SHUFFLE_HORIZONTAL(name, type)
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:104
static unsigned int seed
Definition: videogen.c:78
static double c[64]