Mercurial > libavcodec.hg
comparison dsputil.c @ 3323:87c54a3f8d19 libavcodec
Snow: fix subband weighting in wavelet cmp functions. use 32x32 cmp in iterative motion estimation.
author | lorenm |
---|---|
date | Tue, 30 May 2006 05:44:22 +0000 |
parents | 7aa9f80e7954 |
children | b8996cc5ccae |
comparison
equal
deleted
inserted
replaced
3322:0b4f548dfb44 | 3323:87c54a3f8d19 |
---|---|
291 return s; | 291 return s; |
292 } | 292 } |
293 | 293 |
294 | 294 |
295 static inline int w_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int w, int h, int type){ | 295 static inline int w_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int w, int h, int type){ |
296 #ifdef CONFIG_SNOW_ENCODER //idwt is in snow.c | 296 #ifdef CONFIG_SNOW_ENCODER //dwt is in snow.c |
297 int s, i, j; | 297 int s, i, j; |
298 const int dec_count= w==8 ? 3 : 4; | 298 const int dec_count= w==8 ? 3 : 4; |
299 int tmp[16*16]; | 299 int tmp[32*32]; |
300 #if 0 | |
301 int level, ori; | 300 int level, ori; |
302 static const int scale[2][2][4][4]={ | 301 static const int scale[2][2][4][4]={ |
303 { | 302 { |
304 { | 303 { |
305 //8x8 dec=3 | 304 // 9/7 8x8 dec=3 |
306 {268, 239, 239, 213}, | 305 {268, 239, 239, 213}, |
307 { 0, 224, 224, 152}, | 306 { 0, 224, 224, 152}, |
308 { 0, 135, 135, 110}, | 307 { 0, 135, 135, 110}, |
309 },{ | 308 },{ |
310 //16x16 dec=4 | 309 // 9/7 16x16 or 32x32 dec=4 |
311 {344, 310, 310, 280}, | 310 {344, 310, 310, 280}, |
312 { 0, 320, 320, 228}, | 311 { 0, 320, 320, 228}, |
313 { 0, 175, 175, 136}, | 312 { 0, 175, 175, 136}, |
314 { 0, 129, 129, 102}, | 313 { 0, 129, 129, 102}, |
315 } | 314 } |
316 },{ | 315 },{ |
317 {//FIXME 5/3 | 316 { |
318 //8x8 dec=3 | 317 // 5/3 8x8 dec=3 |
319 {275, 245, 245, 218}, | 318 {275, 245, 245, 218}, |
320 { 0, 230, 230, 156}, | 319 { 0, 230, 230, 156}, |
321 { 0, 138, 138, 113}, | 320 { 0, 138, 138, 113}, |
322 },{ | 321 },{ |
323 //16x16 dec=4 | 322 // 5/3 16x16 or 32x32 dec=4 |
324 {352, 317, 317, 286}, | 323 {352, 317, 317, 286}, |
325 { 0, 328, 328, 233}, | 324 { 0, 328, 328, 233}, |
326 { 0, 180, 180, 140}, | 325 { 0, 180, 180, 140}, |
327 { 0, 132, 132, 105}, | 326 { 0, 132, 132, 105}, |
328 } | 327 } |
329 } | 328 } |
330 }; | 329 }; |
331 #endif | |
332 | 330 |
333 for (i = 0; i < h; i++) { | 331 for (i = 0; i < h; i++) { |
334 for (j = 0; j < w; j+=4) { | 332 for (j = 0; j < w; j+=4) { |
335 tmp[16*i+j+0] = (pix1[j+0] - pix2[j+0])<<4; | 333 tmp[32*i+j+0] = (pix1[j+0] - pix2[j+0])<<4; |
336 tmp[16*i+j+1] = (pix1[j+1] - pix2[j+1])<<4; | 334 tmp[32*i+j+1] = (pix1[j+1] - pix2[j+1])<<4; |
337 tmp[16*i+j+2] = (pix1[j+2] - pix2[j+2])<<4; | 335 tmp[32*i+j+2] = (pix1[j+2] - pix2[j+2])<<4; |
338 tmp[16*i+j+3] = (pix1[j+3] - pix2[j+3])<<4; | 336 tmp[32*i+j+3] = (pix1[j+3] - pix2[j+3])<<4; |
339 } | 337 } |
340 pix1 += line_size; | 338 pix1 += line_size; |
341 pix2 += line_size; | 339 pix2 += line_size; |
342 } | 340 } |
343 | 341 |
344 ff_spatial_dwt(tmp, w, h, 16, type, dec_count); | 342 ff_spatial_dwt(tmp, w, h, 32, type, dec_count); |
345 | 343 |
346 s=0; | 344 s=0; |
347 #if 0 | 345 assert(w==h); |
348 for(level=0; level<dec_count; level++){ | 346 for(level=0; level<dec_count; level++){ |
349 for(ori= level ? 1 : 0; ori<4; ori++){ | 347 for(ori= level ? 1 : 0; ori<4; ori++){ |
350 int sx= (ori&1) ? 1<<level: 0; | 348 int size= w>>(dec_count-level); |
351 int stride= 16<<(dec_count-level); | 349 int sx= (ori&1) ? size : 0; |
350 int stride= 32<<(dec_count-level); | |
352 int sy= (ori&2) ? stride>>1 : 0; | 351 int sy= (ori&2) ? stride>>1 : 0; |
353 int size= 1<<level; | |
354 | 352 |
355 for(i=0; i<size; i++){ | 353 for(i=0; i<size; i++){ |
356 for(j=0; j<size; j++){ | 354 for(j=0; j<size; j++){ |
357 int v= tmp[sx + sy + i*stride + j] * scale[type][dec_count-3][level][ori]; | 355 int v= tmp[sx + sy + i*stride + j] * scale[type][dec_count-3][level][ori]; |
358 s += ABS(v); | 356 s += ABS(v); |
359 } | 357 } |
360 } | 358 } |
361 } | 359 } |
362 } | 360 } |
363 #endif | |
364 for (i = 0; i < h; i++) { | |
365 for (j = 0; j < w; j+=4) { | |
366 s+= ABS(tmp[16*i+j+0]); | |
367 s+= ABS(tmp[16*i+j+1]); | |
368 s+= ABS(tmp[16*i+j+2]); | |
369 s+= ABS(tmp[16*i+j+3]); | |
370 } | |
371 } | |
372 assert(s>=0); | 361 assert(s>=0); |
373 | 362 return s>>9; |
374 return s>>2; | |
375 #endif | 363 #endif |
376 } | 364 } |
377 | 365 |
378 static int w53_8_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h){ | 366 static int w53_8_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h){ |
379 return w_c(v, pix1, pix2, line_size, 8, h, 1); | 367 return w_c(v, pix1, pix2, line_size, 8, h, 1); |
387 return w_c(v, pix1, pix2, line_size, 16, h, 1); | 375 return w_c(v, pix1, pix2, line_size, 16, h, 1); |
388 } | 376 } |
389 | 377 |
390 static int w97_16_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h){ | 378 static int w97_16_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h){ |
391 return w_c(v, pix1, pix2, line_size, 16, h, 0); | 379 return w_c(v, pix1, pix2, line_size, 16, h, 0); |
380 } | |
381 | |
382 int w53_32_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h){ | |
383 return w_c(v, pix1, pix2, line_size, 32, h, 1); | |
384 } | |
385 | |
386 int w97_32_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h){ | |
387 return w_c(v, pix1, pix2, line_size, 32, h, 0); | |
392 } | 388 } |
393 | 389 |
394 static void get_pixels_c(DCTELEM *restrict block, const uint8_t *pixels, int line_size) | 390 static void get_pixels_c(DCTELEM *restrict block, const uint8_t *pixels, int line_size) |
395 { | 391 { |
396 int i; | 392 int i; |