FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vf_colorchannelmixer.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/opt.h"
22 #include "avfilter.h"
23 #include "drawutils.h"
24 #include "formats.h"
25 #include "internal.h"
26 #include "video.h"
27 
28 #define R 0
29 #define G 1
30 #define B 2
31 #define A 3
32 
33 typedef struct {
34  const AVClass *class;
35  double rr, rg, rb, ra;
36  double gr, gg, gb, ga;
37  double br, bg, bb, ba;
38  double ar, ag, ab, aa;
39 
40  int *lut[4][4];
41 
42  int *buffer;
43 
44  uint8_t rgba_map[4];
46 
47 #define OFFSET(x) offsetof(ColorChannelMixerContext, x)
48 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
50  { "rr", "set the red gain for the red channel", OFFSET(rr), AV_OPT_TYPE_DOUBLE, {.dbl=1}, -2, 2, FLAGS },
51  { "rg", "set the green gain for the red channel", OFFSET(rg), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -2, 2, FLAGS },
52  { "rb", "set the blue gain for the red channel", OFFSET(rb), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -2, 2, FLAGS },
53  { "ra", "set the alpha gain for the red channel", OFFSET(ra), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -2, 2, FLAGS },
54  { "gr", "set the red gain for the green channel", OFFSET(gr), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -2, 2, FLAGS },
55  { "gg", "set the green gain for the green channel", OFFSET(gg), AV_OPT_TYPE_DOUBLE, {.dbl=1}, -2, 2, FLAGS },
56  { "gb", "set the blue gain for the green channel", OFFSET(gb), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -2, 2, FLAGS },
57  { "ga", "set the alpha gain for the green channel", OFFSET(ga), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -2, 2, FLAGS },
58  { "br", "set the red gain for the blue channel", OFFSET(br), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -2, 2, FLAGS },
59  { "bg", "set the green gain for the blue channel", OFFSET(bg), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -2, 2, FLAGS },
60  { "bb", "set the blue gain for the blue channel", OFFSET(bb), AV_OPT_TYPE_DOUBLE, {.dbl=1}, -2, 2, FLAGS },
61  { "ba", "set the alpha gain for the blue channel", OFFSET(ba), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -2, 2, FLAGS },
62  { "ar", "set the red gain for the alpha channel", OFFSET(ar), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -2, 2, FLAGS },
63  { "ag", "set the green gain for the alpha channel", OFFSET(ag), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -2, 2, FLAGS },
64  { "ab", "set the blue gain for the alpha channel", OFFSET(ab), AV_OPT_TYPE_DOUBLE, {.dbl=0}, -2, 2, FLAGS },
65  { "aa", "set the alpha gain for the alpha channel", OFFSET(aa), AV_OPT_TYPE_DOUBLE, {.dbl=1}, -2, 2, FLAGS },
66  { NULL }
67 };
68 
69 AVFILTER_DEFINE_CLASS(colorchannelmixer);
70 
72 {
73  static const enum AVPixelFormat pix_fmts[] = {
82  };
83 
84  AVFilterFormats *fmts_list = ff_make_format_list(pix_fmts);
85  if (!fmts_list)
86  return AVERROR(ENOMEM);
87  return ff_set_common_formats(ctx, fmts_list);
88 }
89 
90 static int config_output(AVFilterLink *outlink)
91 {
92  AVFilterContext *ctx = outlink->src;
94  int i, j, size, *buffer;
95 
96  ff_fill_rgba_map(s->rgba_map, outlink->format);
97 
98  switch (outlink->format) {
99  case AV_PIX_FMT_RGB48:
100  case AV_PIX_FMT_BGR48:
101  case AV_PIX_FMT_RGBA64:
102  case AV_PIX_FMT_BGRA64:
103  size = 65536;
104  break;
105  default:
106  size = 256;
107  }
108 
109  s->buffer = buffer = av_malloc(16 * size * sizeof(*s->buffer));
110  if (!s->buffer)
111  return AVERROR(ENOMEM);
112 
113  for (i = 0; i < 4; i++)
114  for (j = 0; j < 4; j++, buffer += size)
115  s->lut[i][j] = buffer;
116 
117  for (i = 0; i < size; i++) {
118  s->lut[R][R][i] = round(i * s->rr);
119  s->lut[R][G][i] = round(i * s->rg);
120  s->lut[R][B][i] = round(i * s->rb);
121  s->lut[R][A][i] = round(i * s->ra);
122 
123  s->lut[G][R][i] = round(i * s->gr);
124  s->lut[G][G][i] = round(i * s->gg);
125  s->lut[G][B][i] = round(i * s->gb);
126  s->lut[G][A][i] = round(i * s->ga);
127 
128  s->lut[B][R][i] = round(i * s->br);
129  s->lut[B][G][i] = round(i * s->bg);
130  s->lut[B][B][i] = round(i * s->bb);
131  s->lut[B][A][i] = round(i * s->ba);
132 
133  s->lut[A][R][i] = round(i * s->ar);
134  s->lut[A][G][i] = round(i * s->ag);
135  s->lut[A][B][i] = round(i * s->ab);
136  s->lut[A][A][i] = round(i * s->aa);
137  }
138 
139  return 0;
140 }
141 
142 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
143 {
144  AVFilterContext *ctx = inlink->dst;
146  AVFilterLink *outlink = ctx->outputs[0];
147  const uint8_t roffset = s->rgba_map[R];
148  const uint8_t goffset = s->rgba_map[G];
149  const uint8_t boffset = s->rgba_map[B];
150  const uint8_t aoffset = s->rgba_map[A];
151  const uint8_t *srcrow = in->data[0];
152  uint8_t *dstrow;
153  AVFrame *out;
154  int i, j;
155 
156  if (av_frame_is_writable(in)) {
157  out = in;
158  } else {
159  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
160  if (!out) {
161  av_frame_free(&in);
162  return AVERROR(ENOMEM);
163  }
164  av_frame_copy_props(out, in);
165  }
166 
167  dstrow = out->data[0];
168  switch (outlink->format) {
169  case AV_PIX_FMT_BGR24:
170  case AV_PIX_FMT_RGB24:
171  for (i = 0; i < outlink->h; i++) {
172  const uint8_t *src = srcrow;
173  uint8_t *dst = dstrow;
174 
175  for (j = 0; j < outlink->w * 3; j += 3) {
176  const uint8_t rin = src[j + roffset];
177  const uint8_t gin = src[j + goffset];
178  const uint8_t bin = src[j + boffset];
179 
180  dst[j + roffset] = av_clip_uint8(s->lut[R][R][rin] +
181  s->lut[R][G][gin] +
182  s->lut[R][B][bin]);
183  dst[j + goffset] = av_clip_uint8(s->lut[G][R][rin] +
184  s->lut[G][G][gin] +
185  s->lut[G][B][bin]);
186  dst[j + boffset] = av_clip_uint8(s->lut[B][R][rin] +
187  s->lut[B][G][gin] +
188  s->lut[B][B][bin]);
189  }
190 
191  srcrow += in->linesize[0];
192  dstrow += out->linesize[0];
193  }
194  break;
195  case AV_PIX_FMT_0BGR:
196  case AV_PIX_FMT_0RGB:
197  case AV_PIX_FMT_BGR0:
198  case AV_PIX_FMT_RGB0:
199  for (i = 0; i < outlink->h; i++) {
200  const uint8_t *src = srcrow;
201  uint8_t *dst = dstrow;
202 
203  for (j = 0; j < outlink->w * 4; j += 4) {
204  const uint8_t rin = src[j + roffset];
205  const uint8_t gin = src[j + goffset];
206  const uint8_t bin = src[j + boffset];
207 
208  dst[j + roffset] = av_clip_uint8(s->lut[R][R][rin] +
209  s->lut[R][G][gin] +
210  s->lut[R][B][bin]);
211  dst[j + goffset] = av_clip_uint8(s->lut[G][R][rin] +
212  s->lut[G][G][gin] +
213  s->lut[G][B][bin]);
214  dst[j + boffset] = av_clip_uint8(s->lut[B][R][rin] +
215  s->lut[B][G][gin] +
216  s->lut[B][B][bin]);
217  if (in != out)
218  dst[j + aoffset] = 0;
219  }
220 
221  srcrow += in->linesize[0];
222  dstrow += out->linesize[0];
223  }
224  break;
225  case AV_PIX_FMT_ABGR:
226  case AV_PIX_FMT_ARGB:
227  case AV_PIX_FMT_BGRA:
228  case AV_PIX_FMT_RGBA:
229  for (i = 0; i < outlink->h; i++) {
230  const uint8_t *src = srcrow;
231  uint8_t *dst = dstrow;
232 
233  for (j = 0; j < outlink->w * 4; j += 4) {
234  const uint8_t rin = src[j + roffset];
235  const uint8_t gin = src[j + goffset];
236  const uint8_t bin = src[j + boffset];
237  const uint8_t ain = src[j + aoffset];
238 
239  dst[j + roffset] = av_clip_uint8(s->lut[R][R][rin] +
240  s->lut[R][G][gin] +
241  s->lut[R][B][bin] +
242  s->lut[R][A][ain]);
243  dst[j + goffset] = av_clip_uint8(s->lut[G][R][rin] +
244  s->lut[G][G][gin] +
245  s->lut[G][B][bin] +
246  s->lut[G][A][ain]);
247  dst[j + boffset] = av_clip_uint8(s->lut[B][R][rin] +
248  s->lut[B][G][gin] +
249  s->lut[B][B][bin] +
250  s->lut[B][A][ain]);
251  dst[j + aoffset] = av_clip_uint8(s->lut[A][R][rin] +
252  s->lut[A][G][gin] +
253  s->lut[A][B][bin] +
254  s->lut[A][A][ain]);
255  }
256 
257  srcrow += in->linesize[0];
258  dstrow += out->linesize[0];
259  }
260  break;
261  case AV_PIX_FMT_BGR48:
262  case AV_PIX_FMT_RGB48:
263  for (i = 0; i < outlink->h; i++) {
264  const uint16_t *src = (const uint16_t *)srcrow;
265  uint16_t *dst = (uint16_t *)dstrow;
266 
267  for (j = 0; j < outlink->w * 3; j += 3) {
268  const uint16_t rin = src[j + roffset];
269  const uint16_t gin = src[j + goffset];
270  const uint16_t bin = src[j + boffset];
271 
272  dst[j + roffset] = av_clip_uint16(s->lut[R][R][rin] +
273  s->lut[R][G][gin] +
274  s->lut[R][B][bin]);
275  dst[j + goffset] = av_clip_uint16(s->lut[G][R][rin] +
276  s->lut[G][G][gin] +
277  s->lut[G][B][bin]);
278  dst[j + boffset] = av_clip_uint16(s->lut[B][R][rin] +
279  s->lut[B][G][gin] +
280  s->lut[B][B][bin]);
281  }
282 
283  srcrow += in->linesize[0];
284  dstrow += out->linesize[0];
285  }
286  break;
287  case AV_PIX_FMT_BGRA64:
288  case AV_PIX_FMT_RGBA64:
289  for (i = 0; i < outlink->h; i++) {
290  const uint16_t *src = (const uint16_t *)srcrow;
291  uint16_t *dst = (uint16_t *)dstrow;
292 
293  for (j = 0; j < outlink->w * 4; j += 4) {
294  const uint16_t rin = src[j + roffset];
295  const uint16_t gin = src[j + goffset];
296  const uint16_t bin = src[j + boffset];
297  const uint16_t ain = src[j + aoffset];
298 
299  dst[j + roffset] = av_clip_uint16(s->lut[R][R][rin] +
300  s->lut[R][G][gin] +
301  s->lut[R][B][bin] +
302  s->lut[R][A][ain]);
303  dst[j + goffset] = av_clip_uint16(s->lut[G][R][rin] +
304  s->lut[G][G][gin] +
305  s->lut[G][B][bin] +
306  s->lut[G][A][ain]);
307  dst[j + boffset] = av_clip_uint16(s->lut[B][R][rin] +
308  s->lut[B][G][gin] +
309  s->lut[B][B][bin] +
310  s->lut[B][A][ain]);
311  dst[j + aoffset] = av_clip_uint16(s->lut[A][R][rin] +
312  s->lut[A][G][gin] +
313  s->lut[A][B][bin] +
314  s->lut[A][A][ain]);
315  }
316 
317  srcrow += in->linesize[0];
318  dstrow += out->linesize[0];
319  }
320  }
321 
322  if (in != out)
323  av_frame_free(&in);
324  return ff_filter_frame(ctx->outputs[0], out);
325 }
326 
327 static av_cold void uninit(AVFilterContext *ctx)
328 {
330 
331  av_freep(&s->buffer);
332 }
333 
335  {
336  .name = "default",
337  .type = AVMEDIA_TYPE_VIDEO,
338  .filter_frame = filter_frame,
339  },
340  { NULL }
341 };
342 
344  {
345  .name = "default",
346  .type = AVMEDIA_TYPE_VIDEO,
347  .config_props = config_output,
348  },
349  { NULL }
350 };
351 
353  .name = "colorchannelmixer",
354  .description = NULL_IF_CONFIG_SMALL("Adjust colors by mixing color channels."),
355  .priv_size = sizeof(ColorChannelMixerContext),
356  .priv_class = &colorchannelmixer_class,
357  .uninit = uninit,
359  .inputs = colorchannelmixer_inputs,
360  .outputs = colorchannelmixer_outputs,
362 };
#define NULL
Definition: coverity.c:32
const char * s
Definition: avisynth_c.h:631
AVFILTER_DEFINE_CLASS(colorchannelmixer)
This structure describes decoded (raw) audio or video data.
Definition: frame.h:171
static int query_formats(AVFilterContext *ctx)
AVOption.
Definition: opt.h:255
static const AVFilterPad outputs[]
Definition: af_ashowinfo.c:248
Main libavfilter public API header.
packed RGB 8:8:8, 24bpp, RGBRGB...
Definition: pixfmt.h:65
#define AV_PIX_FMT_RGBA64
Definition: pixfmt.h:370
#define AV_PIX_FMT_BGRA64
Definition: pixfmt.h:375
packed BGR 8:8:8, 32bpp, XBGRXBGR... X=unused/undefined
Definition: pixfmt.h:278
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
#define OFFSET(x)
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
#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:69
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1158
uint8_t
#define av_cold
Definition: attributes.h:74
#define av_malloc(s)
packed RGB 8:8:8, 32bpp, RGBXRGBX... X=unused/undefined
Definition: pixfmt.h:277
#define A
AVOptions.
static const AVFilterPad colorchannelmixer_inputs[]
packed ABGR 8:8:8:8, 32bpp, ABGRABGR...
Definition: pixfmt.h:96
#define AV_PIX_FMT_BGR48
Definition: pixfmt.h:371
ptrdiff_t size
Definition: opengl_enc.c:101
#define G
A filter pad used for either input or output.
Definition: internal.h:63
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
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:542
static const AVOption colorchannelmixer_options[]
#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:175
packed BGRA 8:8:8:8, 32bpp, BGRABGRA...
Definition: pixfmt.h:97
void * priv
private data for use by the filter
Definition: avfilter.h:654
#define AV_PIX_FMT_RGB48
Definition: pixfmt.h:366
static av_always_inline av_const double round(double x)
Definition: libm.h:162
packed ARGB 8:8:8:8, 32bpp, ARGBARGB...
Definition: pixfmt.h:94
static av_cold void uninit(AVFilterContext *ctx)
packed RGBA 8:8:8:8, 32bpp, RGBARGBA...
Definition: pixfmt.h:95
#define B
static const AVFilterPad colorchannelmixer_outputs[]
static int config_output(AVFilterLink *outlink)
#define ra
Definition: regdef.h:57
packed RGB 8:8:8, 24bpp, BGRBGR...
Definition: pixfmt.h:66
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
Definition: drawutils.c:34
AVS_Value src
Definition: avisynth_c.h:482
misc drawing utilities
#define FLAGS
int av_frame_is_writable(AVFrame *frame)
Check if the frame data is writable.
Definition: frame.c:493
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:199
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
Describe the class of an AVClass context structure.
Definition: log.h:67
Filter definition.
Definition: avfilter.h:470
static const AVFilterPad inputs[]
Definition: af_ashowinfo.c:239
packed BGR 8:8:8, 32bpp, BGRXBGRX... X=unused/undefined
Definition: pixfmt.h:279
const char * name
Filter name.
Definition: avfilter.h:474
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:648
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:209
static int flags
Definition: cpu.c:47
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:182
#define R
AVFilter ff_vf_colorchannelmixer
A list of supported formats for one end of a filter link.
Definition: formats.h:64
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-> out
An instance of a filter.
Definition: avfilter.h:633
#define av_freep(p)
internal API functions
packed RGB 8:8:8, 32bpp, XRGBXRGB... X=unused/undefined
Definition: pixfmt.h:276
AVPixelFormat
Pixel format.
Definition: pixfmt.h:61
for(j=16;j >0;--j)
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:553
GLuint buffer
Definition: opengl_enc.c:102