Statistics
| Branch: | Revision:

ffmpeg / libavcodec / alpha / mpegvideo_alpha.c @ 46b4feec

History | View | Annotate | Download (2.95 KB)

1 1e98dffb Nick Kurshev
/*
2
 * Alpha optimized DSP utils
3
 * Copyright (c) 2002 Falk Hueffner <falk@debian.org>
4
 *
5 ff4ec49e Fabrice Bellard
 * This library is free software; you can redistribute it and/or
6
 * modify it under the terms of the GNU Lesser General Public
7
 * License as published by the Free Software Foundation; either
8
 * version 2 of the License, or (at your option) any later version.
9 1e98dffb Nick Kurshev
 *
10 ff4ec49e Fabrice Bellard
 * This library is distributed in the hope that it will be useful,
11 1e98dffb Nick Kurshev
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 ff4ec49e Fabrice Bellard
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
13
 * Lesser General Public License for more details.
14 1e98dffb Nick Kurshev
 *
15 ff4ec49e Fabrice Bellard
 * 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 1e98dffb Nick Kurshev
 */
19
20
#include "asm.h"
21
#include "../dsputil.h"
22
#include "../mpegvideo.h"
23
24 2dbe7ec8 Falk Hüffner
static void dct_unquantize_h263_axp(MpegEncContext *s, DCTELEM *block,
25 e0580f8c Falk Hüffner
                                    int n, int qscale)
26 1e98dffb Nick Kurshev
{
27 e0580f8c Falk Hüffner
    int i, n_coeffs;
28
    uint64_t qmul, qadd;
29
    uint64_t correction;
30
    DCTELEM *orig_block = block;
31
    DCTELEM block0;
32 db42e13b Falk Hüffner
33 acd2e05c Falk Hüffner
    qadd = WORD_VEC((qscale - 1) | 1);
34
    qmul = qscale << 1;
35
    /* This mask kills spill from negative subwords to the next subword.  */ 
36
    correction = WORD_VEC((qmul - 1) + 1); /* multiplication / addition */
37
38 1e98dffb Nick Kurshev
    if (s->mb_intra) {
39 e0580f8c Falk Hüffner
        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 acd2e05c Falk Hüffner
        } else {
45
            qadd = 0;
46
        }
47
        n_coeffs = 63; // does not always use zigzag table 
48 1e98dffb Nick Kurshev
    } else {
49 6c383066 Falk Hüffner
        n_coeffs = s->intra_scantable.raster_end[s->block_last_index[n]];
50 1e98dffb Nick Kurshev
    }
51 e0580f8c Falk Hüffner
52 acd2e05c Falk Hüffner
    for(i = 0; i <= n_coeffs; block += 4, i += 4) {
53 e0580f8c Falk Hüffner
        uint64_t levels, negmask, zeros, add;
54
55
        levels = ldq(block);
56
        if (levels == 0)
57
            continue;
58
59 2dbe7ec8 Falk Hüffner
#ifdef __alpha_max__
60
        /* I don't think the speed difference justifies runtime
61
           detection.  */
62
        ASM_ACCEPT_MVI;
63 e0580f8c Falk Hüffner
        negmask = maxsw4(levels, -1); /* negative -> ffff (-1) */
64
        negmask = minsw4(negmask, 0); /* positive -> 0000 (0) */
65 2dbe7ec8 Falk Hüffner
#else
66
        negmask = cmpbge(WORD_VEC(0x7fff), levels);
67
        negmask &= (negmask >> 1) | (1 << 7);
68
        negmask = zap(-1, negmask);
69
#endif
70 e0580f8c Falk Hüffner
71
        zeros = cmpbge(0, levels);
72
        zeros &= zeros >> 1;
73
        /* zeros |= zeros << 1 is not needed since qadd <= 255, so
74
           zapping the lower byte suffices.  */
75
76
        levels *= qmul;
77
        levels -= correction & (negmask << 16);
78
79
        /* Negate qadd for negative levels.  */
80
        add = qadd ^ negmask;
81
        add += WORD_VEC(0x0001) & negmask;
82
        /* Set qadd to 0 for levels == 0.  */
83
        add = zap(add, zeros);
84
85
        levels += add;
86
87
        stq(levels, block);
88
    }
89
90
    if (s->mb_intra && !s->h263_aic)
91
        orig_block[0] = block0;
92 1e98dffb Nick Kurshev
}
93
94
void MPV_common_init_axp(MpegEncContext *s)
95
{
96 acd2e05c Falk Hüffner
    s->dct_unquantize_h263 = dct_unquantize_h263_axp;
97 1e98dffb Nick Kurshev
}