Go to the documentation of this file.
29 int max_allocated_lines,
int line_width,
34 buf->base_buffer = base_buffer;
35 buf->line_count = line_count;
36 buf->line_width = line_width;
37 buf->data_count = max_allocated_lines;
38 buf->line =
av_calloc(line_count,
sizeof(*buf->line));
42 if (!buf->data_stack) {
47 for (
i = 0;
i < max_allocated_lines;
i++) {
49 if (!buf->data_stack[
i]) {
58 buf->data_stack_top = max_allocated_lines - 1;
69 return buf->line[
line];
71 buffer = buf->data_stack[buf->data_stack_top];
72 buf->data_stack_top--;
86 buf->data_stack_top++;
87 buf->data_stack[buf->data_stack_top] =
buffer;
98 for (
i = 0;
i < buf->line_count;
i++)
109 for (
i = buf->data_count - 1;
i >= 0;
i--)
116 int dst_step,
int src_step,
int ref_step,
125 #define LIFT(src, ref, inv) ((src) + ((inv) ? -(ref) : +(ref)))
132 for (
i = 0;
i <
w;
i++)
133 dst[
i * dst_step] =
LIFT(
src[
i * src_step],
135 ref[(
i + 1) * ref_step]) +
140 dst[
w * dst_step] =
LIFT(
src[
w * src_step],
146 int dst_step,
int src_step,
int ref_step,
156 #define LIFTS(src, ref, inv) \
157 ((inv) ? (src) + (((ref) + 4 * (src)) >> shift) \
158 : -((-16 * (src) + (ref) + add / \
159 4 + 1 + (5 << 25)) / (5 * 4) - (1 << 23)))
166 for (
i = 0;
i <
w;
i++)
169 ref[(
i + 1) * ref_step]) +
add,
180 const int width2 =
width >> 1;
182 const int w2 = (
width + 1) >> 1;
184 for (x = 0; x < width2; x++) {
186 temp[x + w2] =
b[2 * x + 1];
190 lift(
b + w2,
temp + w2,
temp, 1, 1, 1,
width, -1, 0, 1, 1, 0);
191 lift(
b,
temp,
b + w2, 1, 1, 1,
width, 1, 2, 2, 0, 0);
219 for (y = -2; y <
height; y += 2) {
223 if (y + 1 < (
unsigned)
height)
225 if (y + 2 < (
unsigned)
height)
228 if (y + 1 < (
unsigned)
height)
230 if (y + 0 < (
unsigned)
height)
240 const int w2 = (
width + 1) >> 1;
242 lift(
temp + w2,
b + 1,
b, 1, 2, 2,
width,
W_AM,
W_AO,
W_AS, 1, 1);
243 liftS(
temp,
b,
temp + w2, 1, 2, 1,
width,
W_BM,
W_BO,
W_BS, 0, 0);
244 lift(
b + w2,
temp + w2,
temp, 1, 1, 1,
width,
W_CM,
W_CO,
W_CS, 1, 0);
245 lift(
b,
temp,
b + w2, 1, 1, 1,
width,
W_DM,
W_DO,
W_DS, 0, 0);
273 (5 * 16) - (1 << 23);
294 for (y = -4; y <
height; y += 2) {
298 if (y + 3 < (
unsigned)
height)
300 if (y + 4 < (
unsigned)
height)
303 if (y + 3 < (
unsigned)
height)
305 if (y + 2 < (
unsigned)
height)
307 if (y + 1 < (
unsigned)
height)
309 if (y + 0 < (
unsigned)
height)
320 int stride,
int type,
int decomposition_count)
342 const int width2 =
width >> 1;
343 const int w2 = (
width + 1) >> 1;
346 for (x = 0; x < width2; x++) {
348 temp[2 * x + 1] =
b[x + w2];
354 for (x = 2; x <
width - 1; x += 2) {
356 b[x - 1] =
temp[x - 1] + ((
b[x - 2] +
b[x] + 1) >> 1);
359 b[x] =
temp[x] - ((
temp[x - 1] + 1) >> 1);
360 b[x - 1] =
temp[x - 1] + ((
b[x - 2] +
b[x] + 1) >> 1);
362 b[x - 1] =
temp[x - 1] +
b[x - 2];
384 int height,
int stride_line)
419 for (x = 0; x <
width; x++) {
420 b2[x] -= (
b1[x] +
b3[x] + 2) >> 2;
421 b1[x] += (
b0[x] +
b2[x]) >> 1;
424 if (y + 1 < (
unsigned)
height)
426 if (y + 0 < (
unsigned)
height)
430 if (y - 1 < (
unsigned)
height)
432 if (y + 0 < (
unsigned)
height)
450 if (y + 1 < (
unsigned)
height)
452 if (y + 0 < (
unsigned)
height)
455 if (y - 1 < (
unsigned)
height)
457 if (y + 0 < (
unsigned)
height)
467 const int w2 = (
width + 1) >> 1;
470 temp[0] =
b[0] - ((3 *
b[w2] + 2) >> 2);
471 for (x = 1; x < (
width >> 1); x++) {
472 temp[2 * x] =
b[x] - ((3 * (
b[x + w2 - 1] +
b[x + w2]) + 4) >> 3);
473 temp[2 * x - 1] =
b[x + w2 - 1] -
temp[2 * x - 2] -
temp[2 * x];
476 temp[2 * x] =
b[x] - ((3 *
b[x + w2 - 1] + 2) >> 2);
477 temp[2 * x - 1] =
b[x + w2 - 1] -
temp[2 * x - 2] -
temp[2 * x];
479 temp[2 * x - 1] =
b[x + w2 - 1] - 2 *
temp[2 * x - 2];
482 for (x = 2; x <
width - 1; x += 2) {
484 b[x - 1] =
temp[x - 1] + ((3 * (
b[x - 2] +
b[x])) >> 1);
488 b[x - 1] =
temp[x - 1] + ((3 * (
b[x - 2] +
b[x])) >> 1);
490 b[x - 1] =
temp[x - 1] + 3 *
b[x - 2];
544 int height,
int stride_line)
581 if (y > 0 && y + 4 <
height) {
584 if (y + 3 < (
unsigned)
height)
586 if (y + 2 < (
unsigned)
height)
588 if (y + 1 < (
unsigned)
height)
590 if (y + 0 < (
unsigned)
height)
594 if (y - 1 < (
unsigned)
height)
596 if (y + 0 < (
unsigned)
height)
618 if (y + 3 < (
unsigned)
height)
620 if (y + 2 < (
unsigned)
height)
622 if (y + 1 < (
unsigned)
height)
624 if (y + 0 < (
unsigned)
height)
627 if (y - 1 < (
unsigned)
height)
629 if (y + 0 < (
unsigned)
height)
641 int decomposition_count)
648 stride_line <<
level);
652 stride_line <<
level);
661 int type,
int decomposition_count,
int y)
663 const int support =
type == 1 ? 3 : 5;
675 stride_line <<
level);
681 stride_line <<
level);
689 int decomposition_count)
709 int decomposition_count,
int y)
711 const int support =
type == 1 ? 3 : 5;
732 int stride,
int type,
int decomposition_count)
737 decomposition_count);
738 for (y = 0; y <
height; y += 4)
740 decomposition_count, y);
743 static inline int w_c(
struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size,
747 const int dec_count =
w == 8 ? 3 : 4;
748 int tmp[32 * 32], tmp2[32];
750 static const int scale[2][2][4][4] = {
753 { 268, 239, 239, 213 },
754 { 0, 224, 224, 152 },
755 { 0, 135, 135, 110 },
758 { 344, 310, 310, 280 },
759 { 0, 320, 320, 228 },
760 { 0, 175, 175, 136 },
761 { 0, 129, 129, 102 },
766 { 275, 245, 245, 218 },
767 { 0, 230, 230, 156 },
768 { 0, 138, 138, 113 },
771 { 352, 317, 317, 286 },
772 { 0, 328, 328, 233 },
773 { 0, 180, 180, 140 },
774 { 0, 132, 132, 105 },
779 for (
i = 0;
i <
h;
i++) {
780 for (j = 0; j <
w; j += 4) {
781 tmp[32 *
i + j + 0] = (pix1[j + 0] - pix2[j + 0]) << 4;
782 tmp[32 *
i + j + 1] = (pix1[j + 1] - pix2[j + 1]) << 4;
783 tmp[32 *
i + j + 2] = (pix1[j + 2] - pix2[j + 2]) << 4;
784 tmp[32 *
i + j + 3] = (pix1[j + 3] - pix2[j + 3]) << 4;
795 for (ori =
level ? 1 : 0; ori < 4; ori++) {
797 int sx = (ori & 1) ?
size : 0;
799 int sy = (ori & 2) ?
stride >> 1 : 0;
802 for (j = 0; j <
size; j++) {
814 return w_c(v, pix1, pix2, line_size, 8,
h, 1);
819 return w_c(v, pix1, pix2, line_size, 8,
h, 0);
824 return w_c(v, pix1, pix2, line_size, 16,
h, 1);
829 return w_c(v, pix1, pix2, line_size, 16,
h, 0);
834 return w_c(v, pix1, pix2, line_size, 32,
h, 1);
839 return w_c(v, pix1, pix2, line_size, 32,
h, 0);
856 #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 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)
int ff_w97_32_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h)
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 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
static av_always_inline float scale(float x, float s)
av_cold void ff_dwt_init(SnowDWTContext *c)
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)
static float mul(float src0, float src1)
#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)
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)
static int w_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int w, int h, int type)
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 w53_16_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h)
void ff_slice_buffer_release(slice_buffer *buf, int line)
static int w97_8_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h)
#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 w97_16_c(struct MpegEncContext *v, uint8_t *pix1, 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]
static int shift(int a, int b)
#define slice_buffer_get_line(slice_buf, line_num)
static float add(float src0, float src1)
static void spatial_compose97i_init(DWTCompose *cs, IDWTELEM *buffer, int height, int stride)
int ff_w53_32_c(struct MpegEncContext *v, uint8_t *pix1, 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)
static int w53_8_c(struct MpegEncContext *v, uint8_t *pix1, uint8_t *pix2, ptrdiff_t line_size, int h)
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 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)