FFmpeg
Data Structures | Macros | Functions | Variables
vf_remap.c File Reference
#include "libavutil/imgutils.h"
#include "libavutil/pixdesc.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "formats.h"
#include "framesync.h"
#include "internal.h"
#include "video.h"

Go to the source code of this file.

Data Structures

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

Macros

#define OFFSET(x)   offsetof(RemapContext, x)
 
#define FLAGS   AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
 
#define DEFINE_REMAP_PLANAR_FUNC(name, bits, div)
 remap_planar algorithm expects planes of same size pixels are copied from source to target using : Target_frame[y][x] = Source_frame[ ymap[y][x] ][ [xmap[y][x] ]; More...
 
#define DEFINE_REMAP_PACKED_FUNC(name, bits, div)
 remap_packed algorithm expects pixels with both padded bits (step) and number of components correctly set. More...
 

Functions

 AVFILTER_DEFINE_CLASS (remap)
 
static int query_formats (AVFilterContext *ctx)
 
static int config_input (AVFilterLink *inlink)
 
static int process_frame (FFFrameSync *fs)
 
static int config_output (AVFilterLink *outlink)
 
static int activate (AVFilterContext *ctx)
 
static av_cold void uninit (AVFilterContext *ctx)
 

Variables

static const AVOption remap_options []
 
static const AVFilterPad remap_inputs []
 
static const AVFilterPad remap_outputs []
 
AVFilter ff_vf_remap
 

Detailed Description

Pixel remap filter This filter copies pixel by pixel a source frame to a target frame. It remaps the pixels to a new x,y destination based on two files ymap/xmap. Map files are passed as a parameter and are in PGM format (P2 or P5), where the values are y(rows)/x(cols) coordinates of the source_frame. The target frame dimension is based on mapfile dimensions: specified in the header of the mapfile and reflected in the number of datavalues. Dimensions of ymap and xmap must be equal. Datavalues must be positive or zero. Any datavalue in the ymap or xmap which value is higher then the source frame height or width is silently ignored, leaving a blank/chromakey pixel. This can safely be used as a feature to create overlays.

Algorithm digest: Target_frame[y][x] = Source_frame[ ymap[y][x] ][ [xmap[y][x] ];

Definition in file vf_remap.c.

Macro Definition Documentation

◆ OFFSET

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

Definition at line 61 of file vf_remap.c.

◆ FLAGS

Definition at line 62 of file vf_remap.c.

◆ DEFINE_REMAP_PLANAR_FUNC

#define DEFINE_REMAP_PLANAR_FUNC (   name,
  bits,
  div 
)

remap_planar algorithm expects planes of same size pixels are copied from source to target using : Target_frame[y][x] = Source_frame[ ymap[y][x] ][ [xmap[y][x] ];

Definition at line 139 of file vf_remap.c.

◆ DEFINE_REMAP_PACKED_FUNC

#define DEFINE_REMAP_PACKED_FUNC (   name,
  bits,
  div 
)

remap_packed algorithm expects pixels with both padded bits (step) and number of components correctly set.

pixels are copied from source to target using : Target_frame[y][x] = Source_frame[ ymap[y][x] ][ [xmap[y][x] ];

Definition at line 188 of file vf_remap.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( remap  )

◆ query_formats()

static int query_formats ( AVFilterContext ctx)
static

Definition at line 80 of file vf_remap.c.

◆ config_input()

static int config_input ( AVFilterLink inlink)
static

Definition at line 231 of file vf_remap.c.

◆ process_frame()

static int process_frame ( FFFrameSync fs)
static

Definition at line 258 of file vf_remap.c.

Referenced by config_output().

◆ config_output()

static int config_output ( AVFilterLink outlink)
static

Definition at line 297 of file vf_remap.c.

◆ activate()

static int activate ( AVFilterContext ctx)
static

Definition at line 347 of file vf_remap.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext ctx)
static

Definition at line 353 of file vf_remap.c.

Variable Documentation

◆ remap_options

const AVOption remap_options[]
static
Initial value:
= {
{ "format", "set output format", OFFSET(format), AV_OPT_TYPE_INT, {.i64=0}, 0, 1, FLAGS, "format" },
{ "color", "", 0, AV_OPT_TYPE_CONST, {.i64=0}, .flags = FLAGS, .unit = "format" },
{ "gray", "", 0, AV_OPT_TYPE_CONST, {.i64=1}, .flags = FLAGS, .unit = "format" },
{ NULL }
}

Definition at line 64 of file vf_remap.c.

◆ remap_inputs

const AVFilterPad remap_inputs[]
static
Initial value:
= {
{
.name = "source",
.config_props = config_input,
},
{
.name = "xmap",
},
{
.name = "ymap",
},
{ NULL }
}

Definition at line 360 of file vf_remap.c.

◆ remap_outputs

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

Definition at line 377 of file vf_remap.c.

◆ ff_vf_remap

AVFilter ff_vf_remap
Initial value:
= {
.name = "remap",
.description = NULL_IF_CONFIG_SMALL("Remap pixels."),
.priv_size = sizeof(RemapContext),
.priv_class = &remap_class,
}

Definition at line 386 of file vf_remap.c.

config_output
static int config_output(AVFilterLink *outlink)
Definition: vf_remap.c:297
activate
static int activate(AVFilterContext *ctx)
Definition: vf_remap.c:347
OFFSET
#define OFFSET(x)
Definition: vf_remap.c:61
format
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample format(the sample packing is implied by the sample format) and sample rate. The lists are not just lists
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
NULL
#define NULL
Definition: coverity.c:32
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_remap.c:231
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
uninit
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_remap.c:353
RemapContext
Definition: vf_remap.c:48
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:188
remap_outputs
static const AVFilterPad remap_outputs[]
Definition: vf_remap.c:377
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:125
remap_inputs
static const AVFilterPad remap_inputs[]
Definition: vf_remap.c:360
FLAGS
#define FLAGS
Definition: vf_remap.c:62
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:223
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:116
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_remap.c:80
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:565
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:232