~ubuntu-branches/ubuntu/jaunty/xvidcap/jaunty-proposed

« back to all changes in this revision

Viewing changes to ffmpeg/libavcodec/dsputil.c

  • Committer: Bazaar Package Importer
  • Author(s): Lionel Le Folgoc, Andrew Starr-Bochicchio, Lionel Le Folgoc
  • Date: 2008-12-26 00:10:06 UTC
  • mfrom: (1.1.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20081226001006-2040ls9680bd1blt
Tags: 1.1.7-0.2ubuntu1
[ Andrew Starr-Bochicchio ]
* Merge from debian-multimedia (LP: #298547), Ubuntu Changes:
 - For ffmpeg-related build-deps, fix versionized dependencies
   as the ubuntu versioning is different than debian-multimedia's.

[ Lionel Le Folgoc ]
* LP: #311412 is fixed since the 1.1.7~rc1-0.1 revision.
* debian/patches/03_ffmpeg.diff: updated to fix FTBFS due to libswscale API
  change (cherry-pick from Gentoo #234383).

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 * Copyright (c) 2000, 2001 Fabrice Bellard.
4
4
 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
5
5
 *
 
6
 * gmc & q-pel & 32/64 bit based MC by Michael Niedermayer <michaelni@gmx.at>
 
7
 *
6
8
 * This file is part of FFmpeg.
7
9
 *
8
10
 * FFmpeg is free software; you can redistribute it and/or
18
20
 * You should have received a copy of the GNU Lesser General Public
19
21
 * License along with FFmpeg; if not, write to the Free Software
20
22
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21
 
 *
22
 
 * gmc & q-pel & 32/64 bit based MC by Michael Niedermayer <michaelni@gmx.at>
23
23
 */
24
24
 
25
25
/**
29
29
 
30
30
#include "avcodec.h"
31
31
#include "dsputil.h"
32
 
#include "mpegvideo.h"
33
32
#include "simple_idct.h"
34
33
#include "faandct.h"
 
34
#include "faanidct.h"
 
35
#include "h263.h"
35
36
#include "snow.h"
36
37
 
37
38
/* snow.c */
40
41
/* vorbis.c */
41
42
void vorbis_inverse_coupling(float *mag, float *ang, int blocksize);
42
43
 
 
44
/* flacenc.c */
 
45
void ff_flac_compute_autocorr(const int32_t *data, int len, int lag, double *autoc);
 
46
 
 
47
/* pngdec.c */
 
48
void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp);
 
49
 
43
50
uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP] = {0, };
44
51
uint32_t ff_squareTbl[512] = {0, };
45
52
 
 
53
// 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size
 
54
#define pb_7f (~0UL/255 * 0x7f)
 
55
#define pb_80 (~0UL/255 * 0x80)
 
56
 
46
57
const uint8_t ff_zigzag_direct[64] = {
47
58
    0,   1,  8, 16,  9,  2,  3, 10,
48
59
    17, 24, 32, 25, 18, 11,  4,  5,
140
151
        0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F,
141
152
};
142
153
 
 
154
static const uint8_t idct_sse2_row_perm[8] = {0, 4, 1, 5, 2, 6, 3, 7};
 
155
 
 
156
void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable){
 
157
    int i;
 
158
    int end;
 
159
 
 
160
    st->scantable= src_scantable;
 
161
 
 
162
    for(i=0; i<64; i++){
 
163
        int j;
 
164
        j = src_scantable[i];
 
165
        st->permutated[i] = permutation[j];
 
166
#ifdef ARCH_POWERPC
 
167
        st->inverse[j] = i;
 
168
#endif
 
169
    }
 
170
 
 
171
    end=-1;
 
172
    for(i=0; i<64; i++){
 
173
        int j;
 
174
        j = st->permutated[i];
 
175
        if(j>end) end=j;
 
176
        st->raster_end[i]= end;
 
177
    }
 
178
}
 
179
 
143
180
static int pix_sum_c(uint8_t * pix, int line_size)
144
181
{
145
182
    int s, i, j;
210
247
    return s;
211
248
}
212
249
 
213
 
