FFmpeg
Data Structures | Macros | Functions | Variables
vf_shufflepixels.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/avstring.h"
#include "libavutil/common.h"
#include "libavutil/internal.h"
#include "libavutil/imgutils.h"
#include "libavutil/lfg.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/random_seed.h"
#include "avfilter.h"
#include "internal.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  ShufflePixelsContext
 
struct  ThreadData
 Used for passing data between threads. More...
 

Macros

#define SHUFFLE_HORIZONTAL(name, type)
 
#define SHUFFLE_VERTICAL(name, type)
 
#define SHUFFLE_BLOCK(name, type)
 
#define OFFSET(x)   offsetof(ShufflePixelsContext, x)
 
#define FLAGS   (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM)
 

Functions

static void make_horizontal_map (AVFilterContext *ctx)
 
static void make_vertical_map (AVFilterContext *ctx)
 
static void make_block_map (AVFilterContext *ctx)
 
static int config_output (AVFilterLink *outlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
static av_cold void uninit (AVFilterContext *ctx)
 
 AVFILTER_DEFINE_CLASS (shufflepixels)
 

Variables

static enum AVPixelFormat pix_fmts []
 
static const AVOption shufflepixels_options []
 
static const AVFilterPad shufflepixels_inputs []
 
static const AVFilterPad shufflepixels_outputs []
 
const AVFilter ff_vf_shufflepixels
 

Macro Definition Documentation

◆ SHUFFLE_HORIZONTAL

#define SHUFFLE_HORIZONTAL (   name,
  type 
)
Value:
static int shuffle_horizontal## name(AVFilterContext *ctx, void *arg, \
int jobnr, int nb_jobs) \
{ \
ShufflePixelsContext *s = ctx->priv; \
ThreadData *td = arg; \
AVFrame *in = td->in; \
AVFrame *out = td->out; \
for (int p = 0; p < s->nb_planes; p++) { \
const int slice_start = (s->planeheight[p] * jobnr) / nb_jobs; \
const int slice_end = (s->planeheight[p] * (jobnr+1)) / nb_jobs; \
type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
const type *src = (const type *)(in->data[p] + \
slice_start * in->linesize[p]); \
const int32_t *map = s->map; \
for (int y = slice_start; y < slice_end; y++) { \
for (int x = 0; x < s->planewidth[p]; x++) { \
dst[x] = src[map[x]]; \
} \
\
dst += out->linesize[p] / sizeof(type); \
src += in->linesize[p] / sizeof(type); \
} \
} \
\
return 0; \
}

Definition at line 197 of file vf_shufflepixels.c.

◆ SHUFFLE_VERTICAL

#define SHUFFLE_VERTICAL (   name,
  type 
)
Value:
static int shuffle_vertical## name(AVFilterContext *ctx, void *arg, \
int jobnr, int nb_jobs) \
{ \
ShufflePixelsContext *s = ctx->priv; \
ThreadData *td = arg; \
AVFrame *in = td->in; \
AVFrame *out = td->out; \
for (int p = 0; p < s->nb_planes; p++) { \
const int slice_start = (s->planeheight[p] * jobnr) / nb_jobs; \
const int slice_end = (s->planeheight[p] * (jobnr+1)) / nb_jobs; \
type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
const int32_t *map = s->map; \
for (int y = slice_start; y < slice_end; y++) { \
const type *src = (const type *)(in->data[p] + \
map[y] * in->linesize[p]); \
\
memcpy(dst, src, s->linesize[p]); \
dst += out->linesize[p] / sizeof(type); \
} \
} \
\
return 0; \
}

Definition at line 230 of file vf_shufflepixels.c.

◆ SHUFFLE_BLOCK

#define SHUFFLE_BLOCK (   name,
  type 
)
Value:
static int shuffle_block## name(AVFilterContext *ctx, void *arg, \
int jobnr, int nb_jobs) \
{ \
ShufflePixelsContext *s = ctx->priv; \
ThreadData *td = arg; \
AVFrame *in = td->in; \
AVFrame *out = td->out; \
for (int p = 0; p < s->nb_planes; p++) { \
const int slice_start = (s->planeheight[p] * jobnr) / nb_jobs; \
const int slice_end = (s->planeheight[p] * (jobnr+1)) / nb_jobs; \
type *dst = (type *)(out->data[p] + slice_start * out->linesize[p]); \
const type *src = (const type *)in->data[p]; \
const int32_t *map = s->map + slice_start * s->planewidth[p]; \
\
for (int y = slice_start; y < slice_end; y++) { \
for (int x = 0; x < s->planewidth[p]; x++) { \
int ymap = map[x] / s->planewidth[p]; \
int xmap = map[x] % s->planewidth[p]; \
\
dst[x] = src[xmap + ymap * in->linesize[p] / sizeof(type)]; \
} \
\
dst += out->linesize[p] / sizeof(type); \
map += s->planewidth[p]; \
} \
} \
\
return 0; \
}

