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

« back to all changes in this revision

Viewing changes to ffmpeg/libavcodec/sh4/dsputil_sh4.c

  • Committer: Bazaar Package Importer
  • Author(s): John Dong
  • Date: 2008-02-25 15:47:12 UTC
  • mfrom: (1.1.1 upstream)
  • Revision ID: james.westby@ubuntu.com-20080225154712-qvr11ekcea4c9ry8
Tags: 1.1.6-0.1ubuntu1
* Merge from debian-multimedia (LP: #120003), Ubuntu Changes:
 - For ffmpeg-related build-deps, remove cvs from package names.
 - Standards-Version 3.7.3
 - Maintainer Spec

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
 *
4
4
 * Copyright (c) 2003 BERO <bero@geocities.co.jp>
5
5
 *
6
 
 * This library is free software; you can redistribute it and/or
 
6
 * This file is part of FFmpeg.
 
7
 *
 
8
 * FFmpeg is free software; you can redistribute it and/or
7
9
 * modify it under the terms of the GNU Lesser General Public
8
10
 * License as published by the Free Software Foundation; either
9
 
 * version 2 of the License, or (at your option) any later version.
 
11
 * version 2.1 of the License, or (at your option) any later version.
10
12
 *
11
 
 * This library is distributed in the hope that it will be useful,
 
13
 * FFmpeg is distributed in the hope that it will be useful,
12
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
14
16
 * Lesser General Public License for more details.
15
17
 *
16
18
 * You should have received a copy of the GNU Lesser General Public
17
 
 * License along with this library; if not, write to the Free Software
18
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
19
 * License along with FFmpeg; if not, write to the Free Software
 
20
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19
21
 */
20
22
 
21
23
#include "../avcodec.h"
24
26
static void memzero_align8(void *dst,size_t size)
25
27
{
26
28
#if defined(__SH4__) || defined(__SH4_SINGLE__) || defined(__SH4_SINGLE_ONLY__)
27
 
        (char*)dst+=size;
28
 
        size/=8*4;
29
 
        asm(
 
29
        (char*)dst+=size;
 
30
        size/=8*4;
 
31
        asm(
30
32
#if defined(__SH4__)
31
 
        " fschg\n"  //single float mode
 
33
        " fschg\n"  //single float mode
32
34
#endif
33
 
        " fldi0 fr0\n"
34
 
        " fldi0 fr1\n"
35
 
        " fschg\n"  // double
36
 
        "1: \n" \
37
 
        " dt %1\n"
38
 
        " fmov  dr0,@-%0\n"
39
 
        " fmov  dr0,@-%0\n"
40
 
        " fmov  dr0,@-%0\n"
41
 
        " bf.s 1b\n"
42
 
        " fmov  dr0,@-%0\n"
 
35
        " fldi0 fr0\n"
 
36
        " fldi0 fr1\n"
 
37
        " fschg\n"  // double
 
38
        "1: \n" \
 
39
        " dt %1\n"
 
40
        " fmov  dr0,@-%0\n"
 
41
        " fmov  dr0,@-%0\n"
 
42
        " fmov  dr0,@-%0\n"
 
43
        " bf.s 1b\n"
 
44
        " fmov  dr0,@-%0\n"
43
45
#if defined(__SH4_SINGLE__) || defined(__SH4_SINGLE_ONLY__)
44
 
        " fschg" //back to single
 
46
        " fschg" //back to single
45
47
#endif
46
 
        : : "r"(dst),"r"(size): "memory" );
 
48
        : : "r"(dst),"r"(size): "memory" );
47
49
#else
48
 
        double *d = dst;
49
 
        size/=8*4;
50
 
        do {
51
 
                d[0] = 0.0;
52
 
                d[1] = 0.0;
53
 
                d[2] = 0.0;
54
 
                d[3] = 0.0;
55
 
                d+=4;
56
 
        } while(--size);
 
50
        double *d = dst;
 
51
        size/=8*4;
 
52
        do {
 
53
                d[0] = 0.0;
 
54
                d[1] = 0.0;
 
55
                d[2] = 0.0;
 
56
                d[3] = 0.0;
 
57
                d+=4;
 
58
        } while(--size);
57
59
#endif
58
60
}
59
61
 
60
62
static void clear_blocks_sh4(DCTELEM *blocks)
61
63
{
62
 
//      if (((int)blocks&7)==0) 
63
 
        memzero_align8(blocks,sizeof(DCTELEM)*6*64);
 
64
//        if (((int)blocks&7)==0)
 
65
        memzero_align8(blocks,sizeof(DCTELEM)*6*64);
64
66
}
65
67
 
66
68
extern void idct_sh4(DCTELEM *block);
67
69
static void idct_put(uint8_t *dest, int line_size, DCTELEM *block)
68
70
{
69
 
        idct_sh4(block);
70
 
        int i;
71
 
        uint8_t *cm = cropTbl + MAX_NEG_CROP;
72
 
        for(i=0;i<8;i++) {
73
 
                dest[0] = cm[block[0]];
74
 
                dest[1] = cm[block[1]];
75
 
                dest[2] = cm[block[2]];
76
 
                dest[3] = cm[block[3]];
77
 
                dest[4] = cm[block[4]];
78
 
                dest[5] = cm[block[5]];
79
 
                dest[6] = cm[block[6]];
80
 
                dest[7] = cm[block[7]];
81
 
                dest+=line_size;
82
 
                block+=8;
83
 
        }
 
71
        idct_sh4(block);
 
72
        int i;
 
73
        uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
 
74
        for(i=0;i<8;i++) {
 
75
                dest[0] = cm[block[0]];
 
76
                dest[1] = cm[block[1]];
 
77
                dest[2] = cm[block[2]];
 
78
                dest[3] = cm[block[3]];
 
79
                dest[4] = cm[block[4]];
 
80
                dest[5] = cm[block[5]];
 
81
                dest[6] = cm[block[6]];
 
82
                dest[7] = cm[block[7]];
 
83
                dest+=line_size;
 
84
                block+=8;
 
85
        }
84
86
}
85
87
static void idct_add(uint8_t *dest, int line_size, DCTELEM *block)
86
88
{
87
 
        idct_sh4(block);
88
 
        int i;
89
 
        uint8_t *cm = cropTbl + MAX_NEG_CROP;
90
 
        for(i=0;i<8;i++) {
91
 
                dest[0] = cm[dest[0]+block[0]];
92
 
                dest[1] = cm[dest[1]+block[1]];
93
 
                dest[2] = cm[dest[2]+block[2]];
94
 
                dest[3] = cm[dest[3]+block[3]];
95
 
                dest[4] = cm[dest[4]+block[4]];
96
 
                dest[5] = cm[dest[5]+block[5]];
97
 
                dest[6] = cm[dest[6]+block[6]];
98
 
                dest[7] = cm[dest[7]+block[7]];
99
 
                dest+=line_size;
100
 
                block+=8;
101
 
        }
 
89
        idct_sh4(block);
 
90
        int i;
 
91
        uint8_t *cm = ff_cropTbl + MAX_NEG_CROP;
 
92
        for(i=0;i<8;i++) {
 
93
                dest[0] = cm[dest[0]+block[0]];
 
94
                dest[1] = cm[dest[1]+block[1]];
 
95
                dest[2] = cm[dest[2]+block[2]];
 
96
                dest[3] = cm[dest[3]+block[3]];
 
97
                dest[4] = cm[dest[4]+block[4]];
 
98
                dest[5] = cm[dest[5]+block[5]];
 
99
                dest[6] = cm[dest[6]+block[6]];
 
100
                dest[7] = cm[dest[7]+block[7]];
 
101
                dest+=line_size;
 
102
                block+=8;
 
103
        }
102
104
}
103
105
 
104
106
extern void dsputil_init_align(DSPContext* c, AVCodecContext *avctx);
105
107
 
106
108
void dsputil_init_sh4(DSPContext* c, AVCodecContext *avctx)
107
109
{
108
 
        const int idct_algo= avctx->idct_algo;
109
 
        dsputil_init_align(c,avctx);
 
110
        const int idct_algo= avctx->idct_algo;
 
111
        dsputil_init_align(c,avctx);
110
112
 
111
 
        c->clear_blocks = clear_blocks_sh4;
112
 
        if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SH4){        
113
 
                c->idct_put = idct_put;
114
 
                c->idct_add = idct_add;
 
113
        c->clear_blocks = clear_blocks_sh4;
 
114
        if(idct_algo==FF_IDCT_AUTO || idct_algo==FF_IDCT_SH4){
 
115
                c->idct_put = idct_put;
 
116
                c->idct_add = idct_add;
115
117
               c->idct     = idct_sh4;
116
 
                c->idct_permutation_type= FF_NO_IDCT_PERM; //FF_SIMPLE_IDCT_PERM; //FF_LIBMPEG2_IDCT_PERM;
117
 
        }
 
118
                c->idct_permutation_type= FF_NO_IDCT_PERM; //FF_SIMPLE_IDCT_PERM; //FF_LIBMPEG2_IDCT_PERM;
 
119
        }
118
120
}