~ubuntu-branches/debian/sid/mplayer/sid

« back to all changes in this revision

Viewing changes to libavcodec/dsputil.c

  • Committer: Bazaar Package Importer
  • Author(s): A Mennucc1
  • Date: 2009-03-23 10:05:45 UTC
  • mfrom: (4.1.4 sid)
  • Revision ID: james.westby@ubuntu.com-20090323100545-x8h79obawnnte7kk
Tags: 1.0~rc2+svn20090303-5
debian/control : move docbook-xml,docbook-xsl,xsltproc from 
Build-Depends-Indep to Build-Depends, since they are needed to run
configure

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
2
 * DSP utils
3
 
 * Copyright (c) 2000, 2001 Fabrice Bellard.
 
3
 * Copyright (c) 2000, 2001 Fabrice Bellard
4
4
 * Copyright (c) 2002-2004 Michael Niedermayer <michaelni@gmx.at>
5
5
 *
6
6
 * gmc & q-pel & 32/64 bit based MC by Michael Niedermayer <michaelni@gmx.at>
23
23
 */
24
24
 
25
25
/**
26
 
 * @file dsputil.c
 
26
 * @file libavcodec/dsputil.c
27
27
 * DSP utils
28
28
 */
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 "mathops.h"
35
36
#include "h263.h"
36
37
#include "snow.h"
37
38
 
41
42
/* vorbis.c */
42
43
void vorbis_inverse_coupling(float *mag, float *ang, int blocksize);
43
44
 
 
45
/* ac3dec.c */
 
46
void ff_ac3_downmix_c(float (*samples)[256], float (*matrix)[2], int out_ch, int in_ch, int len);
 
47
 
44
48
/* flacenc.c */
45
49
void ff_flac_compute_autocorr(const int32_t *data, int len, int lag, double *autoc);
46
50
 
 
51
/* pngdec.c */
 
52
void ff_add_png_paeth_prediction(uint8_t *dst, uint8_t *src, uint8_t *top, int w, int bpp);
 
53
 
 
54
/* eaidct.c */
 
55
void ff_ea_idct_put_c(uint8_t *dest, int linesize, DCTELEM *block);
 
56
 
47
57
uint8_t ff_cropTbl[256 + 2 * MAX_NEG_CROP] = {0, };
48
58
uint32_t ff_squareTbl[512] = {0, };
49
59
 
 
60
// 0x7f7f7f7f or 0x7f7f7f7f7f7f7f7f or whatever, depending on the cpu's native arithmetic size
 
61
#define pb_7f (~0UL/255 * 0x7f)
 
62
#define pb_80 (~0UL/255 * 0x80)
 
63
 
50
64
const uint8_t ff_zigzag_direct[64] = {
51
65
    0,   1,  8, 16,  9,  2,  3, 10,
52
66
    17, 24, 32, 25, 18, 11,  4,  5,
144
158
        0x32, 0x3A, 0x36, 0x3B, 0x33, 0x3E, 0x37, 0x3F,
145
159
};
146
160
 
 
161
static const uint8_t idct_sse2_row_perm[8] = {0, 4, 1, 5, 2, 6, 3, 7};
 
162
 
 
163
void ff_init_scantable(uint8_t *permutation, ScanTable *st, const uint8_t *src_scantable){
 
164
    int i;
 
165
    int end;
 
166
 
 
167
    st->scantable= src_scantable;
 
168
 
 
169
    for(i=0; i<64; i++){
 
170
        int j;
 
171
        j = src_scantable[i];
 
172
        st->permutated[i] = permutation[j];
 
173
#if ARCH_PPC
 
174
        st->inverse[j] = i;
 
175
#endif
 
176
    }
 
177
 
 
178
    end=-1;
 
179
    for(i=0; i<64; i++){
 
180
        int j;
 
181
        j = st->permutated[i];
 
182
        if(j>end) end=j;
 
183
        st->raster_end[i]= end;
 
184
    }
 
185
}
 
186
 
147
187
static int pix_sum_c(uint8_t * pix, int line_size)
148
188
{
149
189
    int s, i, j;
214
254
    return s;
215
255
}
216
256
 
217
 
