Revision ca32f7f2

View differences:

libavcodec/h264.c
687 687

  
688 688
static void init_dequant8_coeff_table(H264Context *h){
689 689
    int i,q,x;
690
    const int transpose = (h->h264dsp.h264_idct8_add != ff_h264_idct8_add_c); //FIXME ugly
691 690
    h->dequant8_coeff[0] = h->dequant8_buffer[0];
692 691
    h->dequant8_coeff[1] = h->dequant8_buffer[1];
693 692

  
......
701 700
            int shift = div6[q];
702 701
            int idx = rem6[q];
703 702
            for(x=0; x<64; x++)
704
                h->dequant8_coeff[i][q][transpose ? (x>>3)|((x&7)<<3) : x] =
703
                h->dequant8_coeff[i][q][(x>>3)|((x&7)<<3)] =
705 704
                    ((uint32_t)dequant8_coeff_init[idx][ dequant8_coeff_init_scan[((x>>1)&12) | (x&3)] ] *
706 705
                    h->pps.scaling_matrix8[i][x]) << shift;
707 706
        }
......
710 709

  
711 710
static void init_dequant4_coeff_table(H264Context *h){
712 711
    int i,j,q,x;
713
    const int transpose = (h->h264dsp.h264_idct_add != ff_h264_idct_add_c); //FIXME ugly
714 712
    for(i=0; i<6; i++ ){
715 713
        h->dequant4_coeff[i] = h->dequant4_buffer[i];
716 714
        for(j=0; j<i; j++){
......
726 724
            int shift = div6[q] + 2;
727 725
            int idx = rem6[q];
728 726
            for(x=0; x<16; x++)
729
                h->dequant4_coeff[i][q][transpose ? (x>>2)|((x<<2)&0xF) : x] =
727
                h->dequant4_coeff[i][q][(x>>2)|((x<<2)&0xF)] =
730 728
                    ((uint32_t)dequant4_coeff_init[idx][(x&1) + ((x>>2)&1)] *
731 729
                    h->pps.scaling_matrix4[i][x]) << shift;
732 730
        }
......
1597 1595
 */
1598 1596
static void init_scan_tables(H264Context *h){
1599 1597
    int i;
1600
    if(h->h264dsp.h264_idct_add == ff_h264_idct_add_c){ //FIXME little ugly
1601
        memcpy(h->zigzag_scan, zigzag_scan, 16*sizeof(uint8_t));
1602
        memcpy(h-> field_scan,  field_scan, 16*sizeof(uint8_t));
1603
    }else{
1604
        for(i=0; i<16; i++){
1598
    for(i=0; i<16; i++){
1605 1599
#define T(x) (x>>2) | ((x<<2) & 0xF)
1606
            h->zigzag_scan[i] = T(zigzag_scan[i]);
1607
            h-> field_scan[i] = T( field_scan[i]);
1600
        h->zigzag_scan[i] = T(zigzag_scan[i]);
1601
        h-> field_scan[i] = T( field_scan[i]);
1608 1602
#undef T
1609
        }
1610 1603
    }
1611
    if(h->h264dsp.h264_idct8_add == ff_h264_idct8_add_c){
1612
        memcpy(h->zigzag_scan8x8,       ff_zigzag_direct,     64*sizeof(uint8_t));
1613
        memcpy(h->zigzag_scan8x8_cavlc, zigzag_scan8x8_cavlc, 64*sizeof(uint8_t));
1614
        memcpy(h->field_scan8x8,        field_scan8x8,        64*sizeof(uint8_t));
1615
        memcpy(h->field_scan8x8_cavlc,  field_scan8x8_cavlc,  64*sizeof(uint8_t));
1616
    }else{
1617
        for(i=0; i<64; i++){
1604
    for(i=0; i<64; i++){
1618 1605
#define T(x) (x>>3) | ((x&7)<<3)
1619
            h->zigzag_scan8x8[i]       = T(ff_zigzag_direct[i]);
1620
            h->zigzag_scan8x8_cavlc[i] = T(zigzag_scan8x8_cavlc[i]);
1621
            h->field_scan8x8[i]        = T(field_scan8x8[i]);
1622
            h->field_scan8x8_cavlc[i]  = T(field_scan8x8_cavlc[i]);
1606
        h->zigzag_scan8x8[i]       = T(ff_zigzag_direct[i]);
1607
        h->zigzag_scan8x8_cavlc[i] = T(zigzag_scan8x8_cavlc[i]);
1608
        h->field_scan8x8[i]        = T(field_scan8x8[i]);
1609
        h->field_scan8x8_cavlc[i]  = T(field_scan8x8_cavlc[i]);
1623 1610
#undef T
1624
        }
1625 1611
    }
1626 1612
    if(h->sps.transform_bypass){ //FIXME same ugly
1627 1613
        h->zigzag_scan_q0          = zigzag_scan;
libavcodec/h264idct.c
34 34
    block[0] += 1<<(shift-1);
35 35

  
36 36
    for(i=0; i<4; i++){
37
        const int z0=  block[0 + block_stride*i]     +  block[2 + block_stride*i];
38
        const int z1=  block[0 + block_stride*i]     -  block[2 + block_stride*i];
39
        const int z2= (block[1 + block_stride*i]>>1) -  block[3 + block_stride*i];
40
        const int z3=  block[1 + block_stride*i]     + (block[3 + block_stride*i]>>1);
41

  
42
        block[0 + block_stride*i]= z0 + z3;
43
        block[1 + block_stride*i]= z1 + z2;
44
        block[2 + block_stride*i]= z1 - z2;
45
        block[3 + block_stride*i]= z0 - z3;
46
    }
47

  
48
    for(i=0; i<4; i++){
49 37
        const int z0=  block[i + block_stride*0]     +  block[i + block_stride*2];
50 38
        const int z1=  block[i + block_stride*0]     -  block[i + block_stride*2];
51 39
        const int z2= (block[i + block_stride*1]>>1) -  block[i + block_stride*3];
52 40
        const int z3=  block[i + block_stride*1]     + (block[i + block_stride*3]>>1);
53 41

  
42
        block[i + block_stride*0]= z0 + z3;
43
        block[i + block_stride*1]= z1 + z2;
44
        block[i + block_stride*2]= z1 - z2;
45
        block[i + block_stride*3]= z0 - z3;
46
    }
47

  
48
    for(i=0; i<4; i++){
49
        const int z0=  block[0 + block_stride*i]     +  block[2 + block_stride*i];
50
        const int z1=  block[0 + block_stride*i]     -  block[2 + block_stride*i];
51
        const int z2= (block[1 + block_stride*i]>>1) -  block[3 + block_stride*i];
52
        const int z3=  block[1 + block_stride*i]     + (block[3 + block_stride*i]>>1);
53

  
54 54
        dst[i + 0*stride]= cm[ add*dst[i + 0*stride] + ((z0 + z3) >> shift) ];
55 55
        dst[i + 1*stride]= cm[ add*dst[i + 1*stride] + ((z1 + z2) >> shift) ];
56 56
        dst[i + 2*stride]= cm[ add*dst[i + 2*stride] + ((z1 - z2) >> shift) ];
......
78 78

  
79 79
    for( i = 0; i < 8; i++ )
80 80
    {
81
        const int a0 =  block[0+i*8] + block[4+i*8];
82
        const int a2 =  block[0+i*8] - block[4+i*8];
83
        const int a4 = (block[2+i*8]>>1) - block[6+i*8];
84
        const int a6 = (block[6+i*8]>>1) + block[2+i*8];
81
        const int a0 =  block[i+0*8] + block[i+4*8];
82
        const int a2 =  block[i+0*8] - block[i+4*8];
83
        const int a4 = (block[i+2*8]>>1) - block[i+6*8];
84
        const int a6 = (block[i+6*8]>>1) + block[i+2*8];
85 85

  
86 86
        const int b0 = a0 + a6;
87 87
        const int b2 = a2 + a4;
88 88
        const int b4 = a2 - a4;
89 89
        const int b6 = a0 - a6;
90 90

  
91
        const int a1 = -block[3+i*8] + block[5+i*8] - block[7+i*8] - (block[7+i*8]>>1);
92
        const int a3 =  block[1+i*8] + block[7+i*8] - block[3+i*8] - (block[3+i*8]>>1);
93
        const int a5 = -block[1+i*8] + block[7+i*8] + block[5+i*8] + (block[5+i*8]>>1);
94
        const int a7 =  block[3+i*8] + block[5+i*8] + block[1+i*8] + (block[1+i*8]>>1);
91
        const int a1 = -block[i+3*8] + block[i+5*8] - block[i+7*8] - (block[i+7*8]>>1);
92
        const int a3 =  block[i+1*8] + block[i+7*8] - block[i+3*8] - (block[i+3*8]>>1);
93
        const int a5 = -block[i+1*8] + block[i+7*8] + block[i+5*8] + (block[i+5*8]>>1);
94
        const int a7 =  block[i+3*8] + block[i+5*8] + block[i+1*8] + (block[i+1*8]>>1);
95 95

  
96 96
        const int b1 = (a7>>2) + a1;
97 97
        const int b3 =  a3 + (a5>>2);
98 98
        const int b5 = (a3>>2) - a5;
99 99
        const int b7 =  a7 - (a1>>2);
100 100

  
101
        block[0+i*8] = b0 + b7;
102
        block[7+i*8] = b0 - b7;
103
        block[1+i*8] = b2 + b5;
104
        block[6+i*8] = b2 - b5;
105
        block[2+i*8] = b4 + b3;
106
        block[5+i*8] = b4 - b3;
107
        block[3+i*8] = b6 + b1;
108
        block[4+i*8] = b6 - b1;
101
        block[i+0*8] = b0 + b7;
102
        block[i+7*8] = b0 - b7;
103
        block[i+1*8] = b2 + b5;
104
        block[i+6*8] = b2 - b5;
105
        block[i+2*8] = b4 + b3;
106
        block[i+5*8] = b4 - b3;
107
        block[i+3*8] = b6 + b1;
108
        block[i+4*8] = b6 - b1;
109 109
    }
110 110
    for( i = 0; i < 8; i++ )
111 111
    {
112
        const int a0 =  block[i+0*8] + block[i+4*8];
113
        const int a2 =  block[i+0*8] - block[i+4*8];
114
        const int a4 = (block[i+2*8]>>1) - block[i+6*8];
115
        const int a6 = (block[i+6*8]>>1) + block[i+2*8];
112
        const int a0 =  block[0+i*8] + block[4+i*8];
113
        const int a2 =  block[0+i*8] - block[4+i*8];
114
        const int a4 = (block[2+i*8]>>1) - block[6+i*8];
115
        const int a6 = (block[6+i*8]>>1) + block[2+i*8];
116 116

  
117 117
        const int b0 = a0 + a6;
118 118
        const int b2 = a2 + a4;
119 119
        const int b4 = a2 - a4;
120 120
        const int b6 = a0 - a6;
121 121

  
122
        const int a1 = -block[i+3*8] + block[i+5*8] - block[i+7*8] - (block[i+7*8]>>1);
123
        const int a3 =  block[i+1*8] + block[i+7*8] - block[i+3*8] - (block[i+3*8]>>1);
124
        const int a5 = -block[i+1*8] + block[i+7*8] + block[i+5*8] + (block[i+5*8]>>1);
125
        const int a7 =  block[i+3*8] + block[i+5*8] + block[i+1*8] + (block[i+1*8]>>1);
122
        const int a1 = -block[3+i*8] + block[5+i*8] - block[7+i*8] - (block[7+i*8]>>1);
123
        const int a3 =  block[1+i*8] + block[7+i*8] - block[3+i*8] - (block[3+i*8]>>1);
124
        const int a5 = -block[1+i*8] + block[7+i*8] + block[5+i*8] + (block[5+i*8]>>1);
125
        const int a7 =  block[3+i*8] + block[5+i*8] + block[1+i*8] + (block[1+i*8]>>1);
126 126

  
127 127
        const int b1 = (a7>>2) + a1;
128 128
        const int b3 =  a3 + (a5>>2);

Also available in: Unified diff