FFmpeg  2.6.3
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
vf_colorlevels.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2013 Paul B Mahol
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 #include "libavutil/imgutils.h"
22 #include "libavutil/opt.h"
23 #include "libavutil/pixdesc.h"
24 #include "avfilter.h"
25 #include "drawutils.h"
26 #include "formats.h"
27 #include "internal.h"
28 #include "video.h"
29 
30 #define R 0
31 #define G 1
32 #define B 2
33 #define A 3
34 
35 typedef struct {
36  double in_min, in_max;
37  double out_min, out_max;
38 } Range;
39 
40 typedef struct {
41  const AVClass *class;
42  Range range[4];
43  int nb_comp;
44  int bpp;
45  int step;
46  uint8_t rgba_map[4];
47  int linesize;
49 
50 #define OFFSET(x) offsetof(ColorLevelsContext, x)
51 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
52 static const AVOption colorlevels_options[] = {
53  { "rimin", "set input red black point", OFFSET(range[R].in_min), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -1, 1, FLAGS },
54  { "gimin", "set input green black point", OFFSET(range[G].in_min), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -1, 1, FLAGS },
55  { "bimin", "set input blue black point", OFFSET(range[B].in_min), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -1, 1, FLAGS },
56  { "aimin", "set input alpha black point", OFFSET(range[A].in_min), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -1, 1, FLAGS },
57  { "rimax", "set input red white point", OFFSET(range[R].in_max), AV_OPT_TYPE_DOUBLE, {.dbl=1}, -1, 1, FLAGS },
58  { "gimax", "set input green white point", OFFSET(range[G].in_max), AV_OPT_TYPE_DOUBLE, {.dbl=1}, -1, 1, FLAGS },
59  { "bimax", "set input blue white point", OFFSET(range[B].in_max), AV_OPT_TYPE_DOUBLE, {.dbl=1}, -1, 1, FLAGS },
60  { "aimax", "set input alpha white point", OFFSET(range[A].in_max), AV_OPT_TYPE_DOUBLE, {.dbl=1}, -1, 1, FLAGS },
61  { "romin", "set output red black point", OFFSET(range[R].out_min), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 1, FLAGS },
62  { "gomin", "set output green black point", OFFSET(range[G].out_min), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 1, FLAGS },
63  { "bomin", "set output blue black point", OFFSET(range[B].out_min), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 1, FLAGS },
64  { "aomin", "set output alpha black point", OFFSET(range[A].out_min), AV_OPT_TYPE_DOUBLE, {.dbl=0}, 0, 1, FLAGS },
65  { "romax", "set output red white point", OFFSET(range[R].out_max), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS },
66  { "gomax", "set output green white point", OFFSET(range[G].out_max), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS },
67  { "bomax", "set output blue white point", OFFSET(range[B].out_max), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS },
68  { "aomax", "set output alpha white point", OFFSET(range[A].out_max), AV_OPT_TYPE_DOUBLE, {.dbl=1}, 0, 1, FLAGS },
69  { NULL }
70 };
71 
72 AVFILTER_DEFINE_CLASS(colorlevels);
73 
75 {
76  static const enum AVPixelFormat pix_fmts[] = {
85  };
86 
88  return 0;
89 }
90 
91 static int config_input(AVFilterLink *inlink)
92 {
93  AVFilterContext *ctx = inlink->dst;
94  ColorLevelsContext *s = ctx->priv;
95  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
96 
97  s->nb_comp = desc->nb_components;
98  s->bpp = (desc->comp[0].depth_minus1 + 1) >> 3;
99  s->step = (av_get_padded_bits_per_pixel(desc) >> 3) / s->bpp;
100  s->linesize = inlink->w * s->step;
101  ff_fill_rgba_map(s->rgba_map, inlink->format);
102 
103  return 0;
104 }
105 
106 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
107 {
108  AVFilterContext *ctx = inlink->dst;
109  ColorLevelsContext *s = ctx->priv;
110  AVFilterLink *outlink = ctx->outputs[0];
111  const int step = s->step;
112  AVFrame *out;
113  int x, y, i;
114 
115  if (av_frame_is_writable(in)) {
116  out = in;
117  } else {
118  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
119  if (!out) {
120  av_frame_free(&in);
121  return AVERROR(ENOMEM);
122  }
123  av_frame_copy_props(out, in);
124  }
125 
126  switch (s->bpp) {
127  case 1:
128  for (i = 0; i < s->nb_comp; i++) {
129  Range *r = &s->range[i];
130  const uint8_t offset = s->rgba_map[i];
131  const uint8_t *srcrow = in->data[0];
132  uint8_t *dstrow = out->data[0];
133  int imin = round(r->in_min * UINT8_MAX);
134  int imax = round(r->in_max * UINT8_MAX);
135  int omin = round(r->out_min * UINT8_MAX);
136  int omax = round(r->out_max * UINT8_MAX);
137  double coeff;
138 
139  if (imin < 0) {
140  imin = UINT8_MAX;
141  for (y = 0; y < inlink->h; y++) {
142  const uint8_t *src = srcrow;
143 
144  for (x = 0; x < s->linesize; x += step)
145  imin = FFMIN(imin, src[x + offset]);
146  srcrow += in->linesize[0];
147  }
148  }
149  if (imax < 0) {
150  srcrow = in->data[0];
151  imax = 0;
152  for (y = 0; y < inlink->h; y++) {
153  const uint8_t *src = srcrow;
154 
155  for (x = 0; x < s->linesize; x += step)
156  imax = FFMAX(imax, src[x + offset]);
157  srcrow += in->linesize[0];
158  }
159  }
160 
161  srcrow = in->data[0];
162  coeff = (omax - omin) / (double)(imax - imin);
163  for (y = 0; y < inlink->h; y++) {
164  const uint8_t *src = srcrow;
165  uint8_t *dst = dstrow;
166 
167  for (x = 0; x < s->linesize; x += step)
168  dst[x + offset] = av_clip_uint8((src[x + offset] - imin) * coeff + omin);
169  dstrow += out->linesize[0];
170  srcrow += in->linesize[0];
171  }
172  }
173  break;
174  case 2:
175  for (i = 0; i < s->nb_comp; i++) {
176  Range *r = &s->range[i];
177  const uint8_t offset = s->rgba_map[i];
178  const uint8_t *srcrow = in->data[0];
179  uint8_t *dstrow = out->data[0];
180  int imin = round(r->in_min * UINT16_MAX);
181  int imax = round(r->in_max * UINT16_MAX);
182  int omin = round(r->out_min * UINT16_MAX);
183  int omax = round(r->out_max * UINT16_MAX);
184  double coeff;
185 
186  if (imin < 0) {
187  imin = UINT16_MAX;
188  for (y = 0; y < inlink->h; y++) {
189  const uint16_t *src = (const uint16_t *)srcrow;
190 
191  for (x = 0; x < s->linesize; x += step)
192  imin = FFMIN(imin, src[x + offset]);
193  srcrow += in->linesize[0];
194  }
195  }
196  if (imax < 0) {
197  srcrow = in->data[0];
198  imax = 0;
199  for (y = 0; y < inlink->h; y++) {
200  const uint16_t *src = (const uint16_t *)srcrow;
201 
202  for (x = 0; x < s->linesize; x += step)
203  imax = FFMAX(imax, src[x + offset]);
204  srcrow += in->linesize[0];
205  }
206  }
207 
208  srcrow = in->data[0];
209  coeff = (omax - omin) / (double)(imax - imin);
210  for (y = 0; y < inlink->h; y++) {
211  const uint16_t *src = (const uint16_t*)srcrow;
212  uint16_t *dst = (uint16_t *)dstrow;
213 
214  for (x = 0; x < s->linesize; x += step)
215  dst[x + offset] = av_clip_uint16((src[x + offset] - imin) * coeff + omin);
216  dstrow += out->linesize[0];
217  srcrow += in->linesize[0];
218  }
219  }
220  }
221 
222  if (in != out)
223  av_frame_free(&in);
224  return ff_filter_frame(outlink, out);
225 }
226 
227 static const AVFilterPad colorlevels_inputs[] = {
228  {
229  .name = "default",
230  .type = AVMEDIA_TYPE_VIDEO,
231  .filter_frame = filter_frame,
232  .config_props = config_input,
233  },
234  { NULL }
235 };
236 
238  {
239  .name = "default",
240  .type = AVMEDIA_TYPE_VIDEO,
241  },
242  { NULL }
243 };
244 
246  .name = "colorlevels",
247  .description = NULL_IF_CONFIG_SMALL("Adjust the color levels."),
248  .priv_size = sizeof(ColorLevelsContext),
249  .priv_class = &colorlevels_class,
251  .inputs = colorlevels_inputs,
252  .outputs = colorlevels_outputs,
254 };
#define NULL
Definition: coverity.c:32
const char * s
Definition: avisynth_c.h:669
#define G
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2029
This structure describes decoded (raw) audio or video data.
Definition: frame.h:163
AVOption.
Definition: opt.h:255
misc image utilities
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:246
Main libavfilter public API header.
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:70
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:348
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_dlog(ac->avr,"%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
#define AV_PIX_FMT_BGRA64
Definition: pixfmt.h:353
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition: pixfmt.h:264
AVFrame * ff_get_video_buffer(AVFilterLink *link, int w, int h)
Request a picture buffer with a specific set of permissions.
Definition: video.c:109
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:294
#define AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
Some filters support a generic "enable" expression option that can be used to enable or disable a fil...
Definition: avfilter.h:451
const char * name
Pad name.
Definition: internal.h:67
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1145
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:100
uint8_t
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition: pixfmt.h:263
AVOptions.
#define A
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:101
static int query_formats(AVFilterContext *ctx)
#define AV_PIX_FMT_BGR48
Definition: pixfmt.h:349
void 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:539
double out_min
A filter pad used for either input or output.
Definition: internal.h:61
uint16_t depth_minus1
Number of bits in the component minus 1.
Definition: pixdesc.h:57
#define FLAGS
static const AVFilterPad colorlevels_inputs[]
#define AVERROR(e)
Definition: error.h:43
void av_frame_free(AVFrame **frame)
Free the frame and any dynamically allocated objects in it, e.g.
Definition: frame.c:148
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification. ...
Definition: internal.h:180
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:102
const char * r
Definition: vf_curves.c:107
void * priv
private data for use by the filter
Definition: avfilter.h:654
int av_get_padded_bits_per_pixel(const AVPixFmtDescriptor *pixdesc)
Return the number of bits per pixel for the pixel format described by pixdesc, including any padding ...
Definition: pixdesc.c:1994
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:344
static av_always_inline av_const double round(double x)
Definition: libm.h:162
static const uint8_t offset[127][2]
Definition: vf_spp.c:92
#define FFMAX(a, b)
Definition: common.h:64
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:99
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:100
uint8_t nb_components
The number of components each pixel has, (1-4)
Definition: pixdesc.h:71
static int config_input(AVFilterLink *inlink)
#define FFMIN(a, b)
Definition: common.h:66
static const AVOption colorlevels_options[]
float y
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:71
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
Definition: drawutils.c:33
AVS_Value src
Definition: avisynth_c.h:524
misc drawing utilities
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:403
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:191
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
double in_min
#define B
static const AVFilterPad colorlevels_outputs[]
Describe the class of an AVClass context structure.
Definition: log.h:66
Filter definition.
Definition: avfilter.h:470
static const AVFilterPad inputs[]
Definition: af_ashowinfo.c:237
double out_max
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition: pixfmt.h:265
const char * name
Filter name.
Definition: avfilter.h:474
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:648
static int flags
Definition: cpu.c:47
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:174
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_dlog(ac->avr,"%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-> out
#define OFFSET(x)
double in_max
AVFilter ff_vf_colorlevels
static const double coeff[2][5]
Definition: vf_owdenoise.c:71
An instance of a filter.
Definition: avfilter.h:633
#define R
AVFILTER_DEFINE_CLASS(colorlevels)
internal API functions
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition: pixfmt.h:262
AVPixelFormat
Pixel format.
Definition: pixfmt.h:66
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:463