FFmpeg
Data Structures | Macros | Functions | Variables
vf_shufflepixels.c File Reference
#include "libavutil/avassert.h"
#include "libavutil/common.h"
#include "libavutil/internal.h"
#include "libavutil/imgutils.h"
#include "libavutil/lfg.h"
#include "libavutil/mem.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "libavutil/random_seed.h"
#include "avfilter.h"
#include "filters.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, .unit = "dir" },
{ "d", "set shuffle direction", OFFSET(direction), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, .unit = "dir" },
{ "forward", 0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, .unit = "dir" },
{ "inverse", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, .unit = "dir" },
{ "mode", "set shuffle mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, FLAGS, .unit = "mode" },
{ "m", "set shuffle mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, 2, FLAGS, .unit = "mode" },
{ "horizontal", 0, 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, .unit = "mode" },
{ "vertical", 0, 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, .unit = "mode" },
{ "block", 0, 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, .unit = "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:525
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
FILTER_PIXFMTS_ARRAY
#define FILTER_PIXFMTS_ARRAY(array)
Definition: filters.h:242
out
FILE * out
Definition: movenc.c:55
FLAGS
#define FLAGS
Definition: vf_shufflepixels.c:405
shufflepixels_inputs
static const AVFilterPad shufflepixels_inputs[]
Definition: vf_shufflepixels.c:427
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: filters.h:262
mode
Definition: swscale.c:52
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:482
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:520
slice_end
static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output)
Handle slice ends.
Definition: mpeg12dec.c:1720
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:212
OFFSET
#define OFFSET(x)
Definition: vf_shufflepixels.c:404
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:518
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:547
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:486
shufflepixels_outputs
static const AVFilterPad shufflepixels_outputs[]
Definition: vf_shufflepixels.c:435
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:505
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:522
s
#define s(width, name)
Definition: cbs_vp9.c:198
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:523
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:515
AV_OPT_TYPE_INT64
@ AV_OPT_TYPE_INT64
Underlying C type is int64_t.
Definition: opt.h:263
ctx
AVFormatContext * ctx
Definition: movenc.c:49
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:485
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: filters.h:263
arg
const char * arg
Definition: jacosubdec.c:67
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:483
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:521
NULL
#define NULL
Definition: coverity.c:32
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:81
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:517
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:94
dst
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition: dsp.h:83
for
for(k=2;k<=8;++k)
Definition: h264pred_template.c:425
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:509
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:174
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:542
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:182
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:519
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:501
slice_start
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)
Definition: dec.c:736
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:539
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_shufflepixels.c:59
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:72
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition: opt.h:259
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:78
AVFilterContext
An instance of a filter.
Definition: avfilter.h:457
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:165
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:152
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
map
const VDPAUPixFmtMap * map
Definition: hwcontext_vdpau.c:71
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:512
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition: opt.h:299
src
#define src
Definition: vp8dsp.c:248