FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
vf_pixelize.c File Reference
#include "libavutil/common.h"
#include "libavutil/internal.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "internal.h"
#include "video.h"

Go to the source code of this file.

Data Structures

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

Macros

#define PIXELIZE_AVG(name, type, stype)
 
#define PIXELIZE_MIN(name, type, stype)
 
#define PIXELIZE_MAX(name, type, stype)
 
#define OFFSET(x)   offsetof(PixelizeContext, x)
 
#define FLAGS   (AV_OPT_FLAG_FILTERING_PARAM | AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_RUNTIME_PARAM)
 

Enumerations

enum  PixelizeModes { PIXELIZE_AVG, PIXELIZE_MIN, PIXELIZE_MAX, PIXELIZE_MODES }
 

Functions

static int pixelize_slice (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int config_output (AVFilterLink *outlink)
 
static int filter_frame (AVFilterLink *inlink, AVFrame *in)
 
 AVFILTER_DEFINE_CLASS (pixelize)
 

Variables

static enum AVPixelFormat pix_fmts []
 
static const AVOption pixelize_options []
 
static const AVFilterPad pixelize_inputs []
 
static const AVFilterPad pixelize_outputs []
 
const AVFilter ff_vf_pixelize
 

Macro Definition Documentation

◆ PIXELIZE_AVG

#define PIXELIZE_AVG (   name,
  type,
  stype 
)
Value:
static int pixelize_avg##name(const uint8_t *ssrc, uint8_t *ddst, \
ptrdiff_t src_linesize, ptrdiff_t dst_linesize, \
int w, int h) \
{ \
const type *src = (const type *)ssrc; \
type *dst = (type *)ddst; \
stype sum = 0; \
type fill; \
for (int y = 0; y < h; y++) { \
for (int x = 0; x < w; x++) \
sum += src[x]; \
\
src += src_linesize / sizeof(type); \
} \
\
fill = sum / (w * h); \
for (int y = 0; y < h; y++) { \
for (int x = 0; x < w; x++) \
dst[x] = fill; \
\
dst += dst_linesize / sizeof(type); \
} \
\
return 0; \
}

Definition at line 93 of file vf_pixelize.c.

◆ PIXELIZE_MIN

#define PIXELIZE_MIN (   name,
  type,
  stype 
)
Value:
static int pixelize_min##name(const uint8_t *ssrc, uint8_t *ddst, \
ptrdiff_t src_linesize, ptrdiff_t dst_linesize, \
int w, int h) \
{ \
const type *src = (const type *)ssrc; \
type *dst = (type *)ddst; \
type fill = src[0]; \
for (int y = 0; y < h; y++) { \
for (int x = 0; x < w; x++) \
fill = FFMIN(src[x], fill); \
\
src += src_linesize / sizeof(type); \
} \
for (int y = 0; y < h; y++) { \
for (int x = 0; x < w; x++) \
dst[x] = fill; \
\
dst += dst_linesize / sizeof(type); \
} \
\
return 0; \
}

Definition at line 121 of file vf_pixelize.c.

◆ PIXELIZE_MAX

#define PIXELIZE_MAX (   name,
  type,
  stype 
)
Value:
static int pixelize_max##name(const uint8_t *ssrc, uint8_t *ddst, \
ptrdiff_t src_linesize, ptrdiff_t dst_linesize, \
int w, int h) \
{ \
const type *src = (const type *)ssrc; \
type *dst = (type *)ddst; \
type fill = src[0]; \
for (int y = 0; y < h; y++) { \
for (int x = 0; x < w; x++) \
fill = FFMAX(src[x], fill); \
\
src += src_linesize / sizeof(type); \
} \
for (int y = 0; y < h; y++) { \
for (int x = 0; x < w; x++) \
dst[x] = fill; \
\
dst += dst_linesize / sizeof(type); \
} \
\
return 0; \
}

Definition at line 147 of file vf_pixelize.c.

◆ OFFSET

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

Definition at line 305 of file vf_pixelize.c.

◆ FLAGS

Definition at line 306 of file vf_pixelize.c.

Enumeration Type Documentation

◆ PixelizeModes

Enumerator
PIXELIZE_AVG 
PIXELIZE_MIN 
PIXELIZE_MAX 
PIXELIZE_MODES 

Definition at line 30 of file vf_pixelize.c.

Function Documentation

◆ pixelize_slice()

static int pixelize_slice ( AVFilterContext ctx,
void *  arg,
int  jobnr,
int  nb_jobs 
)
static

Definition at line 180 of file vf_pixelize.c.

Referenced by filter_frame().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 227 of file vf_pixelize.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 260 of file vf_pixelize.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( pixelize  )

Variable Documentation

◆ pix_fmts

enum AVPixelFormat pix_fmts[]
static

◆ pixelize_options

