FFmpeg
Loading...
Searching...
No Matches
vf_remap.c File Reference

Pixel remap filter This filter copies pixel by pixel a source frame to a target frame. More...

#include "libavutil/colorspace.h"
#include "libavutil/imgutils.h"
#include "libavutil/pixdesc.h"
#include "libavutil/opt.h"
#include "avfilter.h"
#include "drawutils.h"
#include "filters.h"
#include "formats.h"
#include "framesync.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)
 
#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] ];
 
#define DEFINE_REMAP_PACKED_FUNC(name, bits, div)
 remap_packed algorithm expects pixels with both padded bits (step) and number of components correctly set.
 

Functions

 AVFILTER_DEFINE_CLASS (remap)
 
static int query_formats (const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
 
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 []
 
const FFFilter 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)
Value:
offsetof(RemapContext, x)

Definition at line 65 of file vf_remap.c.

◆ FLAGS

Definition at line 66 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 136 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 187 of file vf_remap.c.

Function Documentation

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( remap )

◆ query_formats()

static int query_formats ( const AVFilterContext * ctx,
AVFilterFormatsConfig ** cfg_in,
AVFilterFormatsConfig ** cfg_out )
static

Definition at line 85 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 275 of file vf_remap.c.

◆ config_output()

static int config_output ( AVFilterLink * outlink)
static

Definition at line 311 of file vf_remap.c.

◆ activate()

static int activate ( AVFilterContext * ctx)
static

Definition at line 363 of file vf_remap.c.

◆ uninit()

static av_cold void uninit ( AVFilterContext * ctx)
static

Definition at line 369 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, .unit = "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" },
{ "fill", "set the color of the unmapped pixels", OFFSET(fill_rgba), AV_OPT_TYPE_COLOR, {.str="black"}, .flags = FLAGS },
{ NULL }
}
static const char *const format[]
Definition af_aiir.c:444
#define FLAGS
Definition cmdutils.c:598
#define NULL
Definition coverity.c:32
#define OFFSET(x)
@ AV_OPT_TYPE_CONST
Special option type for declaring named constants.
Definition opt.h:298
@ AV_OPT_TYPE_INT
Underlying C type is int.
Definition opt.h:258
@ AV_OPT_TYPE_COLOR
Underlying C type is uint8_t[4].
Definition opt.h:322

Definition at line 68 of file vf_remap.c.

◆ remap_inputs

const AVFilterPad remap_inputs[]
static
Initial value:
= {
{
.name = "source",
.config_props = config_input,
},
{
.name = "xmap",
},
{
.name = "ymap",
},
}
static int config_input(AVFilterLink *inlink)
@ AVMEDIA_TYPE_VIDEO
Definition avutil.h:200

Definition at line 376 of file vf_remap.c.

◆ remap_outputs

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

Definition at line 392 of file vf_remap.c.

◆ ff_vf_remap

const FFFilter ff_vf_remap
Initial value:
= {
.p.name = "remap",
.p.description = NULL_IF_CONFIG_SMALL("Remap pixels."),
.p.priv_class = &remap_class,
.priv_size = sizeof(RemapContext),
}
static int query_formats(const AVFilterContext *ctx, AVFilterFormatsConfig **cfg_in, AVFilterFormatsConfig **cfg_out)
Definition aeval.c:246
#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)
static int activate(AVBitStreamFilterContext *ctx)
#define FILTER_INPUTS(array)
Definition filters.h:264
#define FILTER_OUTPUTS(array)
Definition filters.h:265
#define FILTER_QUERY_FUNC2(func)
Definition filters.h:241
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition internal.h:88
static const AVFilterPad remap_inputs[]
Definition vf_remap.c:376
static const AVFilterPad remap_outputs[]
Definition vf_remap.c:392

Definition at line 400 of file vf_remap.c.