FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
vf_neighbor.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2012-2013 Oka Motofumi (chikuzen.mo at gmail dot com)
3  * Copyright (c) 2015 Paul B Mahol
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15  * Lesser General Public License for more details.
16  *
17  * You should have received a copy of the GNU Lesser General Public
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "libavutil/imgutils.h"
23 #include "libavutil/intreadwrite.h"
24 #include "libavutil/pixdesc.h"
25 #include "libavutil/opt.h"
26 #include "avfilter.h"
27 #include "formats.h"
28 #include "internal.h"
29 #include "video.h"
30 
31 typedef struct ThreadData {
32  AVFrame *in, *out;
33 } ThreadData;
34 
35 typedef struct NContext {
36  const AVClass *class;
37  int planeheight[4];
38  int planewidth[4];
39  int nb_planes;
40  int threshold[4];
42 
43  int depth;
44  int bpc;
45 
46  void (*filter)(uint8_t *dst, const uint8_t *p1, int width,
47  int threshold, const uint8_t *coordinates[], int coord);
48 } NContext;
49 
51 {
52  static const enum AVPixelFormat pix_fmts[] = {
71  };
72 
73  return ff_set_common_formats(ctx, ff_make_format_list(pix_fmts));
74 }
75 
76 static void erosion(uint8_t *dst, const uint8_t *p1, int width,
77  int threshold, const uint8_t *coordinates[], int coord)
78 {
79  int x, i;
80 
81  for (x = 0; x < width; x++) {
82  int min = p1[x];
83  int limit = FFMAX(min - threshold, 0);
84 
85  for (i = 0; i < 8; i++) {
86  if (coord & (1 << i)) {
87  min = FFMIN(min, *(coordinates[i] + x));
88  }
89  min = FFMAX(min, limit);
90  }
91 
92  dst[x] = min;
93  }
94 }
95 
96 static void erosion16(uint8_t *dstp, const uint8_t *p1, int width,
97  int threshold, const uint8_t *coordinates[], int coord)
98 {
99  uint16_t *dst = (uint16_t *)dstp;
100  int x, i;
101 
102  for (x = 0; x < width; x++) {
103  int min = AV_RN16A(&p1[2 * x]);
104  int limit = FFMAX(min - threshold, 0);
105 
106  for (i = 0; i < 8; i++) {
107  if (coord & (1 << i)) {
108  min = FFMIN(min, AV_RN16A(coordinates[i] + x * 2));
109  }
110  min = FFMAX(min, limit);
111  }
112 
113  dst[x] = min;
114  }
115 }
116 
117 static void dilation(uint8_t *dst, const uint8_t *p1, int width,
118  int threshold, const uint8_t *coordinates[], int coord)
119 {
120  int x, i;
121 
122  for (x = 0; x < width; x++) {
123  int max = p1[x];
124  int limit = FFMIN(max + threshold, 255);
125 
126  for (i = 0; i < 8; i++) {
127  if (coord & (1 << i)) {
128  max = FFMAX(max, *(coordinates[i] + x));
129  }
130  max = FFMIN(max, limit);
131  }
132 
133  dst[x] = max;
134  }
135 }
136 
137 static void dilation16(uint8_t *dstp, const uint8_t *p1, int width,
138  int threshold, const uint8_t *coordinates[], int coord)
139 {
140  uint16_t *dst = (uint16_t *)dstp;
141  int x, i;
142 
143  for (x = 0; x < width; x++) {
144  int max = AV_RN16A(&p1[x * 2]);
145  int limit = FFMIN(max + threshold, 255);
146 
147  for (i = 0; i < 8; i++) {
148  if (coord & (1 << i)) {
149  max = FFMAX(max, AV_RN16A(coordinates[i] + x * 2));
150  }
151  max = FFMIN(max, limit);
152  }
153 
154  dst[x] = max;
155  }
156 }
157 
158 static void deflate(uint8_t *dst, const uint8_t *p1, int width,
159  int threshold, const uint8_t *coordinates[], int coord)
160 {
161  int x, i;
162 
163  for (x = 0; x < width; x++) {
164  int sum = 0;
165  int limit = FFMAX(p1[x] - threshold, 0);
166 
167  for (i = 0; i < 8; sum += *(coordinates[i++] + x));
168 
169  dst[x] = FFMAX(FFMIN(sum / 8, p1[x]), limit);
170  }
171 }
172 
173 static void deflate16(uint8_t *dstp, const uint8_t *p1, int width,
174  int threshold, const uint8_t *coordinates[], int coord)
175 {
176  uint16_t *dst = (uint16_t *)dstp;
177  int x, i;
178 
179  for (x = 0; x < width; x++) {
180  int sum = 0;
181  int limit = FFMAX(AV_RN16A(&p1[2 * x]) - threshold, 0);
182 
183  for (i = 0; i < 8; sum += AV_RN16A(coordinates[i++] + x * 2));
184 
185  dst[x] = FFMAX(FFMIN(sum / 8, p1[x]), limit);
186  }
187 }
188 
189 static void inflate(uint8_t *dst, const uint8_t *p1, int width,
190  int threshold, const uint8_t *coordinates[], int coord)
191 {
192  int x, i;
193 
194  for (x = 0; x < width; x++) {
195  int sum = 0;
196  int limit = FFMIN(p1[x] + threshold, 255);
197 
198  for (i = 0; i < 8; sum += *(coordinates[i++] + x));
199 
200  dst[x] = FFMIN(FFMAX(sum / 8, p1[x]), limit);
201  }
202 }
203 
204 static void inflate16(uint8_t *dstp, const uint8_t *p1, int width,
205  int threshold, const uint8_t *coordinates[], int coord)
206 {
207  uint16_t *dst = (uint16_t *)dstp;
208  int x, i;
209 
210  for (x = 0; x < width; x++) {
211  int sum = 0;
212  int limit = FFMIN(AV_RN16A(&p1[2 * x]) + threshold, 255);
213 
214  for (i = 0; i < 8; sum += AV_RN16A(coordinates[i++] + x * 2));
215 
216  dst[x] = FFMIN(FFMAX(sum / 8, p1[x]), limit);
217  }
218 }
219 
220 static int config_input(AVFilterLink *inlink)
221 {
222  AVFilterContext *ctx = inlink->dst;
223  NContext *s = ctx->priv;
225 
226  s->depth = desc->comp[0].depth;
227  s->bpc = (s->depth + 7) / 8;
228 
229  s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
230  s->planewidth[0] = s->planewidth[3] = inlink->w;
231  s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
232  s->planeheight[0] = s->planeheight[3] = inlink->h;
233 
235 
236  if (!strcmp(ctx->filter->name, "erosion"))
237  s->filter = s->depth > 8 ? erosion16 : erosion;
238  else if (!strcmp(ctx->filter->name, "dilation"))
239  s->filter = s->depth > 8 ? dilation16 : dilation;
240  else if (!strcmp(ctx->filter->name, "deflate"))
241  s->filter = s->depth > 8 ? deflate16 : deflate;
242  else if (!strcmp(ctx->filter->name, "inflate"))
243  s->filter = s->depth > 8 ? inflate16 : inflate;
244 
245  return 0;
246 }
247 
248 static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
249 {
250  NContext *s = ctx->priv;
251  ThreadData *td = arg;
252  AVFrame *out = td->out;
253  AVFrame *in = td->in;
254  int plane, y;
255 
256  for (plane = 0; plane < s->nb_planes; plane++) {
257  const int bpc = s->bpc;
258  const int threshold = s->threshold[plane];
259  const int stride = in->linesize[plane];
260  const int dstride = out->linesize[plane];
261  const int height = s->planeheight[plane];
262  const int width = s->planewidth[plane];
263  const int slice_start = (height * jobnr) / nb_jobs;
264  const int slice_end = (height * (jobnr+1)) / nb_jobs;
265  const uint8_t *src = (const uint8_t *)in->data[plane] + slice_start * stride;
266  uint8_t *dst = out->data[plane] + slice_start * dstride;
267 
268  if (!threshold) {
269  av_image_copy_plane(dst, dstride, src, stride, width * bpc, slice_end - slice_start);
270  continue;
271  }
272 
273  for (y = slice_start; y < slice_end; y++) {
274  const int nh = y > 0;
275  const int ph = y < height - 1;
276  const uint8_t *coordinates[] = { src - nh * stride, src + 1 * bpc - nh * stride, src + 2 * bpc - nh * stride,
277  src, src + 2 * bpc,
278  src + ph * stride, src + 1 * bpc + ph * stride, src + 2 * bpc + ph * stride};
279 
280  const uint8_t *coordinateslb[] = { src + 1 * bpc - nh * stride, src - nh * stride, src + 1 * bpc - nh * stride,
281  src + 1 * bpc, src + 1 * bpc,
282  src + 1 * bpc + ph * stride, src + ph * stride, src + 1 * bpc + ph * stride};
283 
284  const uint8_t *coordinatesrb[] = { src + (width - 2) * bpc - nh * stride, src + (width - 1) * bpc - nh * stride, src + (width - 2) * bpc - nh * stride,
285  src + (width - 2) * bpc, src + (width - 2) * bpc,
286  src + (width - 2) * bpc + ph * stride, src + (width - 1) * bpc + ph * stride, src + (width - 2) * bpc + ph * stride};
287 
288  s->filter(dst, src, 1, threshold, coordinateslb, s->coordinates);
289  s->filter(dst + 1 * bpc, src + 1 * bpc, width - 2, threshold, coordinates, s->coordinates);
290  s->filter(dst + (width - 1) * bpc, src + (width - 1) * bpc, 1, threshold, coordinatesrb, s->coordinates);
291 
292  src += stride;
293  dst += dstride;
294  }
295  }
296 
297  return 0;
298 }
299 
300 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
301 {
302  AVFilterContext *ctx = inlink->dst;
303  AVFilterLink *outlink = ctx->outputs[0];
304  NContext *s = ctx->priv;
305  ThreadData td;
306  AVFrame *out;
307 
308  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
309  if (!out) {
310  av_frame_free(&in);
311  return AVERROR(ENOMEM);
312  }
313  av_frame_copy_props(out, in);
314 
315  td.in = in;
316  td.out = out;
318 
319  av_frame_free(&in);
320  return ff_filter_frame(outlink, out);
321 }
322 
323 static const AVFilterPad neighbor_inputs[] = {
324  {
325  .name = "default",
326  .type = AVMEDIA_TYPE_VIDEO,
327  .filter_frame = filter_frame,
328  .config_props = config_input,
329  },
330  { NULL }
331 };
332 
333 static const AVFilterPad neighbor_outputs[] = {
334  {
335  .name = "default",
336  .type = AVMEDIA_TYPE_VIDEO,
337  },
338  { NULL }
339 };
340 
341 #define OFFSET(x) offsetof(NContext, x)
342 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
343 
344 #define DEFINE_NEIGHBOR_FILTER(name_, description_) \
345 AVFILTER_DEFINE_CLASS(name_); \
346  \
347 AVFilter ff_vf_##name_ = { \
348  .name = #name_, \
349  .description = NULL_IF_CONFIG_SMALL(description_), \
350  .priv_size = sizeof(NContext), \
351  .priv_class = &name_##_class, \
352  .query_formats = query_formats, \
353  .inputs = neighbor_inputs, \
354  .outputs = neighbor_outputs, \
355  .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC| \
356  AVFILTER_FLAG_SLICE_THREADS, \
357 }
358 
359 #if CONFIG_EROSION_FILTER
360 
361 static const AVOption erosion_options[] = {
362  { "threshold0", "set threshold for 1st plane", OFFSET(threshold[0]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
363  { "threshold1", "set threshold for 2nd plane", OFFSET(threshold[1]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
364  { "threshold2", "set threshold for 3rd plane", OFFSET(threshold[2]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
365  { "threshold3", "set threshold for 4th plane", OFFSET(threshold[3]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
366  { "coordinates", "set coordinates", OFFSET(coordinates), AV_OPT_TYPE_INT, {.i64=255}, 0, 255, FLAGS },
367  { NULL }
368 };
369 
370 DEFINE_NEIGHBOR_FILTER(erosion, "Apply erosion effect.");
371 
372 #endif /* CONFIG_EROSION_FILTER */
373 
374 #if CONFIG_DILATION_FILTER
375 
376 static const AVOption dilation_options[] = {
377  { "threshold0", "set threshold for 1st plane", OFFSET(threshold[0]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
378  { "threshold1", "set threshold for 2nd plane", OFFSET(threshold[1]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
379  { "threshold2", "set threshold for 3rd plane", OFFSET(threshold[2]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
380  { "threshold3", "set threshold for 4th plane", OFFSET(threshold[3]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
381  { "coordinates", "set coordinates", OFFSET(coordinates), AV_OPT_TYPE_INT, {.i64=255}, 0, 255, FLAGS },
382  { NULL }
383 };
384 
385 DEFINE_NEIGHBOR_FILTER(dilation, "Apply dilation effect.");
386 
387 #endif /* CONFIG_DILATION_FILTER */
388 
389 #if CONFIG_DEFLATE_FILTER
390 
391 static const AVOption deflate_options[] = {
392  { "threshold0", "set threshold for 1st plane", OFFSET(threshold[0]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
393  { "threshold1", "set threshold for 2nd plane", OFFSET(threshold[1]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
394  { "threshold2", "set threshold for 3rd plane", OFFSET(threshold[2]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
395  { "threshold3", "set threshold for 4th plane", OFFSET(threshold[3]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
396  { NULL }
397 };
398 
399 DEFINE_NEIGHBOR_FILTER(deflate, "Apply deflate effect.");
400 
401 #endif /* CONFIG_DEFLATE_FILTER */
402 
403 #if CONFIG_INFLATE_FILTER
404 
405 static const AVOption inflate_options[] = {
406  { "threshold0", "set threshold for 1st plane", OFFSET(threshold[0]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
407  { "threshold1", "set threshold for 2nd plane", OFFSET(threshold[1]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
408  { "threshold2", "set threshold for 3rd plane", OFFSET(threshold[2]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
409  { "threshold3", "set threshold for 4th plane", OFFSET(threshold[3]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
410  { NULL }
411 };
412 
413 DEFINE_NEIGHBOR_FILTER(inflate, "Apply inflate effect.");
414 
415 #endif /* CONFIG_INFLATE_FILTER */
int plane
Definition: avisynth_c.h:422
static void dilation(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord)
Definition: vf_neighbor.c:117
#define NULL
Definition: coverity.c:32
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:420
AVFrame * out
Definition: af_adeclick.c:485
int planewidth[4]
Definition: vf_neighbor.c:38
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:414
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
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:416
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:389
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:399
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:417
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
misc image utilities
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2486
Main libavfilter public API header.
const char * desc
Definition: nvenc.c:65
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:168
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:395
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:359
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:383
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
#define src
Definition: vp8dsp.c:254
uint8_t log2_chroma_w
Amount to shift the luma width right to find the chroma width.
Definition: pixdesc.h:92
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:360
const char * name
Pad name.
Definition: internal.h:60
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:361
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1080
AVFrame * in
Definition: af_afftdn.c:1082
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
AVComponentDescriptor comp[4]
Parameters that describe how pixels are packed.
Definition: pixdesc.h:117
uint8_t
AVOptions.
int threshold[4]
Definition: vf_neighbor.c:40
static int filter_slice(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
Definition: vf_neighbor.c:248
static void deflate(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord)
Definition: vf_neighbor.c:158
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:413
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:394
#define height
static void inflate(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord)
Definition: vf_neighbor.c:189
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
Definition: pixfmt.h:100
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:79
static const AVFilterPad neighbor_outputs[]
Definition: vf_neighbor.c:333
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:392
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:384
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:419
#define FLAGS
Definition: vf_neighbor.c:342
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_neighbor.c:300
A filter pad used for either input or output.
Definition: internal.h:54
static void erosion16(uint8_t *dstp, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord)
Definition: vf_neighbor.c:96
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:176
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 td
Definition: regdef.h:70
static void inflate16(uint8_t *dstp, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord)
Definition: vf_neighbor.c:204
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:101
int nb_planes
Definition: vf_neighbor.c:39
BYTE * dstp
Definition: avisynth_c.h:813
#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:202
void(* filter)(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord)
Definition: vf_neighbor.c:46
void * priv
private data for use by the filter
Definition: avfilter.h:353
#define OFFSET(x)
Definition: vf_neighbor.c:341
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:421
const char * arg
Definition: jacosubdec.c:66
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:400
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:382
#define FFMAX(a, b)
Definition: common.h:94
int coordinates
Definition: vf_neighbor.c:41
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:401
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:377
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:398
int ff_filter_get_nb_threads(AVFilterContext *ctx)
Get number of threads for current filter instance.
Definition: avfilter.c:802
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:363
#define FFMIN(a, b)
Definition: common.h:96
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:78
#define width
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
AVFormatContext * ctx
Definition: movenc.c:48
#define s(width, name)
Definition: cbs_vp9.c:257
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:418
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:378
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:397
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:390
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:387
Used for passing data between threads.
Definition: af_adeclick.c:484
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:257
static int query_formats(AVFilterContext *ctx)
Definition: vf_neighbor.c:50
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:177
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:362
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
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:379
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
Describe the class of an AVClass context structure.
Definition: log.h:67
static void dilation16(uint8_t *dstp, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord)
Definition: vf_neighbor.c:137
static void erosion(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord)
Definition: vf_neighbor.c:76
const char * name
Filter name.
Definition: avfilter.h:148
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:385
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:376
AVFilterLink ** outputs
array of pointers to output links
Definition: avfilter.h:350
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:266
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:388
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:396
AVFilterInternal * internal
An opaque struct for libavfilter internal use.
Definition: avfilter.h:378
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:380
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:386
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:240
static int config_input(AVFilterLink *inlink)
Definition: vf_neighbor.c:220
GLint GLenum GLboolean GLsizei stride
Definition: opengl_enc.c:105
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
Y , 8bpp.
Definition: pixfmt.h:74
int planeheight[4]
Definition: vf_neighbor.c:37
if(ret< 0)
Definition: vf_mcdeint.c:279
static const AVFilterPad neighbor_inputs[]
Definition: vf_neighbor.c:323
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:215
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:415
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:80
static void deflate16(uint8_t *dstp, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord)
Definition: vf_neighbor.c:173
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
#define DEFINE_NEIGHBOR_FILTER(name_, description_)
Definition: vf_neighbor.c:344
avfilter_execute_func * execute
Definition: internal.h:155
static int slice_end(AVCodecContext *avctx, AVFrame *pict)
Handle slice ends.
Definition: mpeg12dec.c:2029
int depth
Definition: vf_neighbor.c:43
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:258
#define AV_RN16A(p)
Definition: intreadwrite.h:522
An instance of a filter.
Definition: avfilter.h:338
FILE * out
Definition: movenc.c:54
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
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
#define stride
internal API functions
int depth
Number of bits in the component.
Definition: pixdesc.h:58
float min
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
const AVFilter * filter
the AVFilter of which this is an instance
Definition: avfilter.h:341
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:391
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:654
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58