static void bswap_buf(uint32_t *dst, uint32_t *src, int w){
 
250
static void bswap_buf(uint32_t *dst, const uint32_t *src, int w){
214
251
    int i;
215
252
 
216
253
    for(i=0; i+8<=w; i+=8){
392
429
}
393
430
#endif
394
431
 
 
432
/* draw the edges of width 'w' of an image of size width, height */
 
433
//FIXME check that this is ok for mpeg4 interlaced
 
434
static void draw_edges_c(uint8_t *buf, int wrap, int width, int height, int w)
 
435
{
 
436
    uint8_t *ptr, *last_line;
 
437
    int i;
 
438
 
 
439
    last_line = buf + (height - 1) * wrap;
 
440
    for(i=0;i<w;i++) {
 
441
        /* top and bottom */
 
442
        memcpy(buf - (i + 1) * wrap, buf, width);
 
443
        memcpy(last_line + (i + 1) * wrap, last_line, width);
 
444
    }
 
445
    /* left and right */
 
446
    ptr = buf;
 
447
    for(i=0;i<height;i++) {
 
448
        memset(ptr - w, ptr[0], w);
 
449
        memset(ptr + width, ptr[width-1], w);
 
450
        ptr += wrap;
 
451
    }
 
452
    /* corners */
 
453
    for(i=0;i<w;i++) {
 
454
        memset(buf - (i + 1) * wrap - w, buf[0], w); /* top left */
 
455
        memset(buf - (i + 1) * wrap + width, buf[width-1], w); /* top right */
 
456
        memset(last_line + (i + 1) * wrap - w, last_line[0], w); /* top left */
 
457
        memset(last_line + (i + 1) * wrap + width, last_line[width-1], w); /* top right */
 
458
    }
 
459
}
 
460
 
 
461
/**
 
462
 * Copies a rectangular area of samples to a temporary buffer and replicates the boarder samples.
 
463
 * @param buf destination buffer
 
464
 * @param src source buffer
 
465
 * @param linesize number of bytes between 2 vertically adjacent samples in both the source and destination buffers
 
466
 * @param block_w width of block
 
467
 * @param block_h height of block
 
468
 * @param src_x x coordinate of the top left sample of the block in the source buffer
 
469
 * @param src_y y coordinate of the top left sample of the block in the source buffer
 
470
 * @param w width of the source buffer
 
471
 * @param h height of the source buffer
 
472
 */
 
473
void ff_emulated_edge_mc(uint8_t *buf, uint8_t *src, int linesize, int block_w, int block_h,
 
474
                                    int src_x, int src_y, int w, int h){
 
475
    int x, y;
 
476
    int start_y, start_x, end_y, end_x;
 
477
 
 
478
    if(src_y>= h){
 
479
        src+= (h-1-src_y)*linesize;
 
480
        src_y=h-1;
 
481
    }else if(src_y<=-block_h){
 
482
        src+= (1-block_h-src_y)*linesize;
 
483
        src_y=1-block_h;
 
484
    }
 
485
    if(src_x>= w){
 
486
        src+= (w-1-src_x);
 
487
        src_x=w-1;
 
488
    }else if(src_x<=-block_w){
 
489
        src+= (1-block_w-src_x);
 
490
        src_x=1-block_w;
 
491
    }
 
492
 
 
493
    start_y= FFMAX(0, -src_y);
 
494
    start_x= FFMAX(0, -src_x);
 
495
    end_y= FFMIN(block_h, h-src_y);
 
496
    end_x= FFMIN(block_w, w-src_x);
 
497
 
 
498
    // copy existing part
 
499
    for(y=start_y; y<end_y; y++){
 
500
        for(x=start_x; x<end_x; x++){
 
501
            buf[x + y*linesize]= src[x + y*linesize];
 
502
        }
 
503
    }
 
504
 
 
505
    //top
 
506
    for(y=0; y<start_y; y++){
 
507
        for(x=start_x; x<end_x; x++){
 
508
            buf[x + y*linesize]= buf[x + start_y*linesize];
 
509
        }
 
510
    }
 
511
 
 
512
    //bottom
 
513
    for(y=end_y; y<block_h; y++){
 
514
        for(x=start_x; x<end_x; x++){
 
515
            buf[x + y*linesize]= buf[x + (end_y-1)*linesize];
 
516
        }
 
517
    }
 
518
 
 
519
    for(y=0; y<block_h; y++){
 
520
       //left
 
521
        for(x=0; x<start_x; x++){
 
522
            buf[x + y*linesize]= buf[start_x + y*linesize];
 
523
        }
 
524
 
 
525
       //right
 
526
        for(x=end_x; x<block_w; x++){
 
527
            buf[x + y*linesize]= buf[end_x - 1 + y*linesize];
 
528
        }
 
529
    }
 
530
}
 
531
 
395
532
static void get_pixels_c(DCTELEM *restrict block, const uint8_t *pixels, int line_size)
396
533
{
397
534
    int i;
592
729
    }
593
730
}
594
731
 
 
732
static int sum_abs_dctelem_c(DCTELEM *block)
 
733
{
 
734
    int sum=0, i;
 
735
    for(i=0; i<64; i++)
 
736
        sum+= FFABS(block[i]);
 
737
    return sum;
 
738
}
 
739
 
595
740
#if 0
596
741
 
597
742
#define PIXOP2(OPNAME, OP) \
599
744
{\
600
745
    int i;\
601
746
    for(i=0; i<h; i++){\
602
 
        OP(*((uint64_t*)block), LD64(pixels));\
 
747
        OP(*((uint64_t*)block), AV_RN64(pixels));\
603
748
        pixels+=line_size;\
604
749
        block +=line_size;\
605
750
    }\
609
754
{\
610
755
    int i;\
611
756
    for(i=0; i<h; i++){\
612
 
        const uint64_t a= LD64(pixels  );\
613
 
        const uint64_t b= LD64(pixels+1);\
 
757
        const uint64_t a= AV_RN64(pixels  );\
 
758
        const uint64_t b= AV_RN64(pixels+1);\
614
759
        OP(*((uint64_t*)block), (a&b) + (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
615
760
        pixels+=line_size;\
616
761
        block +=line_size;\
621
766
{\
622
767
    int i;\
623
768
    for(i=0; i<h; i++){\
624
 
        const uint64_t a= LD64(pixels  );\
625
 
        const uint64_t b= LD64(pixels+1);\
 
769
        const uint64_t a= AV_RN64(pixels  );\
 
770
        const uint64_t b= AV_RN64(pixels+1);\
626
771
        OP(*((uint64_t*)block), (a|b) - (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
627
772
        pixels+=line_size;\
628
773
        block +=line_size;\
633
778
{\
634
779
    int i;\
635
780
    for(i=0; i<h; i++){\
636
 
        const uint64_t a= LD64(pixels          );\
637
 
        const uint64_t b= LD64(pixels+line_size);\
 
781
        const uint64_t a= AV_RN64(pixels          );\
 
782
        const uint64_t b= AV_RN64(pixels+line_size);\
638
783
        OP(*((uint64_t*)block), (a&b) + (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
639
784
        pixels+=line_size;\
640
785
        block +=line_size;\
645
790
{\
646
791
    int i;\
647
792
    for(i=0; i<h; i++){\
648
 
        const uint64_t a= LD64(pixels          );\
649
 
        const uint64_t b= LD64(pixels+line_size);\
 
793
        const uint64_t a= AV_RN64(pixels          );\
 
794
        const uint64_t b= AV_RN64(pixels+line_size);\
650
795
        OP(*((uint64_t*)block), (a|b) - (((a^b)&0xFEFEFEFEFEFEFEFEULL)>>1));\
651
796
        pixels+=line_size;\
652
797
        block +=line_size;\
656
801
static void OPNAME ## _pixels_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
657
802
{\
658
803
        int i;\
659
 
        const uint64_t a= LD64(pixels  );\
660
 
        const uint64_t b= LD64(pixels+1);\
 
804
        const uint64_t a= AV_RN64(pixels  );\
 
805
        const uint64_t b= AV_RN64(pixels+1);\
661
806
        uint64_t l0=  (a&0x0303030303030303ULL)\
662
807
                    + (b&0x0303030303030303ULL)\
663
808
                    + 0x0202020202020202ULL;\
667
812
\
668
813
        pixels+=line_size;\
669
814
        for(i=0; i<h; i+=2){\
670
 
            uint64_t a= LD64(pixels  );\
671
 
            uint64_t b= LD64(pixels+1);\
 
815
            uint64_t a= AV_RN64(pixels  );\
 
816
            uint64_t b= AV_RN64(pixels+1);\
672
817
            l1=  (a&0x0303030303030303ULL)\
673
818
               + (b&0x0303030303030303ULL);\
674
819
            h1= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
676
821
            OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\
677
822
            pixels+=line_size;\
678
823
            block +=line_size;\
679
 
            a= LD64(pixels  );\
680
 
            b= LD64(pixels+1);\
 
824
            a= AV_RN64(pixels  );\
 
825
            b= AV_RN64(pixels+1);\
681
826
            l0=  (a&0x0303030303030303ULL)\
682
827
               + (b&0x0303030303030303ULL)\
683
828
               + 0x0202020202020202ULL;\
692
837
static void OPNAME ## _no_rnd_pixels_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
693
838
{\
694
839
        int i;\
695
 
        const uint64_t a= LD64(pixels  );\
696
 
        const uint64_t b= LD64(pixels+1);\
 
840
        const uint64_t a= AV_RN64(pixels  );\
 
841
        const uint64_t b= AV_RN64(pixels+1);\
697
842
        uint64_t l0=  (a&0x0303030303030303ULL)\
698
843
                    + (b&0x0303030303030303ULL)\
699
844
                    + 0x0101010101010101ULL;\
703
848
\
704
849
        pixels+=line_size;\
705
850
        for(i=0; i<h; i+=2){\
706
 
            uint64_t a= LD64(pixels  );\
707
 
            uint64_t b= LD64(pixels+1);\
 
851
            uint64_t a= AV_RN64(pixels  );\
 
852
            uint64_t b= AV_RN64(pixels+1);\
708
853
            l1=  (a&0x0303030303030303ULL)\
709
854
               + (b&0x0303030303030303ULL);\
710
855
            h1= ((a&0xFCFCFCFCFCFCFCFCULL)>>2)\
712
857
            OP(*((uint64_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0F0F0F0F0FULL));\
713
858
            pixels+=line_size;\
714
859
            block +=line_size;\
715
 
            a= LD64(pixels  );\
716
 
            b= LD64(pixels+1);\
 
860
            a= AV_RN64(pixels  );\
 
861
            b= AV_RN64(pixels+1);\
717
862
            l0=  (a&0x0303030303030303ULL)\
718
863
               + (b&0x0303030303030303ULL)\
719
864
               + 0x0101010101010101ULL;\
740
885
static void OPNAME ## _pixels2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
741
886
    int i;\
742
887
    for(i=0; i<h; i++){\
743
 
        OP(*((uint16_t*)(block  )), LD16(pixels  ));\
 
888
        OP(*((uint16_t*)(block  )), AV_RN16(pixels  ));\
744
889
        pixels+=line_size;\
745
890
        block +=line_size;\
746
891
    }\
748
893
static void OPNAME ## _pixels4_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
749
894
    int i;\
750
895
    for(i=0; i<h; i++){\
751
 
        OP(*((uint32_t*)(block  )), LD32(pixels  ));\
 
896
        OP(*((uint32_t*)(block  )), AV_RN32(pixels  ));\
752
897
        pixels+=line_size;\
753
898
        block +=line_size;\
754
899
    }\
756
901
static void OPNAME ## _pixels8_c(uint8_t *block, const uint8_t *pixels, int line_size, int h){\
757
902
    int i;\
758
903
    for(i=0; i<h; i++){\
759
 
        OP(*((uint32_t*)(block  )), LD32(pixels  ));\
760
 
        OP(*((uint32_t*)(block+4)), LD32(pixels+4));\
 
904
        OP(*((uint32_t*)(block  )), AV_RN32(pixels  ));\
 
905
        OP(*((uint32_t*)(block+4)), AV_RN32(pixels+4));\
761
906
        pixels+=line_size;\
762
907
        block +=line_size;\
763
908
    }\
771
916
    int i;\
772
917
    for(i=0; i<h; i++){\
773
918
        uint32_t a,b;\
774
 
        a= LD32(&src1[i*src_stride1  ]);\
775
 
        b= LD32(&src2[i*src_stride2  ]);\
 
919
        a= AV_RN32(&src1[i*src_stride1  ]);\
 
920
        b= AV_RN32(&src2[i*src_stride2  ]);\
776
921
        OP(*((uint32_t*)&dst[i*dst_stride  ]), no_rnd_avg32(a, b));\
777
 
        a= LD32(&src1[i*src_stride1+4]);\
778
 
        b= LD32(&src2[i*src_stride2+4]);\
 
922
        a= AV_RN32(&src1[i*src_stride1+4]);\
 
923
        b= AV_RN32(&src2[i*src_stride2+4]);\
779
924
        OP(*((uint32_t*)&dst[i*dst_stride+4]), no_rnd_avg32(a, b));\
780
925
    }\
781
926
}\
785
930
    int i;\
786
931
    for(i=0; i<h; i++){\
787
932
        uint32_t a,b;\
788
 
        a= LD32(&src1[i*src_stride1  ]);\
789
 
        b= LD32(&src2[i*src_stride2  ]);\
 
933
        a= AV_RN32(&src1[i*src_stride1  ]);\
 
934
        b= AV_RN32(&src2[i*src_stride2  ]);\
790
935
        OP(*((uint32_t*)&dst[i*dst_stride  ]), rnd_avg32(a, b));\
791
 
        a= LD32(&src1[i*src_stride1+4]);\
792
 
        b= LD32(&src2[i*src_stride2+4]);\
 
936
        a= AV_RN32(&src1[i*src_stride1+4]);\
 
937
        b= AV_RN32(&src2[i*src_stride2+4]);\
793
938
        OP(*((uint32_t*)&dst[i*dst_stride+4]), rnd_avg32(a, b));\
794
939
    }\
795
940
}\
799
944
    int i;\
800
945
    for(i=0; i<h; i++){\
801
946
        uint32_t a,b;\
802
 
        a= LD32(&src1[i*src_stride1  ]);\
803
 
        b= LD32(&src2[i*src_stride2  ]);\
 
947
        a= AV_RN32(&src1[i*src_stride1  ]);\
 
948
        b= AV_RN32(&src2[i*src_stride2  ]);\
804
949
        OP(*((uint32_t*)&dst[i*dst_stride  ]), rnd_avg32(a, b));\
805
950
    }\
806
951
}\
810
955
    int i;\
811
956
    for(i=0; i<h; i++){\
812
957
        uint32_t a,b;\
813
 
        a= LD16(&src1[i*src_stride1  ]);\
814
 
        b= LD16(&src2[i*src_stride2  ]);\
 
958
        a= AV_RN16(&src1[i*src_stride1  ]);\
 
959
        b= AV_RN16(&src2[i*src_stride2  ]);\
815
960
        OP(*((uint16_t*)&dst[i*dst_stride  ]), rnd_avg32(a, b));\
816
961
    }\
817
962
}\
849
994
    int i;\
850
995
    for(i=0; i<h; i++){\
851
996
        uint32_t a, b, c, d, l0, l1, h0, h1;\
852
 
        a= LD32(&src1[i*src_stride1]);\
853
 
        b= LD32(&src2[i*src_stride2]);\
854
 
        c= LD32(&src3[i*src_stride3]);\
855
 
        d= LD32(&src4[i*src_stride4]);\
 
997
        a= AV_RN32(&src1[i*src_stride1]);\
 
998
        b= AV_RN32(&src2[i*src_stride2]);\
 
999
        c= AV_RN32(&src3[i*src_stride3]);\
 
1000
        d= AV_RN32(&src4[i*src_stride4]);\
856
1001
        l0=  (a&0x03030303UL)\
857
1002
           + (b&0x03030303UL)\
858
1003
           + 0x02020202UL;\
863
1008
        h1= ((c&0xFCFCFCFCUL)>>2)\
864
1009
          + ((d&0xFCFCFCFCUL)>>2);\
865
1010
        OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
866
 
        a= LD32(&src1[i*src_stride1+4]);\
867
 
        b= LD32(&src2[i*src_stride2+4]);\
868
 
        c= LD32(&src3[i*src_stride3+4]);\
869
 
        d= LD32(&src4[i*src_stride4+4]);\
 
1011
        a= AV_RN32(&src1[i*src_stride1+4]);\
 
1012
        b= AV_RN32(&src2[i*src_stride2+4]);\
 
1013
        c= AV_RN32(&src3[i*src_stride3+4]);\
 
1014
        d= AV_RN32(&src4[i*src_stride4+4]);\
870
1015
        l0=  (a&0x03030303UL)\
871
1016
           + (b&0x03030303UL)\
872
1017
           + 0x02020202UL;\
901
1046
    int i;\
902
1047
    for(i=0; i<h; i++){\
903
1048
        uint32_t a, b, c, d, l0, l1, h0, h1;\
904
 
        a= LD32(&src1[i*src_stride1]);\
905
 
        b= LD32(&src2[i*src_stride2]);\
906
 
        c= LD32(&src3[i*src_stride3]);\
907
 
        d= LD32(&src4[i*src_stride4]);\
 
1049
        a= AV_RN32(&src1[i*src_stride1]);\
 
1050
        b= AV_RN32(&src2[i*src_stride2]);\
 
1051
        c= AV_RN32(&src3[i*src_stride3]);\
 
1052
        d= AV_RN32(&src4[i*src_stride4]);\
908
1053
        l0=  (a&0x03030303UL)\
909
1054
           + (b&0x03030303UL)\
910
1055
           + 0x01010101UL;\
915
1060
        h1= ((c&0xFCFCFCFCUL)>>2)\
916
1061
          + ((d&0xFCFCFCFCUL)>>2);\
917
1062
        OP(*((uint32_t*)&dst[i*dst_stride]), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
918
 
        a= LD32(&src1[i*src_stride1+4]);\
919
 
        b= LD32(&src2[i*src_stride2+4]);\
920
 
        c= LD32(&src3[i*src_stride3+4]);\
921
 
        d= LD32(&src4[i*src_stride4+4]);\
 
1063
        a= AV_RN32(&src1[i*src_stride1+4]);\
 
1064
        b= AV_RN32(&src2[i*src_stride2+4]);\
 
1065
        c= AV_RN32(&src3[i*src_stride3+4]);\
 
1066
        d= AV_RN32(&src4[i*src_stride4+4]);\
922
1067
        l0=  (a&0x03030303UL)\
923
1068
           + (b&0x03030303UL)\
924
1069
           + 0x01010101UL;\
978
1123
static inline void OPNAME ## _pixels4_xy2_c(uint8_t *block, const uint8_t *pixels, int line_size, int h)\
979
1124
{\
980
1125
        int i;\
981
 
        const uint32_t a= LD32(pixels  );\
982
 
        const uint32_t b= LD32(pixels+1);\
 
1126
        const uint32_t a= AV_RN32(pixels  );\
 
1127
        const uint32_t b= AV_RN32(pixels+1);\
983
1128
        uint32_t l0=  (a&0x03030303UL)\
984
1129
                    + (b&0x03030303UL)\
985
1130
                    + 0x02020202UL;\
989
1134
\
990
1135
        pixels+=line_size;\
991
1136
        for(i=0; i<h; i+=2){\
992
 
            uint32_t a= LD32(pixels  );\
993
 
            uint32_t b= LD32(pixels+1);\
 
1137
            uint32_t a= AV_RN32(pixels  );\
 
1138
            uint32_t b= AV_RN32(pixels+1);\
994
1139
            l1=  (a&0x03030303UL)\
995
1140
               + (b&0x03030303UL);\
996
1141
            h1= ((a&0xFCFCFCFCUL)>>2)\
998
1143
            OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
999
1144
            pixels+=line_size;\
1000
1145
            block +=line_size;\
1001
 
            a= LD32(pixels  );\
1002
 
            b= LD32(pixels+1);\
 
1146
            a= AV_RN32(pixels  );\
 
1147
            b= AV_RN32(pixels+1);\
1003
1148
            l0=  (a&0x03030303UL)\
1004
1149
               + (b&0x03030303UL)\
1005
1150
               + 0x02020202UL;\
1016
1161
    int j;\
1017
1162
    for(j=0; j<2; j++){\
1018
1163
        int i;\
1019
 
        const uint32_t a= LD32(pixels  );\
1020
 
        const uint32_t b= LD32(pixels+1);\
 
1164
        const uint32_t a= AV_RN32(pixels  );\
 
1165
        const uint32_t b= AV_RN32(pixels+1);\
1021
1166
        uint32_t l0=  (a&0x03030303UL)\
1022
1167
                    + (b&0x03030303UL)\
1023
1168
                    + 0x02020202UL;\
1027
1172
\
1028
1173
        pixels+=line_size;\
1029
1174
        for(i=0; i<h; i+=2){\
1030
 
            uint32_t a= LD32(pixels  );\
1031
 
            uint32_t b= LD32(pixels+1);\
 
1175
            uint32_t a= AV_RN32(pixels  );\
 
1176
            uint32_t b= AV_RN32(pixels+1);\
1032
1177
            l1=  (a&0x03030303UL)\
1033
1178
               + (b&0x03030303UL);\
1034
1179
            h1= ((a&0xFCFCFCFCUL)>>2)\
1036
1181
            OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
1037
1182
            pixels+=line_size;\
1038
1183
            block +=line_size;\
1039
 
            a= LD32(pixels  );\
1040
 
            b= LD32(pixels+1);\
 
1184
            a= AV_RN32(pixels  );\
 
1185
            b= AV_RN32(pixels+1);\
1041
1186
            l0=  (a&0x03030303UL)\
1042
1187
               + (b&0x03030303UL)\
1043
1188
               + 0x02020202UL;\
1057
1202
    int j;\
1058
1203
    for(j=0; j<2; j++){\
1059
1204
        int i;\
1060
 
        const uint32_t a= LD32(pixels  );\
1061
 
        const uint32_t b= LD32(pixels+1);\
 
1205
        const uint32_t a= AV_RN32(pixels  );\
 
1206
        const uint32_t b= AV_RN32(pixels+1);\
1062
1207
        uint32_t l0=  (a&0x03030303UL)\
1063
1208
                    + (b&0x03030303UL)\
1064
1209
                    + 0x01010101UL;\
1068
1213
\
1069
1214
        pixels+=line_size;\
1070
1215
        for(i=0; i<h; i+=2){\
1071
 
            uint32_t a= LD32(pixels  );\
1072
 
            uint32_t b= LD32(pixels+1);\
 
1216
            uint32_t a= AV_RN32(pixels  );\
 
1217
            uint32_t b= AV_RN32(pixels+1);\
1073
1218
            l1=  (a&0x03030303UL)\
1074
1219
               + (b&0x03030303UL);\
1075
1220
            h1= ((a&0xFCFCFCFCUL)>>2)\
1077
1222
            OP(*((uint32_t*)block), h0+h1+(((l0+l1)>>2)&0x0F0F0F0FUL));\
1078
1223
            pixels+=line_size;\
1079
1224
            block +=line_size;\
1080
 
            a= LD32(pixels  );\
1081
 
            b= LD32(pixels+1);\
 
1225
            a= AV_RN32(pixels  );\
 
1226
            b= AV_RN32(pixels+1);\
1082
1227
            l0=  (a&0x03030303UL)\
1083
1228
               + (b&0x03030303UL)\
1084
1229
               + 0x01010101UL;\
1428
1573
    \
1429
1574
    assert(x<8 && y<8 && x>=0 && y>=0);\
1430
1575
\
1431
 
    for(i=0; i<h; i++)\
1432
 
    {\
1433
 
        OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
1434
 
        OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
1435
 
        dst+= stride;\
1436
 
        src+= stride;\
 
1576
    if(D){\
 
1577
        for(i=0; i<h; i++){\
 
1578
            OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
 
1579
            OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
 
1580
            dst+= stride;\
 
1581
            src+= stride;\
 
1582
        }\
 
1583
    }else{\
 
1584
        const int E= B+C;\
 
1585
        const int step= C ? stride : 1;\
 
1586
        for(i=0; i<h; i++){\
 
1587
            OP(dst[0], (A*src[0] + E*src[step+0]));\
 
1588
            OP(dst[1], (A*src[1] + E*src[step+1]));\
 
1589
            dst+= stride;\
 
1590
            src+= stride;\
 
1591
        }\
1437
1592
    }\
1438
1593
}\
1439
1594
\
1446
1601
    \
1447
1602
    assert(x<8 && y<8 && x>=0 && y>=0);\
1448
1603
\
1449
 
    for(i=0; i<h; i++)\
1450
 
    {\
1451
 
        OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
1452
 
        OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
1453
 
        OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
1454
 
        OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
1455
 
        dst+= stride;\
1456
 
        src+= stride;\
 
1604
    if(D){\
 
1605
        for(i=0; i<h; i++){\
 
1606
            OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
 
1607
            OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
 
1608
            OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
 
1609
            OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
 
1610
            dst+= stride;\
 
1611
            src+= stride;\
 
1612
        }\
 
1613
    }else{\
 
1614
        const int E= B+C;\
 
1615
        const int step= C ? stride : 1;\
 
1616
        for(i=0; i<h; i++){\
 
1617
            OP(dst[0], (A*src[0] + E*src[step+0]));\
 
1618
            OP(dst[1], (A*src[1] + E*src[step+1]));\
 
1619
            OP(dst[2], (A*src[2] + E*src[step+2]));\
 
1620
            OP(dst[3], (A*src[3] + E*src[step+3]));\
 
1621
            dst+= stride;\
 
1622
            src+= stride;\
 
1623
        }\
1457
1624
    }\
1458
1625
}\
1459
1626
\
1466
1633
    \
1467
1634
    assert(x<8 && y<8 && x>=0 && y>=0);\
1468
1635
\
1469
 
    for(i=0; i<h; i++)\
1470
 
    {\
1471
 
        OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
1472
 
        OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
1473
 
        OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
1474
 
        OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
1475
 
        OP(dst[4], (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5]));\
1476
 
        OP(dst[5], (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6]));\
1477
 
        OP(dst[6], (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7]));\
1478
 
        OP(dst[7], (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8]));\
1479
 
        dst+= stride;\
1480
 
        src+= stride;\
 
1636
    if(D){\
 
1637
        for(i=0; i<h; i++){\
 
1638
            OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
 
1639
            OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
 
1640
            OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
 
1641
            OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
 
1642
            OP(dst[4], (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5]));\
 
1643
            OP(dst[5], (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6]));\
 
1644
            OP(dst[6], (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7]));\
 
1645
            OP(dst[7], (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8]));\
 
1646
            dst+= stride;\
 
1647
            src+= stride;\
 
1648
        }\
 
1649
    }else{\
 
1650
        const int E= B+C;\
 
1651
        const int step= C ? stride : 1;\
 
1652
        for(i=0; i<h; i++){\
 
1653
            OP(dst[0], (A*src[0] + E*src[step+0]));\
 
1654
            OP(dst[1], (A*src[1] + E*src[step+1]));\
 
1655
            OP(dst[2], (A*src[2] + E*src[step+2]));\
 
1656
            OP(dst[3], (A*src[3] + E*src[step+3]));\
 
1657
            OP(dst[4], (A*src[4] + E*src[step+4]));\
 
1658
            OP(dst[5], (A*src[5] + E*src[step+5]));\
 
1659
            OP(dst[6], (A*src[6] + E*src[step+6]));\
 
1660
            OP(dst[7], (A*src[7] + E*src[step+7]));\
 
1661
            dst+= stride;\
 
1662
            src+= stride;\
 
1663
        }\
1481
1664
    }\
1482
1665
}
1483
1666
 
2012
2195
 
2013
2196
#if 1
2014
2197
#define H264_LOWPASS(OPNAME, OP, OP2) \
2015
 
static void OPNAME ## h264_qpel2_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
 
2198
static av_unused void OPNAME ## h264_qpel2_h_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
2016
2199
    const int h=2;\
2017
2200
    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
2018
2201
    int i;\
2025
2208
    }\
2026
2209
}\
2027
2210
\
2028
 
static void OPNAME ## h264_qpel2_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
 
2211
static av_unused void OPNAME ## h264_qpel2_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride){\
2029
2212
    const int w=2;\
2030
2213
    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
2031
2214
    int i;\
2045
2228
    }\
2046
2229
}\
2047
2230
\
2048
 
static void OPNAME ## h264_qpel2_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
 
2231
static av_unused void OPNAME ## h264_qpel2_hv_lowpass(uint8_t *dst, int16_t *tmp, uint8_t *src, int dstStride, int tmpStride, int srcStride){\
2049
2232
    const int h=2;\
2050
2233
    const int w=2;\
2051
2234
    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;\
2549
2732
}
2550
2733
#endif /* CONFIG_VC1_DECODER||CONFIG_WMV3_DECODER */
2551
2734
 
2552
 
#if defined(CONFIG_H264_ENCODER)
 
2735
void ff_intrax8dsp_init(DSPContext* c, AVCodecContext *avctx);
 
2736
 
2553
2737
/* H264 specific */
2554
 
void ff_h264dsp_init(DSPContext* c, AVCodecContext *avctx);
2555
 
#endif /* CONFIG_H264_ENCODER */
 
2738
void ff_h264dspenc_init(DSPContext* c, AVCodecContext *avctx);
2556
2739
 
2557
2740
static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int w){
2558
2741
    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
2632
2815
}
2633
2816
 
2634
2817
static void h263_v_loop_filter_c(uint8_t *src, int stride, int qscale){
 
2818
    if(ENABLE_ANY_H263) {
2635
2819
    int x;
2636
2820
    const int strength= ff_h263_loop_filter_strength[qscale];
2637
2821
 
2664
2848
        src[x-2*stride] = p0 - d2;
2665
2849
        src[x+  stride] = p3 + d2;
2666
2850
    }
 
2851
    }
2667
2852
}
2668
2853
 
2669
2854
static void h263_h_loop_filter_c(uint8_t *src, int stride, int qscale){
 
2855
    if(ENABLE_ANY_H263) {
2670
2856
    int y;
2671
2857
    const int strength= ff_h263_loop_filter_strength[qscale];
2672
2858
 
2699
2885
        src[y*stride-2] = p0 - d2;
2700
2886
        src[y*stride+1] = p3 + d2;
2701
2887
    }
 
2888
    }
2702
2889
}
2703
2890
 
2704
2891
static void h261_loop_filter_c(uint8_t *src, int stride){
3131
3318
    DCTELEM temp[64];
3132
3319
 
3133
3320
    if(last<=0) return;
3134
 
    //if(permutation[1]==1) return; //FIXME its ok but not clean and might fail for some perms
 
3321
    //if(permutation[1]==1) return; //FIXME it is ok but not clean and might fail for some permutations
3135
3322
 
3136
3323
    for(i=0; i<=last; i++){
3137
3324
        const int j= scantable[i];
3219
3406
}
3220
3407
 
3221
3408
static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){
3222
 
    int i;
3223
 
    for(i=0; i+7<w; i+=8){
3224
 
        dst[i+0] += src[i+0];
3225
 
        dst[i+1] += src[i+1];
3226
 
        dst[i+2] += src[i+2];
3227
 
        dst[i+3] += src[i+3];
3228
 
        dst[i+4] += src[i+4];
3229
 
        dst[i+5] += src[i+5];
3230
 
        dst[i+6] += src[i+6];
3231
 
        dst[i+7] += src[i+7];
3232
 
    }
3233
 
    for(; i<w; i++)
3234
 
        dst[i+0] += src[i+0];
 
3409
    long i;
 
3410
    for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
 
3411
        long a = *(long*)(src+i);
 
3412
        long b = *(long*)(dst+i);
 
3413
        *(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80);
 
3414
    }
 
3415
    for(; i<w; i++)
 
3416
        dst[i+0] += src[i+0];
 
3417
}
 
3418
 
 
3419
static void add_bytes_l2_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
 
3420
    long i;
 
3421
    for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
 
3422
        long a = *(long*)(src1+i);
 
3423
        long b = *(long*)(src2+i);
 
3424
        *(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80);
 
3425
    }
 
3426
    for(; i<w; i++)
 
3427
        dst[i] = src1[i]+src2[i];
3235
3428
}
3236
3429
 
3237
3430
static void diff_bytes_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
3238
 
    int i;
3239
 
    for(i=0; i+7<w; i+=8){
3240
 
        dst[i+0] = src1[i+0]-src2[i+0];
3241
 
        dst[i+1] = src1[i+1]-src2[i+1];
3242
 
        dst[i+2] = src1[i+2]-src2[i+2];
3243
 
        dst[i+3] = src1[i+3]-src2[i+3];
3244
 
        dst[i+4] = src1[i+4]-src2[i+4];
3245
 
        dst[i+5] = src1[i+5]-src2[i+5];
3246
 
        dst[i+6] = src1[i+6]-src2[i+6];
3247
 
        dst[i+7] = src1[i+7]-src2[i+7];
 
3431
    long i;
 
3432
#ifndef HAVE_FAST_UNALIGNED
 
3433
    if((long)src2 & (sizeof(long)-1)){
 
3434
        for(i=0; i+7<w; i+=8){
 
3435
            dst[i+0] = src1[i+0]-src2[i+0];
 
3436
            dst[i+1] = src1[i+1]-src2[i+1];
 
3437
            dst[i+2] = src1[i+2]-src2[i+2];
 
3438
            dst[i+3] = src1[i+3]-src2[i+3];
 
3439
            dst[i+4] = src1[i+4]-src2[i+4];
 
3440
            dst[i+5] = src1[i+5]-src2[i+5];
 
3441
            dst[i+6] = src1[i+6]-src2[i+6];
 
3442
            dst[i+7] = src1[i+7]-src2[i+7];
 
3443
        }
 
3444
    }else
 
3445
#endif
 
3446
    for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
 
3447
        long a = *(long*)(src1+i);
 
3448
        long b = *(long*)(src2+i);
 
3449
        *(long*)(dst+i) = ((a|pb_80) - (b&pb_7f)) ^ ((a^b^pb_80)&pb_80);
3248
3450
    }
3249
3451
    for(; i<w; i++)
3250
3452
        dst[i+0] = src1[i+0]-src2[i+0];
3385
3587
 
3386
3588
static int dct_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
3387
3589
    MpegEncContext * const s= (MpegEncContext *)c;
3388
 
    DECLARE_ALIGNED_8(uint64_t, aligned_temp[sizeof(DCTELEM)*64/8]);
 
3590
    DECLARE_ALIGNED_16(uint64_t, aligned_temp[sizeof(DCTELEM)*64/8]);
3389
3591
    DCTELEM * const temp= (DCTELEM*)aligned_temp;
3390
 
    int sum=0, i;
3391
3592
 
3392
3593
    assert(h==8);
3393
3594
 
3394
3595
    s->dsp.diff_pixels(temp, src1, src2, stride);
3395
3596
    s->dsp.fdct(temp);
3396
 
 
3397
 
    for(i=0; i<64; i++)
3398
 
        sum+= FFABS(temp[i]);
3399
 
 
3400
 
    return sum;
 
3597
    return s->dsp.sum_abs_dctelem(temp);
3401
3598
}
3402
3599
 
3403
3600
#ifdef CONFIG_GPL
3430
3627
 
3431
3628
static int dct264_sad8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
3432
3629
    MpegEncContext * const s= (MpegEncContext *)c;
3433
 
    int16_t dct[8][8];
 
3630
    DCTELEM dct[8][8];
3434
3631
    int i;
3435
3632
    int sum=0;
3436
3633
 
3437
 
    s->dsp.diff_pixels(dct, src1, src2, stride);
 
3634
    s->dsp.diff_pixels(dct[0], src1, src2, stride);
3438
3635
 
3439
3636
#define SRC(x) dct[i][x]
3440
3637
#define DST(x,v) dct[i][x]= v
3486
3683
 
3487
3684
    s->block_last_index[0/*FIXME*/]= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i);
3488
3685
    s->dct_unquantize_inter(s, temp, 0, s->qscale);
3489
 
    simple_idct(temp); //FIXME
 
3686
    ff_simple_idct(temp); //FIXME
3490
3687
 
3491
3688
    for(i=0; i<64; i++)
3492
3689
        sum+= (temp[i]-bak[i])*(temp[i]-bak[i]);
3501
3698
    DECLARE_ALIGNED_8 (uint64_t, aligned_bak[stride]);
3502
3699
    DCTELEM * const temp= (DCTELEM*)aligned_temp;
3503
3700
    uint8_t * const bak= (uint8_t*)aligned_bak;
3504
 
    int i, last, run, bits, level, distoration, start_i;
 
3701
    int i, last, run, bits, level, distortion, start_i;
3505
3702
    const int esc_length= s->ac_esc_length;
3506
3703
    uint8_t * length;
3507
3704
    uint8_t * last_length;
3568
3765
 
3569
3766
    s->dsp.idct_add(bak, stride, temp);
3570
3767
 
3571
 
    distoration= s->dsp.sse[1](NULL, bak, src1, stride, 8);
 
3768
    distortion= s->dsp.sse[1](NULL, bak, src1, stride, 8);
3572
3769
 
3573
 
    return distoration + ((bits*s->qscale*s->qscale*109 + 64)>>7);
 
3770
    return distortion + ((bits*s->qscale*s->qscale*109 + 64)>>7);
3574
3771
}
3575
3772
 
3576
3773
static int bit8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
3694
3891
    return score;
3695
3892
}
3696
3893
 
3697
 
WARPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c)
3698
 
WARPER8_16_SQ(hadamard8_intra8x8_c, hadamard8_intra16_c)
3699
 
WARPER8_16_SQ(dct_sad8x8_c, dct_sad16_c)
 
3894
static int ssd_int8_vs_int16_c(const int8_t *pix1, const int16_t *pix2,
 
3895
                               int size){
 
3896
    int score=0;
 
3897
    int i;
 
3898
    for(i=0; i<size; i++)
 
3899
        score += (pix1[i]-pix2[i])*(pix1[i]-pix2[i]);
 
3900
    return score;
 
3901
}
 
3902
 
 
3903
WRAPPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c)
 
3904
WRAPPER8_16_SQ(hadamard8_intra8x8_c, hadamard8_intra16_c)
 
3905
WRAPPER8_16_SQ(dct_sad8x8_c, dct_sad16_c)
3700
3906
#ifdef CONFIG_GPL
3701
 
WARPER8_16_SQ(dct264_sad8x8_c, dct264_sad16_c)
 
3907
WRAPPER8_16_SQ(dct264_sad8x8_c, dct264_sad16_c)
3702
3908
#endif
3703
 
WARPER8_16_SQ(dct_max8x8_c, dct_max16_c)
3704
 
WARPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c)
3705
 
