FFmpeg
vf_fillborders.c
Go to the documentation of this file.
1 /*
2  * Copyright (c) 2017 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/colorspace.h"
22 #include "libavutil/common.h"
23 #include "libavutil/opt.h"
24 #include "libavutil/pixdesc.h"
25 #include "avfilter.h"
26 #include "drawutils.h"
27 #include "formats.h"
28 #include "internal.h"
29 #include "video.h"
30 
31 enum { Y, U, V, A };
32 enum { R, G, B };
33 
35 
36 typedef struct Borders {
37  int left, right, top, bottom;
38 } Borders;
39 
40 typedef struct FillBordersContext {
41  const AVClass *class;
42  int left, right, top, bottom;
43  int mode;
44 
45  int nb_planes;
46  int depth;
48  int planewidth[4];
49  int planeheight[4];
53 
56 
58 {
59  static const enum AVPixelFormat pix_fmts[] = {
78  };
80  if (!fmts_list)
81  return AVERROR(ENOMEM);
82  return ff_set_common_formats(ctx, fmts_list);
83 }
84 
86 {
87  int p, y;
88 
89  for (p = 0; p < s->nb_planes; p++) {
90  uint8_t *ptr = frame->data[p];
91  int linesize = frame->linesize[p];
92 
93  for (y = s->borders[p].top; y < s->planeheight[p] - s->borders[p].bottom; y++) {
94  memset(ptr + y * linesize,
95  *(ptr + y * linesize + s->borders[p].left),
96  s->borders[p].left);
97  memset(ptr + y * linesize + s->planewidth[p] - s->borders[p].right,
98  *(ptr + y * linesize + s->planewidth[p] - s->borders[p].right - 1),
99  s->borders[p].right);
100  }
101 
102  for (y = 0; y < s->borders[p].top; y++) {
103  memcpy(ptr + y * linesize,
104  ptr + s->borders[p].top * linesize, s->planewidth[p]);
105  }
106 
107  for (y = s->planeheight[p] - s->borders[p].bottom; y < s->planeheight[p]; y++) {
108  memcpy(ptr + y * linesize,
109  ptr + (s->planeheight[p] - s->borders[p].bottom - 1) * linesize,
110  s->planewidth[p]);
111  }
112  }
113 }
114 
116 {
117  int p, y, x;
118 
119  for (p = 0; p < s->nb_planes; p++) {
120  uint16_t *ptr = (uint16_t *)frame->data[p];
121  int linesize = frame->linesize[p] / 2;
122 
123  for (y = s->borders[p].top; y < s->planeheight[p] - s->borders[p].bottom; y++) {
124  for (x = 0; x < s->borders[p].left; x++) {
125  ptr[y * linesize + x] = *(ptr + y * linesize + s->borders[p].left);
126  }
127 
128  for (x = 0; x < s->borders[p].right; x++) {
129  ptr[y * linesize + s->planewidth[p] - s->borders[p].right + x] =
130  *(ptr + y * linesize + s->planewidth[p] - s->borders[p].right - 1);
131  }
132  }
133 
134  for (y = 0; y < s->borders[p].top; y++) {
135  memcpy(ptr + y * linesize,
136  ptr + s->borders[p].top * linesize, s->planewidth[p] * 2);
137  }
138 
139  for (y = s->planeheight[p] - s->borders[p].bottom; y < s->planeheight[p]; y++) {
140  memcpy(ptr + y * linesize,
141  ptr + (s->planeheight[p] - s->borders[p].bottom - 1) * linesize,
142  s->planewidth[p] * 2);
143  }
144  }
145 }
146 
148 {
149  int p, y, x;
150 
151  for (p = 0; p < s->nb_planes; p++) {
152  uint8_t *ptr = frame->data[p];
153  int linesize = frame->linesize[p];
154 
155  for (y = s->borders[p].top; y < s->planeheight[p] - s->borders[p].bottom; y++) {
156  for (x = 0; x < s->borders[p].left; x++) {
157  ptr[y * linesize + x] = ptr[y * linesize + s->borders[p].left * 2 - 1 - x];
158  }
159 
160  for (x = 0; x < s->borders[p].right; x++) {
161  ptr[y * linesize + s->planewidth[p] - s->borders[p].right + x] =
162  ptr[y * linesize + s->planewidth[p] - s->borders[p].right - 1 - x];
163  }
164  }
165 
166  for (y = 0; y < s->borders[p].top; y++) {
167  memcpy(ptr + y * linesize,
168  ptr + (s->borders[p].top * 2 - 1 - y) * linesize,
169  s->planewidth[p]);
170  }
171 
172  for (y = 0; y < s->borders[p].bottom; y++) {
173  memcpy(ptr + (s->planeheight[p] - s->borders[p].bottom + y) * linesize,
174  ptr + (s->planeheight[p] - s->borders[p].bottom - 1 - y) * linesize,
175  s->planewidth[p]);
176  }
177  }
178 }
179 
181 {
182  int p, y, x;
183 
184  for (p = 0; p < s->nb_planes; p++) {
185  uint16_t *ptr = (uint16_t *)frame->data[p];
186  int linesize = frame->linesize[p] / 2;
187 
188  for (y = s->borders[p].top; y < s->planeheight[p] - s->borders[p].bottom; y++) {
189  for (x = 0; x < s->borders[p].left; x++) {
190  ptr[y * linesize + x] = ptr[y * linesize + s->borders[p].left * 2 - 1 - x];
191  }
192 
193  for (x = 0; x < s->borders[p].right; x++) {
194  ptr[y * linesize + s->planewidth[p] - s->borders[p].right + x] =
195  ptr[y * linesize + s->planewidth[p] - s->borders[p].right - 1 - x];
196  }
197  }
198 
199  for (y = 0; y < s->borders[p].top; y++) {
200  memcpy(ptr + y * linesize,
201  ptr + (s->borders[p].top * 2 - 1 - y) * linesize,
202  s->planewidth[p] * 2);
203  }
204 
205  for (y = 0; y < s->borders[p].bottom; y++) {
206  memcpy(ptr + (s->planeheight[p] - s->borders[p].bottom + y) * linesize,
207  ptr + (s->planeheight[p] - s->borders[p].bottom - 1 - y) * linesize,
208  s->planewidth[p] * 2);
209  }
210  }
211 }
212 
214 {
215  int p, y;
216 
217  for (p = 0; p < s->nb_planes; p++) {
218  uint8_t *ptr = frame->data[p];
219  uint8_t fill = s->fill[p];
220  int linesize = frame->linesize[p];
221 
222  for (y = s->borders[p].top; y < s->planeheight[p] - s->borders[p].bottom; y++) {
223  memset(ptr + y * linesize, fill, s->borders[p].left);
224  memset(ptr + y * linesize + s->planewidth[p] - s->borders[p].right, fill,
225  s->borders[p].right);
226  }
227 
228  for (y = 0; y < s->borders[p].top; y++) {
229  memset(ptr + y * linesize, fill, s->planewidth[p]);
230  }
231 
232  for (y = s->planeheight[p] - s->borders[p].bottom; y < s->planeheight[p]; y++) {
233  memset(ptr + y * linesize, fill, s->planewidth[p]);
234  }
235  }
236 }
237 
239 {
240  int p, y, x;
241 
242  for (p = 0; p < s->nb_planes; p++) {
243  uint16_t *ptr = (uint16_t *)frame->data[p];
244  uint16_t fill = s->fill[p] << (s->depth - 8);
245  int linesize = frame->linesize[p] / 2;
246 
247  for (y = s->borders[p].top; y < s->planeheight[p] - s->borders[p].bottom; y++) {
248  for (x = 0; x < s->borders[p].left; x++) {
249  ptr[y * linesize + x] = fill;
250  }
251 
252  for (x = 0; x < s->borders[p].right; x++) {
253  ptr[y * linesize + s->planewidth[p] - s->borders[p].right + x] = fill;
254  }
255  }
256 
257  for (y = 0; y < s->borders[p].top; y++) {
258  for (x = 0; x < s->planewidth[p]; x++) {
259  ptr[y * linesize + x] = fill;
260  }
261  }
262 
263  for (y = s->planeheight[p] - s->borders[p].bottom; y < s->planeheight[p]; y++) {
264  for (x = 0; x < s->planewidth[p]; x++) {
265  ptr[y * linesize + x] = fill;
266  }
267  }
268  }
269 }
270 
272 {
273  FillBordersContext *s = inlink->dst->priv;
274 
275  s->fillborders(s, frame);
276 
277  return ff_filter_frame(inlink->dst->outputs[0], frame);
278 }
279 
281 {
282  AVFilterContext *ctx = inlink->dst;
283  FillBordersContext *s = ctx->priv;
285 
286  s->nb_planes = desc->nb_components;
287  s->depth = desc->comp[0].depth;
288 
289  s->planeheight[1] = s->planeheight[2] = AV_CEIL_RSHIFT(inlink->h, desc->log2_chroma_h);
290  s->planeheight[0] = s->planeheight[3] = inlink->h;
291  s->planewidth[1] = s->planewidth[2] = AV_CEIL_RSHIFT(inlink->w, desc->log2_chroma_w);
292  s->planewidth[0] = s->planewidth[3] = inlink->w;
293 
294  s->borders[0].left = s->borders[3].left = s->left;
295  s->borders[0].right = s->borders[3].right = s->right;
296  s->borders[0].top = s->borders[3].top = s->top;
297  s->borders[0].bottom = s->borders[3].bottom = s->bottom;
298 
299  s->borders[1].left = s->left >> desc->log2_chroma_w;
300  s->borders[1].right = s->right >> desc->log2_chroma_w;
301  s->borders[1].top = s->top >> desc->log2_chroma_h;
302  s->borders[1].bottom = s->bottom >> desc->log2_chroma_h;
303 
304  s->borders[2].left = s->left >> desc->log2_chroma_w;
305  s->borders[2].right = s->right >> desc->log2_chroma_w;
306  s->borders[2].top = s->top >> desc->log2_chroma_h;
307  s->borders[2].bottom = s->bottom >> desc->log2_chroma_h;
308 
309  if (inlink->w < s->left + s->right ||
310  inlink->w <= s->left ||
311  inlink->w <= s->right ||
312  inlink->h < s->top + s->bottom ||
313  inlink->h <= s->top ||
314  inlink->h <= s->bottom ||
315  inlink->w < s->left * 2 ||
316  inlink->w < s->right * 2 ||
317  inlink->h < s->top * 2 ||
318  inlink->h < s->bottom * 2) {
319  av_log(ctx, AV_LOG_ERROR, "Borders are bigger than input frame size.\n");
320  return AVERROR(EINVAL);
321  }
322 
323  switch (s->mode) {
324  case FM_SMEAR: s->fillborders = s->depth <= 8 ? smear_borders8 : smear_borders16; break;
325  case FM_MIRROR: s->fillborders = s->depth <= 8 ? mirror_borders8 : mirror_borders16; break;
326  case FM_FIXED: s->fillborders = s->depth <= 8 ? fixed_borders8 : fixed_borders16; break;
327  }
328 
329  s->yuv_color[Y] = RGB_TO_Y_CCIR(s->rgba_color[R], s->rgba_color[G], s->rgba_color[B]);
330  s->yuv_color[U] = RGB_TO_U_CCIR(s->rgba_color[R], s->rgba_color[G], s->rgba_color[B], 0);
331  s->yuv_color[V] = RGB_TO_V_CCIR(s->rgba_color[R], s->rgba_color[G], s->rgba_color[B], 0);
332  s->yuv_color[A] = s->rgba_color[A];
333 
334  if (desc->flags & AV_PIX_FMT_FLAG_RGB) {
335  uint8_t rgba_map[4];
336  int i;
337 
338  ff_fill_rgba_map(rgba_map, inlink->format);
339  for (i = 0; i < 4; i++)
340  s->fill[rgba_map[i]] = s->rgba_color[i];
341  } else {
342  memcpy(s->fill, s->yuv_color, sizeof(s->yuv_color));
343  }
344 
345  return 0;
346 }
347 
348 #define OFFSET(x) offsetof(FillBordersContext, x)
349 #define FLAGS AV_OPT_FLAG_VIDEO_PARAM|AV_OPT_FLAG_FILTERING_PARAM
350 
351 static const AVOption fillborders_options[] = {
352  { "left", "set the left fill border", OFFSET(left), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
353  { "right", "set the right fill border", OFFSET(right), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
354  { "top", "set the top fill border", OFFSET(top), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
355  { "bottom", "set the bottom fill border", OFFSET(bottom), AV_OPT_TYPE_INT, {.i64=0}, 0, INT_MAX, FLAGS },
356  { "mode", "set the fill borders mode", OFFSET(mode), AV_OPT_TYPE_INT, {.i64=FM_SMEAR}, 0, FM_NB_MODES-1, FLAGS, "mode" },
357  { "smear", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FM_SMEAR}, 0, 0, FLAGS, "mode" },
358  { "mirror", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FM_MIRROR}, 0, 0, FLAGS, "mode" },
359  { "fixed", NULL, 0, AV_OPT_TYPE_CONST, {.i64=FM_FIXED}, 0, 0, FLAGS, "mode" },
360  { "color", "set the color for the fixed mode", OFFSET(rgba_color), AV_OPT_TYPE_COLOR, {.str = "black"}, .flags = FLAGS },
361  { NULL }
362 };
363 
365 
366 static const AVFilterPad fillborders_inputs[] = {
367  {
368  .name = "default",
369  .type = AVMEDIA_TYPE_VIDEO,
370  .config_props = config_input,
371  .filter_frame = filter_frame,
372  .needs_writable = 1,
373  },
374  { NULL }
375 };
376 
378  {
379  .name = "default",
380  .type = AVMEDIA_TYPE_VIDEO,
381  },
382  { NULL }
383 };
384 
386  .name = "fillborders",
387  .description = NULL_IF_CONFIG_SMALL("Fill borders of the input video."),
388  .priv_size = sizeof(FillBordersContext),
389  .priv_class = &fillborders_class,
394 };
AV_PIX_FMT_YUVA422P16
#define AV_PIX_FMT_YUVA422P16
Definition: pixfmt.h:430
filter_frame
static int filter_frame(AVFilterLink *inlink, AVFrame *frame)
Definition: vf_fillborders.c:271
AV_PIX_FMT_GBRAP16
#define AV_PIX_FMT_GBRAP16
Definition: pixfmt.h:409
AVPixelFormat
AVPixelFormat
Pixel format.
Definition: pixfmt.h:64
AVERROR
Filter the word “frame” indicates either a video frame or a group of audio as stored in an AVFrame structure Format for each input and each output the list of supported formats For video that means pixel format For audio that means channel sample they are references to shared objects When the negotiation mechanism computes the intersection of the formats supported at each end of a all references to both lists are replaced with a reference to the intersection And when a single format is eventually chosen for a link amongst the remaining all references to the list are updated That means that if a filter requires that its input and output have the same format amongst a supported all it has to do is use a reference to the same list of formats query_formats can leave some formats unset and return AVERROR(EAGAIN) to cause the negotiation mechanism toagain later. That can be used by filters with complex requirements to use the format negotiated on one link to set the formats supported on another. Frame references ownership and permissions
opt.h
ff_make_format_list
AVFilterFormats * ff_make_format_list(const int *fmts)
Create a list of supported formats.
Definition: formats.c:283
FillBordersContext::planeheight
int planeheight[4]
Definition: vf_fillborders.c:49
ff_filter_frame
int ff_filter_frame(AVFilterLink *link, AVFrame *frame)
Send a frame of data to the next filter.
Definition: avfilter.c:1080
av_pix_fmt_desc_get
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
Definition: pixdesc.c:2522
RGB_TO_U_CCIR
#define RGB_TO_U_CCIR(r1, g1, b1, shift)
Definition: colorspace.h:102
inlink
The exact code depends on how similar the blocks are and how related they are to the and needs to apply these operations to the correct inlink or outlink if there are several Macros are available to factor that when no extra processing is inlink
Definition: filter_design.txt:212
AV_PIX_FMT_YUVA422P9
#define AV_PIX_FMT_YUVA422P9
Definition: pixfmt.h:422
fixed_borders16
static void fixed_borders16(FillBordersContext *s, AVFrame *frame)
Definition: vf_fillborders.c:238
AVFrame
This structure describes decoded (raw) audio or video data.
Definition: frame.h:295
pixdesc.h
AV_PIX_FMT_YUVA420P16
#define AV_PIX_FMT_YUVA420P16
Definition: pixfmt.h:429
AV_PIX_FMT_YUVA420P10
#define AV_PIX_FMT_YUVA420P10
Definition: pixfmt.h:424
FillBordersContext::nb_planes
int nb_planes
Definition: vf_fillborders.c:45
AVOption
AVOption.
Definition: opt.h:246
V
@ V
Definition: vf_fillborders.c:31
FillBordersContext::rgba_color
uint8_t rgba_color[4]
Definition: vf_fillborders.c:52
R
@ R
Definition: vf_fillborders.c:32
AV_PIX_FMT_YUV420P10
#define AV_PIX_FMT_YUV420P10
Definition: pixfmt.h:387
AV_PIX_FMT_YUV440P
@ AV_PIX_FMT_YUV440P
planar YUV 4:4:0 (1 Cr & Cb sample per 1x2 Y samples)
Definition: pixfmt.h:99
B
@ B
Definition: vf_fillborders.c:32
AVFilter::name
const char * name
Filter name.
Definition: avfilter.h:148
video.h
AV_PIX_FMT_YUVA422P10
#define AV_PIX_FMT_YUVA422P10
Definition: pixfmt.h:425
smear_borders8
static void smear_borders8(FillBordersContext *s, AVFrame *frame)
Definition: vf_fillborders.c:85
AV_PIX_FMT_GRAY9
#define AV_PIX_FMT_GRAY9
Definition: pixfmt.h:367
AVFilterFormats
A list of supported formats for one end of a filter link.
Definition: formats.h:64
formats.h
AV_PIX_FMT_YUVA420P9
#define AV_PIX_FMT_YUVA420P9
Definition: pixfmt.h:421
AV_PIX_FMT_GBRP14
#define AV_PIX_FMT_GBRP14
Definition: pixfmt.h:405
AV_PIX_FMT_GBRAP
@ AV_PIX_FMT_GBRAP
planar GBRA 4:4:4:4 32bpp
Definition: pixfmt.h:215
G
@ G
Definition: vf_fillborders.c:32
AV_PIX_FMT_GBRP10
#define AV_PIX_FMT_GBRP10
Definition: pixfmt.h:403
AV_PIX_FMT_YUVA444P16
#define AV_PIX_FMT_YUVA444P16
Definition: pixfmt.h:431
AV_PIX_FMT_YUV422P9
#define AV_PIX_FMT_YUV422P9
Definition: pixfmt.h:385
AV_PIX_FMT_GRAY16
#define AV_PIX_FMT_GRAY16
Definition: pixfmt.h:371
AVFilterPad
A filter pad used for either input or output.
Definition: internal.h:54
AV_PIX_FMT_YUV444P10
#define AV_PIX_FMT_YUV444P10
Definition: pixfmt.h:390
AV_PIX_FMT_YUVJ411P
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
Definition: pixfmt.h:258
colorspace.h
AV_LOG_ERROR
#define AV_LOG_ERROR
Something went wrong and cannot losslessly be recovered.
Definition: log.h:176
AVFILTER_DEFINE_CLASS
AVFILTER_DEFINE_CLASS(fillborders)
OFFSET
#define OFFSET(x)
Definition: vf_fillborders.c:348
AV_PIX_FMT_YUV422P16
#define AV_PIX_FMT_YUV422P16
Definition: pixfmt.h:399
ff_set_common_formats
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
AV_PIX_FMT_YUVJ422P
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
Definition: pixfmt.h:79
AV_PIX_FMT_GBRAP10
#define AV_PIX_FMT_GBRAP10
Definition: pixfmt.h:407
Borders::left
int left
Definition: vf_fillborders.c:37
s
#define s(width, name)
Definition: cbs_vp9.c:257
AV_PIX_FMT_GBRAP12
#define AV_PIX_FMT_GBRAP12
Definition: pixfmt.h:408
AV_PIX_FMT_YUVA420P
@ AV_PIX_FMT_YUVA420P
planar YUV 4:2:0, 20bpp, (1 Cr & Cb sample per 2x2 Y & A samples)
Definition: pixfmt.h:101
AV_PIX_FMT_YUV444P16
#define AV_PIX_FMT_YUV444P16
Definition: pixfmt.h:400
AV_CEIL_RSHIFT
#define AV_CEIL_RSHIFT(a, b)
Definition: common.h:58
RGB_TO_Y_CCIR
#define RGB_TO_Y_CCIR(r, g, b)
Definition: colorspace.h:98
FillBordersContext::depth
int depth
Definition: vf_fillborders.c:46
FillBordersContext::top
int top
Definition: vf_fillborders.c:42
outputs
static const AVFilterPad outputs[]
Definition: af_acontrast.c:203
pix_fmts
static enum AVPixelFormat pix_fmts[]
Definition: libkvazaar.c:275
AV_PIX_FMT_YUV420P9
#define AV_PIX_FMT_YUV420P9
Definition: pixfmt.h:384
AV_PIX_FMT_YUV420P16
#define AV_PIX_FMT_YUV420P16
Definition: pixfmt.h:398
ctx
AVFormatContext * ctx
Definition: movenc.c:48
AV_PIX_FMT_GRAY14
#define AV_PIX_FMT_GRAY14
Definition: pixfmt.h:370
AV_PIX_FMT_YUV420P
@ AV_PIX_FMT_YUV420P
planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)
Definition: pixfmt.h:66
AV_PIX_FMT_YUVJ444P
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
Definition: pixfmt.h:80
AV_PIX_FMT_GRAY10
#define AV_PIX_FMT_GRAY10
Definition: pixfmt.h:368
FillBordersContext::borders
Borders borders[4]
Definition: vf_fillborders.c:47
AV_PIX_FMT_GBRP16
#define AV_PIX_FMT_GBRP16
Definition: pixfmt.h:406
AVClass
Describe the class of an AVClass context structure.
Definition: log.h:67
NULL
#define NULL
Definition: coverity.c:32
FillBordersContext
Definition: vf_fillborders.c:40
query_formats
static int query_formats(AVFilterContext *ctx)
Definition: vf_fillborders.c:57
Y
@ Y
Definition: vf_fillborders.c:31
AV_PIX_FMT_YUVJ420P
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
Definition: pixfmt.h:78
AV_OPT_TYPE_COLOR
@ AV_OPT_TYPE_COLOR
Definition: opt.h:238
RGB_TO_V_CCIR
#define RGB_TO_V_CCIR(r1, g1, b1, shift)
Definition: colorspace.h:106
mirror_borders8
static void mirror_borders8(FillBordersContext *s, AVFrame *frame)
Definition: vf_fillborders.c:147
AV_PIX_FMT_YUV422P10
#define AV_PIX_FMT_YUV422P10
Definition: pixfmt.h:388
FM_FIXED
@ FM_FIXED
Definition: vf_fillborders.c:34
inputs
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several inputs
Definition: filter_design.txt:243
AV_PIX_FMT_GRAY8
@ AV_PIX_FMT_GRAY8
Y , 8bpp.
Definition: pixfmt.h:74
AV_PIX_FMT_GBRP9
#define AV_PIX_FMT_GBRP9
Definition: pixfmt.h:402
smear_borders16
static void smear_borders16(FillBordersContext *s, AVFrame *frame)
Definition: vf_fillborders.c:115
Borders::right
int right
Definition: vf_fillborders.c:37
for
for(j=16;j >0;--j)
Definition: h264pred_template.c:469
FillBordersContext::right
int right
Definition: vf_fillborders.c:42
FillBordersContext::left
int left
Definition: vf_fillborders.c:42
desc
const char * desc
Definition: nvenc.c:68
NULL_IF_CONFIG_SMALL
#define NULL_IF_CONFIG_SMALL(x)
Return NULL if CONFIG_SMALL is true, otherwise the argument without modification.
Definition: internal.h:188
AV_PIX_FMT_FLAG_RGB
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
Definition: pixdesc.h:148
ff_vf_fillborders
AVFilter ff_vf_fillborders
Definition: vf_fillborders.c:385
AV_PIX_FMT_YUV422P12
#define AV_PIX_FMT_YUV422P12
Definition: pixfmt.h:392
AV_PIX_FMT_YUV444P12
#define AV_PIX_FMT_YUV444P12
Definition: pixfmt.h:394
FLAGS
#define FLAGS
Definition: vf_fillborders.c:349
FillBordersContext::fillborders
void(* fillborders)(struct FillBordersContext *s, AVFrame *frame)
Definition: vf_fillborders.c:54
AV_PIX_FMT_YUVA444P
@ AV_PIX_FMT_YUVA444P
planar YUV 4:4:4 32bpp, (1 Cr & Cb sample per 1x1 Y & A samples)
Definition: pixfmt.h:177
AV_PIX_FMT_YUVA444P10
#define AV_PIX_FMT_YUVA444P10
Definition: pixfmt.h:426
FillBordersContext::bottom
int bottom
Definition: vf_fillborders.c:42
internal.h
AVFILTER_FLAG_SUPPORT_TIMELINE_GENERIC
#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:125
fillborders_outputs
static const AVFilterPad fillborders_outputs[]
Definition: vf_fillborders.c:377
FM_MIRROR
@ FM_MIRROR
Definition: vf_fillborders.c:34
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:259
U
@ U
Definition: vf_fillborders.c:31
Borders::top
int top
Definition: vf_fillborders.c:37
AV_PIX_FMT_GBRP12
#define AV_PIX_FMT_GBRP12
Definition: pixfmt.h:404
common.h
FillBordersContext::fill
uint8_t fill[4]
Definition: vf_fillborders.c:50
AV_PIX_FMT_YUVJ440P
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
Definition: pixfmt.h:100
uint8_t
uint8_t
Definition: audio_convert.c:194
AVFilterPad::name
const char * name
Pad name.
Definition: internal.h:60
AV_PIX_FMT_YUV444P9
#define AV_PIX_FMT_YUV444P9
Definition: pixfmt.h:386
FillBordersContext::planewidth
int planewidth[4]
Definition: vf_fillborders.c:48
AVFilter
Filter definition.
Definition: avfilter.h:144
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
AV_PIX_FMT_YUVA444P9
#define AV_PIX_FMT_YUVA444P9
Definition: pixfmt.h:423
Borders
Definition: vf_fillborders.c:36
AV_PIX_FMT_YUV420P12
#define AV_PIX_FMT_YUV420P12
Definition: pixfmt.h:391
left
Tag MUST be and< 10hcoeff half pel interpolation filter coefficients, hcoeff[0] are the 2 middle coefficients[1] are the next outer ones and so on, resulting in a filter like:...eff[2], hcoeff[1], hcoeff[0], hcoeff[0], hcoeff[1], hcoeff[2] ... the sign of the coefficients is not explicitly stored but alternates after each coeff and coeff[0] is positive, so ...,+,-,+,-,+,+,-,+,-,+,... hcoeff[0] is not explicitly stored but found by subtracting the sum of all stored coefficients with signs from 32 hcoeff[0]=32 - hcoeff[1] - hcoeff[2] - ... a good choice for hcoeff and htaps is htaps=6 hcoeff={40,-10, 2} an alternative which requires more computations at both encoder and decoder side and may or may not be better is htaps=8 hcoeff={42,-14, 6,-2}ref_frames minimum of the number of available reference frames and max_ref_frames for example the first frame after a key frame always has ref_frames=1spatial_decomposition_type wavelet type 0 is a 9/7 symmetric compact integer wavelet 1 is a 5/3 symmetric compact integer wavelet others are reserved stored as delta from last, last is reset to 0 if always_reset||keyframeqlog quality(logarithmic quantizer scale) stored as delta from last, last is reset to 0 if always_reset||keyframemv_scale stored as delta from last, last is reset to 0 if always_reset||keyframe FIXME check that everything works fine if this changes between framesqbias dequantization bias stored as delta from last, last is reset to 0 if always_reset||keyframeblock_max_depth maximum depth of the block tree stored as delta from last, last is reset to 0 if always_reset||keyframequant_table quantization tableHighlevel bitstream structure:==============================--------------------------------------------|Header|--------------------------------------------|------------------------------------|||Block0||||split?||||yes no||||......... intra?||||:Block01 :yes no||||:Block02 :....... ..........||||:Block03 ::y DC ::ref index:||||:Block04 ::cb DC ::motion x :||||......... :cr DC ::motion y :||||....... ..........|||------------------------------------||------------------------------------|||Block1|||...|--------------------------------------------|------------ ------------ ------------|||Y subbands||Cb subbands||Cr subbands||||--- ---||--- ---||--- ---|||||LL0||HL0||||LL0||HL0||||LL0||HL0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||LH0||HH0||||LH0||HH0||||LH0||HH0|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HL1||LH1||||HL1||LH1||||HL1||LH1|||||--- ---||--- ---||--- ---||||--- ---||--- ---||--- ---|||||HH1||HL2||||HH1||HL2||||HH1||HL2|||||...||...||...|||------------ ------------ ------------|--------------------------------------------Decoding process:=================------------|||Subbands|------------||||------------|Intra DC||||LL0 subband prediction ------------|\ Dequantization ------------------- \||Reference frames|\ IDWT|------- -------|Motion \|||Frame 0||Frame 1||Compensation . OBMC v -------|------- -------|--------------. \------> Frame n output Frame Frame<----------------------------------/|...|------------------- Range Coder:============Binary Range Coder:------------------- The implemented range coder is an adapted version based upon "Range encoding: an algorithm for removing redundancy from a digitised message." by G. N. N. Martin. The symbols encoded by the Snow range coder are bits(0|1). The associated probabilities are not fix but change depending on the symbol mix seen so far. bit seen|new state ---------+----------------------------------------------- 0|256 - state_transition_table[256 - old_state];1|state_transition_table[old_state];state_transition_table={ 0, 0, 0, 0, 0, 0, 0, 0, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 94, 95, 96, 97, 98, 99, 100, 101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111, 112, 113, 114, 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132, 133, 133, 134, 135, 136, 137, 138, 139, 140, 141, 142, 143, 144, 145, 146, 147, 148, 149, 150, 151, 152, 152, 153, 154, 155, 156, 157, 158, 159, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 170, 171, 171, 172, 173, 174, 175, 176, 177, 178, 179, 180, 181, 182, 183, 184, 185, 186, 187, 188, 189, 190, 190, 191, 192, 194, 194, 195, 196, 197, 198, 199, 200, 201, 202, 202, 204, 205, 206, 207, 208, 209, 209, 210, 211, 212, 213, 215, 215, 216, 217, 218, 219, 220, 220, 222, 223, 224, 225, 226, 227, 227, 229, 229, 230, 231, 232, 234, 234, 235, 236, 237, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 0, 0, 0, 0, 0, 0, 0};FIXME Range Coding of integers:------------------------- FIXME Neighboring Blocks:===================left and top are set to the respective blocks unless they are outside of the image in which case they are set to the Null block top-left is set to the top left block unless it is outside of the image in which case it is set to the left block if this block has no larger parent block or it is at the left side of its parent block and the top right block is not outside of the image then the top right block is used for top-right else the top-left block is used Null block y, cb, cr are 128 level, ref, mx and my are 0 Motion Vector Prediction:=========================1. the motion vectors of all the neighboring blocks are scaled to compensate for the difference of reference frames scaled_mv=(mv *(256 *(current_reference+1)/(mv.reference+1))+128)> the median of the scaled left
Definition: snow.txt:386
AV_PIX_FMT_YUV422P14
#define AV_PIX_FMT_YUV422P14
Definition: pixfmt.h:396
FM_SMEAR
@ FM_SMEAR
Definition: vf_fillborders.c:34
FillBordersContext::yuv_color
uint8_t yuv_color[4]
Definition: vf_fillborders.c:51
fixed_borders8
static void fixed_borders8(FillBordersContext *s, AVFrame *frame)
Definition: vf_fillborders.c:213
Borders::bottom
int bottom
Definition: vf_fillborders.c:37
mode
mode
Definition: ebur128.h:83
AV_PIX_FMT_NONE
@ AV_PIX_FMT_NONE
Definition: pixfmt.h:65
AV_OPT_TYPE_INT
@ AV_OPT_TYPE_INT
Definition: opt.h:223
avfilter.h
FM_NB_MODES
@ FM_NB_MODES
Definition: vf_fillborders.c:34
A
@ A
Definition: vf_fillborders.c:31
AV_PIX_FMT_YUV444P
@ AV_PIX_FMT_YUV444P
planar YUV 4:4:4, 24bpp, (1 Cr & Cb sample per 1x1 Y samples)
Definition: pixfmt.h:71
config_input
static int config_input(AVFilterLink *inlink)
Definition: vf_fillborders.c:280
AVFilterContext
An instance of a filter.
Definition: avfilter.h:338
AV_PIX_FMT_GBRP
@ AV_PIX_FMT_GBRP
planar GBR 4:4:4 24bpp
Definition: pixfmt.h:168
AVMEDIA_TYPE_VIDEO
@ AVMEDIA_TYPE_VIDEO
Definition: avutil.h:201
AV_PIX_FMT_YUV422P
@ AV_PIX_FMT_YUV422P
planar YUV 4:2:2, 16bpp, (1 Cr & Cb sample per 2x1 Y samples)
Definition: pixfmt.h:70
AVPixFmtDescriptor
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
Definition: pixdesc.h:81
AV_PIX_FMT_YUV411P
@ AV_PIX_FMT_YUV411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples)
Definition: pixfmt.h:73
ff_fill_rgba_map
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
Definition: drawutils.c:35
fillborders_options
static const AVOption fillborders_options[]
Definition: vf_fillborders.c:351
FillMode
FillMode
Definition: vf_fillborders.c:34
flags
#define flags(name, subs,...)
Definition: cbs_av1.c:565
AV_PIX_FMT_YUV410P
@ AV_PIX_FMT_YUV410P
planar YUV 4:1:0, 9bpp, (1 Cr & Cb sample per 4x4 Y samples)
Definition: pixfmt.h:72
av_log
#define av_log(a,...)
Definition: tableprint_vlc.h:28
fillborders_inputs
static const AVFilterPad fillborders_inputs[]
Definition: vf_fillborders.c:366
AV_PIX_FMT_YUV440P12
#define AV_PIX_FMT_YUV440P12
Definition: pixfmt.h:393
AV_PIX_FMT_YUV444P14
#define AV_PIX_FMT_YUV444P14
Definition: pixfmt.h:397
FillBordersContext::mode
int mode
Definition: vf_fillborders.c:43
AV_PIX_FMT_GRAY12
#define AV_PIX_FMT_GRAY12
Definition: pixfmt.h:369
drawutils.h
AV_OPT_TYPE_CONST
@ AV_OPT_TYPE_CONST
Definition: opt.h:232
AV_PIX_FMT_YUVA422P
@ AV_PIX_FMT_YUVA422P
planar YUV 4:2:2 24bpp, (1 Cr & Cb sample per 2x1 Y & A samples)
Definition: pixfmt.h:176
AV_PIX_FMT_YUV420P14
#define AV_PIX_FMT_YUV420P14
Definition: pixfmt.h:395
mirror_borders16
static void mirror_borders16(FillBordersContext *s, AVFrame *frame)
Definition: vf_fillborders.c:180