Definition at line 260 of file vf_shufflepixels.c.

◆ OFFSET

#define OFFSET (   x)    offsetof(ShufflePixelsContext, x)

Definition at line 404 of file vf_shufflepixels.c.

◆ FLAGS

Definition at line 405 of file vf_shufflepixels.c.

Function Documentation

◆ make_horizontal_map()

static void make_horizontal_map ( AVFilterContext ctx)
static

Definition at line 70 of file vf_shufflepixels.c.

Referenced by config_output().

◆ make_vertical_map()

static void make_vertical_map ( AVFilterContext ctx)
static

Definition at line 108 of file vf_shufflepixels.c.

Referenced by config_output().

◆ make_block_map()

static void make_block_map ( AVFilterContext ctx)
static

Definition at line 146 of file vf_shufflepixels.c.

Referenced by config_output().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 295 of file vf_shufflepixels.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 365 of file vf_shufflepixels.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 396 of file vf_shufflepixels.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( shufflepixels  )

Variable Documentation

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static

◆ shufflepixels_options

const AVOption shufflepixels_options[]
static
Initial value:
= {
{ "direction", "set shuffle direction", OFFSET(direction), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "dir" },
{ "d", "set shuffle direction", OFFSET(direction), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "dir" },
{ "forward", 0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "dir" },
{ "inverse", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "dir" },
{ "mode", "set shuffle mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, FLAGS, "mode" },
{ "m", "set shuffle mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, FLAGS, "mode" },
{ "horizontal", 0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, "mode" },
{ "vertical", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, "mode" },
{ "block", 0, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, "mode" },
{ "width", "set block width", OFFSET(block_w), AV_OPT_TYPE_INT, {.i64=10}, 1, 8000, FLAGS },
{ "w", "set block width", OFFSET(block_w), AV_OPT_TYPE_INT, {.i64=10}, 1, 8000, FLAGS },
{ "height", "set block height", OFFSET(block_h), AV_OPT_TYPE_INT, {.i64=10}, 1, 8000, FLAGS },
{ "h", "set block height", OFFSET(block_h), AV_OPT_TYPE_INT, {.i64=10}, 1, 8000, FLAGS },
{ "seed", "set random seed", OFFSET(seed), AV_OPT_TYPE_INT64, {.i64=-1}, -1, UINT_MAX, FLAGS },
{ "s", "set random seed", OFFSET(seed), AV_OPT_TYPE_INT64, {.i64=-1}, -1, UINT_MAX, FLAGS },
{ NULL },
}

Definition at line 406 of file vf_shufflepixels.c.

◆ shufflepixels_inputs

const AVFilterPad shufflepixels_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
},
}

Definition at line 427 of file vf_shufflepixels.c.

◆ shufflepixels_outputs

const AVFilterPad shufflepixels_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
}

Definition at line 435 of file vf_shufflepixels.c.

◆ ff_vf_shufflepixels

const AVFilter ff_vf_shufflepixels
Initial value:
= {
.name = "shufflepixels",
.description = NULL_IF_CONFIG_SMALL("Shuffle video pixels."),
.priv_size = sizeof(ShufflePixelsContext),
.priv_class = &shufflepixels_class,
}

Definition at line 443 of file vf_shufflepixels.c.

AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:428
td
#define td
Definition: regdef.h:70
name
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default minimum maximum flags name is the option name
Definition: writing_filters.txt:88
out
FILE * out
Definition: movenc.c:54
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: internal.h:170
FLAGS
#define FLAGS
Definition: vf_shufflepixels.c:405
shufflepixels_inputs
static const AVFilterPad shufflepixels_inputs[]
Definition: vf_shufflepixels.c:427
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:386
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:424
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:205
OFFSET
#define OFFSET(x)
Definition: vf_shufflepixels.c:404
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:422
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:450
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:390
shufflepixels_outputs
static const AVFilterPad shufflepixels_outputs[]
Definition: vf_shufflepixels.c:435
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:409
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:426
s
#define s(width, name)
Definition: cbs_vp9.c:256
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:427
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:419
slice_end
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:2013
AV_OPT_TYPE_INT64
@ AV_OPT_TYPE_INT64
Definition: opt.h:226
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:389
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:190
arg
const char * arg
Definition: jacosubdec.c:67
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:387
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:425
NULL
#define NULL
Definition: coverity.c:32
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:421
seed
static unsigned int seed
Definition: videogen.c:78
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
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:413
ShufflePixelsContext
Definition: vf_shufflepixels.c:35
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_shufflepixels.c:396
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:167
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:445
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:152
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:423
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:405
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:442
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_shufflepixels.c:59
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
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_shufflepixels.c:295
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:408
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:158
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:127
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
map
const VDPAUPixFmtMap * map
Definition: hwcontext_vdpau.c:71
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:191
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
int32_t
int32_t
Definition: audioconvert.c:56
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_shufflepixels.c:365
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:416
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234