Revision 05aec7bb libavcodec/dsputil.c

View differences:

libavcodec/dsputil.c
33 33
#include "faandct.h"
34 34
#include "faanidct.h"
35 35
#include "mathops.h"
36
#include "snow.h"
37 36
#include "mpegvideo.h"
38 37
#include "config.h"
39 38
#include "lpc.h"
......
329 328
    return s;
330 329
}
331 330

  
332

  
333
#if CONFIG_SNOW_ENCODER //dwt is in snow.c
334
static inline int w_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int w, int h, int type){
335
    int s, i, j;
336
    const int dec_count= w==8 ? 3 : 4;
337
    int tmp[32*32];
338
    int level, ori;
339
    static const int scale[2][2][4][4]={
340
      {
341
        {
342
            // 9/7 8x8 dec=3
343
            {268, 239, 239, 213},
344
            {  0, 224, 224, 152},
345
            {  0, 135, 135, 110},
346
        },{
347
            // 9/7 16x16 or 32x32 dec=4
348
            {344, 310, 310, 280},
349
            {  0, 320, 320, 228},
350
            {  0, 175, 175, 136},
351
            {  0, 129, 129, 102},
352
        }
353
      },{
354
        {
355
            // 5/3 8x8 dec=3
356
            {275, 245, 245, 218},
357
            {  0, 230, 230, 156},
358
            {  0, 138, 138, 113},
359
        },{
360
            // 5/3 16x16 or 32x32 dec=4
361
            {352, 317, 317, 286},
362
            {  0, 328, 328, 233},
363
            {  0, 180, 180, 140},
364
            {  0, 132, 132, 105},
365
        }
366
      }
367
    };
368

  
369
    for (i = 0; i < h; i++) {
370
        for (j = 0; j < w; j+=4) {
371
            tmp[32*i+j+0] = (pix1[j+0] - pix2[j+0])<<4;
372
            tmp[32*i+j+1] = (pix1[j+1] - pix2[j+1])<<4;
373
            tmp[32*i+j+2] = (pix1[j+2] - pix2[j+2])<<4;
374
            tmp[32*i+j+3] = (pix1[j+3] - pix2[j+3])<<4;
375
        }
376
        pix1 += line_size;
377
        pix2 += line_size;
378
    }
379

  
380
    ff_spatial_dwt(tmp, w, h, 32, type, dec_count);
381

  
382
    s=0;
383
    assert(w==h);
384
    for(level=0; level<dec_count; level++){
385
        for(ori= level ? 1 : 0; ori<4; ori++){
386
            int size= w>>(dec_count-level);
387
            int sx= (ori&1) ? size : 0;
388
            int stride= 32<<(dec_count-level);
389
            int sy= (ori&2) ? stride>>1 : 0;
390

  
391
            for(i=0; i<size; i++){
392
                for(j=0; j<size; j++){
393
                    int v= tmp[sx + sy + i*stride + j] * scale[type][dec_count-3][level][ori];
394
                    s += FFABS(v);
395
                }
396
            }
397
        }
398
    }
399
    assert(s>=0);
400
    return s>>9;
401
}
402

  
403
static int w53_8_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h){
404
    return w_c(v, pix1, pix2, line_size,  8, h, 1);
405
}
406

  
407
static int w97_8_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h){
408
    return w_c(v, pix1, pix2, line_size,  8, h, 0);
409
}
410

  
411
static int w53_16_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h){
412
    return w_c(v, pix1, pix2, line_size, 16, h, 1);
413
}
414

  
415
static int w97_16_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h){
416
    return w_c(v, pix1, pix2, line_size, 16, h, 0);
417
}
418

  
419
int w53_32_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h){
420
    return w_c(v, pix1, pix2, line_size, 32, h, 1);
421
}
422

  
423
int w97_32_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int h){
424
    return w_c(v, pix1, pix2, line_size, 32, h, 0);
425
}
426
#endif
427

  
428 331
/* draw the edges of width 'w' of an image of size width, height */
429 332
//FIXME check that this is ok for mpeg4 interlaced
430 333
static void draw_edges_c(uint8_t *buf, int wrap, int width, int height, int w)
......
3531 3434
        case FF_CMP_NSSE:
3532 3435
            cmp[i]= c->nsse[i];
3533 3436
            break;
3534
#if CONFIG_SNOW_ENCODER
3437
#if CONFIG_DWT
3535 3438
        case FF_CMP_W53:
3536 3439
            cmp[i]= c->w53[i];
3537 3440
            break;
......
4816 4719
    c->vsse[5]= vsse_intra8_c;
4817 4720
    c->nsse[0]= nsse16_c;
4818 4721
    c->nsse[1]= nsse8_c;
4819
#if CONFIG_SNOW_ENCODER
4820
    c->w53[0]= w53_16_c;
4821
    c->w53[1]= w53_8_c;
4822
    c->w97[0]= w97_16_c;
4823
    c->w97[1]= w97_8_c;
4722
#if CONFIG_DWT
4723
    ff_dsputil_init_dwt(c);
4824 4724
#endif
4825 4725

  
4826 4726
    c->ssd_int8_vs_int16 = ssd_int8_vs_int16_c;
......
4865 4765
    c->try_8x8basis= try_8x8basis_c;
4866 4766
    c->add_8x8basis= add_8x8basis_c;
4867 4767

  
4868
#if CONFIG_SNOW_DECODER
4869
    c->vertical_compose97i = ff_snow_vertical_compose97i;
4870
    c->horizontal_compose97i = ff_snow_horizontal_compose97i;
4871
    c->inner_add_yblock = ff_snow_inner_add_yblock;
4872
#endif
4873

  
4874 4768
#if CONFIG_VORBIS_DECODER
4875 4769
    c->vorbis_inverse_coupling = vorbis_inverse_coupling;
4876 4770
#endif

Also available in: Unified diff