FFmpeg
Data Structures | Macros | Enumerations | Functions | Variables
vf_tonemap.c File Reference
#include <float.h>
#include <stdio.h>
#include <string.h>
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "colorspace.h"
#include "formats.h"
#include "internal.h"
#include "video.h"

Go to the source code of this file.

Data Structures

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

Macros

#define MIX(x, y, a)   (x) * (1 - (a)) + (y) * (a)
 
#define OFFSET(x)   offsetof(TonemapContext, x)
 
#define FLAGS   AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
 

Enumerations

enum  TonemapAlgorithm {
  TONEMAP_NONE, TONEMAP_LINEAR, TONEMAP_GAMMA, TONEMAP_CLIP,
  TONEMAP_REINHARD, TONEMAP_HABLE, TONEMAP_MOBIUS, TONEMAP_MAX,
  TONEMAP_NONE, TONEMAP_LINEAR, TONEMAP_GAMMA, TONEMAP_CLIP,
  TONEMAP_REINHARD, TONEMAP_HABLE, TONEMAP_MOBIUS, TONEMAP_MAX
}
 

Functions

static av_cold int init (AVFilterContext *ctx)
 
static float hable (float in)
 
static float mobius (float in, float j, double peak)
 
static void tonemap (TonemapContext *s, AVFrame *out, const AVFrame *in, const AVPixFmtDescriptor *desc, int x, int y, double peak)
 
static int tonemap_slice (AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
 
static int filter_frame (AVFilterLink *link, AVFrame *in)
 
 AVFILTER_DEFINE_CLASS (tonemap)
 

Variables

static const struct LumaCoefficients luma_coefficients [AVCOL_SPC_NB]
 
static const AVOption tonemap_options []
 
static const AVFilterPad tonemap_inputs []
 
static const AVFilterPad tonemap_outputs []
 
const AVFilter ff_vf_tonemap
 

Detailed Description

tonemap algorithms

Definition in file vf_tonemap.c.

Macro Definition Documentation

◆ MIX

#define MIX (   x,
  y,
  a 
)    (x) * (1 - (a)) + (y) * (a)

Definition at line 118 of file vf_tonemap.c.

◆ OFFSET

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

Definition at line 292 of file vf_tonemap.c.

◆ FLAGS

Definition at line 293 of file vf_tonemap.c.

Enumeration Type Documentation

◆ TonemapAlgorithm

Enumerator
TONEMAP_NONE 
TONEMAP_LINEAR 
TONEMAP_GAMMA 
TONEMAP_CLIP 
TONEMAP_REINHARD 
TONEMAP_HABLE 
TONEMAP_MOBIUS 
TONEMAP_MAX 
TONEMAP_NONE 
TONEMAP_LINEAR 
TONEMAP_GAMMA 
TONEMAP_CLIP 
TONEMAP_REINHARD 
TONEMAP_HABLE 
TONEMAP_MOBIUS 
TONEMAP_MAX 

Definition at line 42 of file vf_tonemap.c.

Function Documentation

◆ init()

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 74 of file vf_tonemap.c.

◆ hable()

static float hable ( float  in)
static

Definition at line 99 of file vf_tonemap.c.

Referenced by tonemap().

◆ mobius()

static float mobius ( float  in,
float  j,
double  peak 
)
static

Definition at line 105 of file vf_tonemap.c.

Referenced by tonemap().

◆ tonemap()

static void tonemap ( TonemapContext s,
AVFrame out,
const AVFrame in,
const AVPixFmtDescriptor desc,
int  x,
int  y,
double  peak 
)
static

Definition at line 119 of file vf_tonemap.c.

Referenced by tonemap_slice().

◆ tonemap_slice()

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

Definition at line 190 of file vf_tonemap.c.

Referenced by filter_frame().

◆ filter_frame()

static int filter_frame ( AVFilterLink link,
AVFrame in 
)
static

Definition at line 208 of file vf_tonemap.c.

◆ AVFILTER_DEFINE_CLASS()

AVFILTER_DEFINE_CLASS ( tonemap  )

Variable Documentation

◆ luma_coefficients

const struct LumaCoefficients luma_coefficients[AVCOL_SPC_NB]
static
Initial value:
= {
[AVCOL_SPC_FCC] = { 0.30, 0.59, 0.11 },
[AVCOL_SPC_BT470BG] = { 0.299, 0.587, 0.114 },
[AVCOL_SPC_SMPTE170M] = { 0.299, 0.587, 0.114 },
[AVCOL_SPC_BT709] = { 0.2126, 0.7152, 0.0722 },
[AVCOL_SPC_SMPTE240M] = { 0.212, 0.701, 0.087 },
[AVCOL_SPC_BT2020_NCL] = { 0.2627, 0.6780, 0.0593 },
[AVCOL_SPC_BT2020_CL] = { 0.2627, 0.6780, 0.0593 },
}

Definition at line 53 of file vf_tonemap.c.

Referenced by filter_frame().

◆ tonemap_options