static void bswap_buf(uint32_t *dst, uint32_t *src, int w){
 
257
static void bswap_buf(uint32_t *dst, const uint32_t *src, int w){
218
258
    int i;
219
259
 
220
260
    for(i=0; i+8<=w; i+=8){
301
341
}
302
342
 
303
343
 
304
 
#ifdef CONFIG_SNOW_ENCODER //dwt is in snow.c
 
344
#if CONFIG_SNOW_ENCODER //dwt is in snow.c
305
345
static inline int w_c(void *v, uint8_t * pix1, uint8_t * pix2, int line_size, int w, int h, int type){
306
346
    int s, i, j;
307
347
    const int dec_count= w==8 ? 3 : 4;
396
436
}
397
437
#endif
398
438
 
 
439
/* draw the edges of width 'w' of an image of size width, height */
 
440
//FIXME check that this is ok for mpeg4 interlaced
 
441
static void draw_edges_c(uint8_t *buf, int wrap, int width, int height, int w)
 
442
{
 
443
    uint8_t *ptr, *last_line;
 
444
    int i;
 
445
 
 
446
    last_line = buf + (height - 1) * wrap;
 
447
    for(i=0;i<w;i++) {
 
448
        /* top and bottom */
 
449
        memcpy(buf - (i + 1) * wrap, buf, width);
 
450
        memcpy(last_line + (i + 1) * wrap, last_line, width);
 
451
    }
 
452
    /* left and right */
 
453
    ptr = buf;
 
454
    for(i=0;i<height;i++) {
 
455
        memset(ptr - w, ptr[0], w);
 
456
        memset(ptr + width, ptr[width-1], w);
 
457
        ptr += wrap;
 
458
    }
 
459
    /* corners */
 
460
    for(i=0;i<w;i++) {
 
461
        memset(buf - (i + 1) * wrap - w, buf[0], w); /* top left */
 
462
        memset(buf - (i + 1) * wrap + width, buf[width-1], w); /* top right */
 
463
        memset(last_line + (i + 1) * wrap - w, last_line[0], w); /* top left */
 
464
        memset(last_line + (i + 1) * wrap + width, last_line[width-1], w); /* top right */
 
465
    }
 
466
}
 
467
 
 
468
/**
 
469
 * Copies a rectangular area of samples to a temporary buffer and replicates the boarder samples.
 
470
 * @param buf destination buffer
 
471
 * @param src source buffer
 
472
 * @param linesize number of bytes between 2 vertically adjacent samples in both the source and destination buffers
 
473
 * @param block_w width of block
 
474
 * @param block_h height of block
 
475
 * @param src_x x coordinate of the top left sample of the block in the source buffer
 
476
 * @param src_y y coordinate of the top left sample of the block in the source buffer
 
477
 * @param w width of the source buffer
 
478
 * @param h height of the source buffer
 
479
 */
 
480
void ff_emulated_edge_mc(uint8_t *buf, uint8_t *src, int linesize, int block_w, int block_h,
 
481
                                    int src_x, int src_y, int w, int h){
 
482
    int x, y;
 
483
    int start_y, start_x, end_y, end_x;
 
484
 
 
485
    if(src_y>= h){
 
486
        src+= (h-1-src_y)*linesize;
 
487
        src_y=h-1;
 
488
    }else if(src_y<=-block_h){
 
489
        src+= (1-block_h-src_y)*linesize;
 
490
        src_y=1-block_h;
 
491
    }
 
492
    if(src_x>= w){
 
493
        src+= (w-1-src_x);
 
494
        src_x=w-1;
 
495
    }else if(src_x<=-block_w){
 
496
        src+= (1-block_w-src_x);
 
497
        src_x=1-block_w;
 
498
    }
 
499
 
 
500
    start_y= FFMAX(0, -src_y);
 
501
    start_x= FFMAX(0, -src_x);
 
502
    end_y= FFMIN(block_h, h-src_y);
 
503
    end_x= FFMIN(block_w, w-src_x);
 
504
 
 
505
    // copy existing part
 
506
    for(y=start_y; y<end_y; y++){
 
507
        for(x=start_x; x<end_x; x++){
 
508
            buf[x + y*linesize]= src[x + y*linesize];
 
509
        }
 
510
    }
 
511
 
 
512
    //top
 
513
    for(y=0; y<start_y; y++){
 
514
        for(x=start_x; x<end_x; x++){
 
515
            buf[x + y*linesize]= buf[x + start_y*linesize];
 
516
        }
 
517
    }
 
518
 
 
519
    //bottom
 
520
    for(y=end_y; y<block_h; y++){
 
521
        for(x=start_x; x<end_x; x++){
 
522
            buf[x + y*linesize]= buf[x + (end_y-1)*linesize];
 
523
        }
 
524
    }
 
525
 
 
526
    for(y=0; y<block_h; y++){
 
527
       //left
 
528
        for(x=0; x<start_x; x++){
 
529
            buf[x + y*linesize]= buf[start_x + y*linesize];
 
530
        }
 
531
 
 
532
       //right
 
533
        for(x=end_x; x<block_w; x++){
 
534
            buf[x + y*linesize]= buf[end_x - 1 + y*linesize];
 
535
        }
 
536
    }
 
537
}
 
538
 
399
539
static void get_pixels_c(DCTELEM *restrict block, const uint8_t *pixels, int line_size)
400
540
{
401
541
    int i;
1440
1580
    \
1441
1581
    assert(x<8 && y<8 && x>=0 && y>=0);\
1442
1582
\
1443
 
    for(i=0; i<h; i++)\
1444
 
    {\
1445
 
        OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
1446
 
        OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
1447
 
        dst+= stride;\
1448
 
        src+= stride;\
 
1583
    if(D){\
 
1584
        for(i=0; i<h; i++){\
 
1585
            OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
 
1586
            OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
 
1587
            dst+= stride;\
 
1588
            src+= stride;\
 
1589
        }\
 
1590
    }else{\
 
1591
        const int E= B+C;\
 
1592
        const int step= C ? stride : 1;\
 
1593
        for(i=0; i<h; i++){\
 
1594
            OP(dst[0], (A*src[0] + E*src[step+0]));\
 
1595
            OP(dst[1], (A*src[1] + E*src[step+1]));\
 
1596
            dst+= stride;\
 
1597
            src+= stride;\
 
1598
        }\
1449
1599
    }\
1450
1600
}\
1451
1601
\
1458
1608
    \
1459
1609
    assert(x<8 && y<8 && x>=0 && y>=0);\
1460
1610
\
1461
 
    for(i=0; i<h; i++)\
1462
 
    {\
1463
 
        OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
1464
 
        OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
1465
 
        OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
1466
 
        OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
1467
 
        dst+= stride;\
1468
 
        src+= stride;\
 
1611
    if(D){\
 
1612
        for(i=0; i<h; i++){\
 
1613
            OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
 
1614
            OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
 
1615
            OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
 
1616
            OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
 
1617
            dst+= stride;\
 
1618
            src+= stride;\
 
1619
        }\
 
1620
    }else{\
 
1621
        const int E= B+C;\
 
1622
        const int step= C ? stride : 1;\
 
1623
        for(i=0; i<h; i++){\
 
1624
            OP(dst[0], (A*src[0] + E*src[step+0]));\
 
1625
            OP(dst[1], (A*src[1] + E*src[step+1]));\
 
1626
            OP(dst[2], (A*src[2] + E*src[step+2]));\
 
1627
            OP(dst[3], (A*src[3] + E*src[step+3]));\
 
1628
            dst+= stride;\
 
1629
            src+= stride;\
 
1630
        }\
1469
1631
    }\
1470
1632
}\
1471
1633
\
1478
1640
    \
1479
1641
    assert(x<8 && y<8 && x>=0 && y>=0);\
1480
1642
\
1481
 
    for(i=0; i<h; i++)\
1482
 
    {\
1483
 
        OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
1484
 
        OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
1485
 
        OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
1486
 
        OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
1487
 
        OP(dst[4], (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5]));\
1488
 
        OP(dst[5], (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6]));\
1489
 
        OP(dst[6], (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7]));\
1490
 
        OP(dst[7], (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8]));\
1491
 
        dst+= stride;\
1492
 
        src+= stride;\
 
1643
    if(D){\
 
1644
        for(i=0; i<h; i++){\
 
1645
            OP(dst[0], (A*src[0] + B*src[1] + C*src[stride+0] + D*src[stride+1]));\
 
1646
            OP(dst[1], (A*src[1] + B*src[2] + C*src[stride+1] + D*src[stride+2]));\
 
1647
            OP(dst[2], (A*src[2] + B*src[3] + C*src[stride+2] + D*src[stride+3]));\
 
1648
            OP(dst[3], (A*src[3] + B*src[4] + C*src[stride+3] + D*src[stride+4]));\
 
1649
            OP(dst[4], (A*src[4] + B*src[5] + C*src[stride+4] + D*src[stride+5]));\
 
1650
            OP(dst[5], (A*src[5] + B*src[6] + C*src[stride+5] + D*src[stride+6]));\
 
1651
            OP(dst[6], (A*src[6] + B*src[7] + C*src[stride+6] + D*src[stride+7]));\
 
1652
            OP(dst[7], (A*src[7] + B*src[8] + C*src[stride+7] + D*src[stride+8]));\
 
1653
            dst+= stride;\
 
1654
            src+= stride;\
 
1655
        }\
 
1656
    }else{\
 
1657
        const int E= B+C;\
 
1658
        const int step= C ? stride : 1;\
 
1659
        for(i=0; i<h; i++){\
 
1660
            OP(dst[0], (A*src[0] + E*src[step+0]));\
 
1661
            OP(dst[1], (A*src[1] + E*src[step+1]));\
 
1662
            OP(dst[2], (A*src[2] + E*src[step+2]));\
 
1663
            OP(dst[3], (A*src[3] + E*src[step+3]));\
 
1664
            OP(dst[4], (A*src[4] + E*src[step+4]));\
 
1665
            OP(dst[5], (A*src[5] + E*src[step+5]));\
 
1666
            OP(dst[6], (A*src[6] + E*src[step+6]));\
 
1667
            OP(dst[7], (A*src[7] + E*src[step+7]));\
 
1668
            dst+= stride;\
 
1669
            src+= stride;\
 
1670
        }\
1493
1671
    }\
1494
1672
}
1495
1673
 
2534
2712
    }
2535
2713
}
2536
2714
 
2537
 
#ifdef CONFIG_CAVS_DECODER
 
2715
#if CONFIG_CAVS_DECODER
2538
2716
/* AVS specific */
2539
2717
void ff_cavsdsp_init(DSPContext* c, AVCodecContext *avctx);
2540
2718
 
2552
2730
}
2553
2731
#endif /* CONFIG_CAVS_DECODER */
2554
2732
 
2555
 
#if defined(CONFIG_VC1_DECODER) || defined(CONFIG_WMV3_DECODER)
 
2733
#if CONFIG_VC1_DECODER || CONFIG_WMV3_DECODER
2556
2734
/* VC-1 specific */
2557
2735
void ff_vc1dsp_init(DSPContext* c, AVCodecContext *avctx);
2558
2736
 