const AVOption pixelize_options[]
static
Initial value:
= {
{ "width", "set block width", OFFSET(block_w[0]), AV_OPT_TYPE_INT, {.i64=16}, 1, 1024, FLAGS },
{ "w", "set block width", OFFSET(block_w[0]), AV_OPT_TYPE_INT, {.i64=16}, 1, 1024, FLAGS },
{ "height", "set block height", OFFSET(block_h[0]), AV_OPT_TYPE_INT, {.i64=16}, 1, 1024, FLAGS },
{ "h", "set block height", OFFSET(block_h[0]), AV_OPT_TYPE_INT, {.i64=16}, 1, 1024, FLAGS },
{ "mode", "set the pixelize mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, PIXELIZE_MODES-1, FLAGS, "mode" },
{ "m", "set the pixelize mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=0}, 0, PIXELIZE_MODES-1, FLAGS, "mode" },
{ "avg", "average", 0, AV_OPT_TYPE_CONST, {.i64=PIXELIZE_AVG}, 0, 0, FLAGS, "mode" },
{ "min", "minimum", 0, AV_OPT_TYPE_CONST, {.i64=PIXELIZE_MIN}, 0, 0, FLAGS, "mode" },
{ "max", "maximum", 0, AV_OPT_TYPE_CONST, {.i64=PIXELIZE_MAX}, 0, 0, FLAGS, "mode" },
{ "planes", "set what planes to filter", OFFSET(planes), AV_OPT_TYPE_FLAGS, {.i64=15}, 0, 15, FLAGS },
{ "p", "set what planes to filter", OFFSET(planes), AV_OPT_TYPE_FLAGS, {.i64=15}, 0, 15, FLAGS },
{ NULL },
}

Definition at line 308 of file vf_pixelize.c.

◆ pixelize_inputs

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

Definition at line 325 of file vf_pixelize.c.

◆ pixelize_outputs

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

Definition at line 333 of file vf_pixelize.c.

◆ ff_vf_pixelize

const AVFilter ff_vf_pixelize
Initial value:
= {
.name = "pixelize",
.description = NULL_IF_CONFIG_SMALL("Pixelize video."),
.priv_size = sizeof(PixelizeContext),
.priv_class = &pixelize_class,
.process_command = ff_filter_process_command,
}

Definition at line 341 of file vf_pixelize.c.

AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:454
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:433
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: internal.h:170
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:446
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:453
w
uint8_t w
Definition: llviddspenc.c:38
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:448
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:411
PIXELIZE_MIN
#define PIXELIZE_MIN(name, type, stype)
Definition: vf_pixelize.c:121
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
FFMAX
#define FFMAX(a, b)
Definition: macros.h:47
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:449
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:391
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:445
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: vf_pixelize.c:59
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:429
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:205
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:427
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:455
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:409
PIXELIZE_MAX
#define PIXELIZE_MAX(name, type, stype)
Definition: vf_pixelize.c:147
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:395
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:414
AV_PIX_FMT_YUVJ411P
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:248
pixelize_inputs
static const AVFilterPad pixelize_inputs[]
Definition: vf_pixelize.c:325
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:423
AV_PIX_FMT_YUVJ422P
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:79
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:431
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:432
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:424
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_pixelize.c:227
AV_PIX_FMT_YUVA444P12
#define AV_PIX_FMT_YUVA444P12
Definition: pixfmt.h:452
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:408
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:422
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:394
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:190
AV_PIX_FMT_YUVJ444P
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:80
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:392
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:430
FLAGS
#define FLAGS
Definition: vf_pixelize.c:306
NULL
#define NULL
Definition: coverity.c:32
AV_PIX_FMT_YUVJ420P
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:78
AV_PIX_FMT_YUV440P10
#define AV_PIX_FMT_YUV440P10
Definition: pixfmt.h:413
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:412
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:426
planes
static const struct @335 planes[]
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_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:416
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:418
ff_filter_process_command
int ff_filter_process_command(AVFilterContext *ctx, const char *cmd, const char *arg, char *res, int res_len, int flags)
Generic processing of user supplied commands that are set in the same way as the filter options.
Definition: avfilter.c:863
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:450
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
pixelize_outputs
static const AVFilterPad pixelize_outputs[]
Definition: vf_pixelize.c:333
PIXELIZE_MODES
@ PIXELIZE_MODES
Definition: vf_pixelize.c:34
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:428
FFMIN
#define FFMIN(a, b)
Definition: macros.h:49
AV_PIX_FMT_YUVJ440P
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition: pixfmt.h:100
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:410
PixelizeContext
Definition: vf_pixelize.c:37
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:447
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:415
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:420
mode
mode
Definition: ebur128.h:83
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_PIX_FMT_YUVA422P12
#define AV_PIX_FMT_YUVA422P12
Definition: pixfmt.h:451
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
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
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
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:191
src
INIT_CLIP pixel * src
Definition: h264pred_template.c:418
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
AV_OPT_TYPE_FLAGS
@ AV_OPT_TYPE_FLAGS
Definition: opt.h:224
PIXELIZE_AVG
#define PIXELIZE_AVG(name, type, stype)
Definition: vf_pixelize.c:93
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:417
h
h
Definition: vp9dsp_template.c:2038
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:421
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:393
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_pixelize.c:260
AV_PIX_FMT_YUVA422P
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:166
AV_PIX_FMT_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:419
OFFSET
#define OFFSET(x)
Definition: vf_pixelize.c:305