FFmpeg
Loading...
Searching...
No Matches
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)
 
#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 FFFilter 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) \
{ \
ThreadData *td = arg; \
AVFrame *in = td->in; \
AVFrame *out = td->out; \
\
for (int p = 0; p < s->nb_planes; p++) { \
const int slice_start = ff_slice_pos(s->planeheight[p], jobnr, nb_jobs); \
const int slice_end = ff_slice_pos(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; \
}
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
Definition dsp.h:87
static FILE * out
static AVFormatContext * ctx
int32_t
#define s(width, name)
Definition cbs_vp9.c:198
cl_device_type type
const VDPAUPixFmtMap * map
const char * arg
Definition jacosubdec.c:65
static int ff_slice_pos(int total, int jobnr, int nb_jobs)
Compute the boundary index for a slice when work of size total is split into nb_jobs slices.
Definition filters.h:763
static int slice_end(AVCodecContext *avctx, AVFrame *pict, int *got_output)
Handle slice ends.
Definition mpeg12dec.c:1697
const char * name
Definition qsvenc.c:142
An instance of a filter.
Definition avfilter.h:273
This structure describes decoded (raw) audio or video data.
Definition frame.h:472
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition frame.h:493
int linesize[AV_NUM_DATA_POINTERS]
For video, a positive or negative value, which is typically indicating the size in bytes of each pict...
Definition frame.h:517
Used for passing data between threads.
Definition dsddec.c:71
AVFrame * out
#define src
Definition vp8dsp.c:248
static int slice_start(SliceContext *sc, VVCContext *s, VVCFrameContext *fc, const CodedBitstreamUnit *unit, const int is_first_slice)
Definition dec.c:844

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) \
{ \
ThreadData *td = arg; \
AVFrame *in = td->in; \
AVFrame *out = td->out; \
\
for (int p = 0; p < s->nb_planes; p++) { \
const int slice_start = ff_slice_pos(s->planeheight[p], jobnr, nb_jobs); \
const int slice_end = ff_slice_pos(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) \
{ \
ThreadData *td = arg; \
AVFrame *in = td->in; \
AVFrame *out = td->out; \
\
for (int p = 0; p < s->nb_planes; p++) { \
const int slice_start = ff_slice_pos(s->planeheight[p], jobnr, nb_jobs); \
const int slice_end = ff_slice_pos(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)
Value:

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
Initial value:
= {
}
#define AV_PIX_FMT_GBRAP12
Definition pixfmt.h:569
#define AV_PIX_FMT_YUV444P12
Definition pixfmt.h:552
#define AV_PIX_FMT_YUV444P9
Definition pixfmt.h:544
#define AV_PIX_FMT_GRAY9
Definition pixfmt.h:524
#define AV_PIX_FMT_GBRAP16
Definition pixfmt.h:571
#define AV_PIX_FMT_GBRP9
Definition pixfmt.h:563
#define AV_PIX_FMT_YUVA444P10
Definition pixfmt.h:598
#define AV_PIX_FMT_GBRP10
Definition pixfmt.h:564
#define AV_PIX_FMT_GBRP12
Definition pixfmt.h:565
@ AV_PIX_FMT_NONE
Definition pixfmt.h:72
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition pixfmt.h:81
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition pixfmt.h:78
@ 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_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition pixfmt.h:212
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition pixfmt.h:165
#define AV_PIX_FMT_GRAY10
Definition pixfmt.h:525
#define AV_PIX_FMT_GRAY14
Definition pixfmt.h:527
#define AV_PIX_FMT_GRAY16
Definition pixfmt.h:528
#define AV_PIX_FMT_GBRAP10
Definition pixfmt.h:568
#define AV_PIX_FMT_YUVA444P16
Definition pixfmt.h:603
#define AV_PIX_FMT_GBRP16
Definition pixfmt.h:567
#define AV_PIX_FMT_YUV444P14
Definition pixfmt.h:555
#define AV_PIX_FMT_YUVA444P9
Definition pixfmt.h:595
#define AV_PIX_FMT_GBRP14
Definition pixfmt.h:566
#define AV_PIX_FMT_YUV444P16
Definition pixfmt.h:558
#define AV_PIX_FMT_YUV444P10
Definition pixfmt.h:548

Definition at line 59 of file vf_shufflepixels.c.

◆ 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 },
}
#define FLAGS
Definition cmdutils.c:598
#define NULL
Definition coverity.c:32
mode
Use these values in ebur128_init (or'ed).
Definition ebur128.h:83
#define OFFSET(x)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT64
Underlying C type is int64_t.
Definition opt.h:262
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
static unsigned int seed
Definition videogen.c:78

Definition at line 406 of file vf_shufflepixels.c.

◆ shufflepixels_inputs

const AVFilterPad shufflepixels_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
},
}
static int filter_frame(DBEDecodeContext *s, AVFrame *frame)
Definition dolby_e.c:1067
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200

Definition at line 427 of file vf_shufflepixels.c.

◆ shufflepixels_outputs

const AVFilterPad shufflepixels_outputs[]
static
Initial value:
= {
{
.name = "default",
.config_props = config_output,
},
}
static int config_output(AVBitStreamFilterLink *outlink)

Definition at line 435 of file vf_shufflepixels.c.

◆ ff_vf_shufflepixels

const FFFilter ff_vf_shufflepixels
Initial value:
= {
.p.name = "shufflepixels",
.p.description = NULL_IF_CONFIG_SMALL("Shuffle video pixels."),
.p.priv_class = &shufflepixels_class,
.priv_size = sizeof(ShufflePixelsContext),
}
#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:196
#define AVFILTER_FLAG_SLICE_THREADS
The filter supports multithreading by splitting frames into multiple parts and processing them concur...
Definition avfilter.h:166
static av_cold void uninit(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_PIXFMTS_ARRAY(array)
Definition filters.h:244
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static enum AVPixelFormat pix_fmts[]
Definition libkvazaar.c:296
static const AVFilterPad shufflepixels_inputs[]
static const AVFilterPad shufflepixels_outputs[]

Definition at line 443 of file vf_shufflepixels.c.