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 int query_formats (AVFilterContext *ctx)
 
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 const AVOption shufflepixels_options []
 
static const AVFilterPad shufflepixels_inputs []
 
static const AVFilterPad shufflepixels_outputs []
 
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 204 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 237 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 267 of file vf_shufflepixels.c.

◆ OFFSET

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

Definition at line 405 of file vf_shufflepixels.c.

◆ FLAGS

Definition at line 406 of file vf_shufflepixels.c.

Function Documentation

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 59 of file vf_shufflepixels.c.

◆ make_horizontal_map()

static void make_horizontal_map ( AVFilterContext ctx)
static

Definition at line 77 of file vf_shufflepixels.c.

Referenced by config_output().

◆ make_vertical_map()

static void make_vertical_map ( AVFilterContext ctx)
static

Definition at line 115 of file vf_shufflepixels.c.

Referenced by config_output().

◆ make_block_map()

static void make_block_map ( AVFilterContext ctx)
static

Definition at line 153 of file vf_shufflepixels.c.

Referenced by config_output().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 302 of file vf_shufflepixels.c.

◆ filter_frame()

static int filter_frame ( AVFilterLink inlink,
AVFrame in 
)
static

Definition at line 372 of file vf_shufflepixels.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 397 of file vf_shufflepixels.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( shufflepixels  )

Variable Documentation

◆ 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 407 of file vf_shufflepixels.c.

◆ shufflepixels_inputs

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

Definition at line 428 of file vf_shufflepixels.c.

◆ shufflepixels_outputs

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

Definition at line 437 of file vf_shufflepixels.c.

◆ ff_vf_shufflepixels

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 446 of file vf_shufflepixels.c.

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
FLAGS
#define FLAGS
Definition: vf_shufflepixels.c:406
shufflepixels_inputs
static const AVFilterPad shufflepixels_inputs[]
Definition: vf_shufflepixels.c:428
OFFSET
#define OFFSET(x)
Definition: vf_shufflepixels.c:405
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
shufflepixels_outputs
static const AVFilterPad shufflepixels_outputs[]
Definition: vf_shufflepixels.c:437
s
#define s(width, name)
Definition: cbs_vp9.c:257
slice_end
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:2033
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_shufflepixels.c:59
AV_OPT_TYPE_INT64
@ AV_OPT_TYPE_INT64
Definition: opt.h:226
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
ctx
AVFormatContext * ctx
Definition: movenc.c:48
int32_t
int32_t
Definition: audio_convert.c:194
arg
const char * arg
Definition: jacosubdec.c:66
NULL
#define NULL
Definition: coverity.c:32
src
#define src
Definition: vp8dsp.c:255
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
seed
static unsigned int seed
Definition: videogen.c:78
for
for(j=16;j >0;--j)
Definition: h264pred_template.c:469
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
ShufflePixelsContext
Definition: vf_shufflepixels.c:35
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_shufflepixels.c:397
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:126
in
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
Definition: audio_convert.c:326
mode
mode
Definition: ebur128.h:83
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:225
config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_shufflepixels.c:302
AVFilterContext
An instance of a filter.
Definition: avfilter.h:341
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:117
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
map
const VDPAUPixFmtMap * map
Definition: hwcontext_vdpau.c:71
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:561
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_shufflepixels.c:372
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:234