const AVOption tonemap_options[]
static
Initial value:
= {
{ "tonemap", "tonemap algorithm selection", OFFSET(tonemap), AV_OPT_TYPE_INT, {.i64 = TONEMAP_NONE}, TONEMAP_NONE, TONEMAP_MAX - 1, FLAGS, "tonemap" },
{ "none", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_NONE}, 0, 0, FLAGS, "tonemap" },
{ "linear", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_LINEAR}, 0, 0, FLAGS, "tonemap" },
{ "gamma", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_GAMMA}, 0, 0, FLAGS, "tonemap" },
{ "clip", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_CLIP}, 0, 0, FLAGS, "tonemap" },
{ "reinhard", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_REINHARD}, 0, 0, FLAGS, "tonemap" },
{ "hable", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_HABLE}, 0, 0, FLAGS, "tonemap" },
{ "mobius", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_MOBIUS}, 0, 0, FLAGS, "tonemap" },
{ "param", "tonemap parameter", OFFSET(param), AV_OPT_TYPE_DOUBLE, {.dbl = NAN}, DBL_MIN, DBL_MAX, FLAGS },
{ "desat", "desaturation strength", OFFSET(desat), AV_OPT_TYPE_DOUBLE, {.dbl = 2}, 0, DBL_MAX, FLAGS },
{ "peak", "signal peak override", OFFSET(peak), AV_OPT_TYPE_DOUBLE, {.dbl = 0}, 0, DBL_MAX, FLAGS },
{ NULL }
}

Definition at line 294 of file vf_tonemap.c.

◆ tonemap_inputs

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

Definition at line 311 of file vf_tonemap.c.

◆ tonemap_outputs

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

Definition at line 319 of file vf_tonemap.c.

◆ ff_vf_tonemap

const AVFilter ff_vf_tonemap
Initial value:
= {
.name = "tonemap",
.description = NULL_IF_CONFIG_SMALL("Conversion to/from different dynamic ranges."),
.init = init,
.priv_size = sizeof(TonemapContext),
.priv_class = &tonemap_class,
}

Definition at line 326 of file vf_tonemap.c.

TONEMAP_GAMMA
@ TONEMAP_GAMMA
Definition: vf_tonemap.c:45
FLAGS
#define FLAGS
Definition: vf_tonemap.c:293
tonemap_inputs
static const AVFilterPad tonemap_inputs[]
Definition: vf_tonemap.c:311
AVCOL_SPC_BT2020_CL
@ AVCOL_SPC_BT2020_CL
ITU-R BT2020 constant luminance system.
Definition: pixfmt.h:535
tonemap_outputs
static const AVFilterPad tonemap_outputs[]
Definition: vf_tonemap.c:319
AVCOL_SPC_BT470BG
@ AVCOL_SPC_BT470BG
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601
Definition: pixfmt.h:529
tonemap
static void tonemap(TonemapContext *s, AVFrame *out, const AVFrame *in, const AVPixFmtDescriptor *desc, int x, int y, double peak)
Definition: vf_tonemap.c:119
AVCOL_SPC_SMPTE170M
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
Definition: pixfmt.h:530
AV_OPT_TYPE_DOUBLE
@ AV_OPT_TYPE_DOUBLE
Definition: opt.h:226
NAN
#define NAN
Definition: mathematics.h:64
FILTER_INPUTS
#define FILTER_INPUTS(array)
Definition: internal.h:191
init
static av_cold int init(AVFilterContext *ctx)
Definition: vf_tonemap.c:74
NULL
#define NULL
Definition: coverity.c:32
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
FILTER_PIXFMTS
#define FILTER_PIXFMTS(...)
Definition: internal.h:177
AV_PIX_FMT_GBRPF32
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:433
AVCOL_SPC_SMPTE240M
@ AVCOL_SPC_SMPTE240M
derived from 170M primaries and D65 white point, 170M is derived from BT470 System M's primaries
Definition: pixfmt.h:531
AVCOL_SPC_BT2020_NCL
@ AVCOL_SPC_BT2020_NCL
ITU-R BT2020 non-constant luminance system.
Definition: pixfmt.h:534
TONEMAP_CLIP
@ TONEMAP_CLIP
Definition: vf_tonemap.c:46
TonemapContext
Definition: vf_tonemap.c:63
TONEMAP_HABLE
@ TONEMAP_HABLE
Definition: vf_tonemap.c:48
AVCOL_SPC_FCC
@ AVCOL_SPC_FCC
FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
Definition: pixfmt.h:528
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:224
AV_PIX_FMT_GBRAPF32
#define AV_PIX_FMT_GBRAPF32
Definition: pixfmt.h:434
TONEMAP_MAX
@ TONEMAP_MAX
Definition: vf_tonemap.c:50
OFFSET
#define OFFSET(x)
Definition: vf_tonemap.c:292
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:121
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
TONEMAP_NONE
@ TONEMAP_NONE
Definition: vf_tonemap.c:43
FILTER_OUTPUTS
#define FILTER_OUTPUTS(array)
Definition: internal.h:192
filter_frame
static int filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_tonemap.c:208
AVCOL_SPC_BT709
@ AVCOL_SPC_BT709
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / derived in SMPTE RP 177 Annex B
Definition: pixfmt.h:525
TONEMAP_MOBIUS
@ TONEMAP_MOBIUS
Definition: vf_tonemap.c:49
TONEMAP_LINEAR
@ TONEMAP_LINEAR
Definition: vf_tonemap.c:44
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:233
TONEMAP_REINHARD
@ TONEMAP_REINHARD
Definition: vf_tonemap.c:47