WARPER8_16_SQ(rd8x8_c, rd16_c)
3706
 
WARPER8_16_SQ(bit8x8_c, bit16_c)
 
3909
WRAPPER8_16_SQ(dct_max8x8_c, dct_max16_c)
 
3910
WRAPPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c)
 
3911
WRAPPER8_16_SQ(rd8x8_c, rd16_c)
 
3912
WRAPPER8_16_SQ(bit8x8_c, bit16_c)
3707
3913
 
3708
3914
static void vector_fmul_c(float *dst, const float *src, int len){
3709
3915
    int i;
3727
3933
void ff_float_to_int16_c(int16_t *dst, const float *src, int len){
3728
3934
    int i;
3729
3935
    for(i=0; i<len; i++) {
3730
 
        int_fast32_t tmp = ((int32_t*)src)[i];
 
3936
        int_fast32_t tmp = ((const int32_t*)src)[i];
3731
3937
        if(tmp & 0xf0000){
3732
3938
            tmp = (0x43c0ffff - tmp)>>31;
3733
3939
            // is this faster on some gcc/cpu combinations?
3738
3944
    }
3739
3945
}
3740
3946
 
 
3947
#define W0 2048
 
3948
#define W1 2841 /* 2048*sqrt (2)*cos (1*pi/16) */
 
3949
#define W2 2676 /* 2048*sqrt (2)*cos (2*pi/16) */
 
3950
#define W3 2408 /* 2048*sqrt (2)*cos (3*pi/16) */
 
3951
#define W4 2048 /* 2048*sqrt (2)*cos (4*pi/16) */
 
3952
#define W5 1609 /* 2048*sqrt (2)*cos (5*pi/16) */
 
3953
#define W6 1108 /* 2048*sqrt (2)*cos (6*pi/16) */
 
3954
#define W7 565  /* 2048*sqrt (2)*cos (7*pi/16) */
 
3955
 
 
3956
static void wmv2_idct_row(short * b)
 
3957
{
 
3958
    int s1,s2;
 
3959
    int a0,a1,a2,a3,a4,a5,a6,a7;
 
3960
    /*step 1*/
 
3961
    a1 = W1*b[1]+W7*b[7];
 
3962
    a7 = W7*b[1]-W1*b[7];
 
3963
    a5 = W5*b[5]+W3*b[3];
 
3964
    a3 = W3*b[5]-W5*b[3];
 
3965
    a2 = W2*b[2]+W6*b[6];
 
3966
    a6 = W6*b[2]-W2*b[6];
 
3967
    a0 = W0*b[0]+W0*b[4];
 
3968
    a4 = W0*b[0]-W0*b[4];
 
3969
    /*step 2*/
 
3970
    s1 = (181*(a1-a5+a7-a3)+128)>>8;//1,3,5,7,
 
3971
    s2 = (181*(a1-a5-a7+a3)+128)>>8;
 
3972
    /*step 3*/
 
3973
    b[0] = (a0+a2+a1+a5 + (1<<7))>>8;
 
3974
    b[1] = (a4+a6 +s1   + (1<<7))>>8;
 
3975
    b[2] = (a4-a6 +s2   + (1<<7))>>8;
 
3976
    b[3] = (a0-a2+a7+a3 + (1<<7))>>8;
 
3977
    b[4] = (a0-a2-a7-a3 + (1<<7))>>8;
 
3978
    b[5] = (a4-a6 -s2   + (1<<7))>>8;
 
3979
    b[6] = (a4+a6 -s1   + (1<<7))>>8;
 
3980
    b[7] = (a0+a2-a1-a5 + (1<<7))>>8;
 
3981
}
 
3982
static void wmv2_idct_col(short * b)
 
3983
{
 
3984
    int s1,s2;
 
3985
    int a0,a1,a2,a3,a4,a5,a6,a7;
 
3986
    /*step 1, with extended precision*/
 
3987
    a1 = (W1*b[8*1]+W7*b[8*7] + 4)>>3;
 
3988
    a7 = (W7*b[8*1]-W1*b[8*7] + 4)>>3;
 
3989
    a5 = (W5*b[8*5]+W3*b[8*3] + 4)>>3;
 
3990
    a3 = (W3*b[8*5]-W5*b[8*3] + 4)>>3;
 
3991
    a2 = (W2*b[8*2]+W6*b[8*6] + 4)>>3;
 
3992
    a6 = (W6*b[8*2]-W2*b[8*6] + 4)>>3;
 
3993
    a0 = (W0*b[8*0]+W0*b[8*4]    )>>3;
 
3994
    a4 = (W0*b[8*0]-W0*b[8*4]    )>>3;
 
3995
    /*step 2*/
 
3996
    s1 = (181*(a1-a5+a7-a3)+128)>>8;
 
3997
    s2 = (181*(a1-a5-a7+a3)+128)>>8;
 
3998
    /*step 3*/
 
3999
    b[8*0] = (a0+a2+a1+a5 + (1<<13))>>14;
 
4000
    b[8*1] = (a4+a6 +s1   + (1<<13))>>14;
 
4001
    b[8*2] = (a4-a6 +s2   + (1<<13))>>14;
 
4002
    b[8*3] = (a0-a2+a7+a3 + (1<<13))>>14;
 
4003
 
 
4004
    b[8*4] = (a0-a2-a7-a3 + (1<<13))>>14;
 
4005
    b[8*5] = (a4-a6 -s2   + (1<<13))>>14;
 
4006
    b[8*6] = (a4+a6 -s1   + (1<<13))>>14;
 
4007
    b[8*7] = (a0+a2-a1-a5 + (1<<13))>>14;
 
4008
}
 
4009
void ff_wmv2_idct_c(short * block){
 
4010
    int i;
 
4011
 
 
4012
    for(i=0;i<64;i+=8){
 
4013
        wmv2_idct_row(block+i);
 
4014
    }
 
4015
    for(i=0;i<8;i++){
 
4016
        wmv2_idct_col(block+i);
 
4017
    }
 
4018
}
3741
4019
/* XXX: those functions should be suppressed ASAP when all IDCTs are
3742
4020
 converted */
 
4021
static void ff_wmv2_idct_put_c(uint8_t *dest, int line_size, DCTELEM *block)
 
4022
{
 
4023
    ff_wmv2_idct_c(block);
 
4024
    put_pixels_clamped_c(block, dest, line_size);
 
4025
}
 
4026
static void ff_wmv2_idct_add_c(uint8_t *dest, int line_size, DCTELEM *block)
 
4027
{
 
4028
    ff_wmv2_idct_c(block);
 
4029
    add_pixels_clamped_c(block, dest, line_size);
 
4030
}
3743
4031
static void ff_jref_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
3744
4032
{
3745
4033
    j_rev_dct (block);
3786
4074
    dest[0] = cm[dest[0] + ((block[0] + 4)>>3)];
3787
4075
}
3788
4076
 
3789
 
static void just_return() { return; }
 
4077
static void just_return(void *mem av_unused, int stride av_unused, int h av_unused) { return; }
3790
4078
 
3791
4079
/* init static data */
3792
4080
void dsputil_static_init(void)
3810
4098
    static int did_fail=0;
3811
4099
    DECLARE_ALIGNED_16(int, aligned);
3812
4100
 
3813
 
    if((int)&aligned & 15){
 
4101
    if((long)&aligned & 15){
3814
4102
        if(!did_fail){
3815
4103
#if defined(HAVE_MMX) || defined(HAVE_ALTIVEC)
3816
4104
            av_log(NULL, AV_LOG_ERROR,
3817
4105
                "Compiler did not align stack variables. Libavcodec has been miscompiled\n"
3818
4106
                "and may be very slow or crash. This is not a bug in libavcodec,\n"
3819
 
                "but in the compiler. Do not report crashes to FFmpeg developers.\n");
 
4107
                "but in the compiler. You may try recompiling using gcc >= 4.2.\n"
 
4108
                "Do not report crashes to FFmpeg developers.\n");
3820
4109
#endif
3821
4110
            did_fail=1;
3822
4111
        }
3847
4136
#endif //CONFIG_ENCODERS
3848
4137
 
3849
4138
    if(avctx->lowres==1){
3850
 
        if(avctx->idct_algo==FF_IDCT_INT || avctx->idct_algo==FF_IDCT_AUTO){
 
4139
        if(avctx->idct_algo==FF_IDCT_INT || avctx->idct_algo==FF_IDCT_AUTO || !ENABLE_H264_DECODER){
3851
4140
            c->idct_put= ff_jref_idct4_put;
3852
4141
            c->idct_add= ff_jref_idct4_add;
3853
4142
        }else{
3872
4161
            c->idct_add= ff_jref_idct_add;
3873
4162
            c->idct    = j_rev_dct;
3874
4163
            c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
3875
 
        }else if(avctx->idct_algo==FF_IDCT_VP3){
 
4164
        }else if((ENABLE_VP3_DECODER || ENABLE_VP5_DECODER || ENABLE_VP6_DECODER || ENABLE_THEORA_DECODER ) &&
 
4165
                avctx->idct_algo==FF_IDCT_VP3){
3876
4166
            c->idct_put= ff_vp3_idct_put_c;
3877
4167
            c->idct_add= ff_vp3_idct_add_c;
3878
4168
            c->idct    = ff_vp3_idct_c;
3879
4169
            c->idct_permutation_type= FF_NO_IDCT_PERM;
 
4170
        }else if(avctx->idct_algo==FF_IDCT_WMV2){
 
4171
            c->idct_put= ff_wmv2_idct_put_c;
 
4172
            c->idct_add= ff_wmv2_idct_add_c;
 
4173
            c->idct    = ff_wmv2_idct_c;
 
4174
            c->idct_permutation_type= FF_NO_IDCT_PERM;
 
4175
        }else if(avctx->idct_algo==FF_IDCT_FAAN){
 
4176
            c->idct_put= ff_faanidct_put;
 
4177
            c->idct_add= ff_faanidct_add;
 
4178
            c->idct    = ff_faanidct;
 
4179
            c->idct_permutation_type= FF_NO_IDCT_PERM;
3880
4180
        }else{ //accurate/default
3881
 
            c->idct_put= simple_idct_put;
3882
 
            c->idct_add= simple_idct_add;
3883
 
            c->idct    = simple_idct;
 
4181
            c->idct_put= ff_simple_idct_put;
 
4182
            c->idct_add= ff_simple_idct_add;
 
4183
            c->idct    = ff_simple_idct;
3884
4184
            c->idct_permutation_type= FF_NO_IDCT_PERM;
3885
4185
        }
3886
4186
    }
3887
4187
 
3888
 
    c->h264_idct_add= ff_h264_idct_add_c;
3889
 
    c->h264_idct8_add= ff_h264_idct8_add_c;
3890
 
    c->h264_idct_dc_add= ff_h264_idct_dc_add_c;
3891
 
    c->h264_idct8_dc_add= ff_h264_idct8_dc_add_c;
 
4188
    if (ENABLE_H264_DECODER) {
 
4189
        c->h264_idct_add= ff_h264_idct_add_c;
 
4190
        c->h264_idct8_add= ff_h264_idct8_add_c;
 
4191
        c->h264_idct_dc_add= ff_h264_idct_dc_add_c;
 
4192
        c->h264_idct8_dc_add= ff_h264_idct8_dc_add_c;
 
4193
    }
3892
4194
 
3893
4195
    c->get_pixels = get_pixels_c;
3894
4196
    c->diff_pixels = diff_pixels_c;
3897
4199
    c->add_pixels_clamped = add_pixels_clamped_c;
3898
4200
    c->add_pixels8 = add_pixels8_c;
3899
4201
    c->add_pixels4 = add_pixels4_c;
 
4202
    c->sum_abs_dctelem = sum_abs_dctelem_c;
3900
4203
    c->gmc1 = gmc1_c;
3901
4204
    c->gmc = ff_gmc_c;
3902
4205
    c->clear_blocks = clear_blocks_c;
4025
4328
    c->biweight_h264_pixels_tab[8]= biweight_h264_pixels2x4_c;
4026
4329
    c->biweight_h264_pixels_tab[9]= biweight_h264_pixels2x2_c;
4027
4330
 
 
4331
    c->draw_edges = draw_edges_c;
 
4332
 
4028
4333
#ifdef CONFIG_CAVS_DECODER
4029
4334
    ff_cavsdsp_init(c,avctx);
4030
4335
#endif
4031
4336
#if defined(CONFIG_VC1_DECODER) || defined(CONFIG_WMV3_DECODER)
4032
4337
    ff_vc1dsp_init(c,avctx);
4033
4338
#endif
 
4339
#if defined(CONFIG_WMV2_DECODER) || defined(CONFIG_VC1_DECODER) || defined(CONFIG_WMV3_DECODER)
 
4340
    ff_intrax8dsp_init(c,avctx);
 
4341
#endif
4034
4342
#if defined(CONFIG_H264_ENCODER)
4035
 
    ff_h264dsp_init(c,avctx);
 
4343
    ff_h264dspenc_init(c,avctx);
4036
4344
#endif
4037
4345
 
4038
4346
    c->put_mspel_pixels_tab[0]= put_mspel8_mc00_c;
4076
4384
    c->w97[1]= w97_8_c;
4077
4385
#endif
4078
4386
 
 
4387
    c->ssd_int8_vs_int16 = ssd_int8_vs_int16_c;
 
4388
 
4079
4389
    c->add_bytes= add_bytes_c;
 
4390
    c->add_bytes_l2= add_bytes_l2_c;
4080
4391
    c->diff_bytes= diff_bytes_c;
4081
4392
    c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c;
4082
4393
    c->bswap_buf= bswap_buf;
 
4394
#ifdef CONFIG_PNG_DECODER
 
4395
    c->add_png_paeth_prediction= ff_add_png_paeth_prediction;
 
4396
#endif
4083
4397
 
4084
4398
    c->h264_v_loop_filter_luma= h264_v_loop_filter_luma_c;
4085
4399
    c->h264_h_loop_filter_luma= h264_h_loop_filter_luma_c;
4089
4403
    c->h264_h_loop_filter_chroma_intra= h264_h_loop_filter_chroma_intra_c;
4090
4404
    c->h264_loop_filter_strength= NULL;
4091
4405
 
4092
 
    c->h263_h_loop_filter= h263_h_loop_filter_c;
4093
 
    c->h263_v_loop_filter= h263_v_loop_filter_c;
 
4406
    if (ENABLE_ANY_H263) {
 
4407
        c->h263_h_loop_filter= h263_h_loop_filter_c;
 
4408
        c->h263_v_loop_filter= h263_v_loop_filter_c;
 
4409
    }
4094
4410
 
4095
4411
    c->h261_loop_filter= h261_loop_filter_c;
4096
4412
 
4106
4422
#ifdef CONFIG_VORBIS_DECODER
4107
4423
    c->vorbis_inverse_coupling = vorbis_inverse_coupling;
4108
4424
#endif
 
4425
#ifdef CONFIG_FLAC_ENCODER
 
4426
    c->flac_compute_autocorr = ff_flac_compute_autocorr;
 
4427
#endif
4109
4428
    c->vector_fmul = vector_fmul_c;
4110
4429
    c->vector_fmul_reverse = vector_fmul_reverse_c;
4111
4430
    c->vector_fmul_add_add = ff_vector_fmul_add_add_c;
4121
4440
    memset(c->put_2tap_qpel_pixels_tab, 0, sizeof(c->put_2tap_qpel_pixels_tab));
4122
4441
    memset(c->avg_2tap_qpel_pixels_tab, 0, sizeof(c->avg_2tap_qpel_pixels_tab));
4123
4442
 
4124
 
#ifdef HAVE_MMX
4125
 
    dsputil_init_mmx(c, avctx);
4126
 
#endif
4127
 
#ifdef ARCH_ARMV4L
4128
 
    dsputil_init_armv4l(c, avctx);
4129
 
#endif
4130
 
#ifdef HAVE_MLIB
4131
 
    dsputil_init_mlib(c, avctx);
4132
 
#endif
4133
 
#ifdef ARCH_SPARC
4134
 
   dsputil_init_vis(c,avctx);
4135
 
#endif
4136
 
#ifdef ARCH_ALPHA
4137
 
    dsputil_init_alpha(c, avctx);
4138
 
#endif
4139
 
#ifdef ARCH_POWERPC
4140
 
    dsputil_init_ppc(c, avctx);
4141
 
#endif
4142
 
#ifdef HAVE_MMI
4143
 
    dsputil_init_mmi(c, avctx);
4144
 
#endif
4145
 
#ifdef ARCH_SH4
4146
 
    dsputil_init_sh4(c,avctx);
4147
 
#endif
4148
 
#ifdef ARCH_BFIN
4149
 
    dsputil_init_bfin(c,avctx);
4150
 
#endif
 
4443
    if (ENABLE_MMX)      dsputil_init_mmx   (c, avctx);
 
4444
    if (ENABLE_ARMV4L)   dsputil_init_armv4l(c, avctx);
 
4445
    if (ENABLE_MLIB)     dsputil_init_mlib  (c, avctx);
 
4446
    if (ENABLE_VIS)      dsputil_init_vis   (c, avctx);
 
4447
    if (ENABLE_ALPHA)    dsputil_init_alpha (c, avctx);
 
4448
    if (ENABLE_POWERPC)  dsputil_init_ppc   (c, avctx);
 
4449
    if (ENABLE_MMI)      dsputil_init_mmi   (c, avctx);
 
4450
    if (ENABLE_SH4)      dsputil_init_sh4   (c, avctx);
 
4451
    if (ENABLE_BFIN)     dsputil_init_bfin  (c, avctx);
4151
4452
 
4152
4453
    for(i=0; i<64; i++){
4153
4454
        if(!c->put_2tap_qpel_pixels_tab[0][i])
4177
4478
        for(i=0; i<64; i++)
4178
4479
            c->idct_permutation[i]= (i&0x24) | ((i&3)<<3) | ((i>>3)&3);
4179
4480
        break;
 
4481
    case FF_SSE2_IDCT_PERM:
 
4482
        for(i=0; i<64; i++)
 
4483
            c->idct_permutation[i]= (i&0x38) | idct_sse2_row_perm[i&7];
 
4484
        break;
4180
4485
    default:
4181
4486
        av_log(avctx, AV_LOG_ERROR, "Internal error, IDCT permutation not set\n");
4182
4487
    }