Mercurial > libavcodec.hg
comparison 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 |
comparison
equal
deleted
inserted
replaced
513:fb670ca9f8eb | 514:c9f724e3a797 |
---|---|
21 #include "../dsputil.h" | 21 #include "../dsputil.h" |
22 #include "../mpegvideo.h" | 22 #include "../mpegvideo.h" |
23 | 23 |
24 extern UINT8 zigzag_end[64]; | 24 extern UINT8 zigzag_end[64]; |
25 | 25 |
26 static void dct_unquantize_h263_axp(MpegEncContext *s, | 26 static void dct_unquantize_h263_mvi(MpegEncContext *s, DCTELEM *block, |
27 DCTELEM *block, int n, int qscale) | 27 int n, int qscale) |
28 { | 28 { |
29 int i, level; | 29 int i, n_coeffs; |
30 UINT64 qmul, qadd; | 30 uint64_t qmul, qadd; |
31 uint64_t correction; | |
32 DCTELEM *orig_block = block; | |
33 DCTELEM block0; | |
31 | 34 |
32 ASM_ACCEPT_MVI; | 35 ASM_ACCEPT_MVI; |
33 | 36 |
34 if (s->mb_intra) { | 37 if (s->mb_intra) { |
35 if (n < 4) | 38 if (!s->h263_aic) { |
36 block[0] = block[0] * s->y_dc_scale; | 39 if (n < 4) |
37 else | 40 block0 = block[0] * s->y_dc_scale; |
38 block[0] = block[0] * s->c_dc_scale; | 41 else |
39 /* Catch up to aligned point. */ | 42 block0 = block[0] * s->c_dc_scale; |
40 qmul = s->qscale << 1; | 43 } |
41 qadd = (s->qscale - 1) | 1; | 44 n_coeffs = 64; // does not always use zigzag table |
42 for (i = 1; i < 4; ++i) { | |
43 level = block[i]; | |
44 if (level) { | |
45 if (level < 0) { | |
46 level = level * qmul - qadd; | |
47 } else { | |
48 level = level * qmul + qadd; | |
49 } | |
50 block[i] = level; | |
51 } | |
52 } | |
53 block += 4; | |
54 i = 60 / 4; | |
55 } else { | 45 } else { |
56 i = zigzag_end[s->block_last_index[n]] / 4; | 46 n_coeffs = zigzag_end[s->block_last_index[n]]; |
57 } | 47 } |
58 qmul = s->qscale << 1; | 48 |
49 qmul = qscale << 1; | |
59 qadd = WORD_VEC((qscale - 1) | 1); | 50 qadd = WORD_VEC((qscale - 1) | 1); |
60 do { | 51 /* This mask kills spill from negative subwords to the next subword. */ |
61 UINT64 levels, negmask, zeromask, corr; | 52 correction = WORD_VEC((qmul - 1) + 1); /* multiplication / addition */ |
62 levels = ldq(block); | |
63 if (levels == 0) | |
64 continue; | |
65 zeromask = cmpbge(0, levels); | |
66 zeromask &= zeromask >> 1; | |
67 /* Negate all negative words. */ | |
68 negmask = maxsw4(levels, WORD_VEC(0xffff)); /* negative -> ffff (-1) */ | |
69 negmask = minsw4(negmask, 0); /* positive -> 0000 (0) */ | |
70 corr = negmask & WORD_VEC(0x0001); /* twos-complement correction */ | |
71 levels ^= negmask; | |
72 levels += corr; | |
73 | 53 |
74 levels = levels * qmul; | 54 for(i = 0; i < n_coeffs; block += 4, i += 4) { |
75 levels += zap(qadd, zeromask); | 55 uint64_t levels, negmask, zeros, add; |
76 | 56 |
77 /* Re-negate negative words. */ | 57 levels = ldq(block); |
78 levels -= corr; | 58 if (levels == 0) |
79 levels ^= negmask; | 59 continue; |
80 | 60 |
81 stq(levels, block); | 61 negmask = maxsw4(levels, -1); /* negative -> ffff (-1) */ |
82 } while (block += 4, --i); | 62 negmask = minsw4(negmask, 0); /* positive -> 0000 (0) */ |
63 | |
64 zeros = cmpbge(0, levels); | |
65 zeros &= zeros >> 1; | |
66 /* zeros |= zeros << 1 is not needed since qadd <= 255, so | |
67 zapping the lower byte suffices. */ | |
68 | |
69 levels *= qmul; | |
70 levels -= correction & (negmask << 16); | |
71 | |
72 /* Negate qadd for negative levels. */ | |
73 add = qadd ^ negmask; | |
74 add += WORD_VEC(0x0001) & negmask; | |
75 /* Set qadd to 0 for levels == 0. */ | |
76 add = zap(add, zeros); | |
77 | |
78 levels += add; | |
79 | |
80 stq(levels, block); | |
81 } | |
82 | |
83 if (s->mb_intra && !s->h263_aic) | |
84 orig_block[0] = block0; | |
83 } | 85 } |
84 | 86 |
85 void MPV_common_init_axp(MpegEncContext *s) | 87 void MPV_common_init_axp(MpegEncContext *s) |
86 { | 88 { |
87 if (amask(AMASK_MVI) == 0) { | 89 if (amask(AMASK_MVI) == 0) { |
88 if (s->out_format == FMT_H263) | 90 s->dct_unquantize_h263 = dct_unquantize_h263_mvi; |
89 s->dct_unquantize = dct_unquantize_h263_axp; | |
90 } | 91 } |
91 } | 92 } |