36 for(i = 0; i < max_allocated_lines; i++){
50 return buf->
line[line];
64 assert(buf->
line[line]);
66 buffer = buf->
line[line];
94 while((
unsigned)v > (
unsigned)m){
103 int dst_step,
int src_step,
int ref_step,
104 int width,
int mul,
int add,
int shift,
106 const int mirror_left= !highpass;
107 const int mirror_right= (width&1) ^ highpass;
108 const int w= (width>>1) - 1 + (highpass & width);
111 #define LIFT(src, ref, inv) ((src) + ((inv) ? - (ref) : + (ref)))
113 dst[0] =
LIFT(src[0], ((mul*2*ref[0]+add)>>shift), inverse);
120 LIFT(src[i*src_step],
121 ((mul*(ref[i*ref_step] + ref[(i+1)*ref_step])+add)>>shift),
127 LIFT(src[w*src_step],
128 ((mul*2*ref[w*ref_step]+add)>>shift),
135 int dst_step,
int src_step,
int ref_step,
136 int width,
int mul,
int add,
int shift,
138 const int mirror_left= !highpass;
139 const int mirror_right= (width&1) ^ highpass;
140 const int w= (width>>1) - 1 + (highpass & width);
143 #define LIFT(src, ref, inv) ((src) + ((inv) ? - (ref) : + (ref)))
145 dst[0] =
LIFT(src[0], ((mul*2*ref[0]+add)>>shift), inverse);
152 LIFT(src[i*src_step],
153 ((mul*(ref[i*ref_step] + ref[(i+1)*ref_step])+add)>>shift),
159 LIFT(src[w*src_step],
160 ((mul*2*ref[w*ref_step]+add)>>shift),
168 int dst_step,
int src_step,
int ref_step,
169 int width,
int mul,
int add,
int shift,
171 const int mirror_left= !highpass;
172 const int mirror_right= (width&1) ^ highpass;
173 const int w= (width>>1) - 1 + (highpass & width);
177 #define LIFTS(src, ref, inv) \
179 (src) + (((ref) + 4*(src))>>shift): \
180 -((-16*(src) + (ref) + add/4 + 1 + (5<<25))/(5*4) - (1<<23)))
182 dst[0] =
LIFTS(src[0], mul*2*ref[0]+add, inverse);
189 LIFTS(src[i*src_step],
190 mul*(ref[i*ref_step] + ref[(i+1)*ref_step])+add,
196 LIFTS(src[w*src_step], mul*2*ref[w*ref_step]+add, inverse);
201 int dst_step,
int src_step,
int ref_step,
202 int width,
int mul,
int add,
int shift,
204 const int mirror_left= !highpass;
205 const int mirror_right= (width&1) ^ highpass;
206 const int w= (width>>1) - 1 + (highpass & width);
210 #define LIFTS(src, ref, inv) \
212 (src) + (((ref) + 4*(src))>>shift): \
213 -((-16*(src) + (ref) + add/4 + 1 + (5<<25))/(5*4) - (1<<23)))
215 dst[0] =
LIFTS(src[0], mul*2*ref[0]+add, inverse);
222 LIFTS(src[i*src_step],
223 mul*(ref[i*ref_step] + ref[(i+1)*ref_step])+add,
229 LIFTS(src[w*src_step], mul*2*ref[w*ref_step]+add, inverse);
236 const int width2= width>>1;
238 const int w2= (width+1)>>1;
240 for(x=0; x<width2; x++){
242 temp[x+w2]= b[2*x + 1];
256 for(x=1; x+1<width2; x+=2){
260 A2 += (A1 + A3 + 2)>>2;
264 A1= temp[x+1+width2];
267 A4 += (A1 + A3 + 2)>>2;
273 A2 += (A1 + A3 + 2)>>2;
278 lift(b+w2, temp+w2, temp, 1, 1, 1, width, -1, 0, 1, 1, 0);
279 lift(b , temp , b+w2, 1, 1, 1, width, 1, 2, 2, 0, 0);
286 for(i=0; i<
width; i++){
287 b1[i] -= (b0[i] + b2[i])>>1;
294 for(i=0; i<
width; i++){
295 b1[i] += (b0[i] + b2[i] + 2)>>2;
304 for(y=-2; y<
height; y+=2){
321 const int w2= (width+1)>>1;
323 lift (temp+w2, b +1, b , 1, 2, 2, width,
W_AM,
W_AO,
W_AS, 1, 1);
324 liftS(temp , b , temp+w2, 1, 2, 1, width,
W_BM,
W_BO,
W_BS, 0, 0);
325 lift (b +w2, temp+w2, temp , 1, 1, 1, width,
W_CM,
W_CO,
W_CS, 1, 0);
326 lift (b , temp , b +w2, 1, 1, 1, width,
W_DM,
W_DO,
W_DS, 0, 0);
333 for(i=0; i<
width; i++){
341 for(i=0; i<
width; i++){
349 for(i=0; i<
width; i++){
353 b1[i] = (16*4*b1[i] - 4*(b0[i] + b2[i]) +
W_BO*5 + (5<<27)) / (5*16) - (1<<23);
361 for(i=0; i<
width; i++){
373 for(y=-4; y<
height; y+=2){
395 for(level=0; level<decomposition_count; level++){
405 const int width2= width>>1;
406 const int w2= (width+1)>>1;
409 for(x=0; x<width2; x++){
411 temp[2*x + 1]= b[x+w2];
416 b[0] = temp[0] - ((temp[1]+1)>>1);
417 for(x=2; x<width-1; x+=2){
418 b[x ] = temp[x ] - ((temp[x-1] + temp[x+1]+2)>>2);
419 b[x-1] = temp[x-1] + ((b [x-2] + b [x ]+1)>>1);
422 b[x ] = temp[x ] - ((temp[x-1]+1)>>1);
423 b[x-1] = temp[x-1] + ((b [x-2] + b [x ]+1)>>1);
425 b[x-1] = temp[x-1] + b[x-2];
431 for(i=0; i<
width; i++){
432 b1[i] += (b0[i] + b2[i])>>1;
439 for(i=0; i<
width; i++){
440 b1[i] -= (b0[i] + b2[i] + 2)>>2;
464 if(y+1<(
unsigned)height && y<(
unsigned)height){
467 for(x=0; x<
width; x++){
468 b2[x] -= (b1[x] + b3[x] + 2)>>2;
469 b1[x] += (b0[x] + b2[x])>>1;
505 while(cs.
y <= height)
512 const int w2= (width+1)>>1;
514 #if 0 //maybe more understadable but slower
515 inv_lift (temp , b , b +w2, 2, 1, 1, width,
W_DM,
W_DO,
W_DS, 0, 1);
516 inv_lift (temp+1 , b +w2, temp , 2, 1, 2, width,
W_CM,
W_CO,
W_CS, 1, 1);
518 inv_liftS(b , temp , temp+1 , 2, 2, 2, width,
W_BM,
W_BO,
W_BS, 0, 1);
519 inv_lift (b+1 , temp+1 , b , 2, 2, 2, width,
W_AM,
W_AO,
W_AS, 1, 0);
522 temp[0] = b[0] - ((3*b[w2]+2)>>2);
523 for(x=1; x<(width>>1); x++){
524 temp[2*x ] = b[x ] - ((3*(b [x+w2-1] + b[x+w2])+4)>>3);
525 temp[2*x-1] = b[x+w2-1] - temp[2*x-2] - temp[2*x];
528 temp[2*x ] = b[x ] - ((3*b [x+w2-1]+2)>>2);
529 temp[2*x-1] = b[x+w2-1] - temp[2*x-2] - temp[2*x];
531 temp[2*x-1] = b[x+w2-1] - 2*temp[2*x-2];
533 b[0] = temp[0] + ((2*temp[0] + temp[1]+4)>>3);
534 for(x=2; x<width-1; x+=2){
535 b[x ] = temp[x ] + ((4*temp[x ] + temp[x-1] + temp[x+1]+8)>>4);
536 b[x-1] = temp[x-1] + ((3*(b [x-2] + b [x ] ))>>1);
539 b[x ] = temp[x ] + ((2*temp[x ] + temp[x-1]+4)>>3);
540 b[x-1] = temp[x-1] + ((3*(b [x-2] + b [x ] ))>>1);
542 b[x-1] = temp[x-1] + 3*b [x-2];
549 for(i=0; i<
width; i++){
557 for(i=0; i<
width; i++){
565 for(i=0; i<
width; i++){
577 for(i=0; i<
width; i++){
585 for(i=0; i<
width; i++){
623 if(y>0 && y+4<height){
669 while(cs.
y <= height)
675 for(level=decomposition_count-1; level>=0; level--){
684 const int support = type==1 ? 3 : 5;
688 for(level=decomposition_count-1; level>=0; level--){
689 while(cs[level].y <=
FFMIN((y>>level)+support, height>>level)){
702 for(level=decomposition_count-1; level>=0; level--){
711 const int support = type==1 ? 3 : 5;
715 for(level=decomposition_count-1; level>=0; level--){
716 while(cs[level].y <=
FFMIN((y>>level)+support, height>>level)){
735 static inline int w_c(
void *
v, uint8_t * pix1, uint8_t * pix2,
int line_size,
int w,
int h,
int type){
737 const int dec_count= w==8 ? 3 : 4;
740 static const int scale[2][2][4][4]={
744 {268, 239, 239, 213},
749 {344, 310, 310, 280},
757 {275, 245, 245, 218},
762 {352, 317, 317, 286},
770 for (i = 0; i < h; i++) {
771 for (j = 0; j < w; j+=4) {
772 tmp[32*i+j+0] = (pix1[j+0] - pix2[j+0])<<4;
773 tmp[32*i+j+1] = (pix1[j+1] - pix2[j+1])<<4;
774 tmp[32*i+j+2] = (pix1[j+2] - pix2[j+2])<<4;
775 tmp[32*i+j+3] = (pix1[j+3] - pix2[j+3])<<4;
785 for(level=0; level<dec_count; level++){
786 for(ori= level ? 1 : 0; ori<4; ori++){
788 int sx= (ori&1) ? size : 0;
790 int sy= (ori&2) ? stride>>1 : 0;
792 for(i=0; i<
size; i++){
793 for(j=0; j<
size; j++){
794 int v= tmp[sx + sy + i*stride + j] * scale[type][dec_count-3][
level][ori];
804 static int w53_8_c(
void *
v, uint8_t * pix1, uint8_t * pix2,
int line_size,
int h){
805 return w_c(v, pix1, pix2, line_size, 8, h, 1);
808 static int w97_8_c(
void *
v, uint8_t * pix1, uint8_t * pix2,
int line_size,
int h){
809 return w_c(v, pix1, pix2, line_size, 8, h, 0);
812 static int w53_16_c(
void *
v, uint8_t * pix1, uint8_t * pix2,
int line_size,
int h){
813 return w_c(v, pix1, pix2, line_size, 16, h, 1);
816 static int w97_16_c(
void *
v, uint8_t * pix1, uint8_t * pix2,
int line_size,
int h){
817 return w_c(v, pix1, pix2, line_size, 16, h, 0);
820 int ff_w53_32_c(
void *
v, uint8_t * pix1, uint8_t * pix2,
int line_size,
int h){
821 return w_c(v, pix1, pix2, line_size, 32, h, 1);
824 int ff_w97_32_c(
void *
v, uint8_t * pix1, uint8_t * pix2,
int line_size,
int h){
825 return w_c(v, pix1, pix2, line_size, 32, h, 0);
#define slice_buffer_get_line(slice_buf, line_num)
void * av_mallocz(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
#define LIFTS(src, ref, inv)
void ff_slice_buffer_release(slice_buffer *buf, int line)
static void spatial_compose97i_init(DWTCompose *cs, IDWTELEM *buffer, int height, int stride)
static void vertical_decompose97iL1(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width)
static void spatial_compose97i_dy_buffered(DWTContext *dsp, DWTCompose *cs, slice_buffer *sb, int width, int height, int stride_line)
void ff_dwt_init_x86(DWTContext *c)
static void spatial_compose53i_buffered_init(DWTCompose *cs, slice_buffer *sb, int height, int stride_line)
static void vertical_compose53iL0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
int ff_w53_32_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
static av_always_inline void inv_lift(IDWTELEM *dst, IDWTELEM *src, IDWTELEM *ref, int dst_step, int src_step, int ref_step, int width, int mul, int add, int shift, int highpass, int inverse)
int ff_w97_32_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
static void spatial_decompose53i(DWTELEM *buffer, int width, int height, int stride)
static void vertical_compose97iL0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
void ff_dwt_init(DWTContext *c)
static int w53_8_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
Macro definitions for various function/variable attributes.
static void av_unused spatial_compose53i(IDWTELEM *buffer, int width, int height, int stride)
void av_freep(void *arg)
Free a memory block which has been allocated with av_malloc(z)() or av_realloc() and set the pointer ...
IDWTELEM ** data_stack
Used for internal purposes.
void ff_spatial_dwt(DWTELEM *buffer, int width, int height, int stride, int type, int decomposition_count)
#define MAX_DECOMPOSITIONS
static void ff_spatial_idwt_init(DWTCompose *cs, IDWTELEM *buffer, int width, int height, int stride, int type, int decomposition_count)
static void spatial_decompose97i(DWTELEM *buffer, int width, int height, int stride)
static int mirror(int v, int m)
Used to minimize the amount of memory used in order to optimize cache performance.
static void ff_spatial_idwt_slice(DWTCompose *cs, IDWTELEM *buffer, int width, int height, int stride, int type, int decomposition_count, int y)
static int w_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int w, int h, int type)
static void horizontal_decompose53i(DWTELEM *b, int width)
static void vertical_compose97iH1(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
static void spatial_compose53i_init(DWTCompose *cs, IDWTELEM *buffer, int height, int stride)
void ff_snow_vertical_compose97i(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5, int width)
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 void spatial_compose53i_dy(DWTCompose *cs, IDWTELEM *buffer, int width, int height, int stride)
void(* 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 void horizontal_compose53i(IDWTELEM *b, int width)
static void spatial_compose97i_buffered_init(DWTCompose *cs, slice_buffer *sb, int height, int stride_line)
void ff_slice_buffer_flush(slice_buffer *buf)
void ff_dsputil_init_dwt(DSPContext *c)
void ff_spatial_idwt_buffered_slice(DWTContext *dsp, DWTCompose *cs, slice_buffer *slice_buf, int width, int height, int stride_line, int type, int decomposition_count, int y)
IDWTELEM * ff_slice_buffer_load_line(slice_buffer *buf, int line)
void(* horizontal_compose97i)(IDWTELEM *b, int width)
void ff_slice_buffer_init(slice_buffer *buf, int line_count, int max_allocated_lines, int line_width, IDWTELEM *base_buffer)
static void vertical_decompose97iH1(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width)
static int w97_16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
void ff_slice_buffer_destroy(slice_buffer *buf)
void * av_malloc(size_t size)
Allocate a block of size bytes with alignment suitable for all memory accesses (including vectors if ...
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_compose97iL1(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)
static void vertical_compose53iH0(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)
static av_always_inline void inv_liftS(IDWTELEM *dst, IDWTELEM *src, IDWTELEM *ref, int dst_step, int src_step, int ref_step, int width, int mul, int add, int shift, int highpass, int inverse)
IDWTELEM ** line
For use by idwt and predict_slices.
static void vertical_decompose97iL0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width)
static const uint16_t scale[4]
static void spatial_compose53i_dy_buffered(DWTCompose *cs, slice_buffer *sb, int width, int height, int stride_line)
static void horizontal_decompose97i(DWTELEM *b, int width)
static int w53_16_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
#define LIFT(src, ref, inv)
static void vertical_decompose53iH0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width)
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 int w97_8_c(void *v, uint8_t *pix1, uint8_t *pix2, int line_size, int h)
static void av_unused spatial_compose97i(IDWTELEM *buffer, int width, int height, int stride)
IDWTELEM * base_buffer
Buffer that this structure is caching.
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)
static void vertical_decompose53iL0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width)
static void vertical_decompose97iH0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width)
static uint32_t inverse(uint32_t v)
find multiplicative inverse modulo 2 ^ 32
void ff_snow_horizontal_compose97i(IDWTELEM *b, int width)
void ff_spatial_idwt(IDWTELEM *buffer, int width, int height, int stride, int type, int decomposition_count)
static void spatial_compose97i_dy(DWTCompose *cs, IDWTELEM *buffer, int width, int height, int stride)
static void vertical_compose97iH0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width)