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

« back to all changes in this revision

Viewing changes to ffmpeg/libavcodec/alpha/mpegvideo_alpha.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:
2
2
 * Alpha optimized DSP utils
3
3
 * Copyright (c) 2002 Falk Hueffner <falk@debian.org>
4
4
 *
5
 
 * This library is free software; you can redistribute it and/or
 
5
 * This file is part of FFmpeg.
 
6
 *
 
7
 * FFmpeg is free software; you can redistribute it and/or
6
8
 * modify it under the terms of the GNU Lesser General Public
7
9
 * License as published by the Free Software Foundation; either
8
 
 * version 2 of the License, or (at your option) any later version.
 
10
 * version 2.1 of the License, or (at your option) any later version.
9
11
 *
10
 
 * This library is distributed in the hope that it will be useful,
 
12
 * FFmpeg is distributed in the hope that it will be useful,
11
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
15
 * Lesser General Public License for more details.
14
16
 *
15
17
 * You should have received a copy of the GNU Lesser General Public
16
 
 * License along with this library; if not, write to the Free Software
17
 
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 
18
 * License along with FFmpeg; if not, write to the Free Software
 
19
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
20
 */
19
21
 
20
22
#include "asm.h"
21
23
#include "../dsputil.h"
22
24
#include "../mpegvideo.h"
23
25
 
24
 
static void dct_unquantize_h263_axp(MpegEncContext *s, DCTELEM *block,
 
26
static void dct_unquantize_h263_intra_axp(MpegEncContext *s, DCTELEM *block,
25
27
                                    int n, int qscale)
26
28
{
27
29
    int i, n_coeffs;
28
30
    uint64_t qmul, qadd;
29
31
    uint64_t correction;
30
32
    DCTELEM *orig_block = block;
31
 
    DCTELEM block0;
 
33
    DCTELEM block0;             /* might not be used uninitialized */
32
34
 
33
35
    qadd = WORD_VEC((qscale - 1) | 1);
34
36
    qmul = qscale << 1;
35
 
    /* This mask kills spill from negative subwords to the next subword.  */ 
 
37
    /* This mask kills spill from negative subwords to the next subword.  */
36
38
    correction = WORD_VEC((qmul - 1) + 1); /* multiplication / addition */
37
39
 
38
 
    if (s->mb_intra) {
39
 
        if (!s->h263_aic) {
40
 
            if (n < 4) 
41
 
                block0 = block[0] * s->y_dc_scale;
42
 
            else
43
 
                block0 = block[0] * s->c_dc_scale;
44
 
        } else {
45
 
            qadd = 0;
46
 
        }
47
 
        n_coeffs = 63; // does not always use zigzag table 
 
40
    if (!s->h263_aic) {
 
41
        if (n < 4)
 
42
            block0 = block[0] * s->y_dc_scale;
 
43
        else
 
44
            block0 = block[0] * s->c_dc_scale;
48
45
    } else {
49
 
        n_coeffs = s->intra_scantable.raster_end[s->block_last_index[n]];
 
46
        qadd = 0;
50
47
    }
 
48
    n_coeffs = 63; // does not always use zigzag table
51
49
 
52
50
    for(i = 0; i <= n_coeffs; block += 4, i += 4) {
53
51
        uint64_t levels, negmask, zeros, add;
90
88
        orig_block[0] = block0;
91
89
}
92
90
 
 
91
static void dct_unquantize_h263_inter_axp(MpegEncContext *s, DCTELEM *block,
 
92
                                    int n, int qscale)
 
93
{
 
94
    int i, n_coeffs;
 
95
    uint64_t qmul, qadd;
 
96
    uint64_t correction;
 
97
 
 
98
    qadd = WORD_VEC((qscale - 1) | 1);
 
99
    qmul = qscale << 1;
 
100
    /* This mask kills spill from negative subwords to the next subword.  */
 
101
    correction = WORD_VEC((qmul - 1) + 1); /* multiplication / addition */
 
102
 
 
103
    n_coeffs = s->intra_scantable.raster_end[s->block_last_index[n]];
 
104
 
 
105
    for(i = 0; i <= n_coeffs; block += 4, i += 4) {
 
106
        uint64_t levels, negmask, zeros, add;
 
107
 
 
108
        levels = ldq(block);
 
109
        if (levels == 0)
 
110
            continue;
 
111
 
 
112
#ifdef __alpha_max__
 
113
        /* I don't think the speed difference justifies runtime
 
114
           detection.  */
 
115
        negmask = maxsw4(levels, -1); /* negative -> ffff (-1) */
 
116
        negmask = minsw4(negmask, 0); /* positive -> 0000 (0) */
 
117
#else
 
118
        negmask = cmpbge(WORD_VEC(0x7fff), levels);
 
119
        negmask &= (negmask >> 1) | (1 << 7);
 
120
        negmask = zap(-1, negmask);
 
121
#endif
 
122
 
 
123
        zeros = cmpbge(0, levels);
 
124
        zeros &= zeros >> 1;
 
125
        /* zeros |= zeros << 1 is not needed since qadd <= 255, so
 
126
           zapping the lower byte suffices.  */
 
127
 
 
128
        levels *= qmul;
 
129
        levels -= correction & (negmask << 16);
 
130
 
 
131
        /* Negate qadd for negative levels.  */
 
132
        add = qadd ^ negmask;
 
133
        add += WORD_VEC(0x0001) & negmask;
 
134
        /* Set qadd to 0 for levels == 0.  */
 
135
        add = zap(add, zeros);
 
136
 
 
137
        levels += add;
 
138
 
 
139
        stq(levels, block);
 
140
    }
 
141
}
 
142
 
93
143
void MPV_common_init_axp(MpegEncContext *s)
94
144
{
95
 
    s->dct_unquantize_h263 = dct_unquantize_h263_axp;
 
145
    s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_axp;
 
146
    s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_axp;
96
147
}