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/pixdesc.h"
24 #include "libavutil/opt.h"
25 #include "avfilter.h"
26 #include "formats.h"
27 #include "internal.h"
28 #include "video.h"
29 
30 typedef struct NContext {
31  const AVClass *class;
32  int planeheight[4];
33  int planewidth[4];
34  int nb_planes;
35  int threshold[4];
38 
39  void (*filter)(uint8_t *dst, const uint8_t *p1, int width,
40  int threshold, const uint8_t *coordinates[], int coord);
41 } NContext;
42 
44 {
45  static const enum AVPixelFormat pix_fmts[] = {
50  };
51 
53  return 0;
54 }
55 
56 static av_cold void uninit(AVFilterContext *ctx)
57 {
58  NContext *s = ctx->priv;
59 
60  av_freep(&s->buffer);
61 }
62 
63 static inline void line_copy8(uint8_t *line, const uint8_t *srcp, int width, int mergin)
64 {
65  int i;
66 
67  memcpy(line, srcp, width);
68 
69  for (i = mergin; i > 0; i--) {
70  line[-i] = line[i];
71  line[width - 1 + i] = line[width - 1 - i];
72  }
73 }
74 
75 static void erosion(uint8_t *dst, const uint8_t *p1, int width,
76  int threshold, const uint8_t *coordinates[], int coord)
77 {
78  int x, i;
79 
80  for (x = 0; x < width; x++) {
81  int min = p1[x];
82  int limit = FFMAX(min - threshold, 0);
83 
84  for (i = 0; i < 8; i++) {
85  if (coord & (1 << i)) {
86  min = FFMIN(min, *(coordinates[i] + x));
87  }
88  min = FFMAX(min, limit);
89  }
90 
91  dst[x] = min;
92  }
93 }
94 
95 static void dilation(uint8_t *dst, const uint8_t *p1, int width,
96  int threshold, const uint8_t *coordinates[], int coord)
97 {
98  int x, i;
99 
100  for (x = 0; x < width; x++) {
101  int max = p1[x];
102  int limit = FFMIN(max + threshold, 255);
103 
104  for (i = 0; i < 8; i++) {
105  if (coord & (1 << i)) {
106  max = FFMAX(max, *(coordinates[i] + x));
107  }
108  max = FFMIN(max, limit);
109  }
110 
111  dst[x] = max;
112  }
113 }
114 
115 static void deflate(uint8_t *dst, const uint8_t *p1, int width,
116  int threshold, const uint8_t *coordinates[], int coord)
117 {
118  int x, i;
119 
120  for (x = 0; x < width; x++) {
121  int sum = 0;
122  int limit = FFMAX(p1[x] - threshold, 0);
123 
124  for (i = 0; i < 8; sum += *(coordinates[i++] + x));
125 
126  dst[x] = FFMAX(FFMIN(sum / 8, p1[x]), limit);
127  }
128 }
129 
130 static void inflate(uint8_t *dst, const uint8_t *p1, int width,
131  int threshold, const uint8_t *coordinates[], int coord)
132 {
133  int x, i;
134 
135  for (x = 0; x < width; x++) {
136  int sum = 0;
137  int limit = FFMIN(p1[x] + threshold, 255);
138 
139  for (i = 0; i < 8; sum += *(coordinates[i++] + x));
140 
141  dst[x] = FFMIN(FFMAX(sum / 8, p1[x]), limit);
142  }
143 }
144 
145 static int config_input(AVFilterLink *inlink)
146 {
147  AVFilterContext *ctx = inlink->dst;
148  NContext *s = ctx->priv;
149  const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(inlink->format);
150  int ret;
151 
152  if ((ret = av_image_fill_linesizes(s->planewidth, inlink->format, inlink->w)) < 0)
153  return ret;
154 
155  s->planeheight[1] = s->planeheight[2] = FF_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
156  s->planeheight[0] = s->planeheight[3] = inlink->h;
157 
159  s->buffer = av_malloc(3 * (s->planewidth[0] + 32));
160  if (!s->buffer)
161  return AVERROR(ENOMEM);
162 
163  if (!strcmp(ctx->filter->name, "erosion"))
164  s->filter = erosion;
165  else if (!strcmp(ctx->filter->name, "dilation"))
166  s->filter = dilation;
167  else if (!strcmp(ctx->filter->name, "deflate"))
168  s->filter = deflate;
169  else if (!strcmp(ctx->filter->name, "inflate"))
170  s->filter = inflate;
171 
172  return 0;
173 }
174 
175 static int filter_frame(AVFilterLink *inlink, AVFrame *in)
176 {
177  AVFilterContext *ctx = inlink->dst;
178  AVFilterLink *outlink = ctx->outputs[0];
179  NContext *s = ctx->priv;
180  AVFrame *out;
181  int plane, y;
182 
183  out = ff_get_video_buffer(outlink, outlink->w, outlink->h);
184  if (!out) {
185  av_frame_free(&in);
186  return AVERROR(ENOMEM);
187  }
188  av_frame_copy_props(out, in);
189 
190  for (plane = 0; plane < s->nb_planes; plane++) {
191  const int threshold = s->threshold[plane];
192 
193  if (threshold) {
194  const uint8_t *src = in->data[plane];
195  uint8_t *dst = out->data[plane];
196  int stride = in->linesize[plane];
197  int height = s->planeheight[plane];
198  int width = s->planewidth[plane];
199  uint8_t *p0 = s->buffer + 16;
200  uint8_t *p1 = p0 + s->planewidth[0];
201  uint8_t *p2 = p1 + s->planewidth[0];
202  uint8_t *orig = p0, *end = p2;
203 
204  line_copy8(p0, src + stride, width, 1);
205  line_copy8(p1, src, width, 1);
206 
207  for (y = 0; y < height; y++) {
208  const uint8_t *coordinates[] = { p0 - 1, p0, p0 + 1,
209  p1 - 1, p1 + 1,
210  p2 - 1, p2, p2 + 1};
211  src += stride * (y < height - 1 ? 1 : -1);
212  line_copy8(p2, src, width, 1);
213 
214  s->filter(dst, p1, width, threshold, coordinates, s->coordinates);
215 
216  p0 = p1;
217  p1 = p2;
218  p2 = (p2 == end) ? orig: p2 + s->planewidth[0];
219  dst += out->linesize[plane];
220  }
221  } else {
222  av_image_copy_plane(out->data[plane], out->linesize[plane],
223  in->data[plane], in->linesize[plane],
224  s->planewidth[plane], s->planeheight[plane]);
225  }
226  }
227 
228  av_frame_free(&in);
229  return ff_filter_frame(outlink, out);
230 }
231 
232 static const AVFilterPad neighbor_inputs[] = {
233  {
234  .name = "default",
235  .type = AVMEDIA_TYPE_VIDEO,
236  .filter_frame = filter_frame,
237  .config_props = config_input,
238  },
239  { NULL }
240 };
241 
242 static const AVFilterPad neighbor_outputs[] = {
243  {
244  .name = "default",
245  .type = AVMEDIA_TYPE_VIDEO,
246  },
247  { NULL }
248 };
249 
250 #define OFFSET(x) offsetof(NContext, x)
251 #define FLAGS AV_OPT_FLAG_FILTERING_PARAM|AV_OPT_FLAG_VIDEO_PARAM
252 
253 #define DEFINE_NEIGHBOR_FILTER(name_, description_) \
254 AVFILTER_DEFINE_CLASS(name_); \
255  \
256 AVFilter ff_vf_##name_ = { \
257  .name = #name_, \
258  .description = NULL_IF_CONFIG_SMALL(description_), \
259  .priv_size = sizeof(NContext), \
260  .priv_class = &name_##_class, \
261  .uninit = uninit, \
262  .query_formats = query_formats, \
263  .inputs = neighbor_inputs, \
264  .outputs = neighbor_outputs, \
265  .flags = AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC, \
266 }
267 
268 #if CONFIG_EROSION_FILTER
269 
270 static const AVOption erosion_options[] = {
271  { "threshold0", "set threshold for 1st plane", OFFSET(threshold[0]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
272  { "threshold1", "set threshold for 2nd plane", OFFSET(threshold[1]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
273  { "threshold2", "set threshold for 3rd plane", OFFSET(threshold[2]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
274  { "threshold3", "set threshold for 4th plane", OFFSET(threshold[3]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
275  { "coordinates", "set coordinates", OFFSET(coordinates), AV_OPT_TYPE_INT, {.i64=255}, 0, 255, FLAGS },
276  { NULL }
277 };
278 
279 DEFINE_NEIGHBOR_FILTER(erosion, "Apply erosion effect");
280 
281 #endif /* CONFIG_EROSION_FILTER */
282 
283 #if CONFIG_DILATION_FILTER
284 
285 static const AVOption dilation_options[] = {
286  { "threshold0", "set threshold for 1st plane", OFFSET(threshold[0]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
287  { "threshold1", "set threshold for 2nd plane", OFFSET(threshold[1]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
288  { "threshold2", "set threshold for 3rd plane", OFFSET(threshold[2]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
289  { "threshold3", "set threshold for 4th plane", OFFSET(threshold[3]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
290  { "coordinates", "set coordinates", OFFSET(coordinates), AV_OPT_TYPE_INT, {.i64=255}, 0, 255, FLAGS },
291  { NULL }
292 };
293 
294 DEFINE_NEIGHBOR_FILTER(dilation, "Apply dilation effect");
295 
296 #endif /* CONFIG_DILATION_FILTER */
297 
298 #if CONFIG_DEFLATE_FILTER
299 
300 static const AVOption deflate_options[] = {
301  { "threshold0", "set threshold for 1st plane", OFFSET(threshold[0]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
302  { "threshold1", "set threshold for 2nd plane", OFFSET(threshold[1]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
303  { "threshold2", "set threshold for 3rd plane", OFFSET(threshold[2]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
304  { "threshold3", "set threshold for 4th plane", OFFSET(threshold[3]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
305  { NULL }
306 };
307 
308 DEFINE_NEIGHBOR_FILTER(deflate, "Apply deflate effect");
309 
310 #endif /* CONFIG_DEFLATE_FILTER */
311 
312 #if CONFIG_INFLATE_FILTER
313 
314 static const AVOption inflate_options[] = {
315  { "threshold0", "set threshold for 1st plane", OFFSET(threshold[0]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
316  { "threshold1", "set threshold for 2nd plane", OFFSET(threshold[1]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
317  { "threshold2", "set threshold for 3rd plane", OFFSET(threshold[2]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
318  { "threshold3", "set threshold for 4th plane", OFFSET(threshold[3]), AV_OPT_TYPE_INT, {.i64=65535}, 0, 65535, FLAGS },
319  { NULL }
320 };
321 
322 DEFINE_NEIGHBOR_FILTER(inflate, "Apply inflate effect");
323 
324 #endif /* CONFIG_INFLATE_FILTER */
int plane
Definition: avisynth_c.h:291
static void dilation(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord)
Definition: vf_neighbor.c:95
#define NULL
Definition: coverity.c:32
const char * s
Definition: avisynth_c.h:631
int planewidth[4]
Definition: vf_neighbor.c:33
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2129
This structure describes decoded (raw) audio or video data.
Definition: frame.h:171
AVOption.
Definition: opt.h:255
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:68
misc image utilities
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2169
Main libavfilter public API header.
static void line_copy8(uint8_t *line, const uint8_t *srcp, int width, int mergin)
Definition: vf_neighbor.c:63
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:188
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
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
BYTE int const BYTE * srcp
Definition: avisynth_c.h:676
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
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:103
uint8_t
#define av_cold
Definition: attributes.h:74
#define av_malloc(s)
AVOptions.
int threshold[4]
Definition: vf_neighbor.c:35
static av_cold int end(AVCodecContext *avctx)
Definition: avrndec.c:90
static void deflate(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord)
Definition: vf_neighbor.c:115
static void inflate(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord)
Definition: vf_neighbor.c:130
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range...
Definition: pixfmt.h:102
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:76
static const AVFilterPad neighbor_outputs[]
Definition: vf_neighbor.c:242
#define FLAGS
Definition: vf_neighbor.c:251
static int filter_frame(AVFilterLink *inlink, AVFrame *in)
Definition: vf_neighbor.c:175
A filter pad used for either input or output.
Definition: internal.h:63
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:281
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
uint8_t log2_chroma_h
Amount to shift the luma height right to find the chroma height.
Definition: pixdesc.h:89
int nb_planes
Definition: vf_neighbor.c:34
#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
void(* filter)(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord)
Definition: vf_neighbor.c:39
void * priv
private data for use by the filter
Definition: avfilter.h:654
#define OFFSET(x)
Definition: vf_neighbor.c:250
uint8_t * buffer
Definition: vf_neighbor.c:37
Definition: graph2dot.c:48
#define FFMAX(a, b)
Definition: common.h:79
int coordinates
Definition: vf_neighbor.c:36
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:67
#define FFMIN(a, b)
Definition: common.h:81
float y
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:75
typedef void(APIENTRY *FF_PFNGLACTIVETEXTUREPROC)(GLenum texture)
#define FF_CEIL_RSHIFT(a, b)
Definition: common.h:57
static av_cold void uninit(AVFilterContext *ctx)
Definition: vf_neighbor.c:56
AVS_Value src
Definition: avisynth_c.h:482
int linesize[AV_NUM_DATA_POINTERS]
For video, size in bytes of each picture line.
Definition: frame.h:199
static int query_formats(AVFilterContext *ctx)
Definition: vf_neighbor.c:43
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:280
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:69
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
BYTE int const BYTE int int int height
Definition: avisynth_c.h:676
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:69
Describe the class of an AVClass context structure.
Definition: log.h:67
int av_image_fill_linesizes(int linesizes[4], enum AVPixelFormat pix_fmt, int width)
Fill plane linesizes for an image with pixel format pix_fmt and width width.
Definition: imgutils.c:88
static void erosion(uint8_t *dst, const uint8_t *p1, int width, int threshold, const uint8_t *coordinates[], int coord)
Definition: vf_neighbor.c:75
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
uint8_t * data[AV_NUM_DATA_POINTERS]
pointer to the picture/channel planes.
Definition: frame.h:182
static int config_input(AVFilterLink *inlink)
Definition: vf_neighbor.c:145
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:63
Y , 8bpp.
Definition: pixfmt.h:71
int planeheight[4]
Definition: vf_neighbor.c:32
static const AVFilterPad neighbor_inputs[]
Definition: vf_neighbor.c:232
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:299
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:77
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:70
#define DEFINE_NEIGHBOR_FILTER(name_, description_)
Definition: vf_neighbor.c:253
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:302
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)
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:101
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:273
internal API functions
float min
AVPixelFormat
Pixel format.
Definition: pixfmt.h:61
const AVFilter * filter
the AVFilter of which this is an instance
Definition: avfilter.h:636
int av_frame_copy_props(AVFrame *dst, const AVFrame *src)
Copy only "metadata" fields from src to dst.
Definition: frame.c:553
static int width