annotate alpha/mpegvideo_alpha.c @ 3153:7aa01243b4d3 libavcodec

use vec_splat_u32 to initialise a v16ui (patch by Likai Liu < liulk _at_ cs.bu.edu >)
author aurel
date Tue, 28 Feb 2006 21:55:18 +0000
parents 0b546eab515d
children c8c591fe26f8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
1 /*
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
2 * Alpha optimized DSP utils
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
3 * Copyright (c) 2002 Falk Hueffner <falk@debian.org>
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
4 *
429
718a22dc121f license/copyright change
glantau
parents: 214
diff changeset
5 * This library is free software; you can redistribute it and/or
718a22dc121f license/copyright change
glantau
parents: 214
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
718a22dc121f license/copyright change
glantau
parents: 214
diff changeset
7 * License as published by the Free Software Foundation; either
718a22dc121f license/copyright change
glantau
parents: 214
diff changeset
8 * version 2 of the License, or (at your option) any later version.
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
9 *
429
718a22dc121f license/copyright change
glantau
parents: 214
diff changeset
10 * This library is distributed in the hope that it will be useful,
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
429
718a22dc121f license/copyright change
glantau
parents: 214
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
718a22dc121f license/copyright change
glantau
parents: 214
diff changeset
13 * Lesser General Public License for more details.
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
14 *
429
718a22dc121f license/copyright change
glantau
parents: 214
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
718a22dc121f license/copyright change
glantau
parents: 214
diff changeset
16 * License along with this library; if not, write to the Free Software
3036
0b546eab515d Update licensing information: The FSF changed postal address.
diego
parents: 2967
diff changeset
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
18 */
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
19
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
20 #include "asm.h"
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
21 #include "../dsputil.h"
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
22 #include "../mpegvideo.h"
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
23
1693
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
24 static void dct_unquantize_h263_intra_axp(MpegEncContext *s, DCTELEM *block,
514
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
25 int n, int qscale)
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
26 {
514
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
27 int i, n_coeffs;
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
28 uint64_t qmul, qadd;
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
29 uint64_t correction;
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
30 DCTELEM *orig_block = block;
2961
dc544c0e6220 remove unused variables
mru
parents: 1693
diff changeset
31 DCTELEM block0; /* might not be used uninitialized */
505
7a976bf93394 Ugly hack to make the assembler accept MVI instructions.
mellum
parents: 429
diff changeset
32
732
bf4304c46cda * Fix dct_unquantize_h263_axp for changed block_last_index indexing.
mellum
parents: 729
diff changeset
33 qadd = WORD_VEC((qscale - 1) | 1);
bf4304c46cda * Fix dct_unquantize_h263_axp for changed block_last_index indexing.
mellum
parents: 729
diff changeset
34 qmul = qscale << 1;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2961
diff changeset
35 /* This mask kills spill from negative subwords to the next subword. */
732
bf4304c46cda * Fix dct_unquantize_h263_axp for changed block_last_index indexing.
mellum
parents: 729
diff changeset
36 correction = WORD_VEC((qmul - 1) + 1); /* multiplication / addition */
bf4304c46cda * Fix dct_unquantize_h263_axp for changed block_last_index indexing.
mellum
parents: 729
diff changeset
37
1693
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
38 if (!s->h263_aic) {
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2961
diff changeset
39 if (n < 4)
1693
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
40 block0 = block[0] * s->y_dc_scale;
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
41 else
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
42 block0 = block[0] * s->c_dc_scale;
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
43 } else {
1693
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
44 qadd = 0;
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
45 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2961
diff changeset
46 n_coeffs = 63; // does not always use zigzag table
514
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
47
732
bf4304c46cda * Fix dct_unquantize_h263_axp for changed block_last_index indexing.
mellum
parents: 729
diff changeset
48 for(i = 0; i <= n_coeffs; block += 4, i += 4) {
514
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
49 uint64_t levels, negmask, zeros, add;
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
50
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
51 levels = ldq(block);
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
52 if (levels == 0)
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
53 continue;
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
54
515
86f73263a61c Make dct_unquantize_h263 work on systems without MVI extension.
mellum
parents: 514
diff changeset
55 #ifdef __alpha_max__
86f73263a61c Make dct_unquantize_h263 work on systems without MVI extension.
mellum
parents: 514
diff changeset
56 /* I don't think the speed difference justifies runtime
86f73263a61c Make dct_unquantize_h263 work on systems without MVI extension.
mellum
parents: 514
diff changeset
57 detection. */
514
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
58 negmask = maxsw4(levels, -1); /* negative -> ffff (-1) */
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
59 negmask = minsw4(negmask, 0); /* positive -> 0000 (0) */
515
86f73263a61c Make dct_unquantize_h263 work on systems without MVI extension.
mellum
parents: 514
diff changeset
60 #else
86f73263a61c Make dct_unquantize_h263 work on systems without MVI extension.
mellum
parents: 514
diff changeset
61 negmask = cmpbge(WORD_VEC(0x7fff), levels);
86f73263a61c Make dct_unquantize_h263 work on systems without MVI extension.
mellum
parents: 514
diff changeset
62 negmask &= (negmask >> 1) | (1 << 7);
86f73263a61c Make dct_unquantize_h263 work on systems without MVI extension.
mellum
parents: 514
diff changeset
63 negmask = zap(-1, negmask);
86f73263a61c Make dct_unquantize_h263 work on systems without MVI extension.
mellum
parents: 514
diff changeset
64 #endif
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
65
514
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
66 zeros = cmpbge(0, levels);
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
67 zeros &= zeros >> 1;
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
68 /* zeros |= zeros << 1 is not needed since qadd <= 255, so
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
69 zapping the lower byte suffices. */
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
70
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
71 levels *= qmul;
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
72 levels -= correction & (negmask << 16);
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
73
514
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
74 /* Negate qadd for negative levels. */
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
75 add = qadd ^ negmask;
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
76 add += WORD_VEC(0x0001) & negmask;
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
77 /* Set qadd to 0 for levels == 0. */
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
78 add = zap(add, zeros);
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
79
514
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
80 levels += add;
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
81
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
82 stq(levels, block);
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
83 }
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
84
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
85 if (s->mb_intra && !s->h263_aic)
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
86 orig_block[0] = block0;
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
87 }
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
88
1693
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
89 static void dct_unquantize_h263_inter_axp(MpegEncContext *s, DCTELEM *block,
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
90 int n, int qscale)
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
91 {
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
92 int i, n_coeffs;
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
93 uint64_t qmul, qadd;
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
94 uint64_t correction;
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
95
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
96 qadd = WORD_VEC((qscale - 1) | 1);
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
97 qmul = qscale << 1;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2961
diff changeset
98 /* This mask kills spill from negative subwords to the next subword. */
1693
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
99 correction = WORD_VEC((qmul - 1) + 1); /* multiplication / addition */
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
100
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
101 n_coeffs = s->intra_scantable.raster_end[s->block_last_index[n]];
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
102
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
103 for(i = 0; i <= n_coeffs; block += 4, i += 4) {
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
104 uint64_t levels, negmask, zeros, add;
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
105
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
106 levels = ldq(block);
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
107 if (levels == 0)
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
108 continue;
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
109
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
110 #ifdef __alpha_max__
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
111 /* I don't think the speed difference justifies runtime
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
112 detection. */
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
113 negmask = maxsw4(levels, -1); /* negative -> ffff (-1) */
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
114 negmask = minsw4(negmask, 0); /* positive -> 0000 (0) */
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
115 #else
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
116 negmask = cmpbge(WORD_VEC(0x7fff), levels);
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
117 negmask &= (negmask >> 1) | (1 << 7);
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
118 negmask = zap(-1, negmask);
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
119 #endif
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
120
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
121 zeros = cmpbge(0, levels);
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
122 zeros &= zeros >> 1;
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
123 /* zeros |= zeros << 1 is not needed since qadd <= 255, so
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
124 zapping the lower byte suffices. */
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
125
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
126 levels *= qmul;
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
127 levels -= correction & (negmask << 16);
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
128
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
129 /* Negate qadd for negative levels. */
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
130 add = qadd ^ negmask;
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
131 add += WORD_VEC(0x0001) & negmask;
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
132 /* Set qadd to 0 for levels == 0. */
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
133 add = zap(add, zeros);
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
134
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
135 levels += add;
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
136
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
137 stq(levels, block);
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
138 }
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
139 }
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
140
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
141 void MPV_common_init_axp(MpegEncContext *s)
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
142 {
1693
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
143 s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_axp;
61cebcb5a997 100l (forgot alpha & ppc)
michael
parents: 1465
diff changeset
144 s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_axp;
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
145 }