2561
2739
}
2562
2740
#endif /* CONFIG_VC1_DECODER||CONFIG_WMV3_DECODER */
2563
2741
 
2564
 
#if defined(CONFIG_H264_ENCODER)
 
2742
void ff_intrax8dsp_init(DSPContext* c, AVCodecContext *avctx);
 
2743
 
2565
2744
/* H264 specific */
2566
2745
void ff_h264dspenc_init(DSPContext* c, AVCodecContext *avctx);
2567
 
#endif /* CONFIG_H264_ENCODER */
 
2746
 
 
2747
#if CONFIG_RV30_DECODER
 
2748
void ff_rv30dsp_init(DSPContext* c, AVCodecContext *avctx);
 
2749
#endif /* CONFIG_RV30_DECODER */
 
2750
 
 
2751
#if CONFIG_RV40_DECODER
 
2752
static void put_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride){
 
2753
    put_pixels16_xy2_c(dst, src, stride, 16);
 
2754
}
 
2755
static void avg_rv40_qpel16_mc33_c(uint8_t *dst, uint8_t *src, int stride){
 
2756
    avg_pixels16_xy2_c(dst, src, stride, 16);
 
2757
}
 
2758
static void put_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, int stride){
 
2759
    put_pixels8_xy2_c(dst, src, stride, 8);
 
2760
}
 
2761
static void avg_rv40_qpel8_mc33_c(uint8_t *dst, uint8_t *src, int stride){
 
2762
    avg_pixels8_xy2_c(dst, src, stride, 8);
 
2763
}
 
2764
 
 
2765
void ff_rv40dsp_init(DSPContext* c, AVCodecContext *avctx);
 
2766
#endif /* CONFIG_RV40_DECODER */
2568
2767
 
2569
2768
static void wmv2_mspel8_v_lowpass(uint8_t *dst, uint8_t *src, int dstStride, int srcStride, int w){
2570
2769
    uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
2644
2843
}
2645
2844
 
