Mercurial > libavcodec.hg
annotate alpha/mpegvideo_alpha.c @ 4928:7ec5c2e20271 libavcodec
Move VC-1 data to .c file
author | kostya |
---|---|
date | Sun, 06 May 2007 11:23:12 +0000 |
parents | c8c591fe26f8 |
children | d5ba514e3f4a |
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 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
5 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
6 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
429 | 8 * modify it under the terms of the GNU Lesser General Public |
9 * License as published by the Free Software Foundation; either | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
10 * version 2.1 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
|
11 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
12 * FFmpeg 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
|
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
429 | 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 * 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
|
16 * |
429 | 17 * You should have received a copy of the GNU Lesser General Public |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3036
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
2967
diff
changeset
|
19 * 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
|
20 */ |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
21 |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
22 #include "asm.h" |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
23 #include "../dsputil.h" |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
24 #include "../mpegvideo.h" |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
25 |
1693 | 26 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
|
27 int n, int qscale) |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
28 { |
514
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
29 int i, n_coeffs; |
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
30 uint64_t qmul, qadd; |
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
31 uint64_t correction; |
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
32 DCTELEM *orig_block = block; |
2961 | 33 DCTELEM block0; /* might not be used uninitialized */ |
505
7a976bf93394
Ugly hack to make the assembler accept MVI instructions.
mellum
parents:
429
diff
changeset
|
34 |
732
bf4304c46cda
* Fix dct_unquantize_h263_axp for changed block_last_index indexing.
mellum
parents:
729
diff
changeset
|
35 qadd = WORD_VEC((qscale - 1) | 1); |
bf4304c46cda
* Fix dct_unquantize_h263_axp for changed block_last_index indexing.
mellum
parents:
729
diff
changeset
|
36 qmul = qscale << 1; |
2967 | 37 /* 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
|
38 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
|
39 |
1693 | 40 if (!s->h263_aic) { |
2967 | 41 if (n < 4) |
1693 | 42 block0 = block[0] * s->y_dc_scale; |
43 else | |
44 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
|
45 } else { |
1693 | 46 qadd = 0; |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
47 } |
2967 | 48 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
|
49 |
732
bf4304c46cda
* Fix dct_unquantize_h263_axp for changed block_last_index indexing.
mellum
parents:
729
diff
changeset
|
50 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
|
51 uint64_t levels, negmask, zeros, add; |
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
52 |
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
53 levels = ldq(block); |
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
54 if (levels == 0) |
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
55 continue; |
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
56 |
515
86f73263a61c
Make dct_unquantize_h263 work on systems without MVI extension.
mellum
parents:
514
diff
changeset
|
57 #ifdef __alpha_max__ |
86f73263a61c
Make dct_unquantize_h263 work on systems without MVI extension.
mellum
parents:
514
diff
changeset
|
58 /* 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
|
59 detection. */ |
514
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
60 negmask = maxsw4(levels, -1); /* negative -> ffff (-1) */ |
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
61 negmask = minsw4(negmask, 0); /* positive -> 0000 (0) */ |
515
86f73263a61c
Make dct_unquantize_h263 work on systems without MVI extension.
mellum
parents:
514
diff
changeset
|
62 #else |
86f73263a61c
Make dct_unquantize_h263 work on systems without MVI extension.
mellum
parents:
514
diff
changeset
|
63 negmask = cmpbge(WORD_VEC(0x7fff), levels); |
86f73263a61c
Make dct_unquantize_h263 work on systems without MVI extension.
mellum
parents:
514
diff
changeset
|
64 negmask &= (negmask >> 1) | (1 << 7); |
86f73263a61c
Make dct_unquantize_h263 work on systems without MVI extension.
mellum
parents:
514
diff
changeset
|
65 negmask = zap(-1, negmask); |
86f73263a61c
Make dct_unquantize_h263 work on systems without MVI extension.
mellum
parents:
514
diff
changeset
|
66 #endif |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
67 |
514
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
68 zeros = cmpbge(0, levels); |
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
69 zeros &= zeros >> 1; |
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
70 /* 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
|
71 zapping the lower byte suffices. */ |
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
72 |
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
73 levels *= qmul; |
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
74 levels -= correction & (negmask << 16); |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
75 |
514
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
76 /* Negate qadd for negative levels. */ |
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
77 add = qadd ^ negmask; |
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
78 add += WORD_VEC(0x0001) & negmask; |
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
79 /* Set qadd to 0 for levels == 0. */ |
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
80 add = zap(add, zeros); |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
81 |
514
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
82 levels += add; |
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 stq(levels, block); |
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
85 } |
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
86 |
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
87 if (s->mb_intra && !s->h263_aic) |
c9f724e3a797
Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents:
505
diff
changeset
|
88 orig_block[0] = block0; |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
89 } |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
90 |
1693 | 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; | |
2967 | 100 /* This mask kills spill from negative subwords to the next subword. */ |
1693 | 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 | |
214
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
143 void MPV_common_init_axp(MpegEncContext *s) |
73df666cacc7
Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff
changeset
|
144 { |
1693 | 145 s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_axp; |
146 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
|
147 } |