Go to the documentation of this file.
30 int max_allocated_lines,
int line_width,
35 buf->base_buffer = base_buffer;
36 buf->line_count = line_count;
37 buf->line_width = line_width;
38 buf->data_count = max_allocated_lines;
39 buf->line =
av_calloc(line_count,
sizeof(*buf->line));
43 if (!buf->data_stack) {
48 for (
i = 0;
i < max_allocated_lines;
i++) {
50 if (!buf->data_stack[
i]) {
59 buf->data_stack_top = max_allocated_lines - 1;
70 return buf->line[
line];
72 buffer = buf->data_stack[buf->data_stack_top];
73 buf->data_stack_top--;
87 buf->data_stack_top++;
88 buf->data_stack[buf->data_stack_top] =
buffer;
99 for (
i = 0;
i < buf->line_count;
i++)
110 for (
i = buf->data_count - 1;
i >= 0;
i--)
117 int dst_step,
int src_step,
int ref_step,
126 #define LIFT(src, ref, inv) ((src) + ((inv) ? -(ref) : +(ref)))
133 for (
i = 0;
i <
w;
i++)
135 ((mul * (
ref[
i * ref_step] +
136 ref[(
i + 1) * ref_step]) +
142 ((mul * 2 *
ref[
w * ref_step] + add) >>
shift),
147 int dst_step,
int src_step,
int ref_step,
157 #define LIFTS(src, ref, inv) \
158 ((inv) ? (src) + (((ref) + 4 * (src)) >> shift) \
159 : -((-16 * (src) + (ref) + add / \
160 4 + 1 + (5 << 25)) / (5 * 4) - (1 << 23)))
167 for (
i = 0;
i <
w;
i++)
169 mul * (
ref[
i * ref_step] +
170 ref[(
i + 1) * ref_step]) + add,
175 mul * 2 *
ref[
w * ref_step] + add,
181 const int width2 =
width >> 1;
183 const int w2 = (
width + 1) >> 1;
185 for (x = 0; x < width2; x++) {
187 temp[x + w2] =
b[2 * x + 1];
191 lift(
b + w2,
temp + w2,
temp, 1, 1, 1,
width, -1, 0, 1, 1, 0);
192 lift(
b,
temp,
b + w2, 1, 1, 1,
width, 1, 2, 2, 0, 0);
220 for (y = -2; y <
height; y += 2) {
224 if (y + 1 < (
unsigned)
height)
226 if (y + 2 < (
unsigned)
height)
229 if (y + 1 < (
unsigned)
height)
231 if (y + 0 < (
unsigned)
height)
241 const int w2 = (
width + 1) >> 1;
243 lift(
temp + w2,
b + 1,
b, 1, 2, 2,
width,
W_AM,
W_AO,
W_AS, 1, 1);
244 liftS(
temp,
b,
temp + w2, 1, 2, 1,
width,
W_BM,
W_BO,
W_BS, 0, 0);
245 lift(
b + w2,
temp + w2,
temp, 1, 1, 1,
width,
W_CM,
W_CO,
W_CS, 1, 0);
246 lift(
b,
temp,
b + w2, 1, 1, 1,
width,
W_DM,
W_DO,
W_DS, 0, 0);
274 (5 * 16) - (1 << 23);
295 for (y = -4; y <
height; y += 2) {
299 if (y + 3 < (
unsigned)
height)
301 if (y + 4 < (
unsigned)
height)
304 if (y + 3 < (
unsigned)
height)
306 if (y + 2 < (
unsigned)
height)
308 if (y + 1 < (
unsigned)
height)
310 if (y + 0 < (
unsigned)
height)
321 int stride,
int type,
int decomposition_count)
343 const int width2 =
width >> 1;
344 const int w2 = (
width + 1) >> 1;
347 for (x = 0; x < width2; x++) {
349 temp[2 * x + 1] =
b[x + w2];
355 for (x = 2; x <
width - 1; x += 2) {
357 b[x - 1] =
temp[x - 1] + ((
b[x - 2] +
b[x] + 1) >> 1);
360 b[x] =
temp[x] - ((
temp[x - 1] + 1) >> 1);
361 b[x - 1] =
temp[x - 1] + ((
b[x - 2] +
b[x] + 1) >> 1);
363 b[x - 1] =
temp[x - 1] +
b[x - 2];
385 int height,
int stride_line)
420 for (x = 0; x <
width; x++) {
421 b2[x] -= (
b1[x] +
b3[x] + 2) >> 2;
422 b1[x] += (
b0[x] +
b2[x]) >> 1;
425 if (y + 1 < (
unsigned)
height)
427 if (y + 0 < (
unsigned)
height)
431 if (y - 1 < (
unsigned)
height)
433 if (y + 0 < (
unsigned)
height)
451 if (y + 1 < (
unsigned)
height)
453 if (y + 0 < (
unsigned)
height)
456 if (y - 1 < (
unsigned)
height)
458 if (y + 0 < (
unsigned)
height)
468 const int w2 = (
width + 1) >> 1;
471 temp[0] =
b[0] - ((3 *
b[w2] + 2) >> 2);
472 for (x = 1; x < (
width >> 1); x++) {
473 temp[2 * x] =
b[x] - ((3 * (
b[x + w2 - 1] +
b[x + w2]) + 4) >> 3);
474 temp[2 * x - 1] =
b[x + w2 - 1] -
temp[2 * x - 2] -
temp[2 * x];
477 temp[2 * x] =
b[x] - ((3 *
b[x + w2 - 1] + 2) >> 2);
478 temp[2 * x - 1] =
b[x + w2 - 1] -
temp[2 * x - 2] -
temp[2 * x];
480 temp[2 * x - 1] =
b[x + w2 - 1] - 2 *
temp[2 * x - 2];
483 for (x = 2; x <
width - 1; x += 2) {
485 b[x - 1] =
temp[x - 1] + ((3 * (
b[x - 2] +
b[x])) >> 1);
489 b[x - 1] =
temp[x - 1] + ((3 * (
b[x - 2] +
b[x])) >> 1);
491 b[x - 1] =
temp[x - 1] + 3 *
b[x - 2];
545 int height,
int stride_line)
582 if (y > 0 && y + 4 <
height) {
585 if (y + 3 < (
unsigned)
height)
587 if (y + 2 < (
unsigned)
height)
589 if (y + 1 < (
unsigned)
height)
591 if (y + 0 < (
unsigned)
height)
595 if (y - 1 < (
unsigned)
height)
597 if (y + 0 < (
unsigned)
height)
619 if (y + 3 < (
unsigned)
height)
621 if (y + 2 < (
unsigned)
height)
623 if (y + 1 < (
unsigned)
height)
625 if (y + 0 < (
unsigned)
height)
628 if (y - 1 < (
unsigned)
height)
630 if (y + 0 < (
unsigned)
height)
642 int decomposition_count)
649 stride_line <<
level);
653 stride_line <<
level);
662 int type,
int decomposition_count,
int y)
664 const int support =
type == 1 ? 3 : 5;
676 stride_line <<
level);
682 stride_line <<
level);
690 int decomposition_count)
710 int decomposition_count,
int y)
712 const int support =
type == 1 ? 3 : 5;
733 int stride,
int type,
int decomposition_count)
738 decomposition_count);
739 for (y = 0; y <
height; y += 4)
741 decomposition_count, y);
744 static inline int w_c(
struct MpegEncContext *v,
const uint8_t *pix1,
const uint8_t *pix2, ptrdiff_t line_size,
748 const int dec_count =
w == 8 ? 3 : 4;
749 int tmp[32 * 32], tmp2[32];
751 static const int scale[2][2][4][4] = {
754 { 268, 239, 239, 213 },
755 { 0, 224, 224, 152 },
756 { 0, 135, 135, 110 },
759 { 344, 310, 310, 280 },
760 { 0, 320, 320, 228 },
761 { 0, 175, 175, 136 },
762 { 0, 129, 129, 102 },
767 { 275, 245, 245, 218 },
768 { 0, 230, 230, 156 },
769 { 0, 138, 138, 113 },
772 { 352, 317, 317, 286 },
773 { 0, 328, 328, 233 },
774 { 0, 180, 180, 140 },
775 { 0, 132, 132, 105 },
780 for (
i = 0;
i <
h;
i++) {
781 for (j = 0; j <
w; j += 4) {
782 tmp[32 *
i + j + 0] = (pix1[j + 0] - pix2[j + 0]) * (1 << 4);
783 tmp[32 *
i + j + 1] = (pix1[j + 1] - pix2[j + 1]) * (1 << 4);
784 tmp[32 *
i + j + 2] = (pix1[j + 2] - pix2[j + 2]) * (1 << 4);
785 tmp[32 *
i + j + 3] = (pix1[j + 3] - pix2[j + 3]) * (1 << 4);
796 for (ori =
level ? 1 : 0; ori < 4; ori++) {
798 int sx = (ori & 1) ?
size : 0;
800 int sy = (ori & 2) ?
stride >> 1 : 0;
803 for (j = 0; j <
size; j++) {
815 return w_c(v, pix1, pix2, line_size, 8,
h, 1);
820 return w_c(v, pix1, pix2, line_size, 8,
h, 0);
825 return w_c(v, pix1, pix2, line_size, 16,
h, 1);
830 return w_c(v, pix1, pix2, line_size, 16,
h, 0);
835 return w_c(v, pix1, pix2, line_size, 32,
h, 1);
840 return w_c(v, pix1, pix2, line_size, 32,
h, 0);
857 #if ARCH_X86 && HAVE_MMX
void ff_dwt_init_x86(SnowDWTContext *c)
static void spatial_compose97i_dy(DWTCompose *cs, IDWTELEM *buffer, IDWTELEM *temp, int width, int height, int stride)
static void spatial_compose53i_dy(DWTCompose *cs, IDWTELEM *buffer, IDWTELEM *temp, int width, int height, int stride)
#define MAX_DECOMPOSITIONS
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
#define LIFT(src, ref, inv)
static int w97_16_c(struct MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
static void snow_horizontal_compose97i(IDWTELEM *b, IDWTELEM *temp, int width)
static void spatial_compose53i_dy_buffered(DWTCompose *cs, slice_buffer *sb, IDWTELEM *temp, int width, int height, int stride_line)
void ff_slice_buffer_flush(slice_buffer *buf)
static void vertical_decompose97iL1(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width)
static void vertical_compose53iL0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
static void vertical_decompose97iH1(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width)
static void vertical_compose97iL1(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
void(* vertical_compose97i)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5, int width)
void ff_spatial_dwt(DWTELEM *buffer, DWTELEM *temp, int width, int height, int stride, int type, int decomposition_count)
static void horizontal_decompose97i(DWTELEM *b, DWTELEM *temp, int width)
static void vertical_compose53iH0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
static int w53_8_c(struct MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
static void spatial_compose97i_dy_buffered(SnowDWTContext *dsp, DWTCompose *cs, slice_buffer *sb, IDWTELEM *temp, int width, int height, int stride_line)
static double b1(void *priv, double x, double y)
void ff_spatial_idwt(IDWTELEM *buffer, IDWTELEM *temp, int width, int height, int stride, int type, int decomposition_count)
int ff_slice_buffer_init(slice_buffer *buf, int line_count, int max_allocated_lines, int line_width, IDWTELEM *base_buffer)
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 type
av_cold void ff_dwt_init(SnowDWTContext *c)
static int w97_8_c(struct MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
void ff_slice_buffer_destroy(slice_buffer *buf)
void ff_spatial_idwt_buffered_init(DWTCompose *cs, slice_buffer *sb, int width, int height, int stride_line, int type, int decomposition_count)
static double b3(void *priv, double x, double y)
static void snow_vertical_compose97i(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5, int width)
static void spatial_compose97i_buffered_init(DWTCompose *cs, slice_buffer *sb, int height, int stride_line)
#define av_assert0(cond)
assert() equivalent, that is always enabled.
static void vertical_compose97iH1(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
void ff_snow_inner_add_yblock(const uint8_t *obmc, const int obmc_stride, uint8_t **block, int b_w, int b_h, int src_x, int src_y, int src_stride, slice_buffer *sb, int add, uint8_t *dst8)
static av_always_inline void liftS(DWTELEM *dst, DWTELEM *src, DWTELEM *ref, int dst_step, int src_step, int ref_step, int width, int mul, int add, int shift, int highpass, int inverse)
IDWTELEM * ff_slice_buffer_load_line(slice_buffer *buf, int line)
static void spatial_decompose97i(DWTELEM *buffer, DWTELEM *temp, int width, int height, int stride)
int ff_w53_32_c(struct MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
static void spatial_compose53i_buffered_init(DWTCompose *cs, slice_buffer *sb, int height, int stride_line)
static av_always_inline av_const int avpriv_mirror(int x, int w)
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
av_cold void ff_dsputil_init_dwt(MECmpContext *c)
static void spatial_idwt_init(DWTCompose *cs, IDWTELEM *buffer, int width, int height, int stride, int type, int decomposition_count)
static void vertical_compose97iL0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
static void vertical_decompose53iH0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width)
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_slice_buffer_release(slice_buffer *buf, int line)
#define LIFTS(src, ref, inv)
static double b2(void *priv, double x, double y)
void(* horizontal_compose97i)(IDWTELEM *b, IDWTELEM *temp, int width)
static int w53_16_c(struct MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
static void vertical_decompose97iH0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width)
#define i(width, name, range_min, range_max)
static av_always_inline void lift(DWTELEM *dst, DWTELEM *src, DWTELEM *ref, int dst_step, int src_step, int ref_step, int width, int mul, int add, int shift, int highpass, int inverse)
#define av_malloc_array(a, b)
static void horizontal_compose53i(IDWTELEM *b, IDWTELEM *temp, int width)
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
static void spatial_idwt_slice(DWTCompose *cs, IDWTELEM *buffer, IDWTELEM *temp, int width, int height, int stride, int type, int decomposition_count, int y)
void * av_calloc(size_t nmemb, size_t size)
static void spatial_decompose53i(DWTELEM *buffer, DWTELEM *temp, int width, int height, int stride)
static void vertical_decompose53iL0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width)
the frame and frame reference mechanism is intended to as much as expensive copies of that data while still allowing the filters to produce correct results The data is stored in buffers represented by AVFrame structures Several references can point to the same frame buffer
static int ref[MAX_W *MAX_W]
#define slice_buffer_get_line(slice_buf, line_num)
static void spatial_compose97i_init(DWTCompose *cs, IDWTELEM *buffer, int height, int stride)
static void scale(int *out, const int *in, const int w, const int h, const int shift)
int ff_w97_32_c(struct MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
static double b0(void *priv, double x, double y)
static void vertical_decompose97iL0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width)
void ff_spatial_idwt_buffered_slice(SnowDWTContext *dsp, DWTCompose *cs, slice_buffer *slice_buf, IDWTELEM *temp, int width, int height, int stride_line, int type, int decomposition_count, int y)
static int w_c(struct MpegEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int w, int h, int type)
static void spatial_compose53i_init(DWTCompose *cs, IDWTELEM *buffer, int height, int stride)
static void horizontal_decompose53i(DWTELEM *b, DWTELEM *temp, int width)
The official guide to swscale for confused that consecutive non overlapping rectangles of slice_bottom special converter These generally are unscaled converters of common like for each output line the vertical scaler pulls lines from a ring buffer When the ring buffer does not contain the wanted line
static void vertical_compose97iH0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)