2646
2845
static void h263_v_loop_filter_c(uint8_t *src, int stride, int qscale){
2647
 
    if(ENABLE_ANY_H263) {
 
2846
    if(CONFIG_ANY_H263) {
2648
2847
    int x;
2649
2848
    const int strength= ff_h263_loop_filter_strength[qscale];
2650
2849
 
2681
2880
}
2682
2881
 
2683
2882
static void h263_h_loop_filter_c(uint8_t *src, int stride, int qscale){
2684
 
    if(ENABLE_ANY_H263) {
 
2883
    if(CONFIG_ANY_H263) {
2685
2884
    int y;
2686
2885
    const int strength= ff_h263_loop_filter_strength[qscale];
2687
2886
 
2793
2992
    h264_loop_filter_luma_c(pix, 1, stride, alpha, beta, tc0);
2794
2993
}
2795
2994
 
 
2995
static inline void h264_loop_filter_luma_intra_c(uint8_t *pix, int xstride, int ystride, int alpha, int beta)
 
2996
{
 
2997
    int d;
 
2998
    for( d = 0; d < 16; d++ ) {
 
2999
        const int p2 = pix[-3*xstride];
 
3000
        const int p1 = pix[-2*xstride];
 
3001
        const int p0 = pix[-1*xstride];
 
3002
 
 
3003
        const int q0 = pix[ 0*xstride];
 
3004
        const int q1 = pix[ 1*xstride];
 
3005
        const int q2 = pix[ 2*xstride];
 
3006
 
 
3007
        if( FFABS( p0 - q0 ) < alpha &&
 
3008
            FFABS( p1 - p0 ) < beta &&
 
3009
            FFABS( q1 - q0 ) < beta ) {
 
3010
 
 
3011
            if(FFABS( p0 - q0 ) < (( alpha >> 2 ) + 2 )){
 
3012
                if( FFABS( p2 - p0 ) < beta)
 
3013
                {
 
3014
                    const int p3 = pix[-4*xstride];
 
3015
                    /* p0', p1', p2' */
 
3016
                    pix[-1*xstride] = ( p2 + 2*p1 + 2*p0 + 2*q0 + q1 + 4 ) >> 3;
 
3017
                    pix[-2*xstride] = ( p2 + p1 + p0 + q0 + 2 ) >> 2;
 
3018
                    pix[-3*xstride] = ( 2*p3 + 3*p2 + p1 + p0 + q0 + 4 ) >> 3;
 
3019
                } else {
 
3020
                    /* p0' */
 
3021
                    pix[-1*xstride] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
 
3022
                }
 
3023
                if( FFABS( q2 - q0 ) < beta)
 
3024
                {
 
3025
                    const int q3 = pix[3*xstride];
 
3026
                    /* q0', q1', q2' */
 
3027
                    pix[0*xstride] = ( p1 + 2*p0 + 2*q0 + 2*q1 + q2 + 4 ) >> 3;
 
3028
                    pix[1*xstride] = ( p0 + q0 + q1 + q2 + 2 ) >> 2;
 
3029
                    pix[2*xstride] = ( 2*q3 + 3*q2 + q1 + q0 + p0 + 4 ) >> 3;
 
3030
                } else {
 
3031
                    /* q0' */
 
3032
                    pix[0*xstride] = ( 2*q1 + q0 + p1 + 2 ) >> 2;
 
3033
                }
 
3034
            }else{
 
3035
                /* p0', q0' */
 
3036
                pix[-1*xstride] = ( 2*p1 + p0 + q1 + 2 ) >> 2;
 
3037
                pix[ 0*xstride] = ( 2*q1 + q0 + p1 + 2 ) >> 2;
 
3038
            }
 
3039
        }
 
3040
        pix += ystride;
 
3041
    }
 
3042
}
 
3043
static void h264_v_loop_filter_luma_intra_c(uint8_t *pix, int stride, int alpha, int beta)
 
3044
{
 
3045
    h264_loop_filter_luma_intra_c(pix, stride, 1, alpha, beta);
 
3046
}
 
3047
static void h264_h_loop_filter_luma_intra_c(uint8_t *pix, int stride, int alpha, int beta)
 
3048
{
 
3049
    h264_loop_filter_luma_intra_c(pix, 1, stride, alpha, beta);
 
3050
}
 
3051
 
2796
3052
static inline void h264_loop_filter_chroma_c(uint8_t *pix, int xstride, int ystride, int alpha, int beta, int8_t *tc0)
2797
3053
{
2798
3054
    int i, d;
3169
3425
void ff_set_cmp(DSPContext* c, me_cmp_func *cmp, int type){
3170
3426
    int i;
3171
3427
 
3172
 
    memset(cmp, 0, sizeof(void*)*5);
 
3428
    memset(cmp, 0, sizeof(void*)*6);
3173
3429
 
3174
 
    for(i=0; i<5; i++){
 
3430
    for(i=0; i<6; i++){
3175
3431
        switch(type&0xFF){
3176
3432
        case FF_CMP_SAD:
3177
3433
            cmp[i]= c->sad[i];
3212
3468
        case FF_CMP_NSSE:
3213
3469
            cmp[i]= c->nsse[i];
3214
3470
            break;
3215
 
#ifdef CONFIG_SNOW_ENCODER
 
3471
#if CONFIG_SNOW_ENCODER
3216
3472
        case FF_CMP_W53:
3217
3473
            cmp[i]= c->w53[i];
3218
3474
            break;
3226
3482
    }
3227
3483
}
3228
3484
 
 
3485
static void clear_block_c(DCTELEM *block)
 
3486
{
 
3487
    memset(block, 0, sizeof(DCTELEM)*64);
 
3488
}
 
3489
 
3229
3490
/**
3230
3491
 * memset(blocks, 0, sizeof(DCTELEM)*6*64)
3231
3492
 */
3235
3496
}
3236
3497
 
3237
3498
static void add_bytes_c(uint8_t *dst, uint8_t *src, int w){
3238
 
    int i;
3239
 
    for(i=0; i+7<w; i+=8){
3240
 
        dst[i+0] += src[i+0];
3241
 
        dst[i+1] += src[i+1];
3242
 
        dst[i+2] += src[i+2];
3243
 
        dst[i+3] += src[i+3];
3244
 
        dst[i+4] += src[i+4];
3245
 
        dst[i+5] += src[i+5];
3246
 
        dst[i+6] += src[i+6];
3247
 
        dst[i+7] += src[i+7];
3248
 
    }
3249
 
    for(; i<w; i++)
3250
 
        dst[i+0] += src[i+0];
 
3499
    long i;
 
3500
    for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
 
3501
        long a = *(long*)(src+i);
 
3502
        long b = *(long*)(dst+i);
 
3503
        *(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80);
 
3504
    }
 
3505
    for(; i<w; i++)
 
3506
        dst[i+0] += src[i+0];
 
3507
}
 
3508
 
 
3509
static void add_bytes_l2_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
 
3510
    long i;
 
3511
    for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
 
3512
        long a = *(long*)(src1+i);
 
3513
        long b = *(long*)(src2+i);
 
3514
        *(long*)(dst+i) = ((a&pb_7f) + (b&pb_7f)) ^ ((a^b)&pb_80);
 
3515
    }
 
3516
    for(; i<w; i++)
 
3517
        dst[i] = src1[i]+src2[i];
3251
3518
}
3252
3519
 
3253
3520
static void diff_bytes_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w){
 
3521
    long i;
 
3522
#if !HAVE_FAST_UNALIGNED
 
3523
    if((long)src2 & (sizeof(long)-1)){
 
3524
        for(i=0; i+7<w; i+=8){
 
3525
            dst[i+0] = src1[i+0]-src2[i+0];
 
3526
            dst[i+1] = src1[i+1]-src2[i+1];
 
3527
            dst[i+2] = src1[i+2]-src2[i+2];
 
3528
            dst[i+3] = src1[i+3]-src2[i+3];
 
3529
            dst[i+4] = src1[i+4]-src2[i+4];
 
3530
            dst[i+5] = src1[i+5]-src2[i+5];
 
3531
            dst[i+6] = src1[i+6]-src2[i+6];
 
3532
            dst[i+7] = src1[i+7]-src2[i+7];
 
3533
        }
 
3534
    }else
 
3535
#endif
 
3536
    for(i=0; i<=w-sizeof(long); i+=sizeof(long)){
 
3537
        long a = *(long*)(src1+i);
 
3538
        long b = *(long*)(src2+i);
 
3539
        *(long*)(dst+i) = ((a|pb_80) - (b&pb_7f)) ^ ((a^b^pb_80)&pb_80);
 
3540
    }
 
3541
    for(; i<w; i++)
 
3542
        dst[i+0] = src1[i+0]-src2[i+0];
 
3543
}
 
3544
 
 
3545
static void add_hfyu_median_prediction_c(uint8_t *dst, uint8_t *src1, uint8_t *diff, int w, int *left, int *left_top){
3254
3546
    int i;
3255
 
    for(i=0; i+7<w; i+=8){
3256
 
        dst[i+0] = src1[i+0]-src2[i+0];
3257
 
        dst[i+1] = src1[i+1]-src2[i+1];
3258
 
        dst[i+2] = src1[i+2]-src2[i+2];
3259
 
        dst[i+3] = src1[i+3]-src2[i+3];
3260
 
        dst[i+4] = src1[i+4]-src2[i+4];
3261
 
        dst[i+5] = src1[i+5]-src2[i+5];
3262
 
        dst[i+6] = src1[i+6]-src2[i+6];
3263
 
        dst[i+7] = src1[i+7]-src2[i+7];
 
3547
    uint8_t l, lt;
 
3548
 
 
3549
    l= *left;
 
3550
    lt= *left_top;
 
3551
 
 
3552
    for(i=0; i<w; i++){
 
3553
        l= mid_pred(l, src1[i], (l + src1[i] - lt)&0xFF) + diff[i];
 
3554
        lt= src1[i];
 
3555
        dst[i]= l;
3264
3556
    }
3265
 
    for(; i<w; i++)
3266
 
        dst[i+0] = src1[i+0]-src2[i+0];
 
3557
 
 
3558
    *left= l;
 
3559
    *left_top= lt;
3267
3560
}
3268
3561
 
3269
3562
static void sub_hfyu_median_prediction_c(uint8_t *dst, uint8_t *src1, uint8_t *src2, int w, int *left, int *left_top){
3411
3704
    return s->dsp.sum_abs_dctelem(temp);
3412
3705
}
3413
3706
 
3414
 
#ifdef CONFIG_GPL
 
3707
#if CONFIG_GPL
3415
3708
#define DCT8_1D {\
3416
3709
    const int s07 = SRC(0) + SRC(7);\
3417
3710
    const int s16 = SRC(1) + SRC(6);\
3497
3790
 
3498
3791
    s->block_last_index[0/*FIXME*/]= s->fast_dct_quantize(s, temp, 0/*FIXME*/, s->qscale, &i);
3499
3792
    s->dct_unquantize_inter(s, temp, 0, s->qscale);
3500
 
    simple_idct(temp); //FIXME
 
3793
    ff_simple_idct(temp); //FIXME
3501
3794
 
3502
3795
    for(i=0; i<64; i++)
3503
3796
        sum+= (temp[i]-bak[i])*(temp[i]-bak[i]);
3512
3805
    DECLARE_ALIGNED_8 (uint64_t, aligned_bak[stride]);
3513
3806
    DCTELEM * const temp= (DCTELEM*)aligned_temp;
3514
3807
    uint8_t * const bak= (uint8_t*)aligned_bak;
3515
 
    int i, last, run, bits, level, distoration, start_i;
 
3808
    int i, last, run, bits, level, distortion, start_i;
3516
3809
    const int esc_length= s->ac_esc_length;
3517
3810
    uint8_t * length;
3518
3811
    uint8_t * last_length;
3579
3872
 
3580
3873
    s->dsp.idct_add(bak, stride, temp);
3581
3874
 
3582
 
    distoration= s->dsp.sse[1](NULL, bak, src1, stride, 8);
 
3875
    distortion= s->dsp.sse[1](NULL, bak, src1, stride, 8);
3583
3876
 
3584
 
    return distoration + ((bits*s->qscale*s->qscale*109 + 64)>>7);
 
3877
    return distortion + ((bits*s->qscale*s->qscale*109 + 64)>>7);
3585
3878
}
3586
3879
 
3587
3880
static int bit8x8_c(/*MpegEncContext*/ void *c, uint8_t *src1, uint8_t *src2, int stride, int h){
3644
3937
    return bits;
3645
3938
}
3646
3939
 
3647
 
static int vsad_intra16_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){
3648
 
    int score=0;
3649
 
    int x,y;
3650
 
 
3651
 
    for(y=1; y<h; y++){
3652
 
        for(x=0; x<16; x+=4){
3653
 
            score+= FFABS(s[x  ] - s[x  +stride]) + FFABS(s[x+1] - s[x+1+stride])
3654
 
                   +FFABS(s[x+2] - s[x+2+stride]) + FFABS(s[x+3] - s[x+3+stride]);
3655
 
        }
3656
 
        s+= stride;
3657
 
    }
3658
 
 
3659
 
    return score;
 
3940
#define VSAD_INTRA(size) \
 
3941
static int vsad_intra##size##_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){ \
 
3942
    int score=0;                                                                                            \
 
3943
    int x,y;                                                                                                \
 
3944
                                                                                                            \
 
3945
    for(y=1; y<h; y++){                                                                                     \
 
3946
        for(x=0; x<size; x+=4){                                                                             \
 
3947
            score+= FFABS(s[x  ] - s[x  +stride]) + FFABS(s[x+1] - s[x+1+stride])                           \
 
3948
                   +FFABS(s[x+2] - s[x+2+stride]) + FFABS(s[x+3] - s[x+3+stride]);                          \
 
3949
        }                                                                                                   \
 
3950
        s+= stride;                                                                                         \
 
3951
    }                                                                                                       \
 
3952
                                                                                                            \
 
3953
    return score;                                                                                           \
3660
3954
}
 
3955
VSAD_INTRA(8)
 
3956
VSAD_INTRA(16)
3661
3957
 
3662
3958
static int vsad16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){
3663
3959
    int score=0;
3675
3971
}
3676
3972
 
