FFmpeg: libavfilter/drawutils.c Source File
Go to the documentation of this file. 1 /*
2 * Copyright 2011 Stefano Sabatini <stefano.sabatini-lala poste it>
3 * Copyright 2012 Nicolas George <nicolas.george normalesup org>
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 <string.h>
23
32
34
36 {
48 } else {
49 int had0 = 0;
50 unsigned depthb = 0;
51 for (
unsigned i = 0;
i <
desc->nb_components;
i++) {
52 /* all components must have same depth in bytes */
53 unsigned db = (
desc->comp[
i].depth + 7) / 8;
54 unsigned pos =
desc->comp[
i].offset / db;
55 if (depthb && (depthb != db))
57
58 if (
desc->comp[
i].offset % db)
60
63 depthb = db;
64 }
65
66 if (
desc->nb_components == 3)
68 }
69
76
77 return 0;
78 }
79
81 {
86 }
87
89 {
94 }
95
98 {
102 unsigned nb_planes = 0;
104 int depthb = 0;
105
123 for (
unsigned i = 0;
i <
desc->nb_components;
i++) {
124 int db;
126 /* for now, only 8-16 bits formats */
127 if (
c->depth < 8 ||
c->depth > 16)
131 /* data must either be in the high or low bits, never middle */
132 if (
c->shift && ((
c->shift +
c->depth) & 0x7))
134 /* mixed >8 and <=8 depth */
135 db = (
c->depth + 7) / 8;
136 if (depthb && (depthb != db))
138 depthb = db;
139 if (db * (
c->offset + 1) > 16)
143 /* strange interleaving */
144 if (pixelstep[
c->plane] != 0 &&
145 pixelstep[
c->plane] !=
c->step)
147 pixelstep[
c->plane] =
c->step;
148 if (pixelstep[
c->plane] >= 8)
150 nb_planes =
FFMAX(nb_planes,
c->plane + 1);
151 }
155 draw->nb_planes = nb_planes;
160 if (luma)
162 memcpy(
draw->pixelstep, pixelstep,
sizeof(
draw->pixelstep));
165 return 0;
166 }
167
170 {
172 }
173
175 {
177 }
178
180 {
181 double yuvad[4];
182 double rgbad[4];
184
185 if (rgba !=
color->rgba)
186 memcpy(
color->rgba, rgba,
sizeof(
color->rgba));
187
189
190 for (
int i = 0;
i < 4;
i++)
191 rgbad[
i] =
color->rgba[
i] / 255.;
192
194 for (
int i = 0;
i < 3;
i++)
195 rgbad[
i] *= rgbad[3];
196 }
197
199 memcpy(yuvad, rgbad, sizeof(double) * 3);
200 else
202
203 yuvad[3] = rgbad[3];
204
205 for (
int i = 0;
i < 3;
i++) {
208 yuvad[
i] *= (
chroma ? 224. : 219.) / 255.;
209 yuvad[
i] += (
chroma ? 128. : 16.) / 255.;
212 }
213 }
214
215 // Ensure we place the alpha appropriately for gray formats
216 if (
desc->nb_components <= 2)
217 yuvad[1] = yuvad[3];
218
219 for (
unsigned i = 0;
i <
desc->nb_components;
i++) {
220 unsigned val = yuvad[
i] * ((1 << (
draw->desc->comp[
i].depth +
draw->desc->comp[
i].shift)) - 1) + 0.5;
221 if (
desc->comp[
i].depth > 8)
223 else
225 }
226 }
227
229 int plane, int x, int y)
230 {
232 (y >>
draw->vsub[plane]) * linesize[plane] +
233 (x >>
draw->hsub[plane]) *
draw->pixelstep[plane];
234 }
235
237 uint8_t *
dst[],
int dst_linesize[],
238 uint8_t *
src[],
int src_linesize[],
239 int dst_x, int dst_y, int src_x, int src_y,
241 {
242 int wp, hp;
244
245 for (
int plane = 0; plane <
draw->nb_planes; plane++) {
250 for (int y = 0; y < hp; y++) {
252 p += src_linesize[plane];
253 q += dst_linesize[plane];
254 }
255 }
256 }
257
259 uint8_t *
dst[],
int dst_linesize[],
260 int dst_x,
int dst_y,
int w,
int h)
261 {
262 int wp, hp;
265
266 for (
int plane = 0; plane <
draw->nb_planes; plane++) {
270 if (!hp)
271 return;
273
274 if (HAVE_BIGENDIAN &&
draw->desc->comp[0].depth > 8) {
275 for (
int x = 0; 2*x <
draw->pixelstep[plane]; x++)
277 }
278
279 /* copy first line from color */
280 for (int x = 0; x < wp; x++) {
281 memcpy(
p, color_tmp.
comp[plane].
u8,
draw->pixelstep[plane]);
282 p +=
draw->pixelstep[plane];
283 }
284 wp *=
draw->pixelstep[plane];
285 /* copy next lines from first line */
286 p = p0 + dst_linesize[plane];
287 for (int y = 1; y < hp; y++) {
289 p += dst_linesize[plane];
290 }
291 }
292 }
293
294 /**
295 * Clip interval [x; x+w[ within [0; wmax[.
296 * The resulting w may be negative if the final interval is empty.
297 * dx, if not null, return the difference between in and out value of x.
298 */
300 {
301 if (dx)
302 *dx = 0;
303 if (*x < 0) {
304 if (dx)
305 *dx = -*x;
307 *x = 0;
308 }
311 }
312
313 /**
314 * Decompose w pixels starting at x
315 * into start + (w starting at x) + end
316 * with x and w aligned on multiples of 1<<sub.
317 */
319 {
320 int mask = (1 << sub) - 1;
321
322 *start = (-*x) &
mask;
323 *x += *start;
324 *start =
FFMIN(*start, *
w);
328 }
329
330 /* If alpha is in the [ 0 ; 0x1010101 ] range,
331 then alpha * value is in the [ 0 ; 0xFFFFFFFF ] range,
332 and >> 24 gives a correct rounding. */
334 int dx,
int w,
unsigned hsub,
int left,
int right)
335 {
337 unsigned tau = 0x1010101 -
alpha;
338
341 *
dst = (*
dst * (0x1010101 - suba) +
src * suba) >> 24;
343 }
344 for (
int x = 0; x <
w; x++) {
345 *
dst = (*
dst * tau + asrc) >> 24;
347 }
348 if (right) {
350 *
dst = (*
dst * (0x1010101 - suba) +
src * suba) >> 24;
351 }
352 }
353
355 int dx,
int w,
unsigned hsub,
int left,
int right)
356 {
358 unsigned tau = 0x10001 -
alpha;
359
365 }
366 for (
int x = 0; x <
w; x++) {
370 }
371 if (right) {
375 }
376 }
377
379 uint8_t *
dst[],
int dst_linesize[],
380 int dst_w, int dst_h,
381 int x0,
int y0,
int w,
int h)
382 {
383 unsigned alpha, nb_planes, nb_comp;
384 int w_sub, h_sub, x_sub, y_sub,
left, right, top, bottom;
386
387 nb_comp =
draw->desc->nb_components -
389
390 /* TODO optimize if alpha = 0xFF */
393 if (
w <= 0 || h <= 0 || !color->rgba[3])
394 return;
395 if (
draw->desc->comp[0].depth <= 8) {
396 /* 0x10203 * alpha + 2 is in the [ 2 ; 0x1010101 - 2 ] range */
398 } else {
399 /* 0x101 * alpha is in the [ 2 ; 0x1001] range */
401 }
403 nb_planes += !nb_planes;
404 for (unsigned plane = 0; plane < nb_planes; plane++) {
408 x_sub = x0;
409 y_sub = y0;
413 const int depth =
draw->desc->comp[
comp].depth;
416
417 if (
draw->desc->comp[
comp].plane != plane)
418 continue;
420 if (top) {
421 if (depth <= 8) {
423 draw->pixelstep[plane], w_sub,
425 } else {
427 draw->pixelstep[plane], w_sub,
429 }
430 p += dst_linesize[plane];
431 }
432 if (depth <= 8) {
433 for (int y = 0; y < h_sub; y++) {
435 draw->pixelstep[plane], w_sub,
437 p += dst_linesize[plane];
438 }
439 } else {
440 for (int y = 0; y < h_sub; y++) {
442 draw->pixelstep[plane], w_sub,
444 p += dst_linesize[plane];
445 }
446 }
447 if (bottom) {
448 if (depth <= 8) {
450 draw->pixelstep[plane], w_sub,
452 } else {
454 draw->pixelstep[plane], w_sub,
456 }
457 }
458 }
459 }
460 }
461
463 const uint8_t *
mask,
int mask_linesize,
int l2depth,
464 unsigned w,
unsigned h,
unsigned shift,
unsigned xm0)
465 {
466 unsigned t = 0;
467 unsigned xmshf = 3 - l2depth;
468 unsigned xmmod = 7 >> l2depth;
469 unsigned mbits = (1 << (1 << l2depth)) - 1;
470 unsigned mmult = 255 / mbits;
472
473 for (
unsigned y = 0; y <
h; y++) {
474 unsigned xm = xm0;
475 for (
unsigned x = 0; x <
w; x++) {
476 t += ((
mask[xm >> xmshf] >> ((~xm & xmmod) << l2depth)) & mbits)
477 * mmult;
478 xm++;
479 }
480 mask += mask_linesize;
481 }
484 }
485
487 const uint8_t *
mask,
int mask_linesize,
int l2depth,
488 unsigned w,
unsigned h,
unsigned shift,
unsigned xm0)
489 {
490 unsigned t = 0;
491 unsigned xmshf = 3 - l2depth;
492 unsigned xmmod = 7 >> l2depth;
493 unsigned mbits = (1 << (1 << l2depth)) - 1;
494 unsigned mmult = 255 / mbits;
495
496 for (
unsigned y = 0; y <
h; y++) {
497 unsigned xm = xm0;
498 for (
unsigned x = 0; x <
w; x++) {
499 t += ((
mask[xm >> xmshf] >> ((~xm & xmmod) << l2depth)) & mbits)
500 * mmult;
501 xm++;
502 }
503 mask += mask_linesize;
504 }
507 }
508
511 const uint8_t *
mask,
int mask_linesize,
int l2depth,
int w,
512 unsigned hsub,
unsigned vsub,
513 int xm,
int left,
int right,
int hband)
514 {
515
521 }
522 for (
int x = 0; x <
w; x++) {
527 }
528 if (right)
530 right, hband,
hsub + vsub, xm);
531 }
532
535 const uint8_t *
mask,
int mask_linesize,
int l2depth,
int w,
536 unsigned hsub,
unsigned vsub,
537 int xm,
int left,
int right,
int hband)
538 {
539
545 }
546 for (
int x = 0; x <
w; x++) {
551 }
552 if (right)
554 right, hband,
hsub + vsub, xm);
555 }
556
558 uint8_t *
dst[],
int dst_linesize[],
int dst_w,
int dst_h,
559 const uint8_t *
mask,
int mask_linesize,
int mask_w,
int mask_h,
560 int l2depth,
unsigned endianness,
int x0,
int y0)
561 {
562 unsigned alpha, nb_planes, nb_comp;
563 int xm0, ym0, w_sub, h_sub, x_sub, y_sub,
left, right, top, bottom;
565 const uint8_t *m;
566
567 nb_comp =
draw->desc->nb_components -
569
572 mask += ym0 * mask_linesize;
573 if (mask_w <= 0 || mask_h <= 0 || !color->rgba[3])
574 return;
575 if (
draw->desc->comp[0].depth <= 8) {
576 /* alpha is in the [ 0 ; 0x10203 ] range,
577 alpha * mask is in the [ 0 ; 0x1010101 - 4 ] range */
578 alpha = (0x10307 *
color->rgba[3] + 0x3) >> 8;
579 } else {
581 }
583 nb_planes += !nb_planes;
584 for (unsigned plane = 0; plane < nb_planes; plane++) {
586 w_sub = mask_w;
587 h_sub = mask_h;
588 x_sub = x0;
589 y_sub = y0;
593 const int depth =
draw->desc->comp[
comp].depth;
596
597 if (
draw->desc->comp[
comp].plane != plane)
598 continue;
601 if (top) {
602 if (depth <= 8) {
605 m, mask_linesize, l2depth, w_sub,
606 draw->hsub[plane],
draw->vsub[plane],
607 xm0,
left, right, top);
608 } else {
611 m, mask_linesize, l2depth, w_sub,
612 draw->hsub[plane],
draw->vsub[plane],
613 xm0,
left, right, top);
614 }
615 p += dst_linesize[plane];
616 m += top * mask_linesize;
617 }
618 if (depth <= 8) {
619 for (int y = 0; y < h_sub; y++) {
622 m, mask_linesize, l2depth, w_sub,
623 draw->hsub[plane],
draw->vsub[plane],
624 xm0,
left, right, 1 <<
draw->vsub[plane]);
625 p += dst_linesize[plane];
626 m += mask_linesize <<
draw->vsub[plane];
627 }
628 } else {
629 for (int y = 0; y < h_sub; y++) {
632 m, mask_linesize, l2depth, w_sub,
633 draw->hsub[plane],
draw->vsub[plane],
634 xm0,
left, right, 1 <<
draw->vsub[plane]);
635 p += dst_linesize[plane];
636 m += mask_linesize <<
draw->vsub[plane];
637 }
638 }
639 if (bottom) {
640 if (depth <= 8) {
643 m, mask_linesize, l2depth, w_sub,
644 draw->hsub[plane],
draw->vsub[plane],
645 xm0,
left, right, bottom);
646 } else {
649 m, mask_linesize, l2depth, w_sub,
650 draw->hsub[plane],
draw->vsub[plane],
651 xm0,
left, right, bottom);
652 }
653 }
654 }
655 }
656 }
657
660 {
662
665 if (round_dir >= 0)
668 }
669
671 {
675
680 return fmts;
681 }
enum AVColorRange color_range
MPEG vs JPEG YUV range.
AVPixelFormat
Pixel format.
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
@ AVALPHA_MODE_PREMULTIPLIED
Alpha channel is multiplied into color values.
static void comp(unsigned char *dst, ptrdiff_t dst_stride, unsigned char *src, ptrdiff_t src_stride, int add)
const AVPixFmtDescriptor * av_pix_fmt_desc_get(enum AVPixelFormat pix_fmt)
static int fill_map(const AVPixFmtDescriptor *desc, uint8_t *map)
static void subsampling_bounds(int sub, int *x, int *w, int *start, int *end)
Decompose w pixels starting at x into start + (w starting at x) + end with x and w aligned on multipl...
enum AVColorSpace colorspace
YUV colorspace type.
@ AVCOL_RANGE_JPEG
Full range content.
const struct AVLumaCoefficients * av_csp_luma_coeffs_from_avcsp(enum AVColorSpace csp)
Retrieves the Luma coefficients necessary to construct a conversion matrix from an enum constant desc...
static void blend_pixel16(uint8_t *dst, unsigned src, unsigned alpha, const uint8_t *mask, int mask_linesize, int l2depth, unsigned w, unsigned h, unsigned shift, unsigned xm0)
@ AVCOL_SPC_RGB
order of coefficients is actually GBR, also IEC 61966-2-1 (sRGB), YZX and ST 428-1
Struct containing luma coefficients to be used for RGB to YUV/YCoCg, or similar calculations.
A link between two filters.
int av_pix_fmt_count_planes(enum AVPixelFormat pix_fmt)
#define AV_PIX_FMT_FLAG_HWACCEL
Pixel format is an HW accelerated format.
enum AVAlphaMode alpha_mode
Indicates how the alpha channel of the video is to be handled.
static double val(void *priv, double ch)
void ff_blend_mask(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_w, int dst_h, const uint8_t *mask, int mask_linesize, int mask_w, int mask_h, int l2depth, unsigned endianness, int x0, int y0)
Blend an alpha mask with an uniform color.
@ AV_PIX_FMT_YUVJ411P
planar YUV 4:1:1, 12bpp, (1 Cr & Cb sample per 4x1 Y samples) full scale (JPEG), deprecated in favor ...
int ff_draw_init2(FFDrawContext *draw, enum AVPixelFormat format, enum AVColorSpace csp, enum AVColorRange range, enum AVAlphaMode alpha, unsigned flags)
Init a draw context.
@ AV_PIX_FMT_YUVJ422P
planar YUV 4:2:2, 16bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV422P and setting col...
#define AV_CEIL_RSHIFT(a, b)
@ AVCOL_SPC_SMPTE170M
also ITU-R BT601-6 525 / ITU-R BT1358 525 / ITU-R BT1700 NTSC / functionally identical to above
static enum AVPixelFormat pix_fmt
void ff_copy_rectangle2(FFDrawContext *draw, uint8_t *dst[], int dst_linesize[], uint8_t *src[], int src_linesize[], int dst_x, int dst_y, int src_x, int src_y, int w, int h)
Copy a rectangle from an image to another.
#define FF_DRAW_PROCESS_ALPHA
Process alpha pixel component.
static void blend_line_hv16(uint8_t *dst, int dst_delta, unsigned src, unsigned alpha, const uint8_t *mask, int mask_linesize, int l2depth, int w, unsigned hsub, unsigned vsub, int xm, int left, int right, int hband)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define AV_PIX_FMT_FLAG_ALPHA
The pixel format has an alpha channel.
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_RL16
int ff_draw_init(FFDrawContext *draw, enum AVPixelFormat format, unsigned flags)
void ff_matrix_mul_3x3_vec(double dst[3], const double vec[3], const double mat[3][3])
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 link
@ AV_PIX_FMT_YUVJ444P
planar YUV 4:4:4, 24bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV444P and setting col...
New swscale design to change SwsGraph is what coordinates multiple passes These can include cascaded scaling error diffusion and so on Or we could have separate passes for the vertical and horizontal scaling In between each SwsPass lies a fully allocated image buffer Graph passes may have different levels of e g we can have a single threaded error diffusion pass following a multi threaded scaling pass SwsGraph is internally recreated whenever the image format
@ AV_PIX_FMT_YUVJ420P
planar YUV 4:2:0, 12bpp, full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV420P and setting col...
int ff_fill_ayuv_map(uint8_t *ayuv_map, enum AVPixelFormat pix_fmt)
static void clip_interval(int wmax, int *x, int *w, int *dx)
Clip interval [x; x+w[ within [0; wmax[.
@ AVCOL_RANGE_UNSPECIFIED
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
AVAlphaMode
Correlation between the alpha channel and color values.
union FFDrawColor::@355 comp[MAX_PLANES]
#define AV_PIX_FMT_FLAG_RGB
The pixel format contains RGB-like data (as opposed to YUV/grayscale).
static int shift(int a, int b)
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
void ff_blend_rectangle(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_w, int dst_h, int x0, int y0, int w, int h)
Blend a rectangle with an uniform color.
static const uint32_t color[16+AV_CLASS_CATEGORY_NB]
void ff_fill_rectangle(FFDrawContext *draw, FFDrawColor *color, uint8_t *dst[], int dst_linesize[], int dst_x, int dst_y, int w, int h)
Fill a rectangle with an uniform color.
#define AV_PIX_FMT_FLAG_BITSTREAM
All values of a component are bit-wise packed end to end.
int format
format of the frame, -1 if unknown or unset Values correspond to enum AVPixelFormat for video frames,...
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf offset
enum AVPixelFormat av_pix_fmt_desc_get_id(const AVPixFmtDescriptor *desc)
static int draw(AVFilterContext *ctx, void *arg, int jobnr, int nb_jobs)
#define AV_PIX_FMT_FLAG_BAYER
The pixel format is following a Bayer pattern.
void ff_fill_rgb2yuv_table(const AVLumaCoefficients *coeffs, double rgb2yuv[3][3])
#define i(width, name, range_min, range_max)
AVFilterFormats * ff_draw_supported_pixel_formats(unsigned flags)
Return the list of pixel formats supported by the draw functions.
AVColorSpace
YUV colorspace type.
int ff_draw_round_to_sub(FFDrawContext *draw, int sub_dir, int round_dir, int value)
Round a dimension according to subsampling.
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf default value
#define AV_PIX_FMT_FLAG_BE
Pixel format is big-endian.
@ AV_PIX_FMT_YUVJ440P
planar YUV 4:4:0 full scale (JPEG), deprecated in favor of AV_PIX_FMT_YUV440P and setting color_range
@ AVCOL_RANGE_MPEG
Narrow or limited range content.
void ff_draw_color(FFDrawContext *draw, FFDrawColor *color, const uint8_t rgba[4])
Prepare a color.
@ AVALPHA_MODE_UNSPECIFIED
Unknown alpha handling, or no alpha channel.
static void blend_pixel(uint8_t *dst, unsigned src, unsigned alpha, const uint8_t *mask, int mask_linesize, int l2depth, unsigned w, unsigned h, unsigned shift, unsigned xm0)
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
#define AV_PIX_FMT_FLAG_XYZ
The pixel format contains XYZ-like data (as opposed to YUV/RGB/grayscale).
static void blend_line(uint8_t *dst, unsigned src, unsigned alpha, int dx, int w, unsigned hsub, int left, int right)
#define AV_PIX_FMT_FLAG_PLANAR
At least one pixel component is not in the first data plane.
IDirect3DDxgiInterfaceAccess _COM_Outptr_ void ** p
int ff_draw_init_from_link(FFDrawContext *draw, const AVFilterLink *link, unsigned flags)
Init a draw context, taking the format, colorspace and range from the given filter link.
Descriptor that unambiguously describes how the bits of a pixel are stored in the up to 4 data planes...
const VDPAUPixFmtMap * map
static const int16_t alpha[]
static uint8_t * pointer_at(FFDrawContext *draw, uint8_t *data[], int linesize[], int plane, int x, int y)
int ff_fill_rgba_map(uint8_t *rgba_map, enum AVPixelFormat pix_fmt)
static void blend_line_hv(uint8_t *dst, int dst_delta, unsigned src, unsigned alpha, const uint8_t *mask, int mask_linesize, int l2depth, int w, unsigned hsub, unsigned vsub, int xm, int left, int right, int hband)
static void blend_line16(uint8_t *dst, unsigned src, unsigned alpha, int dx, int w, unsigned hsub, int left, int right)
AVColorRange
Visual content value range.
#define AV_PIX_FMT_FLAG_PAL
Pixel format has a palette in data[1], values are indexes in this palette.
Generated on Fri Oct 17 2025 19:22:57 for FFmpeg by
doxygen
1.8.17