FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
Data Structures | Macros | Enumerations | Functions | Variables
vf_tonemap.c File Reference

tonemap algorithms More...

#include <float.h>
#include <stdio.h>
#include <string.h>
#include "libavutil/imgutils.h"
#include "libavutil/internal.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/mastering_display_metadata.h"
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avfilter.h"
#include "formats.h"
#include "internal.h"
#include "video.h"

Go to the source code of this file.

Data Structures

struct  LumaCoefficients
 
struct  TonemapContext
 

Macros

#define REFERENCE_WHITE   100.0f
 
#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
}
 

Functions

static int query_formats (AVFilterContext *ctx)
 
static av_cold int init (AVFilterContext *ctx)
 
static double determine_signal_peak (AVFrame *in)
 
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 filter_frame (AVFilterLink *link, AVFrame *in)
 

Variables

static const struct
LumaCoefficients 
luma_coefficients [AVCOL_SPC_NB]
 
static enum AVPixelFormat pix_fmts []
 
static const AVOption tonemap_options []
 
static const AVClass tonemap_class
 
static const AVFilterPad tonemap_inputs []
 
static const AVFilterPad tonemap_outputs []
 
AVFilter ff_vf_tonemap
 

Detailed Description

tonemap algorithms

Definition in file vf_tonemap.c.

Macro Definition Documentation

#define REFERENCE_WHITE   100.0f

Definition at line 42 of file vf_tonemap.c.

Referenced by determine_signal_peak().

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

Definition at line 161 of file vf_tonemap.c.

Referenced by tonemap().

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

Definition at line 303 of file vf_tonemap.c.

Definition at line 304 of file vf_tonemap.c.

Enumeration Type Documentation

Enumerator
TONEMAP_NONE 
TONEMAP_LINEAR 
TONEMAP_GAMMA 
TONEMAP_CLIP 
TONEMAP_REINHARD 
TONEMAP_HABLE 
TONEMAP_MOBIUS 
TONEMAP_MAX 

Definition at line 44 of file vf_tonemap.c.

Function Documentation

static int query_formats ( AVFilterContext ctx)
static

Definition at line 87 of file vf_tonemap.c.

static av_cold int init ( AVFilterContext ctx)
static

Definition at line 92 of file vf_tonemap.c.

static double determine_signal_peak ( AVFrame in)
static

Definition at line 117 of file vf_tonemap.c.

Referenced by filter_frame().

static float hable ( float  in)
static

Definition at line 142 of file vf_tonemap.c.

Referenced by tonemap().

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

Definition at line 148 of file vf_tonemap.c.

Referenced by tonemap().

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

Definition at line 162 of file vf_tonemap.c.

Referenced by filter_frame(), and register_all().

static int filter_frame ( AVFilterLink link,
AVFrame in 
)
static

Definition at line 226 of file vf_tonemap.c.

Variable Documentation

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 },
}
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
Definition: pixfmt.h:486
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 ...
Definition: pixfmt.h:490
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
Definition: pixfmt.h:491
functionally identical to above
Definition: pixfmt.h:492
ITU-R BT2020 non-constant luminance system.
Definition: pixfmt.h:495
FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
Definition: pixfmt.h:489
ITU-R BT2020 constant luminance system.
Definition: pixfmt.h:496

Definition at line 60 of file vf_tonemap.c.

enum AVPixelFormat pix_fmts[]
static
Initial value:
= {
}
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:408
#define AV_PIX_FMT_GBRAPF32
Definition: pixfmt.h:409

Definition at line 81 of file vf_tonemap.c.

Referenced by query_formats().

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 }
}
#define NULL
Definition: coverity.c:32
#define FLAGS
Definition: vf_tonemap.c:304
#define NAN
Definition: math.h:28
#define OFFSET(x)
Definition: vf_tonemap.c:303
static void tonemap(TonemapContext *s, AVFrame *out, const AVFrame *in, const AVPixFmtDescriptor *desc, int x, int y, double peak)
Definition: vf_tonemap.c:162

Definition at line 305 of file vf_tonemap.c.

const AVClass tonemap_class
static
Initial value:
= {
.class_name = "tonemap",
.item_name = av_default_item_name,
.option = tonemap_options,
}
#define LIBAVUTIL_VERSION_INT
Definition: version.h:86
static const AVOption tonemap_options[]
Definition: vf_tonemap.c:305
av_default_item_name

Definition at line 320 of file vf_tonemap.c.

const AVFilterPad tonemap_inputs[]
static
Initial value:
= {
{
.name = "default",
.filter_frame = filter_frame,
},
{ NULL }
}
#define NULL
Definition: coverity.c:32
static int filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_tonemap.c:226

Definition at line 328 of file vf_tonemap.c.

const AVFilterPad tonemap_outputs[]
static
Initial value:
= {
{
.name = "default",
},
{ NULL }
}
#define NULL
Definition: coverity.c:32

Definition at line 337 of file vf_tonemap.c.

AVFilter ff_vf_tonemap
Initial value:
= {
.name = "tonemap",
.description = NULL_IF_CONFIG_SMALL("Conversion to/from different dynamic ranges."),
.init = init,
.query_formats = query_formats,
.priv_size = sizeof(TonemapContext),
.priv_class = &tonemap_class,
}
static int query_formats(AVFilterContext *ctx)
Definition: vf_tonemap.c:87
static const AVFilterPad tonemap_outputs[]
Definition: vf_tonemap.c:337
static const AVClass tonemap_class
Definition: vf_tonemap.c:320
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:179
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:389
static av_cold int init(AVFilterContext *ctx)
Definition: vf_tonemap.c:92
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:379
static const AVFilterPad tonemap_inputs[]
Definition: vf_tonemap.c:328

Definition at line 345 of file vf_tonemap.c.