FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vf_tonemap.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 Vittorio Giovara <vittorio.giovara@gmail.com>
3  *
4  * This file is part of FFmpeg.
5  *
6  * FFmpeg is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or (at your option) any later version.
10  *
11  * FFmpeg is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with FFmpeg; if not, write to the Free Software
18  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19  */
20 
21 /**
22  * @file
23  * tonemap algorithms
24  */
25 
26 #include <float.h>
27 #include <stdio.h>
28 #include <string.h>
29 
30 #include "libavutil/imgutils.h"
31 #include "libavutil/internal.h"
32 #include "libavutil/intreadwrite.h"
34 #include "libavutil/opt.h"
35 #include "libavutil/pixdesc.h"
36 
37 #include "avfilter.h"
38 #include "formats.h"
39 #include "internal.h"
40 #include "video.h"
41 
42 #define REFERENCE_WHITE 100.0f
43 
53 };
54 
55 typedef struct LumaCoefficients {
56  double cr, cg, cb;
58 
59 
61  [AVCOL_SPC_FCC] = { 0.30, 0.59, 0.11 },
62  [AVCOL_SPC_BT470BG] = { 0.299, 0.587, 0.114 },
63  [AVCOL_SPC_SMPTE170M] = { 0.299, 0.587, 0.114 },
64  [AVCOL_SPC_BT709] = { 0.2126, 0.7152, 0.0722 },
65  [AVCOL_SPC_SMPTE240M] = { 0.212, 0.701, 0.087 },
66  [AVCOL_SPC_BT2020_NCL] = { 0.2627, 0.6780, 0.0593 },
67  [AVCOL_SPC_BT2020_CL] = { 0.2627, 0.6780, 0.0593 },
68 };
69 
70 typedef struct TonemapContext {
71  const AVClass *class;
72 
74  double param;
75  double desat;
76  double peak;
77 
80 
81 static const enum AVPixelFormat pix_fmts[] = {
85 };
86 
88 {
90 }
91 
93 {
94  TonemapContext *s = ctx->priv;
95 
96  switch(s->tonemap) {
97  case TONEMAP_GAMMA:
98  if (isnan(s->param))
99  s->param = 1.8f;
100  break;
101  case TONEMAP_REINHARD:
102  if (!isnan(s->param))
103  s->param = (1.0f - s->param) / s->param;
104  break;
105  case TONEMAP_MOBIUS:
106  if (isnan(s->param))
107  s->param = 0.3f;
108  break;
109  }
110 
111  if (isnan(s->param))
112  s->param = 1.0f;
113 
114  return 0;
115 }
116 
118 {
120  double peak = 0;
121 
122  if (sd) {
124  peak = clm->MaxCLL / REFERENCE_WHITE;
125  }
126 
128  if (!peak && sd) {
130  if (metadata->has_luminance)
131  peak = av_q2d(metadata->max_luminance) / REFERENCE_WHITE;
132  }
133 
134  /* smpte2084 needs the side data above to work correctly
135  * if missing, assume that the original transfer was arib-std-b67 */
136  if (!peak)
137  peak = 12;
138 
139  return peak;
140 }
141 
142 static float hable(float in)
143 {
144  float a = 0.15f, b = 0.50f, c = 0.10f, d = 0.20f, e = 0.02f, f = 0.30f;
145  return (in * (in * a + b * c) + d * e) / (in * (in * a + b) + d * f) - e / f;
146 }
147 
148 static float mobius(float in, float j, double peak)
149 {
150  float a, b;
151 
152  if (in <= j)
153  return in;
154 
155  a = -j * j * (peak - 1.0f) / (j * j - 2.0f * j + peak);
156  b = (j * j - 2.0f * j * peak + peak) / FFMAX(peak - 1.0f, 1e-6);
157 
158  return (b * b + 2.0f * b * j + j * j) / (b - a) * (in + a) / (in + b);
159 }
160 
161 #define MIX(x,y,a) (x) * (1 - (a)) + (y) * (a)
162 static void tonemap(TonemapContext *s, AVFrame *out, const AVFrame *in,
163  const AVPixFmtDescriptor *desc, int x, int y, double peak)
164 {
165  const float *r_in = (const float *)(in->data[0] + x * desc->comp[0].step + y * in->linesize[0]);
166  const float *b_in = (const float *)(in->data[1] + x * desc->comp[1].step + y * in->linesize[1]);
167  const float *g_in = (const float *)(in->data[2] + x * desc->comp[2].step + y * in->linesize[2]);
168  float *r_out = (float *)(out->data[0] + x * desc->comp[0].step + y * out->linesize[0]);
169  float *b_out = (float *)(out->data[1] + x * desc->comp[1].step + y * out->linesize[1]);
170  float *g_out = (float *)(out->data[2] + x * desc->comp[2].step + y * out->linesize[2]);
171  float sig, sig_orig;
172 
173  /* load values */
174  *r_out = *r_in;
175  *b_out = *b_in;
176  *g_out = *g_in;
177 
178  /* desaturate to prevent unnatural colors */
179  if (s->desat > 0) {
180  float luma = s->coeffs->cr * *r_in + s->coeffs->cg * *g_in + s->coeffs->cb * *b_in;
181  float overbright = FFMAX(luma - s->desat, 1e-6) / FFMAX(luma, 1e-6);
182  *r_out = MIX(*r_in, luma, overbright);
183  *g_out = MIX(*g_in, luma, overbright);
184  *b_out = MIX(*b_in, luma, overbright);
185  }
186 
187  /* pick the brightest component, reducing the value range as necessary
188  * to keep the entire signal in range and preventing discoloration due to
189  * out-of-bounds clipping */
190  sig = FFMAX(FFMAX3(*r_out, *g_out, *b_out), 1e-6);
191  sig_orig = sig;
192 
193  switch(s->tonemap) {
194  default:
195  case TONEMAP_NONE:
196  // do nothing
197  break;
198  case TONEMAP_LINEAR:
199  sig = sig * s->param / peak;
200  break;
201  case TONEMAP_GAMMA:
202  sig = sig > 0.05f ? pow(sig / peak, 1.0f / s->param)
203  : sig * pow(0.05f / peak, 1.0f / s->param) / 0.05f;
204  break;
205  case TONEMAP_CLIP:
206  sig = av_clipf(sig * s->param, 0, 1.0f);
207  break;
208  case TONEMAP_HABLE:
209  sig = hable(sig) / hable(peak);
210  break;
211  case TONEMAP_REINHARD:
212  sig = sig / (sig + s->param) * (peak + s->param) / peak;
213  break;
214  case TONEMAP_MOBIUS:
215  sig = mobius(sig, s->param, peak);
216  break;
217  }
218 
219  /* apply the computed scale factor to the color,
220  * linearly to prevent discoloration */
221  *r_out *= sig / sig_orig;
222  *g_out *= sig / sig_orig;
223  *b_out *= sig / sig_orig;
224 }
225 
226 static int filter_frame(AVFilterLink *link, AVFrame *in)
227 {
228  TonemapContext *s = link->dst->priv;
229  AVFilterLink *outlink = link->dst->outputs[0];
230  AVFrame *out;
232  const AVPixFmtDescriptor *odesc = av_pix_fmt_desc_get(outlink->format);
233  int ret, x, y;
234  double peak = s->peak;
235 
236  if (!desc || !odesc) {
237  av_frame_free(&in);
238  return AVERROR_BUG;
239  }
240 
241  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
242  if (!out) {
243  av_frame_free(&in);
244  return AVERROR(ENOMEM);
245  }
246 
247  ret = av_frame_copy_props(out, in);
248  if (ret < 0) {
249  av_frame_free(&in);
250  av_frame_free(&out);
251  return ret;
252  }
253 
254  /* input and output transfer will be linear */
255  if (in->color_trc == AVCOL_TRC_UNSPECIFIED) {
256  av_log(s, AV_LOG_WARNING, "Untagged transfer, assuming linear light\n");
258  } else if (in->color_trc != AVCOL_TRC_LINEAR)
259  av_log(s, AV_LOG_WARNING, "Tonemapping works on linear light only\n");
260 
261  /* read peak from side data if not passed in */
262  if (!peak) {
263  peak = determine_signal_peak(in);
264  av_log(s, AV_LOG_DEBUG, "Computed signal peak: %f\n", peak);
265  }
266 
267  /* load original color space even if pixel format is RGB to compute overbrights */
268  s->coeffs = &luma_coefficients[in->colorspace];
269  if (s->desat > 0 && (in->colorspace == AVCOL_SPC_UNSPECIFIED || !s->coeffs)) {
271  av_log(s, AV_LOG_WARNING, "Missing color space information, ");
272  else if (!s->coeffs)
273  av_log(s, AV_LOG_WARNING, "Unsupported color space '%s', ",
275  av_log(s, AV_LOG_WARNING, "desaturation is disabled\n");
276  s->desat = 0;
277  }
278 
279  /* do the tone map */
280  for (y = 0; y < out->height; y++)
281  for (x = 0; x < out->width; x++)
282  tonemap(s, out, in, desc, x, y, peak);
283 
284  /* copy/generate alpha if needed */
285  if (desc->flags & AV_PIX_FMT_FLAG_ALPHA && odesc->flags & AV_PIX_FMT_FLAG_ALPHA) {
286  av_image_copy_plane(out->data[3], out->linesize[3],
287  in->data[3], in->linesize[3],
288  out->linesize[3], outlink->h);
289  } else if (odesc->flags & AV_PIX_FMT_FLAG_ALPHA) {
290  for (y = 0; y < out->height; y++) {
291  for (x = 0; x < out->width; x++) {
292  AV_WN32(out->data[3] + x * odesc->comp[3].step + y * out->linesize[3],
293  av_float2int(1.0f));
294  }
295  }
296  }
297 
298  av_frame_free(&in);
299 
300  return ff_filter_frame(outlink, out);
301 }
302 
303 #define OFFSET(x) offsetof(TonemapContext, x)
304 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
305 static const AVOption tonemap_options[] = {
306  { "tonemap", "tonemap algorithm selection", OFFSET(tonemap), AV_OPT_TYPE_INT, {.i64 = TONEMAP_NONE}, TONEMAP_NONE, TONEMAP_MAX - 1, FLAGS, "tonemap" },
307  { "none", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_NONE}, 0, 0, FLAGS, "tonemap" },
308  { "linear", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_LINEAR}, 0, 0, FLAGS, "tonemap" },
309  { "gamma", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_GAMMA}, 0, 0, FLAGS, "tonemap" },
310  { "clip", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_CLIP}, 0, 0, FLAGS, "tonemap" },
311  { "reinhard", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_REINHARD}, 0, 0, FLAGS, "tonemap" },
312  { "hable", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_HABLE}, 0, 0, FLAGS, "tonemap" },
313  { "mobius", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_MOBIUS}, 0, 0, FLAGS, "tonemap" },
314  { "param", "tonemap parameter", OFFSET(param), AV_OPT_TYPE_DOUBLE, {.dbl = NAN}, DBL_MIN, DBL_MAX, FLAGS },
315  { "desat", "desaturation strength", OFFSET(desat), AV_OPT_TYPE_DOUBLE, {.dbl = 2}, 0, DBL_MAX, FLAGS },
316  { "peak", "signal peak override", OFFSET(peak), AV_OPT_TYPE_DOUBLE, {.dbl = 0}, 0, DBL_MAX, FLAGS },
317  { NULL }
318 };
319 
320 static const AVClass tonemap_class = {
321  .class_name = "tonemap",
322  .item_name = av_default_item_name,
323  .option = tonemap_options,
324  .version = LIBAVUTIL_VERSION_INT,
325  .category = AV_CLASS_CATEGORY_FILTER,
326 };
327 
328 static const AVFilterPad tonemap_inputs[] = {
329  {
330  .name = "default",
331  .type = AVMEDIA_TYPE_VIDEO,
332  .filter_frame = filter_frame,
333  },
334  { NULL }
335 };
336 
337 static const AVFilterPad tonemap_outputs[] = {
338  {
339  .name = "default",
340  .type = AVMEDIA_TYPE_VIDEO,
341  },
342  { NULL }
343 };
344 
346  .name = "tonemap",
347  .description = NULL_IF_CONFIG_SMALL("Conversion to/from different dynamic ranges."),
348  .init = init,
349  .query_formats = query_formats,
350  .priv_size = sizeof(TonemapContext),
351  .priv_class = &tonemap_class,
352  .inputs = tonemap_inputs,
353  .outputs = tonemap_outputs,
354 };
static double determine_signal_peak(AVFrame *in)
Definition: vf_tonemap.c:117
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
Definition: pixfmt.h:486
#define NULL
Definition: coverity.c:32
const char * s
Definition: avisynth_c.h:768
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2419
This structure describes decoded (raw) audio or video data.
Definition: frame.h:201
unsigned MaxCLL
Max content light level (cd/m^2).
AVOption.
Definition: opt.h:246
"Linear transfer characteristics"
Definition: pixfmt.h:464
misc image utilities
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
#define LIBAVUTIL_VERSION_INT
Definition: version.h:86
Main libavfilter public API header.
const char * desc
Definition: nvenc.c:60
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
Content light level (based on CTA-861.3).
Definition: frame.h:136
#define MIX(x, y, a)
Definition: vf_tonemap.c:161
const char * b
Definition: vf_curves.c:113
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
Definition: pixfmt.h:491
Mastering display metadata associated with a video frame.
Definition: frame.h:119
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:92
#define REFERENCE_WHITE
Definition: vf_tonemap.c:42
functionally identical to above
Definition: pixfmt.h:492
const char * av_color_space_name(enum AVColorSpace space)
Definition: pixdesc.c:2803
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
AVFrameSideData * av_frame_get_side_data(const AVFrame *frame, enum AVFrameSideDataType type)
Definition: frame.c:682
const char * name
Pad name.
Definition: internal.h:60
const char * class_name
The name of the class; usually it is the same name as the context structure type to which the AVClass...
Definition: log.h:72
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1151
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:117
#define av_cold
Definition: attributes.h:82
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
Definition: pixdesc.h:173
AVOptions.
static int query_formats(AVFilterContext *ctx)
Definition: vf_tonemap.c:87
Structure to hold side data for an AVFrame.
Definition: frame.h:163
#define FLAGS
Definition: vf_tonemap.c:304
static double av_q2d(AVRational a)
Convert an AVRational to a double.
Definition: rational.h:104
static const AVFilterPad tonemap_outputs[]
Definition: vf_tonemap.c:337
int has_luminance
Flag indicating whether the luminance (min_ and max_) have been set.
static const struct LumaCoefficients luma_coefficients[AVCOL_SPC_NB]
Definition: vf_tonemap.c:60
#define av_log(a,...)
static const AVOption tonemap_options[]
Definition: vf_tonemap.c:305
A filter pad used for either input or output.
Definition: internal.h:54
Content light level needed by to transmit HDR over HDMI (CTA-861.3).
int width
Definition: frame.h:259
int ff_set_common_formats(AVFilterContext *ctx, AVFilterFormats *formats)
A helper for query_formats() which sets all links to the same list of formats.
Definition: formats.c:568
av_default_item_name
#define AVERROR(e)
Definition: error.h:43
static const AVClass tonemap_class
Definition: vf_tonemap.c:320
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:163
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:179
void * priv
private data for use by the filter
Definition: avfilter.h:353
#define AV_LOG_DEBUG
Stuff which is only useful for libav* developers.
Definition: log.h:197
enum AVColorSpace colorspace
YUV colorspace type.
Definition: frame.h:457
#define FFMAX(a, b)
Definition: common.h:94
AVRational max_luminance
Max luminance of mastering display (cd/m^2).
common internal API header
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:106
static float hable(float in)
Definition: vf_tonemap.c:142
ITU-R BT2020 non-constant luminance system.
Definition: pixfmt.h:495
AVFormatContext * ctx
Definition: movenc.c:48
static const AVFilterPad outputs[]
Definition: af_afftfilt.c:389
static av_cold int init(AVFilterContext *ctx)
Definition: vf_tonemap.c:92
enum TonemapAlgorithm tonemap
Definition: vf_tonemap.c:73
FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
Definition: pixfmt.h:489
static const AVFilterPad inputs[]
Definition: af_afftfilt.c:379
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:232
const LumaCoefficients * coeffs
Definition: vf_tonemap.c:78
double desat
Definition: vf_tonemap.c:75
AVFilter ff_vf_tonemap
Definition: vf_tonemap.c:345
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
uint8_t * data
Definition: frame.h:165
uint8_t pi<< 24) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0f/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_U8, uint8_t,(*(constuint8_t *) pi-0x80)*(1.0/(1<< 7))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S16, int16_t,(*(constint16_t *) pi >>8)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0f/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S16, int16_t,*(constint16_t *) pi *(1.0/(1<< 15))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_S32, int32_t,(*(constint32_t *) pi >>24)+0x80) CONV_FUNC_GROUP(AV_SAMPLE_FMT_FLT, float, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0f/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_DBL, double, AV_SAMPLE_FMT_S32, int32_t,*(constint32_t *) pi *(1.0/(1U<< 31))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_FLT, float, av_clip_uint8(lrintf(*(constfloat *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, float, av_clip_int16(lrintf(*(constfloat *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_FLT, float, av_clipl_int32(llrintf(*(constfloat *) pi *(1U<< 31)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_U8, uint8_t, AV_SAMPLE_FMT_DBL, double, av_clip_uint8(lrint(*(constdouble *) pi *(1<< 7))+0x80)) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_DBL, double, av_clip_int16(lrint(*(constdouble *) pi *(1<< 15)))) CONV_FUNC_GROUP(AV_SAMPLE_FMT_S32, int32_t, AV_SAMPLE_FMT_DBL, double, av_clipl_int32(llrint(*(constdouble *) pi *(1U<< 31))))#defineSET_CONV_FUNC_GROUP(ofmt, ifmt) staticvoidset_generic_function(AudioConvert *ac){}voidff_audio_convert_free(AudioConvert **ac){if(!*ac) return;ff_dither_free(&(*ac) ->dc);av_freep(ac);}AudioConvert *ff_audio_convert_alloc(AVAudioResampleContext *avr, enumAVSampleFormatout_fmt, enumAVSampleFormatin_fmt, intchannels, intsample_rate, intapply_map){AudioConvert *ac;intin_planar, out_planar;ac=av_mallocz(sizeof(*ac));if(!ac) returnNULL;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);returnNULL;}returnac;}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;}elseif(in_planar) ac->func_type=CONV_FUNC_TYPE_INTERLEAVE;elseac->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);returnac;}intff_audio_convert(AudioConvert *ac, AudioData *out, AudioData *in){intuse_generic=1;intlen=in->nb_samples;intp;if(ac->dc){av_log(ac->avr, AV_LOG_TRACE,"%dsamples-audio_convert:%sto%s(dithered)\n", len, av_get_sample_fmt_name(ac->in_fmt), av_get_sample_fmt_name(ac->out_fmt));returnff_convert_dither(ac-> in
TonemapAlgorithm
Definition: vf_tonemap.c:44
#define AVERROR_BUG
Internal bug, also see AVERROR_BUG2.
Definition: error.h:50
Describe the class of an AVClass context structure.
Definition: log.h:67
Filter definition.
Definition: avfilter.h:144
#define isnan(x)
Definition: libm.h:340
Copyright (c) 2016 Neil Birkbeck neil.birkbeck@gmail.com
const char * name
Filter name.
Definition: avfilter.h:148
static av_always_inline uint32_t av_float2int(float f)
Reinterpret a float as a 32-bit integer.
Definition: intfloat.h:50
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:350
static int filter_frame(AVFilterLink *link, AVFrame *in)
Definition: vf_tonemap.c:226
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:215
static enum AVPixelFormat pix_fmts[]
Definition: vf_tonemap.c:81
ITU-R BT2020 constant luminance system.
Definition: pixfmt.h:496
static float mobius(float in, float j, double peak)
Definition: vf_tonemap.c:148
#define AV_PIX_FMT_GBRPF32
Definition: pixfmt.h:408
#define AV_PIX_FMT_GBRAPF32
Definition: pixfmt.h:409
if(ret< 0)
Definition: vf_mcdeint.c:279
#define AV_WN32(p, v)
Definition: intreadwrite.h:381
static double c[64]
#define NAN
Definition: math.h:28
An instance of a filter.
Definition: avfilter.h:338
int height
Definition: frame.h:259
FILE * out
Definition: movenc.c:54
enum AVColorTransferCharacteristic color_trc
Definition: frame.h:450
void av_image_copy_plane(uint8_t *dst, int dst_linesize, const uint8_t *src, int src_linesize, int bytewidth, int height)
Copy image plane from src to dst.
Definition: imgutils.c:337
internal API functions
#define OFFSET(x)
Definition: vf_tonemap.c:303
AVPixelFormat
Pixel format.
Definition: pixfmt.h:60
static const AVFilterPad tonemap_inputs[]
Definition: vf_tonemap.c:328
Not part of ABI.
Definition: pixfmt.h:501
static void tonemap(TonemapContext *s, AVFrame *out, const AVFrame *in, const AVPixFmtDescriptor *desc, int x, int y, double peak)
Definition: vf_tonemap.c:162
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:603
#define FFMAX3(a, b, c)
Definition: common.h:95
int step
Number of elements between 2 horizontally consecutive pixels.
Definition: pixdesc.h:41
double param
Definition: vf_tonemap.c:74