3677
3973
#define SQ(a) ((a)*(a))
3678
 
static int vsse_intra16_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){
3679
 
    int score=0;
3680
 
    int x,y;
3681
 
 
3682
 
    for(y=1; y<h; y++){
3683
 
        for(x=0; x<16; x+=4){
3684
 
            score+= SQ(s[x  ] - s[x  +stride]) + SQ(s[x+1] - s[x+1+stride])
3685
 
                   +SQ(s[x+2] - s[x+2+stride]) + SQ(s[x+3] - s[x+3+stride]);
3686
 
        }
3687
 
        s+= stride;
3688
 
    }
3689
 
 
3690
 
    return score;
 
3974
#define VSSE_INTRA(size) \
 
3975
static int vsse_intra##size##_c(/*MpegEncContext*/ void *c, uint8_t *s, uint8_t *dummy, int stride, int h){ \
 
3976
    int score=0;                                                                                            \
 
3977
    int x,y;                                                                                                \
 
3978
                                                                                                            \
 
3979
    for(y=1; y<h; y++){                                                                                     \
 
3980
        for(x=0; x<size; x+=4){                                                                               \
 
3981
            score+= SQ(s[x  ] - s[x  +stride]) + SQ(s[x+1] - s[x+1+stride])                                 \
 
3982
                   +SQ(s[x+2] - s[x+2+stride]) + SQ(s[x+3] - s[x+3+stride]);                                \
 
3983
        }                                                                                                   \
 
3984
        s+= stride;                                                                                         \
 
3985
    }                                                                                                       \
 
3986
                                                                                                            \
 
3987
    return score;                                                                                           \
3691
3988
}
 
3989
VSSE_INTRA(8)
 
3990
VSSE_INTRA(16)
3692
3991
 
3693
3992
static int vsse16_c(/*MpegEncContext*/ void *c, uint8_t *s1, uint8_t *s2, int stride, int h){
3694
3993
    int score=0;
3714
4013
    return score;
3715
4014
}
3716
4015
 
3717
 
WARPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c)
3718
 
WARPER8_16_SQ(hadamard8_intra8x8_c, hadamard8_intra16_c)
3719
 
WARPER8_16_SQ(dct_sad8x8_c, dct_sad16_c)
3720
 
#ifdef CONFIG_GPL
3721
 
WARPER8_16_SQ(dct264_sad8x8_c, dct264_sad16_c)
 
4016
WRAPPER8_16_SQ(hadamard8_diff8x8_c, hadamard8_diff16_c)
 
4017
WRAPPER8_16_SQ(hadamard8_intra8x8_c, hadamard8_intra16_c)
 
4018
WRAPPER8_16_SQ(dct_sad8x8_c, dct_sad16_c)
 
4019
#if CONFIG_GPL
 
4020
WRAPPER8_16_SQ(dct264_sad8x8_c, dct264_sad16_c)
3722
4021
#endif
3723
 
WARPER8_16_SQ(dct_max8x8_c, dct_max16_c)
3724
 
WARPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c)
3725
 
WARPER8_16_SQ(rd8x8_c, rd16_c)
3726
 
WARPER8_16_SQ(bit8x8_c, bit16_c)
 
4022
WRAPPER8_16_SQ(dct_max8x8_c, dct_max16_c)
 
4023
WRAPPER8_16_SQ(quant_psnr8x8_c, quant_psnr16_c)
 
4024
WRAPPER8_16_SQ(rd8x8_c, rd16_c)
 
4025
WRAPPER8_16_SQ(bit8x8_c, bit16_c)
3727
4026
 
3728
4027
static void vector_fmul_c(float *dst, const float *src, int len){
3729
4028
    int i;
3744
4043
        dst[i*step] = src0[i] * src1[i] + src2[i] + src3;
3745
4044
}
3746
4045
 
3747
 
