2
* Alpha optimized DSP utils
3
* Copyright (c) 2002 Falk Hueffner <falk@debian.org>
5
* This file is part of FFmpeg.
7
* FFmpeg is free software; you can redistribute it and/or
8
* modify it under the terms of the GNU Lesser General Public
9
* License as published by the Free Software Foundation; either
10
* version 2.1 of the License, or (at your option) any later version.
12
* FFmpeg is distributed in the hope that it will be useful,
13
* but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15
* Lesser General Public License for more details.
17
* You should have received a copy of the GNU Lesser General Public
18
* License along with FFmpeg; if not, write to the Free Software
19
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22
#include "libavcodec/dsputil.h"
23
#include "libavcodec/mpegvideo.h"
26
static void dct_unquantize_h263_axp(DCTELEM *block, int n_coeffs,
27
uint64_t qscale, uint64_t qadd)
29
uint64_t qmul = qscale << 1;
30
uint64_t correction = WORD_VEC(qmul * 255 >> 8);
33
qadd = WORD_VEC(qadd);
35
for(i = 0; i <= n_coeffs; block += 4, i += 4) {
36
uint64_t levels, negmask, zeros, add, sub;
43
/* I don't think the speed difference justifies runtime
45
negmask = maxsw4(levels, -1); /* negative -> ffff (-1) */
46
negmask = minsw4(negmask, 0); /* positive -> 0000 (0) */
48
negmask = cmpbge(WORD_VEC(0x7fff), levels);
49
negmask &= (negmask >> 1) | (1 << 7);
50
negmask = zap(-1, negmask);
53
zeros = cmpbge(0, levels);
55
/* zeros |= zeros << 1 is not needed since qadd <= 255, so
56
zapping the lower byte suffices. */
59
levels -= correction & (negmask << 16);
61
add = qadd & ~negmask;
63
/* Set qadd to 0 for levels == 0. */
64
add = zap(add, zeros);
72
static void dct_unquantize_h263_intra_axp(MpegEncContext *s, DCTELEM *block,
77
DCTELEM block0 = block[0];
81
block0 *= s->y_dc_scale;
83
block0 *= s->c_dc_scale;
84
qadd = (qscale - 1) | 1;
92
n_coeffs = s->inter_scantable.raster_end[s->block_last_index[n]];
94
dct_unquantize_h263_axp(block, n_coeffs, qscale, qadd);
99
static void dct_unquantize_h263_inter_axp(MpegEncContext *s, DCTELEM *block,
102
int n_coeffs = s->inter_scantable.raster_end[s->block_last_index[n]];
103
dct_unquantize_h263_axp(block, n_coeffs, qscale, (qscale - 1) | 1);
106
void MPV_common_init_axp(MpegEncContext *s)
108
s->dct_unquantize_h263_intra = dct_unquantize_h263_intra_axp;
109
s->dct_unquantize_h263_inter = dct_unquantize_h263_inter_axp;