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"
33 #include "libavutil/opt.h"
34 #include "libavutil/pixdesc.h"
35 
36 #include "avfilter.h"
37 #include "colorspace.h"
38 #include "formats.h"
39 #include "internal.h"
40 #include "video.h"
41 
51 };
52 
54  [AVCOL_SPC_FCC] = { 0.30, 0.59, 0.11 },
55  [AVCOL_SPC_BT470BG] = { 0.299, 0.587, 0.114 },
56  [AVCOL_SPC_SMPTE170M] = { 0.299, 0.587, 0.114 },
57  [AVCOL_SPC_BT709] = { 0.2126, 0.7152, 0.0722 },
58  [AVCOL_SPC_SMPTE240M] = { 0.212, 0.701, 0.087 },
59  [AVCOL_SPC_BT2020_NCL] = { 0.2627, 0.6780, 0.0593 },
60  [AVCOL_SPC_BT2020_CL] = { 0.2627, 0.6780, 0.0593 },
61 };
62 
63 typedef struct TonemapContext {
64  const AVClass *class;
65 
67  double param;
68  double desat;
69  double peak;
70 
71  const struct LumaCoefficients *coeffs;
73 
74 static const enum AVPixelFormat pix_fmts[] = {
78 };
79 
81 {
83 }
84 
86 {
87  TonemapContext *s = ctx->priv;
88 
89  switch(s->tonemap) {
90  case TONEMAP_GAMMA:
91  if (isnan(s->param))
92  s->param = 1.8f;
93  break;
94  case TONEMAP_REINHARD:
95  if (!isnan(s->param))
96  s->param = (1.0f - s->param) / s->param;
97  break;
98  case TONEMAP_MOBIUS:
99  if (isnan(s->param))
100  s->param = 0.3f;
101  break;
102  }
103 
104  if (isnan(s->param))
105  s->param = 1.0f;
106 
107  return 0;
108 }
109 
110 static float hable(float in)
111 {
112  float a = 0.15f, b = 0.50f, c = 0.10f, d = 0.20f, e = 0.02f, f = 0.30f;
113  return (in * (in * a + b * c) + d * e) / (in * (in * a + b) + d * f) - e / f;
114 }
115 
116 static float mobius(float in, float j, double peak)
117 {
118  float a, b;
119 
120  if (in <= j)
121  return in;
122 
123  a = -j * j * (peak - 1.0f) / (j * j - 2.0f * j + peak);
124  b = (j * j - 2.0f * j * peak + peak) / FFMAX(peak - 1.0f, 1e-6);
125 
126  return (b * b + 2.0f * b * j + j * j) / (b - a) * (in + a) / (in + b);
127 }
128 
129 #define MIX(x,y,a) (x) * (1 - (a)) + (y) * (a)
130 static void tonemap(TonemapContext *s, AVFrame *out, const AVFrame *in,
131  const AVPixFmtDescriptor *desc, int x, int y, double peak)
132 {
133  const float *r_in = (const float *)(in->data[0] + x * desc->comp[0].step + y * in->linesize[0]);
134  const float *b_in = (const float *)(in->data[1] + x * desc->comp[1].step + y * in->linesize[1]);
135  const float *g_in = (const float *)(in->data[2] + x * desc->comp[2].step + y * in->linesize[2]);
136  float *r_out = (float *)(out->data[0] + x * desc->comp[0].step + y * out->linesize[0]);
137  float *b_out = (float *)(out->data[1] + x * desc->comp[1].step + y * out->linesize[1]);
138  float *g_out = (float *)(out->data[2] + x * desc->comp[2].step + y * out->linesize[2]);
139  float sig, sig_orig;
140 
141  /* load values */
142  *r_out = *r_in;
143  *b_out = *b_in;
144  *g_out = *g_in;
145 
146  /* desaturate to prevent unnatural colors */
147  if (s->desat > 0) {
148  float luma = s->coeffs->cr * *r_in + s->coeffs->cg * *g_in + s->coeffs->cb * *b_in;
149  float overbright = FFMAX(luma - s->desat, 1e-6) / FFMAX(luma, 1e-6);
150  *r_out = MIX(*r_in, luma, overbright);
151  *g_out = MIX(*g_in, luma, overbright);
152  *b_out = MIX(*b_in, luma, overbright);
153  }
154 
155  /* pick the brightest component, reducing the value range as necessary
156  * to keep the entire signal in range and preventing discoloration due to
157  * out-of-bounds clipping */
158  sig = FFMAX(FFMAX3(*r_out, *g_out, *b_out), 1e-6);
159  sig_orig = sig;
160 
161  switch(s->tonemap) {
162  default:
163  case TONEMAP_NONE:
164  // do nothing
165  break;
166  case TONEMAP_LINEAR:
167  sig = sig * s->param / peak;
168  break;
169  case TONEMAP_GAMMA:
170  sig = sig > 0.05f ? pow(sig / peak, 1.0f / s->param)
171  : sig * pow(0.05f / peak, 1.0f / s->param) / 0.05f;
172  break;
173  case TONEMAP_CLIP:
174  sig = av_clipf(sig * s->param, 0, 1.0f);
175  break;
176  case TONEMAP_HABLE:
177  sig = hable(sig) / hable(peak);
178  break;
179  case TONEMAP_REINHARD:
180  sig = sig / (sig + s->param) * (peak + s->param) / peak;
181  break;
182  case TONEMAP_MOBIUS:
183  sig = mobius(sig, s->param, peak);
184  break;
185  }
186 
187  /* apply the computed scale factor to the color,
188  * linearly to prevent discoloration */
189  *r_out *= sig / sig_orig;
190  *g_out *= sig / sig_orig;
191  *b_out *= sig / sig_orig;
192 }
193 
194 static int filter_frame(AVFilterLink *link, AVFrame *in)
195 {
196  TonemapContext *s = link->dst->priv;
197  AVFilterLink *outlink = link->dst->outputs[0];
198  AVFrame *out;
200  const AVPixFmtDescriptor *odesc = av_pix_fmt_desc_get(outlink->format);
201  int ret, x, y;
202  double peak = s->peak;
203 
204  if (!desc || !odesc) {
205  av_frame_free(&in);
206  return AVERROR_BUG;
207  }
208 
209  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
210  if (!out) {
211  av_frame_free(&in);
212  return AVERROR(ENOMEM);
213  }
214 
215  ret = av_frame_copy_props(out, in);
216  if (ret < 0) {
217  av_frame_free(&in);
218  av_frame_free(&out);
219  return ret;
220  }
221 
222  /* input and output transfer will be linear */
223  if (in->color_trc == AVCOL_TRC_UNSPECIFIED) {
224  av_log(s, AV_LOG_WARNING, "Untagged transfer, assuming linear light\n");
226  } else if (in->color_trc != AVCOL_TRC_LINEAR)
227  av_log(s, AV_LOG_WARNING, "Tonemapping works on linear light only\n");
228 
229  /* read peak from side data if not passed in */
230  if (!peak) {
231  peak = ff_determine_signal_peak(in);
232  av_log(s, AV_LOG_DEBUG, "Computed signal peak: %f\n", peak);
233  }
234 
235  /* load original color space even if pixel format is RGB to compute overbrights */
236  s->coeffs = &luma_coefficients[in->colorspace];
237  if (s->desat > 0 && (in->colorspace == AVCOL_SPC_UNSPECIFIED || !s->coeffs)) {
239  av_log(s, AV_LOG_WARNING, "Missing color space information, ");
240  else if (!s->coeffs)
241  av_log(s, AV_LOG_WARNING, "Unsupported color space '%s', ",
243  av_log(s, AV_LOG_WARNING, "desaturation is disabled\n");
244  s->desat = 0;
245  }
246 
247  /* do the tone map */
248  for (y = 0; y < out->height; y++)
249  for (x = 0; x < out->width; x++)
250  tonemap(s, out, in, desc, x, y, peak);
251 
252  /* copy/generate alpha if needed */
253  if (desc->flags & AV_PIX_FMT_FLAG_ALPHA && odesc->flags & AV_PIX_FMT_FLAG_ALPHA) {
254  av_image_copy_plane(out->data[3], out->linesize[3],
255  in->data[3], in->linesize[3],
256  out->linesize[3], outlink->h);
257  } else if (odesc->flags & AV_PIX_FMT_FLAG_ALPHA) {
258  for (y = 0; y < out->height; y++) {
259  for (x = 0; x < out->width; x++) {
260  AV_WN32(out->data[3] + x * odesc->comp[3].step + y * out->linesize[3],
261  av_float2int(1.0f));
262  }
263  }
264  }
265 
266  av_frame_free(&in);
267 
268  ff_update_hdr_metadata(out, peak);
269 
270  return ff_filter_frame(outlink, out);
271 }
272 
273 #define OFFSET(x) offsetof(TonemapContext, x)
274 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM | AV_OPT_FLAG_FILTERING_PARAM
275 static const AVOption tonemap_options[] = {
276  { "tonemap", "tonemap algorithm selection", OFFSET(tonemap), AV_OPT_TYPE_INT, {.i64 = TONEMAP_NONE}, TONEMAP_NONE, TONEMAP_MAX - 1, FLAGS, "tonemap" },
277  { "none", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_NONE}, 0, 0, FLAGS, "tonemap" },
278  { "linear", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_LINEAR}, 0, 0, FLAGS, "tonemap" },
279  { "gamma", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_GAMMA}, 0, 0, FLAGS, "tonemap" },
280  { "clip", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_CLIP}, 0, 0, FLAGS, "tonemap" },
281  { "reinhard", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_REINHARD}, 0, 0, FLAGS, "tonemap" },
282  { "hable", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_HABLE}, 0, 0, FLAGS, "tonemap" },
283  { "mobius", 0, 0, AV_OPT_TYPE_CONST, {.i64 = TONEMAP_MOBIUS}, 0, 0, FLAGS, "tonemap" },
284  { "param", "tonemap parameter", OFFSET(param), AV_OPT_TYPE_DOUBLE, {.dbl = NAN}, DBL_MIN, DBL_MAX, FLAGS },
285  { "desat", "desaturation strength", OFFSET(desat), AV_OPT_TYPE_DOUBLE, {.dbl = 2}, 0, DBL_MAX, FLAGS },
286  { "peak", "signal peak override", OFFSET(peak), AV_OPT_TYPE_DOUBLE, {.dbl = 0}, 0, DBL_MAX, FLAGS },
287  { NULL }
288 };
289 
290 static const AVClass tonemap_class = {
291  .class_name = "tonemap",
292  .item_name = av_default_item_name,
293  .option = tonemap_options,
294  .version = LIBAVUTIL_VERSION_INT,
295  .category = AV_CLASS_CATEGORY_FILTER,
296 };
297 
298 static const AVFilterPad tonemap_inputs[] = {
299  {
300  .name = "default",
301  .type = AVMEDIA_TYPE_VIDEO,
302  .filter_frame = filter_frame,
303  },
304  { NULL }
305 };
306 
307 static const AVFilterPad tonemap_outputs[] = {
308  {
309  .name = "default",
310  .type = AVMEDIA_TYPE_VIDEO,
311  },
312  { NULL }
313 };
314 
316  .name = "tonemap",
317  .description = NULL_IF_CONFIG_SMALL("Conversion to/from different dynamic ranges."),
318  .init = init,
319  .query_formats = query_formats,
320  .priv_size = sizeof(TonemapContext),
321  .priv_class = &tonemap_class,
322  .inputs = tonemap_inputs,
323  .outputs = tonemap_outputs,
324 };
also ITU-R BT1361 / IEC 61966-2-4 xvYCC709 / SMPTE RP177 Annex B
Definition: pixfmt.h:488
#define NULL
Definition: coverity.c:32
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2446
This structure describes decoded (raw) audio or video data.
Definition: frame.h:226
AVOption.
Definition: opt.h:246
"Linear transfer characteristics"
Definition: pixfmt.h:466
misc image utilities
#define AV_LOG_WARNING
Something somehow does not look correct.
Definition: log.h:182
#define LIBAVUTIL_VERSION_INT
Definition: version.h:85
Main libavfilter public API header.
const char * desc
Definition: nvenc.c:65
also ITU-R BT601-6 625 / ITU-R BT1358 625 / ITU-R BT1700 625 PAL & SECAM / IEC 61966-2-4 xvYCC601 ...
Definition: pixfmt.h:492
#define MIX(x, y, a)
Definition: vf_tonemap.c:129
const char * b
Definition: vf_curves.c:116
const char * av_default_item_name(void *ptr)
Return the context name.
Definition: log.c:191
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC
Definition: pixfmt.h:493
const struct LumaCoefficients * coeffs
Definition: vf_tonemap.c:71
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:99
functionally identical to above
Definition: pixfmt.h:494
const char * av_color_space_name(enum AVColorSpace space)
Definition: pixdesc.c:2839
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
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:1080
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:177
AVOptions.
#define f(width, name)
Definition: cbs_vp9.c:255
static int query_formats(AVFilterContext *ctx)
Definition: vf_tonemap.c:80
#define FLAGS
Definition: vf_tonemap.c:274
static const AVFilterPad tonemap_outputs[]
Definition: vf_tonemap.c:307
static const struct LumaCoefficients luma_coefficients[AVCOL_SPC_NB]
Definition: vf_tonemap.c:53
#define av_log(a,...)
static const AVOption tonemap_options[]
Definition: vf_tonemap.c:275
A filter pad used for either input or output.
Definition: internal.h:54
int width
Definition: frame.h:284
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
#define AVERROR(e)
Definition: error.h:43
static const AVClass tonemap_class
Definition: vf_tonemap.c:290
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:202
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:186
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:482
#define FFMAX(a, b)
Definition: common.h:94
common internal API header
uint64_t flags
Combination of AV_PIX_FMT_FLAG_...
Definition: pixdesc.h:106
#define NAN
Definition: mathematics.h:64
static float hable(float in)
Definition: vf_tonemap.c:110
ITU-R BT2020 non-constant luminance system.
Definition: pixfmt.h:497
AVFormatContext * ctx
Definition: movenc.c:48
#define s(width, name)
Definition: cbs_vp9.c:257
static av_cold int init(AVFilterContext *ctx)
Definition: vf_tonemap.c:85
static const AVFilterPad inputs[]
Definition: af_acontrast.c:193
enum TonemapAlgorithm tonemap
Definition: vf_tonemap.c:66
FCC Title 47 Code of Federal Regulations 73.682 (a)(20)
Definition: pixfmt.h:491
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
void ff_update_hdr_metadata(AVFrame *in, double peak)
Definition: colorspace.c:122
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:257
double desat
Definition: vf_tonemap.c:68
AVFilter ff_vf_tonemap
Definition: vf_tonemap.c:315
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 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:42
#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
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:194
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:240
static enum AVPixelFormat pix_fmts[]
Definition: vf_tonemap.c:74
ITU-R BT2020 constant luminance system.
Definition: pixfmt.h:498
static float mobius(float in, float j, double peak)
Definition: vf_tonemap.c:116
#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:376
static double c[64]
An instance of a filter.
Definition: avfilter.h:338
int height
Definition: frame.h:284
FILE * out
Definition: movenc.c:54
enum AVColorTransferCharacteristic color_trc
Definition: frame.h:475
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:338
internal API functions
#define OFFSET(x)
Definition: vf_tonemap.c:273
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
static const AVFilterPad tonemap_inputs[]
Definition: vf_tonemap.c:298
double ff_determine_signal_peak(AVFrame *in)
Definition: colorspace.c:97
Not part of ABI.
Definition: pixfmt.h:503
static void tonemap(TonemapContext *s, AVFrame *out, const AVFrame *in, const AVPixFmtDescriptor *desc, int x, int y, double peak)
Definition: vf_tonemap.c:130
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:654
#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:67