void ff_float_to_int16_c(int16_t *dst, const float *src, int len){
3748
 
    int i;
3749
 
    for(i=0; i<len; i++) {
3750
 
        int_fast32_t tmp = ((int32_t*)src)[i];
3751
 
        if(tmp & 0xf0000){
3752
 
            tmp = (0x43c0ffff - tmp)>>31;
3753
 
            // is this faster on some gcc/cpu combinations?
3754
 
//          if(tmp > 0x43c0ffff) tmp = 0xFFFF;
3755
 
//          else                 tmp = 0;
 
4046
void ff_vector_fmul_window_c(float *dst, const float *src0, const float *src1, const float *win, float add_bias, int len){
 
4047
    int i,j;
 
4048
    dst += len;
 
4049
    win += len;
 
4050
    src0+= len;
 
4051
    for(i=-len, j=len-1; i<0; i++, j--) {
 
4052
        float s0 = src0[i];
 
4053
        float s1 = src1[j];
 
4054
        float wi = win[i];
 
4055
        float wj = win[j];
 
4056
        dst[i] = s0*wj - s1*wi + add_bias;
 
4057
        dst[j] = s0*wi + s1*wj + add_bias;
 
4058
    }
 
4059
}
 
4060
 
 
4061
static void int32_to_float_fmul_scalar_c(float *dst, const int *src, float mul, int len){
 
4062
    int i;
 
4063
    for(i=0; i<len; i++)
 
4064
        dst[i] = src[i] * mul;
 
4065
}
 
4066
 
 
4067
static av_always_inline int float_to_int16_one(const float *src){
 
4068
    int_fast32_t tmp = *(const int32_t*)src;
 
4069
    if(tmp & 0xf0000){
 
4070
        tmp = (0x43c0ffff - tmp)>>31;
 
4071
        // is this faster on some gcc/cpu combinations?
 
4072
//      if(tmp > 0x43c0ffff) tmp = 0xFFFF;
 
4073
//      else                 tmp = 0;
 
4074
    }
 
4075
    return tmp - 0x8000;
 
4076
}
 
4077
 
 
4078
void ff_float_to_int16_c(int16_t *dst, const float *src, long len){
 
4079
    int i;
 
4080
    for(i=0; i<len; i++)
 
4081
        dst[i] = float_to_int16_one(src+i);
 
4082
}
 
4083
 
 
4084
void ff_float_to_int16_interleave_c(int16_t *dst, const float **src, long len, int channels){
 
4085
    int i,j,c;
 
4086
    if(channels==2){
 
4087
        for(i=0; i<len; i++){
 
4088
            dst[2*i]   = float_to_int16_one(src[0]+i);
 
4089
            dst[2*i+1] = float_to_int16_one(src[1]+i);
3756
4090
        }
3757
 
        dst[i] = tmp - 0x8000;
3758
 
    }
3759
 
}
3760
 
 
 
4091
    }else{
 
4092
        for(c=0; c<channels; c++)
 
4093
            for(i=0, j=c; i<len; i++, j+=channels)
 
4094
                dst[j] = float_to_int16_one(src[c]+i);
 
4095
    }
 
4096
}
 
4097
 
 
4098
static void add_int16_c(int16_t * v1, int16_t * v2, int order)
 
4099
{
 
4100
    while (order--)
 
4101
       *v1++ += *v2++;
 
4102
}
 
4103
 
 
4104
static void sub_int16_c(int16_t * v1, int16_t * v2, int order)
 
4105
{
 
4106
    while (order--)
 
4107
        *v1++ -= *v2++;
 
4108
}
 
4109
 
 
4110
static int32_t scalarproduct_int16_c(int16_t * v1, int16_t * v2, int order, int shift)
 
4111
{
 
4112
    int res = 0;
 
4113
 
 
4114
    while (order--)
 
4115
        res += (*v1++ * *v2++) >> shift;
 
4116
 
 
4117
    return res;
 
4118
}
 
4119
 
 
4120
#define W0 2048
 
4121
#define W1 2841 /* 2048*sqrt (2)*cos (1*pi/16) */
 
4122
#define W2 2676 /* 2048*sqrt (2)*cos (2*pi/16) */
 
4123
#define W3 2408 /* 2048*sqrt (2)*cos (3*pi/16) */
 
4124
#define W4 2048 /* 2048*sqrt (2)*cos (4*pi/16) */
 
4125
#define W5 1609 /* 2048*sqrt (2)*cos (5*pi/16) */
 
4126
#define W6 1108 /* 2048*sqrt (2)*cos (6*pi/16) */
 
4127
#define W7 565  /* 2048*sqrt (2)*cos (7*pi/16) */
 
4128
 
 
4129
static void wmv2_idct_row(short * b)
 
4130
{
 
4131
    int s1,s2;
 
4132
    int a0,a1,a2,a3,a4,a5,a6,a7;
 
4133
    /*step 1*/
 
4134
    a1 = W1*b[1]+W7*b[7];
 
4135
    a7 = W7*b[1]-W1*b[7];
 
4136
    a5 = W5*b[5]+W3*b[3];
 
4137
    a3 = W3*b[5]-W5*b[3];
 
4138
    a2 = W2*b[2]+W6*b[6];
 
4139
    a6 = W6*b[2]-W2*b[6];
 
4140
    a0 = W0*b[0]+W0*b[4];
 
4141
    a4 = W0*b[0]-W0*b[4];
 
4142
    /*step 2*/
 
4143
    s1 = (181*(a1-a5+a7-a3)+128)>>8;//1,3,5,7,
 
4144
    s2 = (181*(a1-a5-a7+a3)+128)>>8;
 
4145
    /*step 3*/
 
4146
    b[0] = (a0+a2+a1+a5 + (1<<7))>>8;
 
4147
    b[1] = (a4+a6 +s1   + (1<<7))>>8;
 
4148
    b[2] = (a4-a6 +s2   + (1<<7))>>8;
 
4149
    b[3] = (a0-a2+a7+a3 + (1<<7))>>8;
 
4150
    b[4] = (a0-a2-a7-a3 + (1<<7))>>8;
 
4151
    b[5] = (a4-a6 -s2   + (1<<7))>>8;
 
4152
    b[6] = (a4+a6 -s1   + (1<<7))>>8;
 
4153
    b[7] = (a0+a2-a1-a5 + (1<<7))>>8;
 
4154
}
 
4155
static void wmv2_idct_col(short * b)
 
4156
{
 
4157
    int s1,s2;
 
4158
    int a0,a1,a2,a3,a4,a5,a6,a7;
 
4159
    /*step 1, with extended precision*/
 
4160
    a1 = (W1*b[8*1]+W7*b[8*7] + 4)>>3;
 
4161
    a7 = (W7*b[8*1]-W1*b[8*7] + 4)>>3;
 
4162
    a5 = (W5*b[8*5]+W3*b[8*3] + 4)>>3;
 
4163
    a3 = (W3*b[8*5]-W5*b[8*3] + 4)>>3;
 
4164
    a2 = (W2*b[8*2]+W6*b[8*6] + 4)>>3;
 
4165
    a6 = (W6*b[8*2]-W2*b[8*6] + 4)>>3;
 
4166
    a0 = (W0*b[8*0]+W0*b[8*4]    )>>3;
 
4167
    a4 = (W0*b[8*0]-W0*b[8*4]    )>>3;
 
4168
    /*step 2*/
 
4169
    s1 = (181*(a1-a5+a7-a3)+128)>>8;
 
4170
    s2 = (181*(a1-a5-a7+a3)+128)>>8;
 
4171
    /*step 3*/
 
4172
    b[8*0] = (a0+a2+a1+a5 + (1<<13))>>14;
 
4173
    b[8*1] = (a4+a6 +s1   + (1<<13))>>14;
 
4174
    b[8*2] = (a4-a6 +s2   + (1<<13))>>14;
 
4175
    b[8*3] = (a0-a2+a7+a3 + (1<<13))>>14;
 
4176
 
 
4177
    b[8*4] = (a0-a2-a7-a3 + (1<<13))>>14;
 
4178
    b[8*5] = (a4-a6 -s2   + (1<<13))>>14;
 
4179
    b[8*6] = (a4+a6 -s1   + (1<<13))>>14;
 
4180
    b[8*7] = (a0+a2-a1-a5 + (1<<13))>>14;
 
4181
}
 
4182
void ff_wmv2_idct_c(short * block){
 
4183
    int i;
 
4184
 
 
4185
    for(i=0;i<64;i+=8){
 
4186
        wmv2_idct_row(block+i);
 
4187
    }
 
4188
    for(i=0;i<8;i++){
 
4189
        wmv2_idct_col(block+i);
 
4190
    }
 
4191
}
3761
4192
/* XXX: those functions should be suppressed ASAP when all IDCTs are
3762
4193
 converted */
 
4194
static void ff_wmv2_idct_put_c(uint8_t *dest, int line_size, DCTELEM *block)
 
4195
{
 
4196
    ff_wmv2_idct_c(block);
 
4197
    put_pixels_clamped_c(block, dest, line_size);
 
4198
}
 
4199
static void ff_wmv2_idct_add_c(uint8_t *dest, int line_size, DCTELEM *block)
 
4200
{
 
4201
    ff_wmv2_idct_c(block);
 
4202
    add_pixels_clamped_c(block, dest, line_size);
 
4203
}
3763
4204
static void ff_jref_idct_put(uint8_t *dest, int line_size, DCTELEM *block)
3764
4205
{
3765
4206
    j_rev_dct (block);
3832
4273
 
3833
4274
    if((long)&aligned & 15){
3834
4275
        if(!did_fail){
3835
 
#if defined(HAVE_MMX) || defined(HAVE_ALTIVEC)
 
4276
#if HAVE_MMX || HAVE_ALTIVEC
3836
4277
            av_log(NULL, AV_LOG_ERROR,
3837
4278
                "Compiler did not align stack variables. Libavcodec has been miscompiled\n"
3838
4279
                "and may be very slow or crash. This is not a bug in libavcodec,\n"
3852
4293
 
3853
4294
    ff_check_alignment();
3854
4295
 
3855
 
#ifdef CONFIG_ENCODERS
 
4296
#if CONFIG_ENCODERS
3856
4297
    if(avctx->dct_algo==FF_DCT_FASTINT) {
3857
4298
        c->fdct = fdct_ifast;
3858
4299
        c->fdct248 = fdct_ifast248;
3868
4309
#endif //CONFIG_ENCODERS
3869
4310
 
3870
4311
    if(avctx->lowres==1){
3871
 
        if(avctx->idct_algo==FF_IDCT_INT || avctx->idct_algo==FF_IDCT_AUTO || !ENABLE_H264_DECODER){
 
4312
        if(avctx->idct_algo==FF_IDCT_INT || avctx->idct_algo==FF_IDCT_AUTO || !CONFIG_H264_DECODER){
3872
4313
            c->idct_put= ff_jref_idct4_put;
3873
4314
            c->idct_add= ff_jref_idct4_add;
3874
4315
        }else{
3893
4334
            c->idct_add= ff_jref_idct_add;
3894
4335
            c->idct    = j_rev_dct;
3895
4336
            c->idct_permutation_type= FF_LIBMPEG2_IDCT_PERM;
3896
 
        }else if((ENABLE_VP3_DECODER || ENABLE_VP5_DECODER || ENABLE_VP6_DECODER || ENABLE_THEORA_DECODER ) &&
 
4337
        }else if((CONFIG_VP3_DECODER || CONFIG_VP5_DECODER || CONFIG_VP6_DECODER || CONFIG_THEORA_DECODER ) &&
3897
4338
                avctx->idct_algo==FF_IDCT_VP3){
3898
4339
            c->idct_put= ff_vp3_idct_put_c;
3899
4340
            c->idct_add= ff_vp3_idct_add_c;
3900
4341
            c->idct    = ff_vp3_idct_c;
3901
4342
            c->idct_permutation_type= FF_NO_IDCT_PERM;
 
4343
        }else if(avctx->idct_algo==FF_IDCT_WMV2){
 
4344
            c->idct_put= ff_wmv2_idct_put_c;
 
4345
            c->idct_add= ff_wmv2_idct_add_c;
 
4346
            c->idct    = ff_wmv2_idct_c;
 
4347
            c->idct_permutation_type= FF_NO_IDCT_PERM;
 
4348
        }else if(avctx->idct_algo==FF_IDCT_FAAN){
 
4349
            c->idct_put= ff_faanidct_put;
 
4350
            c->idct_add= ff_faanidct_add;
 
4351
            c->idct    = ff_faanidct;
 
4352
            c->idct_permutation_type= FF_NO_IDCT_PERM;
 
4353
        }else if(CONFIG_EATGQ_DECODER && avctx->idct_algo==FF_IDCT_EA) {
 
4354
            c->idct_put= ff_ea_idct_put_c;
 
4355
            c->idct_permutation_type= FF_NO_IDCT_PERM;
3902
4356
        }else{ //accurate/default
3903
 
            c->idct_put= simple_idct_put;
3904
 
            c->idct_add= simple_idct_add;
3905
 
            c->idct    = simple_idct;
 
4357
            c->idct_put= ff_simple_idct_put;
 
4358
            c->idct_add= ff_simple_idct_add;
 
4359
            c->idct    = ff_simple_idct;
3906
4360
            c->idct_permutation_type= FF_NO_IDCT_PERM;
3907
4361
        }
3908
4362
    }
3909
4363
 
3910
 
    if (ENABLE_H264_DECODER) {
 
4364
    if (CONFIG_H264_DECODER) {
3911
4365
        c->h264_idct_add= ff_h264_idct_add_c;
3912
4366
        c->h264_idct8_add= ff_h264_idct8_add_c;
3913
4367
        c->h264_idct_dc_add= ff_h264_idct_dc_add_c;
3914
4368
        c->h264_idct8_dc_add= ff_h264_idct8_dc_add_c;
 
4369
        c->h264_idct_add16     = ff_h264_idct_add16_c;
 
4370
        c->h264_idct8_add4     = ff_h264_idct8_add4_c;
 
4371
        c->h264_idct_add8      = ff_h264_idct_add8_c;
 
4372
        c->h264_idct_add16intra= ff_h264_idct_add16intra_c;
3915
4373
    }
3916
4374
 
3917
4375
    c->get_pixels = get_pixels_c;
3924
4382
    c->sum_abs_dctelem = sum_abs_dctelem_c;
3925
4383
    c->gmc1 = gmc1_c;
3926
4384
    c->gmc = ff_gmc_c;
 
4385
    c->clear_block = clear_block_c;
3927
4386
    c->clear_blocks = clear_blocks_c;
3928
4387
    c->pix_sum = pix_sum_c;
3929
4388
    c->pix_norm1 = pix_norm1_c;
4050
4509
    c->biweight_h264_pixels_tab[8]= biweight_h264_pixels2x4_c;
4051
4510
    c->biweight_h264_pixels_tab[9]= biweight_h264_pixels2x2_c;
4052
4511
 
4053
 
#ifdef CONFIG_CAVS_DECODER
 
4512
    c->draw_edges = draw_edges_c;
 
4513
 
 
4514
#if CONFIG_CAVS_DECODER
4054
4515
    ff_cavsdsp_init(c,avctx);
4055
4516
#endif
4056
 
#if defined(CONFIG_VC1_DECODER) || defined(CONFIG_WMV3_DECODER)
 
4517
#if CONFIG_VC1_DECODER || CONFIG_WMV3_DECODER
4057
4518
    ff_vc1dsp_init(c,avctx);
4058
4519
#endif
4059
 
#if defined(CONFIG_H264_ENCODER)
4060
 
    ff_h264dspenc_init(c,avctx);
 
4520
#if CONFIG_WMV2_DECODER || CONFIG_VC1_DECODER || CONFIG_WMV3_DECODER
 
4521
    ff_intrax8dsp_init(c,avctx);
 
4522
#endif
 
4523
#if CONFIG_RV30_DECODER
 
4524
    ff_rv30dsp_init(c,avctx);
 
4525
#endif
 
4526
#if CONFIG_RV40_DECODER
 
4527
    ff_rv40dsp_init(c,avctx);
 
4528
    c->put_rv40_qpel_pixels_tab[0][15] = put_rv40_qpel16_mc33_c;
 
4529
    c->avg_rv40_qpel_pixels_tab[0][15] = avg_rv40_qpel16_mc33_c;
 
4530
    c->put_rv40_qpel_pixels_tab[1][15] = put_rv40_qpel8_mc33_c;
 
4531
    c->avg_rv40_qpel_pixels_tab[1][15] = avg_rv40_qpel8_mc33_c;
4061
4532
#endif
4062
4533
 
4063
4534
    c->put_mspel_pixels_tab[0]= put_mspel8_mc00_c;
4075
4546
 
4076
4547
    SET_CMP_FUNC(hadamard8_diff)
4077
4548
    c->hadamard8_diff[4]= hadamard8_intra16_c;
 
4549
    c->hadamard8_diff[5]= hadamard8_intra8x8_c;
4078
4550
    SET_CMP_FUNC(dct_sad)
4079
4551
    SET_CMP_FUNC(dct_max)
4080
 
#ifdef CONFIG_GPL
 
4552
#if CONFIG_GPL
4081
4553
    SET_CMP_FUNC(dct264_sad)
4082
4554
#endif
4083
4555
    c->sad[0]= pix_abs16_c;
4090
4562
    SET_CMP_FUNC(bit)
4091
4563
    c->vsad[0]= vsad16_c;
4092
4564
    c->vsad[4]= vsad_intra16_c;
 
4565
    c->vsad[5]= vsad_intra8_c;
4093
4566
    c->vsse[0]= vsse16_c;
4094
4567
    c->vsse[4]= vsse_intra16_c;
 
4568
    c->vsse[5]= vsse_intra8_c;
4095
4569
    c->nsse[0]= nsse16_c;
4096
4570
    c->nsse[1]= nsse8_c;
4097
 
#ifdef CONFIG_SNOW_ENCODER
 
4571
#if CONFIG_SNOW_ENCODER
4098
4572
    c->w53[0]= w53_16_c;
4099
4573
    c->w53[1]= w53_8_c;
4100
4574
    c->w97[0]= w97_16_c;
4104
4578
    c->ssd_int8_vs_int16 = ssd_int8_vs_int16_c;
4105
4579
 
4106
4580
    c->add_bytes= add_bytes_c;
 
4581
    c->add_bytes_l2= add_bytes_l2_c;
4107
4582
    c->diff_bytes= diff_bytes_c;
 
4583
    c->add_hfyu_median_prediction= add_hfyu_median_prediction_c;
4108
4584
    c->sub_hfyu_median_prediction= sub_hfyu_median_prediction_c;
4109
4585
    c->bswap_buf= bswap_buf;
 
4586
#if CONFIG_PNG_DECODER
 
4587
    c->add_png_paeth_prediction= ff_add_png_paeth_prediction;
 
4588
#endif
4110
4589
 
4111
4590
    c->h264_v_loop_filter_luma= h264_v_loop_filter_luma_c;
4112
4591
    c->h264_h_loop_filter_luma= h264_h_loop_filter_luma_c;
 
4592
    c->h264_v_loop_filter_luma_intra= h264_v_loop_filter_luma_intra_c;
 
4593
    c->h264_h_loop_filter_luma_intra= h264_h_loop_filter_luma_intra_c;
4113
4594
    c->h264_v_loop_filter_chroma= h264_v_loop_filter_chroma_c;
4114
4595
    c->h264_h_loop_filter_chroma= h264_h_loop_filter_chroma_c;
4115
4596
    c->h264_v_loop_filter_chroma_intra= h264_v_loop_filter_chroma_intra_c;
4116
4597
    c->h264_h_loop_filter_chroma_intra= h264_h_loop_filter_chroma_intra_c;
4117
4598
    c->h264_loop_filter_strength= NULL;
4118
4599
 
4119
 
    if (ENABLE_ANY_H263) {
 
4600
    if (CONFIG_ANY_H263) {
4120
4601
        c->h263_h_loop_filter= h263_h_loop_filter_c;
4121
4602
        c->h263_v_loop_filter= h263_v_loop_filter_c;
4122
4603
    }
4123
4604
 
 
4605
    if (CONFIG_VP3_DECODER || CONFIG_THEORA_DECODER) {
 
4606
        c->vp3_h_loop_filter= ff_vp3_h_loop_filter_c;
 
4607
        c->vp3_v_loop_filter= ff_vp3_v_loop_filter_c;
 
4608
    }
 
4609
    if (CONFIG_VP6_DECODER) {
 
4610
        c->vp6_filter_diag4= ff_vp6_filter_diag4_c;
 
4611
    }
 
4612
 
4124
4613
    c->h261_loop_filter= h261_loop_filter_c;
4125
4614
 
4126
4615
    c->try_8x8basis= try_8x8basis_c;
4127
4616
    c->add_8x8basis= add_8x8basis_c;
4128
4617
 
4129
 
#ifdef CONFIG_SNOW_DECODER
 
4618
#if CONFIG_SNOW_DECODER
4130
4619
    c->vertical_compose97i = ff_snow_vertical_compose97i;
4131
4620
    c->horizontal_compose97i = ff_snow_horizontal_compose97i;
4132
4621
    c->inner_add_yblock = ff_snow_inner_add_yblock;
4133
4622
#endif
4134
4623
 
4135
 
#ifdef CONFIG_VORBIS_DECODER
 
4624
#if CONFIG_VORBIS_DECODER
4136
4625
    c->vorbis_inverse_coupling = vorbis_inverse_coupling;
4137
4626
#endif
4138
 
#ifdef CONFIG_FLAC_ENCODER
 
4627
#if CONFIG_AC3_DECODER
 
4628
    c->ac3_downmix = ff_ac3_downmix_c;
 
4629
#endif
 
4630
#if CONFIG_FLAC_ENCODER
4139
4631
    c->flac_compute_autocorr = ff_flac_compute_autocorr;
4140
4632
#endif
4141
4633
    c->vector_fmul = vector_fmul_c;
4142
4634
    c->vector_fmul_reverse = vector_fmul_reverse_c;
4143
4635
    c->vector_fmul_add_add = ff_vector_fmul_add_add_c;
 
4636
    c->vector_fmul_window = ff_vector_fmul_window_c;
 
4637
    c->int32_to_float_fmul_scalar = int32_to_float_fmul_scalar_c;
4144
4638
    c->float_to_int16 = ff_float_to_int16_c;
 
4639
    c->float_to_int16_interleave = ff_float_to_int16_interleave_c;
 
4640
    c->add_int16 = add_int16_c;
 
4641
    c->sub_int16 = sub_int16_c;
 
4642
    c->scalarproduct_int16 = scalarproduct_int16_c;
4145
4643
 
4146
4644
    c->shrink[0]= ff_img_copy_plane;
4147
4645
    c->shrink[1]= ff_shrink22;
4153
4651
    memset(c->put_2tap_qpel_pixels_tab, 0, sizeof(c->put_2tap_qpel_pixels_tab));
4154
4652
    memset(c->avg_2tap_qpel_pixels_tab, 0, sizeof(c->avg_2tap_qpel_pixels_tab));
4155
4653
 
4156
 
    if (ENABLE_MMX)      dsputil_init_mmx   (c, avctx);
4157
 
    if (ENABLE_ARMV4L)   dsputil_init_armv4l(c, avctx);
4158
 
    if (ENABLE_MLIB)     dsputil_init_mlib  (c, avctx);
4159
 
    if (ENABLE_VIS)      dsputil_init_vis   (c, avctx);
4160
 
    if (ENABLE_ALPHA)    dsputil_init_alpha (c, avctx);
4161
 
    if (ENABLE_POWERPC)  dsputil_init_ppc   (c, avctx);
4162
 
    if (ENABLE_MMI)      dsputil_init_mmi   (c, avctx);
4163
 
    if (ENABLE_SH4)      dsputil_init_sh4   (c, avctx);
4164
 
    if (ENABLE_BFIN)     dsputil_init_bfin  (c, avctx);
 
4654
    if (HAVE_MMX)        dsputil_init_mmx   (c, avctx);
 
4655
    if (ARCH_ARM)        dsputil_init_arm   (c, avctx);
 
4656
    if (CONFIG_MLIB)     dsputil_init_mlib  (c, avctx);
 
4657
    if (HAVE_VIS)        dsputil_init_vis   (c, avctx);
 
4658
    if (ARCH_ALPHA)      dsputil_init_alpha (c, avctx);
 
4659
    if (ARCH_PPC)        dsputil_init_ppc   (c, avctx);
 
4660
    if (HAVE_MMI)        dsputil_init_mmi   (c, avctx);
 
4661
    if (ARCH_SH4)        dsputil_init_sh4   (c, avctx);
 
4662
    if (ARCH_BFIN)       dsputil_init_bfin  (c, avctx);
4165
4663
 
4166
4664
    for(i=0; i<64; i++){
4167
4665
        if(!c->put_2tap_qpel_pixels_tab[0][i])
4191
4689
        for(i=0; i<64; i++)
4192
4690
            c->idct_permutation[i]= (i&0x24) | ((i&3)<<3) | ((i>>3)&3);
4193
4691
        break;
 
4692
    case FF_SSE2_IDCT_PERM:
 
4693
        for(i=0; i<64; i++)
 
4694
            c->idct_permutation[i]= (i&0x38) | idct_sse2_row_perm[i&7];
 
4695
        break;
4194
4696
    default:
4195
4697
        av_log(avctx, AV_LOG_ERROR, "Internal error, IDCT permutation not set\n");
4196
4698
    }