30 int max_allocated_lines,
int line_width,
48 for (
i = 0;
i < max_allocated_lines;
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);
744static inline int w_c(
MPVEncContext *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
uint8_t ptrdiff_t const uint8_t ptrdiff_t int intptr_t intptr_t int int16_t * dst
simple assert() macros that are a bit more flexible than ISO C assert().
#define av_assert1(cond)
assert() equivalent, that does not lie in speed critical code.
#define av_assert0(cond)
assert() equivalent, that is always enabled.
#define i(width, name, range_min, range_max)
common internal and external API header
#define FFABS(a)
Absolute value, Note, INT_MIN / INT64_MIN result in undefined behavior as they are not representable ...
#define MAX_DECOMPOSITIONS
static void scale(int *out, const int *in, const int w, const int h, const int shift)
static int shift(int a, int b)
Macro definitions for various function/variable attributes.
static av_always_inline av_const int avpriv_mirror(int x, int w)
void * av_calloc(size_t nmemb, size_t size)
Memory handling functions.
void ff_snow_inner_add_yblock_c(const uint8_t *obmc, const int obmc_stride, uint8_t **block, int b_w, int b_h, int src_x, int src_stride, IDWTELEM *const *lines, int add, uint8_t *dst8)
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)
static void vertical_decompose97iH0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width)
static void spatial_compose53i_init(DWTCompose *cs, IDWTELEM *buffer, int height, int stride)
static void vertical_compose53iH0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
static void spatial_idwt_slice(DWTCompose *cs, IDWTELEM *buffer, IDWTELEM *temp, int width, int height, int stride, int type, int decomposition_count, int y)
static void horizontal_decompose97i(DWTELEM *b, DWTELEM *temp, int width)
static void horizontal_decompose53i(DWTELEM *b, DWTELEM *temp, int width)
void ff_spatial_idwt(IDWTELEM *buffer, IDWTELEM *temp, int width, int height, int stride, int type, int decomposition_count)
static void spatial_compose97i_init(DWTCompose *cs, IDWTELEM *buffer, int height, int stride)
static int w53_16_c(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
int ff_w53_32_c(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
void ff_slice_buffer_release(slice_buffer *buf, int line)
static void spatial_compose53i_dy_buffered(DWTCompose *cs, slice_buffer *sb, IDWTELEM *temp, int width, int height, int stride_line)
int ff_w97_32_c(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
static int w97_16_c(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
av_cold void ff_dsputil_init_dwt(MECmpContext *c)
static void spatial_decompose97i(DWTELEM *buffer, DWTELEM *temp, int width, int height, int stride)
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 vertical_compose97iL1(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
void ff_slice_buffer_flush(slice_buffer *buf)
void ff_spatial_dwt(DWTELEM *buffer, DWTELEM *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)
static void spatial_compose53i_dy(DWTCompose *cs, IDWTELEM *buffer, IDWTELEM *temp, int width, int height, int stride)
av_cold void ff_dwt_init(SnowDWTContext *c)
static void spatial_compose97i_buffered_init(DWTCompose *cs, slice_buffer *sb, int height, int stride_line)
static int w53_8_c(MPVEncContext *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 void spatial_idwt_init(DWTCompose *cs, IDWTELEM *buffer, int width, int height, int stride, int type, int decomposition_count)
static void horizontal_compose53i(IDWTELEM *b, IDWTELEM *temp, int width)
#define LIFTS(src, ref, inv)
static int w_c(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int w, int h, int type)
static void vertical_decompose97iH1(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width)
static void vertical_decompose53iH0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width)
static void snow_horizontal_compose97i(IDWTELEM *b, IDWTELEM *temp, int width)
void ff_spatial_idwt_buffered_init(DWTCompose *cs, slice_buffer *sb, int width, int height, int stride_line, int type, int decomposition_count)
static void vertical_decompose97iL0(DWTELEM *b0, DWTELEM *b1, DWTELEM *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 void vertical_compose97iH0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
IDWTELEM * ff_slice_buffer_load_line(slice_buffer *buf, int line)
static void vertical_decompose53iL0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width)
void ff_slice_buffer_destroy(slice_buffer *buf)
static int w97_8_c(MPVEncContext *v, const uint8_t *pix1, const uint8_t *pix2, ptrdiff_t line_size, int h)
static void spatial_decompose53i(DWTELEM *buffer, DWTELEM *temp, int width, int height, int stride)
static void snow_vertical_compose97i(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5, int width)
static void vertical_compose97iL0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
static void vertical_compose53iL0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
static void vertical_compose97iH1(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
#define LIFT(src, ref, inv)
static void vertical_decompose97iL1(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width)
static void spatial_compose97i_dy(DWTCompose *cs, IDWTELEM *buffer, IDWTELEM *temp, int width, int height, int stride)
void ff_dwt_init_x86(SnowDWTContext *c)
#define slice_buffer_get_line(slice_buf, line_num)
void(* horizontal_compose97i)(IDWTELEM *b, IDWTELEM *temp, int width)
void(* vertical_compose97i)(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5, int width)
Used to minimize the amount of memory used in order to optimize cache performance.
IDWTELEM ** data_stack
Used for internal purposes.
IDWTELEM ** line
For use by idwt and predict_slices.
IDWTELEM * base_buffer
Buffer that this structure is caching.
#define av_malloc_array(a, b)
static int ref[MAX_W *MAX_W]
static double b1(void *priv, double x, double y)
static double b2(void *priv, double x, double y)
static double b3(void *priv, double x, double y)
static double b0(void *priv, double x, double y)