annotate alpha/mpegvideo_alpha.c @ 514:c9f724e3a797 libavcodec

Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd for some improvements.
author mellum
date Wed, 03 Jul 2002 03:01:06 +0000
parents 7a976bf93394
children 86f73263a61c
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
718a22dc121f license/copyright change
glantau
parents: 214
diff changeset
17 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
24 extern UINT8 zigzag_end[64];
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
25
514
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
26 static void dct_unquantize_h263_mvi(MpegEncContext *s, DCTELEM *block,
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;
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
33 DCTELEM block0;
505
7a976bf93394 Ugly hack to make the assembler accept MVI instructions.
mellum
parents: 429
diff changeset
34
7a976bf93394 Ugly hack to make the assembler accept MVI instructions.
mellum
parents: 429
diff changeset
35 ASM_ACCEPT_MVI;
514
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
36
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
37 if (s->mb_intra) {
514
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
38 if (!s->h263_aic) {
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
39 if (n < 4)
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
40 block0 = block[0] * s->y_dc_scale;
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
41 else
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
42 block0 = block[0] * s->c_dc_scale;
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
43 }
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
44 n_coeffs = 64; // does not always use zigzag table
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
45 } else {
514
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
46 n_coeffs = zigzag_end[s->block_last_index[n]];
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
47 }
514
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
48
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
49 qmul = qscale << 1;
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
50 qadd = WORD_VEC((qscale - 1) | 1);
514
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
51 /* This mask kills spill from negative subwords to the next subword. */
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
52 correction = WORD_VEC((qmul - 1) + 1); /* multiplication / addition */
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
53
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
54 for(i = 0; i < n_coeffs; block += 4, i += 4) {
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
55 uint64_t levels, negmask, zeros, add;
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
56
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
57 levels = ldq(block);
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
58 if (levels == 0)
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
59 continue;
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
60
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
61 negmask = maxsw4(levels, -1); /* negative -> ffff (-1) */
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
62 negmask = minsw4(negmask, 0); /* positive -> 0000 (0) */
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
63
514
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
64 zeros = cmpbge(0, levels);
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
65 zeros &= zeros >> 1;
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
66 /* 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
67 zapping the lower byte suffices. */
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
68
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
69 levels *= qmul;
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
70 levels -= correction & (negmask << 16);
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
71
514
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
72 /* Negate qadd for negative levels. */
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
73 add = qadd ^ negmask;
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
74 add += WORD_VEC(0x0001) & negmask;
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
75 /* Set qadd to 0 for levels == 0. */
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
76 add = zap(add, zeros);
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
77
514
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
78 levels += add;
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
79
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
80 stq(levels, block);
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
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
83 if (s->mb_intra && !s->h263_aic)
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
84 orig_block[0] = block0;
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
85 }
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
86
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
87 void MPV_common_init_axp(MpegEncContext *s)
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
88 {
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
89 if (amask(AMASK_MVI) == 0) {
514
c9f724e3a797 Update and activate dct_unquantize_h263_mvi. Thanks to Mns Rullgrd
mellum
parents: 505
diff changeset
90 s->dct_unquantize_h263 = dct_unquantize_h263_mvi;
214
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
91 }
73df666cacc7 Alpha optimizations by Falk Hueffner <falk.hueffner@student.uni-tuebingen.de>
nickols_k
parents:
diff changeset
92 }