Use updated motion compensation routines.
[libav.git] / libavcodec / alpha / mpegvideo_alpha.c
CommitLineData
1e98dffb
NK
1/*
2 * Alpha optimized DSP utils
3 * Copyright (c) 2002 Falk Hueffner <falk@debian.org>
4 *
ff4ec49e
FB
5 * 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.
1e98dffb 9 *
ff4ec49e 10 * This library is distributed in the hope that it will be useful,
1e98dffb 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
ff4ec49e
FB
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
1e98dffb 14 *
ff4ec49e
FB
15 * 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
1e98dffb
NK
18 */
19
20#include "asm.h"
21#include "../dsputil.h"
22#include "../mpegvideo.h"
23
24extern UINT8 zigzag_end[64];
25
26static void dct_unquantize_h263_axp(MpegEncContext *s,
27 DCTELEM *block, int n, int qscale)
28{
29 int i, level;
30 UINT64 qmul, qadd;
db42e13b
FH
31
32 ASM_ACCEPT_MVI;
33
1e98dffb
NK
34 if (s->mb_intra) {
35 if (n < 4)
36 block[0] = block[0] * s->y_dc_scale;
37 else
38 block[0] = block[0] * s->c_dc_scale;
39 /* Catch up to aligned point. */
40 qmul = s->qscale << 1;
41 qadd = (s->qscale - 1) | 1;
42 for (i = 1; i < 4; ++i) {
43 level = block[i];
44 if (level) {
45 if (level < 0) {
46 level = level * qmul - qadd;
47 } else {
48 level = level * qmul + qadd;
49 }
50 block[i] = level;
51 }
52 }
53 block += 4;
54 i = 60 / 4;
55 } else {
56 i = zigzag_end[s->block_last_index[n]] / 4;
57 }
58 qmul = s->qscale << 1;
59 qadd = WORD_VEC((qscale - 1) | 1);
60 do {
61 UINT64 levels, negmask, zeromask, corr;
62 levels = ldq(block);
63 if (levels == 0)
64 continue;
65 zeromask = cmpbge(0, levels);
66 zeromask &= zeromask >> 1;
67 /* Negate all negative words. */
68 negmask = maxsw4(levels, WORD_VEC(0xffff)); /* negative -> ffff (-1) */
69 negmask = minsw4(negmask, 0); /* positive -> 0000 (0) */
70 corr = negmask & WORD_VEC(0x0001); /* twos-complement correction */
71 levels ^= negmask;
72 levels += corr;
73
74 levels = levels * qmul;
75 levels += zap(qadd, zeromask);
76
77 /* Re-negate negative words. */
78 levels -= corr;
79 levels ^= negmask;
80
81 stq(levels, block);
82 } while (block += 4, --i);
83}
84
85void MPV_common_init_axp(MpegEncContext *s)
86{
87 if (amask(AMASK_MVI) == 0) {
88 if (s->out_format == FMT_H263)
89 s->dct_unquantize = dct_unquantize_h263_axp;
90 }
91}