Revision 1e98dffb libavcodec/simple_idct.c

View differences:

libavcodec/simple_idct.c
23 23
#include <inttypes.h>
24 24

  
25 25
#include "simple_idct.h"
26
#include "../config.h"
26 27

  
27 28
#if 0
28 29
#define W1 2841 /* 2048*sqrt (2)*cos (1*pi/16) */
......
102 103
	return 1;
103 104
}
104 105

  
106
#ifdef ARCH_ALPHA
107
static int inline idctRowCondDC(int16_t *row)
108
{
109
	int_fast32_t a0, a1, a2, a3, b0, b1, b2, b3;
110
	uint64_t *lrow = (uint64_t *) row;
111

  
112
	if (lrow[1] == 0) {
113
		if (lrow[0] == 0)
114
			return 0;
115
		if ((lrow[0] & ~0xffffULL) == 0) {
116
			uint64_t v;
117

  
118
			a0 = W4 * row[0];
119
			a0 += 1 << (ROW_SHIFT - 1);
120
			a0 >>= ROW_SHIFT;
121
			v = (uint16_t) a0;
122
			v += v << 16;
123
			v += v << 32;
124
			lrow[0] = v;
125
			lrow[1] = v;
126

  
127
			return 1;
128
		}
129
	}
130

  
131
	a0 = W4 * row[0];
132
	a1 = W4 * row[0];
133
	a2 = W4 * row[0];
134
	a3 = W4 * row[0];
135

  
136
	if (row[2]) {
137
		a0 += W2 * row[2];
138
		a1 += W6 * row[2];
139
		a2 -= W6 * row[2];
140
		a3 -= W2 * row[2];
141
	}
142

  
143
	if (row[4]) {
144
		a0 += W4 * row[4];
145
		a1 -= W4 * row[4];
146
		a2 -= W4 * row[4];
147
		a3 += W4 * row[4];
148
	}
149

  
150
	if (row[6]) {
151
		a0 += W6 * row[6];
152
		a1 -= W2 * row[6];
153
		a2 += W2 * row[6];
154
		a3 -= W6 * row[6];
155
	}
156

  
157
	a0 += 1 << (ROW_SHIFT - 1);
158
	a1 += 1 << (ROW_SHIFT - 1);
159
	a2 += 1 << (ROW_SHIFT - 1);
160
	a3 += 1 << (ROW_SHIFT - 1);
161

  
162
	if (row[1]) {
163
		b0 = W1 * row[1];
164
		b1 = W3 * row[1];
165
		b2 = W5 * row[1];
166
		b3 = W7 * row[1];
167
	} else {
168
		b0 = 0;
169
		b1 = 0;
170
		b2 = 0;
171
		b3 = 0;
172
	}
173

  
174
	if (row[3]) {
175
		b0 += W3 * row[3];
176
		b1 -= W7 * row[3];
177
		b2 -= W1 * row[3];
178
		b3 -= W5 * row[3];
179
	}
180

  
181
	if (row[5]) {
182
		b0 += W5 * row[5];
183
		b1 -= W1 * row[5];
184
		b2 += W7 * row[5];
185
		b3 += W3 * row[5];
186
	}
187

  
188
	if (row[7]) {
189
		b0 += W7 * row[7];
190
		b1 -= W5 * row[7];
191
		b2 += W3 * row[7];
192
		b3 -= W1 * row[7];
193
	}
194

  
195
	row[0] = (a0 + b0) >> ROW_SHIFT;
196
	row[1] = (a1 + b1) >> ROW_SHIFT;
197
	row[2] = (a2 + b2) >> ROW_SHIFT;
198
	row[3] = (a3 + b3) >> ROW_SHIFT;
199
	row[4] = (a3 - b3) >> ROW_SHIFT;
200
	row[5] = (a2 - b2) >> ROW_SHIFT;
201
	row[6] = (a1 - b1) >> ROW_SHIFT;
202
	row[7] = (a0 - b0) >> ROW_SHIFT;
203

  
204
	return 1;
205
}
206
#else  /* not ARCH_ALPHA */
105 207
static int inline idctRowCondDC (int16_t * row)
106 208
{
107 209
	int a0, a1, a2, a3, b0, b1, b2, b3;
......
147 249
	
148 250
	return 1;
149 251
}
252
#endif /* not ARCH_ALPHA */
150 253

  
151 254
static void inline idctCol (int16_t * col)
152 255
{
......
243 346
		b3 += - W1*col[8*7];
244 347
	}
245 348

  
349
#ifndef ARCH_ALPHA
246 350
	if(!(b0|b1|b2|b3)){
247 351
		col[8*0] = (a0) >> COL_SHIFT;
248 352
		col[8*7] = (a0) >> COL_SHIFT;
......
253 357
		col[8*3] = (a3) >> COL_SHIFT;
254 358
		col[8*4] = (a3) >> COL_SHIFT;
255 359
	}else{
360
#endif
256 361
		col[8*0] = (a0 + b0) >> COL_SHIFT;
257 362
		col[8*7] = (a0 - b0) >> COL_SHIFT;
258 363
		col[8*1] = (a1 + b1) >> COL_SHIFT;
......
261 366
		col[8*5] = (a2 - b2) >> COL_SHIFT;
262 367
		col[8*3] = (a3 + b3) >> COL_SHIFT;
263 368
		col[8*4] = (a3 - b3) >> COL_SHIFT;
369
#ifndef ARCH_ALPHA
264 370
	}
371
#endif
265 372
}
266 373

  
267 374
static void inline idctSparse2Col (int16_t * col)
......
337 444
	col[8*4] = (a3 - b3) >> COL_SHIFT;
338 445
}
339 446

  
447
#ifdef ARCH_ALPHA
448
/* If all rows but the first one are zero after row transformation,
449
   all rows will be identical after column transformation.  */
450
static inline void idctCol2(int16_t *col)
451
{
452
	int i;
453
	uint64_t l, r;
454
	uint64_t *lcol = (uint64_t *) col;
455

  
456
	for (i = 0; i < 8; ++i) {
457
		int a0 = col[0] + (1 << (COL_SHIFT - 1)) / W4;
458

  
459
		a0 *= W4;
460
		col[0] = a0 >> COL_SHIFT;
461
		++col;
462
	}
463

  
464
	l = lcol[0];
465
	r = lcol[1];
466
	lcol[ 2] = l; lcol[ 3] = r;
467
	lcol[ 4] = l; lcol[ 5] = r;
468
	lcol[ 6] = l; lcol[ 7] = r;
469
	lcol[ 8] = l; lcol[ 9] = r;
470
	lcol[10] = l; lcol[11] = r;
471
	lcol[12] = l; lcol[13] = r;
472
	lcol[14] = l; lcol[15] = r;
473
}
474
#endif
340 475

  
341 476
void simple_idct (short *block)
342 477
{
......
411 546
		for(i=0; i<8; i++)
412 547
			idctSparse2Col(block + i);
413 548
	}
414
#else		
549
#elif defined(ARCH_ALPHA)
550
	int shortcut = 1;
551

  
552
	for (i = 0; i < 8; i++) {
553
		int anynonzero = idctRowCondDC(block + 8 * i);
554
		if (i > 0 && anynonzero)
555
			shortcut = 0;
556
	}
557

  
558
	if (shortcut) {
559
		idctCol2(block);
560
	} else {
561
		for (i = 0; i < 8; i++)
562
			idctSparseCol(block + i);
563
	}
564
#else
415 565
	for(i=0; i<8; i++)
416 566
		idctRowCondDC(block + i*8);
417 567
	

Also available in: Unified diff