#define LOG2_MB_SIZE 4
#define MB_SIZE (1<<LOG2_MB_SIZE)
+#define ENCODER_EXTRA_BITS 4
typedef struct x_and_coeff{
int16_t x;
int height;
int qlog; ///< log(qscale)/log[2^(1/6)]
DWTELEM *buf;
+ IDWTELEM *ibuf;
int buf_x_offset;
int buf_y_offset;
int stride_line; ///< Stride measured in lines, not pixels.
int16_t (*ref_mvs[MAX_REF_FRAMES])[2];
uint32_t *ref_scores[MAX_REF_FRAMES];
DWTELEM *spatial_dwt_buffer;
+ IDWTELEM *spatial_idwt_buffer;
int colorspace_type;
int chroma_h_shift;
int chroma_v_shift;
}SnowContext;
typedef struct {
- DWTELEM *b0;
- DWTELEM *b1;
- DWTELEM *b2;
- DWTELEM *b3;
+ IDWTELEM *b0;
+ IDWTELEM *b1;
+ IDWTELEM *b2;
+ IDWTELEM *b3;
int y;
} dwt_compose_t;
static void iterative_me(SnowContext *s);
-static void slice_buffer_init(slice_buffer * buf, int line_count, int max_allocated_lines, int line_width, DWTELEM * base_buffer)
+static void slice_buffer_init(slice_buffer * buf, int line_count, int max_allocated_lines, int line_width, IDWTELEM * base_buffer)
{
int i;
buf->line_count = line_count;
buf->line_width = line_width;
buf->data_count = max_allocated_lines;
- buf->line = (DWTELEM * *) av_mallocz (sizeof(DWTELEM *) * line_count);
- buf->data_stack = (DWTELEM * *) av_malloc (sizeof(DWTELEM *) * max_allocated_lines);
+ buf->line = av_mallocz (sizeof(IDWTELEM *) * line_count);
+ buf->data_stack = av_malloc (sizeof(IDWTELEM *) * max_allocated_lines);
for (i = 0; i < max_allocated_lines; i++)
{
- buf->data_stack[i] = (DWTELEM *) av_malloc (sizeof(DWTELEM) * line_width);
+ buf->data_stack[i] = av_malloc (sizeof(IDWTELEM) * line_width);
}
buf->data_stack_top = max_allocated_lines - 1;
}
-static DWTELEM * slice_buffer_load_line(slice_buffer * buf, int line)
+static IDWTELEM * slice_buffer_load_line(slice_buffer * buf, int line)
{
int offset;
- DWTELEM * buffer;
+ IDWTELEM * buffer;
// av_log(NULL, AV_LOG_DEBUG, "Cache hit: %d\n", line);
static void slice_buffer_release(slice_buffer * buf, int line)
{
int offset;
- DWTELEM * buffer;
+ IDWTELEM * buffer;
assert(line >= 0 && line < buf->line_count);
assert(buf->line[line]);
}
}
-#ifndef lift5
-static av_always_inline void lift5(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 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){
const int mirror_left= !highpass;
const int mirror_right= (width&1) ^ highpass;
const int w= (width>>1) - 1 + (highpass & width);
int i;
+#define LIFT(src, ref, inv) ((src) + ((inv) ? - (ref) : + (ref)))
if(mirror_left){
- int r= 3*2*ref[0];
- r += r>>4;
- r += r>>8;
- dst[0] = LIFT(src[0], ((r+add)>>shift), inverse);
+ dst[0] = LIFT(src[0], ((mul*2*ref[0]+add)>>shift), inverse);
dst += dst_step;
src += src_step;
}
for(i=0; i<w; i++){
- int r= 3*(ref[i*ref_step] + ref[(i+1)*ref_step]);
- r += r>>4;
- r += r>>8;
- dst[i*dst_step] = LIFT(src[i*src_step], ((r+add)>>shift), inverse);
+ dst[i*dst_step] = LIFT(src[i*src_step], ((mul*(ref[i*ref_step] + ref[(i+1)*ref_step])+add)>>shift), inverse);
}
if(mirror_right){
- int r= 3*2*ref[w*ref_step];
- r += r>>4;
- r += r>>8;
- dst[w*dst_step] = LIFT(src[w*src_step], ((r+add)>>shift), inverse);
+ dst[w*dst_step] = LIFT(src[w*src_step], ((mul*2*ref[w*ref_step]+add)>>shift), inverse);
}
}
-#endif
#ifndef liftS
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){
int i;
assert(shift == 4);
-#define LIFTS(src, ref, inv) ((inv) ? (src) + (((ref) + 4*(src))>>shift): (16*4*(src) + 4*(ref) + 8 + (5<<27))/(5*16) - (1<<23))
+#define LIFTS(src, ref, inv) ((inv) ? (src) + (((ref) + 4*(src))>>shift): -((-16*(src) + (ref) + add/4 + 1 + (5<<25))/(5*4) - (1<<23)))
if(mirror_left){
dst[0] = LIFTS(src[0], mul*2*ref[0]+add, inverse);
dst += dst_step;
dst[w*dst_step] = LIFTS(src[w*src_step], mul*2*ref[w*ref_step]+add, inverse);
}
}
-#endif
-
-
-static void inplace_lift(DWTELEM *dst, int width, int *coeffs, int n, int shift, int start, int inverse){
- int x, i;
-
- for(x=start; x<width; x+=2){
- int64_t sum=0;
-
- for(i=0; i<n; i++){
- int x2= x + 2*i - n + 1;
- if (x2< 0) x2= -x2;
- else if(x2>=width) x2= 2*width-x2-2;
- sum += coeffs[i]*(int64_t)dst[x2];
- }
- if(inverse) dst[x] -= (sum + (1<<shift)/2)>>shift;
- else dst[x] += (sum + (1<<shift)/2)>>shift;
- }
-}
-
-static void inplace_liftV(DWTELEM *dst, int width, int height, int stride, int *coeffs, int n, int shift, int start, int inverse){
- int x, y, i;
- for(y=start; y<height; y+=2){
- for(x=0; x<width; x++){
- int64_t sum=0;
-
- for(i=0; i<n; i++){
- int y2= y + 2*i - n + 1;
- if (y2< 0) y2= -y2;
- else if(y2>=height) y2= 2*height-y2-2;
- sum += coeffs[i]*(int64_t)dst[x + y2*stride];
- }
- if(inverse) dst[x + y*stride] -= (sum + (1<<shift)/2)>>shift;
- else dst[x + y*stride] += (sum + (1<<shift)/2)>>shift;
- }
- }
-}
-
-#define SCALEX 1
-#define LX0 0
-#define LX1 1
-
-#if 0 // more accurate 9/7
-#define N1 2
-#define SHIFT1 14
-#define COEFFS1 (int[]){-25987,-25987}
-#define N2 2
-#define SHIFT2 19
-#define COEFFS2 (int[]){-27777,-27777}
-#define N3 2
-#define SHIFT3 15
-#define COEFFS3 (int[]){28931,28931}
-#define N4 2
-#define SHIFT4 15
-#define COEFFS4 (int[]){14533,14533}
-#elif 1 // 13/7 CRF
-#define N1 4
-#define SHIFT1 4
-#define COEFFS1 (int[]){1,-9,-9,1}
-#define N2 4
-#define SHIFT2 4
-#define COEFFS2 (int[]){-1,5,5,-1}
-#define N3 0
-#define SHIFT3 1
-#define COEFFS3 NULL
-#define N4 0
-#define SHIFT4 1
-#define COEFFS4 NULL
-#elif 1 // 3/5
-#define LX0 1
-#define LX1 0
-#define SCALEX 0.5
-#define N1 2
-#define SHIFT1 1
-#define COEFFS1 (int[]){1,1}
-#define N2 2
-#define SHIFT2 2
-#define COEFFS2 (int[]){-1,-1}
-#define N3 0
-#define SHIFT3 0
-#define COEFFS3 NULL
-#define N4 0
-#define SHIFT4 0
-#define COEFFS4 NULL
-#elif 1 // 11/5
-#define N1 0
-#define SHIFT1 1
-#define COEFFS1 NULL
-#define N2 2
-#define SHIFT2 2
-#define COEFFS2 (int[]){-1,-1}
-#define N3 2
-#define SHIFT3 0
-#define COEFFS3 (int[]){-1,-1}
-#define N4 4
-#define SHIFT4 7
-#define COEFFS4 (int[]){-5,29,29,-5}
-#define SCALEX 4
-#elif 1 // 9/7 CDF
-#define N1 2
-#define SHIFT1 7
-#define COEFFS1 (int[]){-203,-203}
-#define N2 2
-#define SHIFT2 12
-#define COEFFS2 (int[]){-217,-217}
-#define N3 2
-#define SHIFT3 7
-#define COEFFS3 (int[]){113,113}
-#define N4 2
-#define SHIFT4 9
-#define COEFFS4 (int[]){227,227}
-#define SCALEX 1
-#elif 1 // 7/5 CDF
-#define N1 0
-#define SHIFT1 1
-#define COEFFS1 NULL
-#define N2 2
-#define SHIFT2 2
-#define COEFFS2 (int[]){-1,-1}
-#define N3 2
-#define SHIFT3 0
-#define COEFFS3 (int[]){-1,-1}
-#define N4 2
-#define SHIFT4 4
-#define COEFFS4 (int[]){3,3}
-#elif 1 // 9/7 MN
-#define N1 4
-#define SHIFT1 4
-#define COEFFS1 (int[]){1,-9,-9,1}
-#define N2 2
-#define SHIFT2 2
-#define COEFFS2 (int[]){1,1}
-#define N3 0
-#define SHIFT3 1
-#define COEFFS3 NULL
-#define N4 0
-#define SHIFT4 1
-#define COEFFS4 NULL
-#else // 13/7 CRF
-#define N1 4
-#define SHIFT1 4
-#define COEFFS1 (int[]){1,-9,-9,1}
-#define N2 4
-#define SHIFT2 4
-#define COEFFS2 (int[]){-1,5,5,-1}
-#define N3 0
-#define SHIFT3 1
-#define COEFFS3 NULL
-#define N4 0
-#define SHIFT4 1
-#define COEFFS4 NULL
-#endif
-static void horizontal_decomposeX(DWTELEM *b, int width){
- DWTELEM temp[width];
- const int width2= width>>1;
- const int w2= (width+1)>>1;
- int x;
-
- inplace_lift(b, width, COEFFS1, N1, SHIFT1, LX1, 0);
- inplace_lift(b, width, COEFFS2, N2, SHIFT2, LX0, 0);
- inplace_lift(b, width, COEFFS3, N3, SHIFT3, LX1, 0);
- inplace_lift(b, width, COEFFS4, N4, SHIFT4, LX0, 0);
-
- for(x=0; x<width2; x++){
- temp[x ]= b[2*x ];
- temp[x+w2]= b[2*x + 1];
- }
- if(width&1)
- temp[x ]= b[2*x ];
- memcpy(b, temp, width*sizeof(int));
-}
-
-static void horizontal_composeX(DWTELEM *b, int width){
- DWTELEM temp[width];
- const int width2= width>>1;
- int x;
- const int w2= (width+1)>>1;
-
- memcpy(temp, b, width*sizeof(int));
- for(x=0; x<width2; x++){
- b[2*x ]= temp[x ];
- b[2*x + 1]= temp[x+w2];
- }
- if(width&1)
- b[2*x ]= temp[x ];
-
- inplace_lift(b, width, COEFFS4, N4, SHIFT4, LX0, 1);
- inplace_lift(b, width, COEFFS3, N3, SHIFT3, LX1, 1);
- inplace_lift(b, width, COEFFS2, N2, SHIFT2, LX0, 1);
- inplace_lift(b, width, COEFFS1, N1, SHIFT1, LX1, 1);
-}
-
-static void spatial_decomposeX(DWTELEM *buffer, int width, int height, int stride){
- int x, y;
-
- for(y=0; y<height; y++){
- for(x=0; x<width; x++){
- buffer[y*stride + x] *= SCALEX;
- }
- }
+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){
+ const int mirror_left= !highpass;
+ const int mirror_right= (width&1) ^ highpass;
+ const int w= (width>>1) - 1 + (highpass & width);
+ int i;
- for(y=0; y<height; y++){
- horizontal_decomposeX(buffer + y*stride, width);
+ assert(shift == 4);
+#define LIFTS(src, ref, inv) ((inv) ? (src) + (((ref) + 4*(src))>>shift): -((-16*(src) + (ref) + add/4 + 1 + (5<<25))/(5*4) - (1<<23)))
+ if(mirror_left){
+ dst[0] = LIFTS(src[0], mul*2*ref[0]+add, inverse);
+ dst += dst_step;
+ src += src_step;
}
- inplace_liftV(buffer, width, height, stride, COEFFS1, N1, SHIFT1, LX1, 0);
- inplace_liftV(buffer, width, height, stride, COEFFS2, N2, SHIFT2, LX0, 0);
- inplace_liftV(buffer, width, height, stride, COEFFS3, N3, SHIFT3, LX1, 0);
- inplace_liftV(buffer, width, height, stride, COEFFS4, N4, SHIFT4, LX0, 0);
-}
-
-static void spatial_composeX(DWTELEM *buffer, int width, int height, int stride){
- int x, y;
-
- inplace_liftV(buffer, width, height, stride, COEFFS4, N4, SHIFT4, LX0, 1);
- inplace_liftV(buffer, width, height, stride, COEFFS3, N3, SHIFT3, LX1, 1);
- inplace_liftV(buffer, width, height, stride, COEFFS2, N2, SHIFT2, LX0, 1);
- inplace_liftV(buffer, width, height, stride, COEFFS1, N1, SHIFT1, LX1, 1);
-
- for(y=0; y<height; y++){
- horizontal_composeX(buffer + y*stride, width);
+ for(i=0; i<w; i++){
+ dst[i*dst_step] = LIFTS(src[i*src_step], mul*(ref[i*ref_step] + ref[(i+1)*ref_step])+add, inverse);
}
- for(y=0; y<height; y++){
- for(x=0; x<width; x++){
- buffer[y*stride + x] /= SCALEX;
- }
+ if(mirror_right){
+ dst[w*dst_step] = LIFTS(src[w*src_step], mul*2*ref[w*ref_step]+add, inverse);
}
}
+#endif
static void horizontal_decompose53i(DWTELEM *b, int width){
DWTELEM temp[width];
DWTELEM temp[width];
const int w2= (width+1)>>1;
- lift (temp+w2, b +1, b , 1, 2, 2, width, -W_AM, W_AO, W_AS, 1, 0);
- liftS(temp , b , temp+w2, 1, 2, 1, width, -W_BM, W_BO, W_BS, 0, 0);
- lift5(b +w2, temp+w2, temp , 1, 1, 1, width, W_CM, W_CO, W_CS, 1, 0);
+ lift (temp+w2, b +1, b , 1, 2, 2, width, W_AM, W_AO, W_AS, 1, 1);
+ liftS(temp , b , temp+w2, 1, 2, 1, width, W_BM, W_BO, W_BS, 0, 0);
+ lift (b +w2, temp+w2, temp , 1, 1, 1, width, W_CM, W_CO, W_CS, 1, 0);
lift (b , temp , b +w2, 1, 1, 1, width, W_DM, W_DO, W_DS, 0, 0);
}
int i;
for(i=0; i<width; i++){
-#ifdef lift5
b1[i] += (W_CM*(b0[i] + b2[i])+W_CO)>>W_CS;
-#else
- int r= 3*(b0[i] + b2[i]);
- r+= r>>4;
- r+= r>>8;
- b1[i] += (r+W_CO)>>W_CS;
-#endif
}
}
#ifdef liftS
b1[i] -= (W_BM*(b0[i] + b2[i])+W_BO)>>W_BS;
#else
- b1[i] = (16*4*b1[i] - 4*(b0[i] + b2[i]) + 8*5 + (5<<27)) / (5*16) - (1<<23);
+ b1[i] = (16*4*b1[i] - 4*(b0[i] + b2[i]) + W_BO*5 + (5<<27)) / (5*16) - (1<<23);
#endif
}
}
switch(type){
case DWT_97: spatial_decompose97i(buffer, width>>level, height>>level, stride<<level); break;
case DWT_53: spatial_decompose53i(buffer, width>>level, height>>level, stride<<level); break;
- case DWT_X: spatial_decomposeX (buffer, width>>level, height>>level, stride<<level); break;
}
}
}
-static void horizontal_compose53i(DWTELEM *b, int width){
- DWTELEM temp[width];
+static void horizontal_compose53i(IDWTELEM *b, int width){
+ IDWTELEM temp[width];
const int width2= width>>1;
const int w2= (width+1)>>1;
int x;
b[width -1] = A3;
b[width2-1] = A2;
#else
- lift(temp , b , b+w2, 1, 1, 1, width, 1, 2, 2, 0, 1);
- lift(temp+w2, b+w2, temp, 1, 1, 1, width, -1, 0, 1, 1, 1);
+ inv_lift(temp , b , b+w2, 1, 1, 1, width, 1, 2, 2, 0, 1);
+ inv_lift(temp+w2, b+w2, temp, 1, 1, 1, width, -1, 0, 1, 1, 1);
#endif
for(x=0; x<width2; x++){
b[2*x ]= temp[x ];
b[2*x ]= temp[x ];
}
-static void vertical_compose53iH0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width){
+static void vertical_compose53iH0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width){
int i;
for(i=0; i<width; i++){
}
}
-static void vertical_compose53iL0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width){
+static void vertical_compose53iL0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width){
int i;
for(i=0; i<width; i++){
cs->y = -1;
}
-static void spatial_compose53i_init(dwt_compose_t *cs, DWTELEM *buffer, int height, int stride){
+static void spatial_compose53i_init(dwt_compose_t *cs, IDWTELEM *buffer, int height, int stride){
cs->b0 = buffer + mirror(-1-1, height-1)*stride;
cs->b1 = buffer + mirror(-1 , height-1)*stride;
cs->y = -1;
static void spatial_compose53i_dy_buffered(dwt_compose_t *cs, slice_buffer * sb, int width, int height, int stride_line){
int y= cs->y;
- DWTELEM *b0= cs->b0;
- DWTELEM *b1= cs->b1;
- DWTELEM *b2= slice_buffer_get_line(sb, mirror(y+1, height-1) * stride_line);
- DWTELEM *b3= slice_buffer_get_line(sb, mirror(y+2, height-1) * stride_line);
+ IDWTELEM *b0= cs->b0;
+ IDWTELEM *b1= cs->b1;
+ IDWTELEM *b2= slice_buffer_get_line(sb, mirror(y+1, height-1) * stride_line);
+ IDWTELEM *b3= slice_buffer_get_line(sb, mirror(y+2, height-1) * stride_line);
{START_TIMER
if(y+1<(unsigned)height) vertical_compose53iL0(b1, b2, b3, width);
cs->y += 2;
}
-static void spatial_compose53i_dy(dwt_compose_t *cs, DWTELEM *buffer, int width, int height, int stride){
+static void spatial_compose53i_dy(dwt_compose_t *cs, IDWTELEM *buffer, int width, int height, int stride){
int y= cs->y;
- DWTELEM *b0= cs->b0;
- DWTELEM *b1= cs->b1;
- DWTELEM *b2= buffer + mirror(y+1, height-1)*stride;
- DWTELEM *b3= buffer + mirror(y+2, height-1)*stride;
+ IDWTELEM *b0= cs->b0;
+ IDWTELEM *b1= cs->b1;
+ IDWTELEM *b2= buffer + mirror(y+1, height-1)*stride;
+ IDWTELEM *b3= buffer + mirror(y+2, height-1)*stride;
{START_TIMER
if(y+1<(unsigned)height) vertical_compose53iL0(b1, b2, b3, width);
cs->y += 2;
}
-static void spatial_compose53i(DWTELEM *buffer, int width, int height, int stride){
+static void spatial_compose53i(IDWTELEM *buffer, int width, int height, int stride){
dwt_compose_t cs;
spatial_compose53i_init(&cs, buffer, height, stride);
while(cs.y <= height)
}
-void ff_snow_horizontal_compose97i(DWTELEM *b, int width){
- DWTELEM temp[width];
+void ff_snow_horizontal_compose97i(IDWTELEM *b, int width){
+ IDWTELEM temp[width];
const int w2= (width+1)>>1;
- lift (temp , b , b +w2, 1, 1, 1, width, W_DM, W_DO, W_DS, 0, 1);
- lift5(temp+w2, b +w2, temp , 1, 1, 1, width, W_CM, W_CO, W_CS, 1, 1);
- liftS(b , temp , temp+w2, 2, 1, 1, width, W_BM, W_BO-1, W_BS, 0, 1);
- lift (b+1 , temp+w2, b , 2, 1, 2, width, -W_AM, W_AO, W_AS, 1, 1);
+ inv_lift (temp , b , b +w2, 1, 1, 1, width, W_DM, W_DO, W_DS, 0, 1);
+ inv_lift (temp+w2, b +w2, temp , 1, 1, 1, width, W_CM, W_CO, W_CS, 1, 1);
+ inv_liftS(b , temp , temp+w2, 2, 1, 1, width, W_BM, W_BO, W_BS, 0, 1);
+ inv_lift (b+1 , temp+w2, b , 2, 1, 2, width, W_AM, W_AO, W_AS, 1, 0);
}
-static void vertical_compose97iH0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width){
+static void vertical_compose97iH0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width){
int i;
for(i=0; i<width; i++){
}
}
-static void vertical_compose97iH1(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width){
+static void vertical_compose97iH1(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width){
int i;
for(i=0; i<width; i++){
-#ifdef lift5
b1[i] -= (W_CM*(b0[i] + b2[i])+W_CO)>>W_CS;
-#else
- int r= 3*(b0[i] + b2[i]);
- r+= r>>4;
- r+= r>>8;
- b1[i] -= (r+W_CO)>>W_CS;
-#endif
}
}
-static void vertical_compose97iL0(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width){
+static void vertical_compose97iL0(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width){
int i;
for(i=0; i<width; i++){
}
}
-static void vertical_compose97iL1(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, int width){
+static void vertical_compose97iL1(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, int width){
int i;
for(i=0; i<width; i++){
}
}
-void ff_snow_vertical_compose97i(DWTELEM *b0, DWTELEM *b1, DWTELEM *b2, DWTELEM *b3, DWTELEM *b4, DWTELEM *b5, int width){
+void ff_snow_vertical_compose97i(IDWTELEM *b0, IDWTELEM *b1, IDWTELEM *b2, IDWTELEM *b3, IDWTELEM *b4, IDWTELEM *b5, int width){
int i;
for(i=0; i<width; i++){
-#ifndef lift5
- int r;
-#endif
b4[i] -= (W_DM*(b3[i] + b5[i])+W_DO)>>W_DS;
-#ifdef lift5
b3[i] -= (W_CM*(b2[i] + b4[i])+W_CO)>>W_CS;
-#else
- r= 3*(b2[i] + b4[i]);
- r+= r>>4;
- r+= r>>8;
- b3[i] -= (r+W_CO)>>W_CS;
-#endif
#ifdef liftS
b2[i] += (W_BM*(b1[i] + b3[i])+W_BO)>>W_BS;
#else
cs->y = -3;
}
-static void spatial_compose97i_init(dwt_compose_t *cs, DWTELEM *buffer, int height, int stride){
+static void spatial_compose97i_init(dwt_compose_t *cs, IDWTELEM *buffer, int height, int stride){
cs->b0 = buffer + mirror(-3-1, height-1)*stride;
cs->b1 = buffer + mirror(-3 , height-1)*stride;
cs->b2 = buffer + mirror(-3+1, height-1)*stride;
static void spatial_compose97i_dy_buffered(DSPContext *dsp, dwt_compose_t *cs, slice_buffer * sb, int width, int height, int stride_line){
int y = cs->y;
- DWTELEM *b0= cs->b0;
- DWTELEM *b1= cs->b1;
- DWTELEM *b2= cs->b2;
- DWTELEM *b3= cs->b3;
- DWTELEM *b4= slice_buffer_get_line(sb, mirror(y + 3, height - 1) * stride_line);
- DWTELEM *b5= slice_buffer_get_line(sb, mirror(y + 4, height - 1) * stride_line);
+ IDWTELEM *b0= cs->b0;
+ IDWTELEM *b1= cs->b1;
+ IDWTELEM *b2= cs->b2;
+ IDWTELEM *b3= cs->b3;
+ IDWTELEM *b4= slice_buffer_get_line(sb, mirror(y + 3, height - 1) * stride_line);
+ IDWTELEM *b5= slice_buffer_get_line(sb, mirror(y + 4, height - 1) * stride_line);
{START_TIMER
if(y>0 && y+4<height){
cs->y += 2;
}
-static void spatial_compose97i_dy(dwt_compose_t *cs, DWTELEM *buffer, int width, int height, int stride){
+static void spatial_compose97i_dy(dwt_compose_t *cs, IDWTELEM *buffer, int width, int height, int stride){
int y = cs->y;
- DWTELEM *b0= cs->b0;
- DWTELEM *b1= cs->b1;
- DWTELEM *b2= cs->b2;
- DWTELEM *b3= cs->b3;
- DWTELEM *b4= buffer + mirror(y+3, height-1)*stride;
- DWTELEM *b5= buffer + mirror(y+4, height-1)*stride;
+ IDWTELEM *b0= cs->b0;
+ IDWTELEM *b1= cs->b1;
+ IDWTELEM *b2= cs->b2;
+ IDWTELEM *b3= cs->b3;
+ IDWTELEM *b4= buffer + mirror(y+3, height-1)*stride;
+ IDWTELEM *b5= buffer + mirror(y+4, height-1)*stride;
{START_TIMER
if(y+3<(unsigned)height) vertical_compose97iL1(b3, b4, b5, width);
cs->y += 2;
}
-static void spatial_compose97i(DWTELEM *buffer, int width, int height, int stride){
+static void spatial_compose97i(IDWTELEM *buffer, int width, int height, int stride){
dwt_compose_t cs;
spatial_compose97i_init(&cs, buffer, height, stride);
while(cs.y <= height)
switch(type){
case DWT_97: spatial_compose97i_buffered_init(cs+level, sb, height>>level, stride_line<<level); break;
case DWT_53: spatial_compose53i_buffered_init(cs+level, sb, height>>level, stride_line<<level); break;
- /* not slicified yet */
- case DWT_X: /*spatial_composeX(buffer, width>>level, height>>level, stride<<level); break;*/
- av_log(NULL, AV_LOG_ERROR, "spatial_composeX neither buffered nor slicified yet.\n"); break;
}
}
}
-static void ff_spatial_idwt_init(dwt_compose_t *cs, DWTELEM *buffer, int width, int height, int stride, int type, int decomposition_count){
+static void ff_spatial_idwt_init(dwt_compose_t *cs, IDWTELEM *buffer, int width, int height, int stride, int type, int decomposition_count){
int level;
for(level=decomposition_count-1; level>=0; level--){
switch(type){
case DWT_97: spatial_compose97i_init(cs+level, buffer, height>>level, stride<<level); break;
case DWT_53: spatial_compose53i_init(cs+level, buffer, height>>level, stride<<level); break;
- /* not slicified yet */
- case DWT_X: spatial_composeX(buffer, width>>level, height>>level, stride<<level); break;
}
}
}
-static void ff_spatial_idwt_slice(dwt_compose_t *cs, DWTELEM *buffer, int width, int height, int stride, int type, int decomposition_count, int y){
+static void ff_spatial_idwt_slice(dwt_compose_t *cs, IDWTELEM *buffer, int width, int height, int stride, int type, int decomposition_count, int y){
const int support = type==1 ? 3 : 5;
int level;
if(type==2) return;
break;
case DWT_53: spatial_compose53i_dy(cs+level, buffer, width>>level, height>>level, stride<<level);
break;
- case DWT_X: break;
}
}
}
break;
case DWT_53: spatial_compose53i_dy_buffered(cs+level, slice_buf, width>>level, height>>level, stride_line<<level);
break;
- case DWT_X: break;
}
}
}
}
-static void ff_spatial_idwt(DWTELEM *buffer, int width, int height, int stride, int type, int decomposition_count){
- if(type==2){
- int level;
- for(level=decomposition_count-1; level>=0; level--)
- spatial_composeX (buffer, width>>level, height>>level, stride<<level);
- }else{
+static void ff_spatial_idwt(IDWTELEM *buffer, int width, int height, int stride, int type, int decomposition_count){
dwt_compose_t cs[MAX_DECOMPOSITIONS];
int y;
ff_spatial_idwt_init(cs, buffer, width, height, stride, type, decomposition_count);
for(y=0; y<height; y+=4)
ff_spatial_idwt_slice(cs, buffer, width, height, stride, type, decomposition_count, y);
- }
}
-static int encode_subband_c0run(SnowContext *s, SubBand *b, DWTELEM *src, DWTELEM *parent, int stride, int orientation){
+static int encode_subband_c0run(SnowContext *s, SubBand *b, IDWTELEM *src, IDWTELEM *parent, int stride, int orientation){
const int w= b->width;
const int h= b->height;
int x, y;
return 0;
}
-static int encode_subband(SnowContext *s, SubBand *b, DWTELEM *src, DWTELEM *parent, int stride, int orientation){
+static int encode_subband(SnowContext *s, SubBand *b, IDWTELEM *src, IDWTELEM *parent, int stride, int orientation){
// encode_subband_qtree(s, b, src, parent, stride, orientation);
// encode_subband_z0run(s, b, src, parent, stride, orientation);
return encode_subband_c0run(s, b, src, parent, stride, orientation);
START_TIMER
- if(b->buf == s->spatial_dwt_buffer || s->qlog == LOSSLESS_QLOG){
+ if(b->ibuf == s->spatial_idwt_buffer || s->qlog == LOSSLESS_QLOG){
qadd= 0;
qmul= 1<<QEXPSHIFT;
}
for(y=start_y; y<h; y++){
int x = 0;
int v;
- DWTELEM * line = slice_buffer_get_line(sb, y * b->stride_line + b->buf_y_offset) + b->buf_x_offset;
- memset(line, 0, b->width*sizeof(DWTELEM));
+ IDWTELEM * line = slice_buffer_get_line(sb, y * b->stride_line + b->buf_y_offset) + b->buf_x_offset;
+ memset(line, 0, b->width*sizeof(IDWTELEM));
v = b->x_coeff[new_index].coeff;
x = b->x_coeff[new_index++].x;
while(x < w)
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){
int y, x;
- DWTELEM * dst;
+ IDWTELEM * dst;
for(y=0; y<b_h; y++){
//FIXME ugly misuse of obmc_stride
const uint8_t *obmc1= obmc + y*obmc_stride;
v <<= 8 - LOG2_OBMC_MAX;
if(FRAC_BITS != 8){
- v += 1<<(7 - FRAC_BITS);
v >>= 8 - FRAC_BITS;
}
if(add){
}
//FIXME name clenup (b_w, block_w, b_width stuff)
-static av_always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer *sb, DWTELEM *dst, uint8_t *dst8, const uint8_t *obmc, int src_x, int src_y, int b_w, int b_h, int w, int h, int dst_stride, int src_stride, int obmc_stride, int b_x, int b_y, int add, int offset_dst, int plane_index){
+static av_always_inline void add_yblock(SnowContext *s, int sliced, slice_buffer *sb, IDWTELEM *dst, uint8_t *dst8, const uint8_t *obmc, int src_x, int src_y, int b_w, int b_h, int w, int h, int dst_stride, int src_stride, int obmc_stride, int b_x, int b_y, int add, int offset_dst, int plane_index){
const int b_width = s->b_width << s->block_max_depth;
const int b_height= s->b_height << s->block_max_depth;
const int b_stride= b_width;
v <<= 8 - LOG2_OBMC_MAX;
if(FRAC_BITS != 8){
- v += 1<<(7 - FRAC_BITS);
v >>= 8 - FRAC_BITS;
}
if(add){
#endif
}
-static av_always_inline void predict_slice_buffered(SnowContext *s, slice_buffer * sb, DWTELEM * old_buffer, int plane_index, int add, int mb_y){
+static av_always_inline void predict_slice_buffered(SnowContext *s, slice_buffer * sb, IDWTELEM * old_buffer, int plane_index, int add, int mb_y){
Plane *p= &s->plane[plane_index];
const int mb_w= s->b_width << s->block_max_depth;
const int mb_h= s->b_height << s->block_max_depth;
for(y=block_w*mb_y; y<FFMIN(h,block_w*(mb_y+1)); y++)
{
// DWTELEM * line = slice_buffer_get_line(sb, y);
- DWTELEM * line = sb->line[y];
+ IDWTELEM * line = sb->line[y];
for(x=0; x<w; x++)
{
// int v= buf[x + y*w] + (128<<FRAC_BITS) + (1<<(FRAC_BITS-1));
for(y=block_w*mb_y; y<FFMIN(h,block_w*(mb_y+1)); y++)
{
// DWTELEM * line = slice_buffer_get_line(sb, y);
- DWTELEM * line = sb->line[y];
+ IDWTELEM * line = sb->line[y];
for(x=0; x<w; x++)
{
line[x] -= 128 << FRAC_BITS;
STOP_TIMER("predict_slice")
}
-static av_always_inline void predict_slice(SnowContext *s, DWTELEM *buf, int plane_index, int add, int mb_y){
+static av_always_inline void predict_slice(SnowContext *s, IDWTELEM *buf, int plane_index, int add, int mb_y){
Plane *p= &s->plane[plane_index];
const int mb_w= s->b_width << s->block_max_depth;
const int mb_h= s->b_height << s->block_max_depth;
STOP_TIMER("predict_slice")
}
-static av_always_inline void predict_plane(SnowContext *s, DWTELEM *buf, int plane_index, int add){
+static av_always_inline void predict_plane(SnowContext *s, IDWTELEM *buf, int plane_index, int add){
const int mb_h= s->b_height << s->block_max_depth;
int mb_y;
for(mb_y=0; mb_y<=mb_h; mb_y++)
const int obmc_stride= plane_index ? block_size : 2*block_size;
const int ref_stride= s->current_picture.linesize[plane_index];
uint8_t *src= s-> input_picture.data[plane_index];
- DWTELEM *dst= (DWTELEM*)s->m.obmc_scratchpad + plane_index*block_size*block_size*4;
+ IDWTELEM *dst= (IDWTELEM*)s->m.obmc_scratchpad + plane_index*block_size*block_size*4; //FIXME change to unsigned
const int b_stride = s->b_width << s->block_max_depth;
const int w= p->width;
const int h= p->height;
b->type|= BLOCK_INTRA;
b->color[plane_index]= 0;
- memset(dst, 0, obmc_stride*obmc_stride*sizeof(DWTELEM));
+ memset(dst, 0, obmc_stride*obmc_stride*sizeof(IDWTELEM));
for(i=0; i<4; i++){
int mb_x2= mb_x + (i &1) - 1;
const int ref_stride= s->current_picture.linesize[plane_index];
uint8_t *dst= s->current_picture.data[plane_index];
uint8_t *src= s-> input_picture.data[plane_index];
- DWTELEM *pred= (DWTELEM*)s->m.obmc_scratchpad + plane_index*block_size*block_size*4;
+ IDWTELEM *pred= (IDWTELEM*)s->m.obmc_scratchpad + plane_index*block_size*block_size*4;
uint8_t cur[ref_stride*2*MB_SIZE]; //FIXME alignment
uint8_t tmp[ref_stride*(2*MB_SIZE+5)];
const int b_stride = s->b_width << s->block_max_depth;
for(y=y0; y<y1; y++){
const uint8_t *obmc1= obmc_edged + y*obmc_stride;
- const DWTELEM *pred1 = pred + y*obmc_stride;
+ const IDWTELEM *pred1 = pred + y*obmc_stride;
uint8_t *cur1 = cur + y*ref_stride;
uint8_t *dst1 = dst + sx + (sy+y)*ref_stride;
for(x=x0; x<x1; x++){
+#if FRAC_BITS >= LOG2_OBMC_MAX
int v = (cur1[x] * obmc1[x]) << (FRAC_BITS - LOG2_OBMC_MAX);
+#else
+ int v = (cur1[x] * obmc1[x] + (1<<(LOG2_OBMC_MAX - FRAC_BITS-1))) >> (LOG2_OBMC_MAX - FRAC_BITS);
+#endif
v = (v + pred1[x]) >> FRAC_BITS;
if(v&(~255)) v= ~(v>>31);
dst1[x] = v;
const int ref_stride= s->current_picture.linesize[plane_index];
uint8_t *dst= s->current_picture.data[plane_index];
uint8_t *src= s-> input_picture.data[plane_index];
- static const DWTELEM zero_dst[4096]; //FIXME
+ static const IDWTELEM zero_dst[4096]; //FIXME
const int b_stride = s->b_width << s->block_max_depth;
const int w= p->width;
const int h= p->height;
}
}
-static void quantize(SnowContext *s, SubBand *b, DWTELEM *src, int stride, int bias){
+static void quantize(SnowContext *s, SubBand *b, IDWTELEM *dst, DWTELEM *src, int stride, int bias){
const int level= b->level;
const int w= b->width;
const int h= b->height;
const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16);
- const int qmul= qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT);
+ const int qmul= qexp[qlog&(QROOT-1)]<<((qlog>>QSHIFT) + ENCODER_EXTRA_BITS);
int x,y, thres1, thres2;
// START_TIMER
- if(s->qlog == LOSSLESS_QLOG) return;
+ if(s->qlog == LOSSLESS_QLOG){
+ for(y=0; y<h; y++)
+ for(x=0; x<w; x++)
+ dst[x + y*stride]= src[x + y*stride];
+ return;
+ }
bias= bias ? 0 : (3*qmul)>>3;
thres1= ((qmul - bias)>>QEXPSHIFT) - 1;
if(i>=0){
i<<= QEXPSHIFT;
i/= qmul; //FIXME optimize
- src[x + y*stride]= i;
+ dst[x + y*stride]= i;
}else{
i= -i;
i<<= QEXPSHIFT;
i/= qmul; //FIXME optimize
- src[x + y*stride]= -i;
+ dst[x + y*stride]= -i;
}
}else
- src[x + y*stride]= 0;
+ dst[x + y*stride]= 0;
}
}
}else{
if(i>=0){
i<<= QEXPSHIFT;
i= (i + bias) / qmul; //FIXME optimize
- src[x + y*stride]= i;
+ dst[x + y*stride]= i;
}else{
i= -i;
i<<= QEXPSHIFT;
i= (i + bias) / qmul; //FIXME optimize
- src[x + y*stride]= -i;
+ dst[x + y*stride]= -i;
}
}else
- src[x + y*stride]= 0;
+ dst[x + y*stride]= 0;
}
}
}
}
}
-static void dequantize_slice_buffered(SnowContext *s, slice_buffer * sb, SubBand *b, DWTELEM *src, int stride, int start_y, int end_y){
+static void dequantize_slice_buffered(SnowContext *s, slice_buffer * sb, SubBand *b, IDWTELEM *src, int stride, int start_y, int end_y){
const int w= b->width;
const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16);
const int qmul= qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT);
for(y=start_y; y<end_y; y++){
// DWTELEM * line = slice_buffer_get_line_from_address(sb, src + (y * stride));
- DWTELEM * line = slice_buffer_get_line(sb, (y * b->stride_line) + b->buf_y_offset) + b->buf_x_offset;
+ IDWTELEM * line = slice_buffer_get_line(sb, (y * b->stride_line) + b->buf_y_offset) + b->buf_x_offset;
for(x=0; x<w; x++){
int i= line[x];
if(i<0){
}
}
-static void dequantize(SnowContext *s, SubBand *b, DWTELEM *src, int stride){
+static void dequantize(SnowContext *s, SubBand *b, IDWTELEM *src, int stride){
const int w= b->width;
const int h= b->height;
const int qlog= av_clip(s->qlog + b->qlog, 0, QROOT*16);
}
}
-static void decorrelate(SnowContext *s, SubBand *b, DWTELEM *src, int stride, int inverse, int use_median){
+static void decorrelate(SnowContext *s, SubBand *b, IDWTELEM *src, int stride, int inverse, int use_median){
const int w= b->width;
const int h= b->height;
int x,y;
}
}
-static void correlate_slice_buffered(SnowContext *s, slice_buffer * sb, SubBand *b, DWTELEM *src, int stride, int inverse, int use_median, int start_y, int end_y){
+static void correlate_slice_buffered(SnowContext *s, slice_buffer * sb, SubBand *b, IDWTELEM *src, int stride, int inverse, int use_median, int start_y, int end_y){
const int w= b->width;
int x,y;
// START_TIMER
- DWTELEM * line=0; // silence silly "could be used without having been initialized" warning
- DWTELEM * prev;
+ IDWTELEM * line=0; // silence silly "could be used without having been initialized" warning
+ IDWTELEM * prev;
if (start_y != 0)
line = slice_buffer_get_line(sb, ((start_y - 1) * b->stride_line) + b->buf_y_offset) + b->buf_x_offset;
// STOP_TIMER("correlate")
}
-static void correlate(SnowContext *s, SubBand *b, DWTELEM *src, int stride, int inverse, int use_median){
+static void correlate(SnowContext *s, SubBand *b, IDWTELEM *src, int stride, int inverse, int use_median){
const int w= b->width;
const int h= b->height;
int x,y;
}
s->spatial_decomposition_type+= get_symbol(&s->c, s->header_state, 1);
- if(s->spatial_decomposition_type > 2){
+ if(s->spatial_decomposition_type > 1){
av_log(s->avctx, AV_LOG_ERROR, "spatial_decomposition_type %d not supported", s->spatial_decomposition_type);
return -1;
}
width= s->avctx->width;
height= s->avctx->height;
- s->spatial_dwt_buffer= av_mallocz(width*height*sizeof(DWTELEM));
+ s->spatial_idwt_buffer= av_mallocz(width*height*sizeof(IDWTELEM));
+ s->spatial_dwt_buffer= av_mallocz(width*height*sizeof(DWTELEM)); //FIXME this doesnt belong here
s->mv_scale= (s->avctx->flags & CODEC_FLAG_QPEL) ? 2 : 4;
s->block_max_depth= (s->avctx->flags & CODEC_FLAG_4MV) ? 1 : 0;
b->buf += b->stride>>1;
b->buf_y_offset = b->stride_line >> 1;
}
+ b->ibuf= s->spatial_idwt_buffer + (b->buf - s->spatial_dwt_buffer);
if(level)
b->parent= &s->plane[plane_index].band[level-1][orientation];
for(level=0; level<s->spatial_decomposition_count; level++){
for(orientation=level ? 1 : 0; orientation<4; orientation++){
SubBand *b= &s->plane[0].band[level][orientation];
- DWTELEM *buf= b->buf;
+ IDWTELEM *buf= b->ibuf;
const int w= b->width;
const int h= b->height;
const int stride= b->stride;
const int qmul= qexp[qlog&(QROOT-1)]<<(qlog>>QSHIFT);
const int qdiv= (1<<16)/qmul;
int x, y;
+ //FIXME this is ugly
+ for(y=0; y<h; y++)
+ for(x=0; x<w; x++)
+ buf[x+y*stride]= b->buf[x+y*stride];
if(orientation==0)
decorrelate(s, b, buf, stride, 1, 0);
for(y=0; y<h; y++)
for(x=0; x<w; x++)
coef_sum+= abs(buf[x+y*stride]) * qdiv >> 16;
- if(orientation==0)
- correlate(s, b, buf, stride, 1, 0);
}
}
for(level=0; level<s->spatial_decomposition_count; level++){
for(orientation=level ? 1 : 0; orientation<4; orientation++){
SubBand *b= &p->band[level][orientation];
- DWTELEM *buf= b->buf;
+ IDWTELEM *ibuf= b->ibuf;
int64_t error=0;
- memset(s->spatial_dwt_buffer, 0, sizeof(int)*width*height);
- buf[b->width/2 + b->height/2*b->stride]= 256*256;
- ff_spatial_idwt(s->spatial_dwt_buffer, width, height, width, s->spatial_decomposition_type, s->spatial_decomposition_count);
+ memset(s->spatial_idwt_buffer, 0, sizeof(*s->spatial_idwt_buffer)*width*height);
+ ibuf[b->width/2 + b->height/2*b->stride]= 256*16;
+ ff_spatial_idwt(s->spatial_idwt_buffer, width, height, width, s->spatial_decomposition_type, s->spatial_decomposition_count);
for(y=0; y<height; y++){
for(x=0; x<width; x++){
- int64_t d= s->spatial_dwt_buffer[x + y*width];
+ int64_t d= s->spatial_idwt_buffer[x + y*width]*16;
error += d*d;
}
}
if(pict->data[plane_index]) //FIXME gray hack
for(y=0; y<h; y++){
for(x=0; x<w; x++){
- s->spatial_dwt_buffer[y*w + x]= pict->data[plane_index][y*pict->linesize[plane_index] + x]<<FRAC_BITS;
+ s->spatial_idwt_buffer[y*w + x]= pict->data[plane_index][y*pict->linesize[plane_index] + x]<<FRAC_BITS;
}
}
- predict_plane(s, s->spatial_dwt_buffer, plane_index, 0);
+ predict_plane(s, s->spatial_idwt_buffer, plane_index, 0);
if( plane_index==0
&& pict->pict_type == P_TYPE
if(s->qlog == LOSSLESS_QLOG){
for(y=0; y<h; y++){
for(x=0; x<w; x++){
- s->spatial_dwt_buffer[y*w + x]= (s->spatial_dwt_buffer[y*w + x] + (1<<(FRAC_BITS-1))-1)>>FRAC_BITS;
+ s->spatial_dwt_buffer[y*w + x]= (s->spatial_idwt_buffer[y*w + x] + (1<<(FRAC_BITS-1))-1)>>FRAC_BITS;
+ }
+ }
+ }else{
+ for(y=0; y<h; y++){
+ for(x=0; x<w; x++){
+ s->spatial_dwt_buffer[y*w + x]=s->spatial_idwt_buffer[y*w + x]<<ENCODER_EXTRA_BITS;
}
}
}
for(orientation=level ? 1 : 0; orientation<4; orientation++){
SubBand *b= &p->band[level][orientation];
- quantize(s, b, b->buf, b->stride, s->qbias);
+ quantize(s, b, b->ibuf, b->buf, b->stride, s->qbias);
if(orientation==0)
- decorrelate(s, b, b->buf, b->stride, pict->pict_type == P_TYPE, 0);
- encode_subband(s, b, b->buf, b->parent ? b->parent->buf : NULL, b->stride, orientation);
+ decorrelate(s, b, b->ibuf, b->stride, pict->pict_type == P_TYPE, 0);
+ encode_subband(s, b, b->ibuf, b->parent ? b->parent->ibuf : NULL, b->stride, orientation);
assert(b->parent==NULL || b->parent->stride == b->stride*2);
if(orientation==0)
- correlate(s, b, b->buf, b->stride, 1, 0);
+ correlate(s, b, b->ibuf, b->stride, 1, 0);
}
}
// av_log(NULL, AV_LOG_DEBUG, "plane:%d bits:%d\n", plane_index, put_bits_count(&s->c.pb) - bits);
for(orientation=level ? 1 : 0; orientation<4; orientation++){
SubBand *b= &p->band[level][orientation];
- dequantize(s, b, b->buf, b->stride);
+ dequantize(s, b, b->ibuf, b->stride);
}
}
- ff_spatial_idwt(s->spatial_dwt_buffer, w, h, w, s->spatial_decomposition_type, s->spatial_decomposition_count);
+ ff_spatial_idwt(s->spatial_idwt_buffer, w, h, w, s->spatial_decomposition_type, s->spatial_decomposition_count);
if(s->qlog == LOSSLESS_QLOG){
for(y=0; y<h; y++){
for(x=0; x<w; x++){
- s->spatial_dwt_buffer[y*w + x]<<=FRAC_BITS;
+ s->spatial_idwt_buffer[y*w + x]<<=FRAC_BITS;
}
}
}
{START_TIMER
- predict_plane(s, s->spatial_dwt_buffer, plane_index, 1);
+ predict_plane(s, s->spatial_idwt_buffer, plane_index, 1);
STOP_TIMER("pred-conv")}
}else{
//ME/MC only
}
}
}else{
- memset(s->spatial_dwt_buffer, 0, sizeof(DWTELEM)*w*h);
- predict_plane(s, s->spatial_dwt_buffer, plane_index, 1);
+ memset(s->spatial_idwt_buffer, 0, sizeof(IDWTELEM)*w*h);
+ predict_plane(s, s->spatial_idwt_buffer, plane_index, 1);
}
}
if(s->avctx->flags&CODEC_FLAG_PSNR){
int plane_index, level, orientation, i;
av_freep(&s->spatial_dwt_buffer);
+ av_freep(&s->spatial_idwt_buffer);
av_freep(&s->m.me.scratchpad);
av_freep(&s->m.me.map);
common_init(avctx);
block_size = MB_SIZE >> s->block_max_depth;
- slice_buffer_init(&s->sb, s->plane[0].height, (block_size) + (s->spatial_decomposition_count * (s->spatial_decomposition_count + 3)) + 1, s->plane[0].width, s->spatial_dwt_buffer);
+ slice_buffer_init(&s->sb, s->plane[0].height, (block_size) + (s->spatial_decomposition_count * (s->spatial_decomposition_count + 3)) + 1, s->plane[0].width, s->spatial_idwt_buffer);
return 0;
}
if(s->avctx->debug&2048){
memset(s->spatial_dwt_buffer, 0, sizeof(DWTELEM)*w*h);
- predict_plane(s, s->spatial_dwt_buffer, plane_index, 1);
+ predict_plane(s, s->spatial_idwt_buffer, plane_index, 1);
for(y=0; y<h; y++){
for(x=0; x<w; x++){
int correlate_end_y = FFMIN(b->height, end_y + 1);
int correlate_start_y = FFMIN(b->height, (start_y ? start_y + 1 : 0));
decode_subband_slice_buffered(s, correlate_band, &s->sb, correlate_start_y, correlate_end_y, decode_state[0][0]);
- correlate_slice_buffered(s, &s->sb, correlate_band, correlate_band->buf, correlate_band->stride, 1, 0, correlate_start_y, correlate_end_y);
- dequantize_slice_buffered(s, &s->sb, correlate_band, correlate_band->buf, correlate_band->stride, start_y, end_y);
+ correlate_slice_buffered(s, &s->sb, correlate_band, correlate_band->ibuf, correlate_band->stride, 1, 0, correlate_start_y, correlate_end_y);
+ dequantize_slice_buffered(s, &s->sb, correlate_band, correlate_band->ibuf, correlate_band->stride, start_y, end_y);
}
else
decode_subband_slice_buffered(s, b, &s->sb, start_y, end_y, decode_state[level][orientation]);
if(s->qlog == LOSSLESS_QLOG){
for(; yq<slice_h && yq<h; yq++){
- DWTELEM * line = slice_buffer_get_line(&s->sb, yq);
+ IDWTELEM * line = slice_buffer_get_line(&s->sb, yq);
for(x=0; x<w; x++){
line[x] <<= FRAC_BITS;
}
}
}
- predict_slice_buffered(s, &s->sb, s->spatial_dwt_buffer, plane_index, 1, mb_y);
+ predict_slice_buffered(s, &s->sb, s->spatial_idwt_buffer, plane_index, 1, mb_y);
y = FFMIN(p->height, slice_starty);
end_y = FFMIN(p->height, slice_h);