svq1: Drop a bunch of useless parentheses

This commit is contained in:
Diego Biurrun 2012-10-10 14:08:21 +02:00
parent 41e46a5fba
commit 63a46c6101
2 changed files with 48 additions and 48 deletions

View File

@ -105,56 +105,56 @@ static const uint8_t string_table[256] = {
/* add child nodes */ \
list[n++] = list[i]; \
list[n++] = list[i] + \
(((level & 1) ? pitch : 1) << ((level / 2) + 1)); \
(((level & 1) ? pitch : 1) << (level / 2 + 1)); \
}
#define SVQ1_ADD_CODEBOOK() \
/* add codebook entries to vector */ \
for (j = 0; j < stages; j++) { \
n3 = codebook[entries[j]] ^ 0x80808080; \
n1 += ((n3 & 0xFF00FF00) >> 8); \
n2 += (n3 & 0x00FF00FF); \
n1 += (n3 & 0xFF00FF00) >> 8; \
n2 += n3 & 0x00FF00FF; \
} \
\
/* clip to [0..255] */ \
if (n1 & 0xFF00FF00) { \
n3 = (((n1 >> 15) & 0x00010001) | 0x01000100) - 0x00010001; \
n3 = (n1 >> 15 & 0x00010001 | 0x01000100) - 0x00010001; \
n1 += 0x7F007F00; \
n1 |= (((~n1 >> 15) & 0x00010001) | 0x01000100) - 0x00010001; \
n1 &= (n3 & 0x00FF00FF); \
n1 |= (~n1 >> 15 & 0x00010001 | 0x01000100) - 0x00010001; \
n1 &= n3 & 0x00FF00FF; \
} \
\
if (n2 & 0xFF00FF00) { \
n3 = (((n2 >> 15) & 0x00010001) | 0x01000100) - 0x00010001; \
n3 = (n2 >> 15 & 0x00010001 | 0x01000100) - 0x00010001; \
n2 += 0x7F007F00; \
n2 |= (((~n2 >> 15) & 0x00010001) | 0x01000100) - 0x00010001; \
n2 &= (n3 & 0x00FF00FF); \
n2 |= (~n2 >> 15 & 0x00010001 | 0x01000100) - 0x00010001; \
n2 &= n3 & 0x00FF00FF; \
}
#define SVQ1_DO_CODEBOOK_INTRA() \
for (y = 0; y < height; y++) { \
for (x = 0; x < (width / 4); x++, codebook++) { \
for (x = 0; x < width / 4; x++, codebook++) { \
n1 = n4; \
n2 = n4; \
SVQ1_ADD_CODEBOOK() \
/* store result */ \
dst[x] = (n1 << 8) | n2; \
dst[x] = n1 << 8 | n2; \
} \
dst += (pitch / 4); \
dst += pitch / 4; \
}
#define SVQ1_DO_CODEBOOK_NONINTRA() \
for (y = 0; y < height; y++) { \
for (x = 0; x < (width / 4); x++, codebook++) { \
for (x = 0; x < width / 4; x++, codebook++) { \
n3 = dst[x]; \
/* add mean value to vector */ \
n1 = n4 + ((n3 & 0xFF00FF00) >> 8); \
n2 = n4 + (n3 & 0x00FF00FF); \
SVQ1_ADD_CODEBOOK() \
/* store result */ \
dst[x] = (n1 << 8) | n2; \
dst[x] = n1 << 8 | n2; \
} \
dst += (pitch / 4); \
dst += pitch / 4; \
}
#define SVQ1_CALC_CODEBOOK_ENTRIES(cbook) \
@ -166,8 +166,8 @@ static const uint8_t string_table[256] = {
entries[j] = (((bit_cache >> (4 * (stages - j - 1))) & 0xF) + \
16 * j) << (level + 1); \
} \
mean -= (stages * 128); \
n4 = ((mean + (mean >> 31)) << 16) | (mean & 0xFFFF);
mean -= stages * 128; \
n4 = mean + (mean >> 31) << 16 | (mean & 0xFFFF);
static int svq1_decode_block_intra(GetBitContext *bitbuf, uint8_t *pixels,
int pitch)
@ -203,7 +203,7 @@ static int svq1_decode_block_intra(GetBitContext *bitbuf, uint8_t *pixels,
continue; /* skip vector */
}
if ((stages > 0) && (level >= 4)) {
if (stages > 0 && level >= 4) {
av_dlog(NULL,
"Error (svq1_decode_block_intra): invalid vector: stages=%i level=%i\n",
stages, level);
@ -329,8 +329,8 @@ static int svq1_motion_inter_block(MpegEncContext *s, GetBitContext *bitbuf,
pmv[1] =
pmv[2] = pmv[0];
} else {
pmv[1] = &motion[(x / 8) + 2];
pmv[2] = &motion[(x / 8) + 4];
pmv[1] = &motion[x / 8 + 2];
pmv[2] = &motion[x / 8 + 4];
}
result = svq1_decode_motion_vector(bitbuf, &mv, pmv);
@ -338,12 +338,12 @@ static int svq1_motion_inter_block(MpegEncContext *s, GetBitContext *bitbuf,
if (result != 0)
return result;
motion[0].x =
motion[(x / 8) + 2].x =
motion[(x / 8) + 3].x = mv.x;
motion[0].y =
motion[(x / 8) + 2].y =
motion[(x / 8) + 3].y = mv.y;
motion[0].x =
motion[x / 8 + 2].x =
motion[x / 8 + 3].x = mv.x;
motion[0].y =
motion[x / 8 + 2].y =
motion[x / 8 + 3].y = mv.y;
if (y + (mv.y >> 1) < 0)
mv.y = 0;
@ -353,7 +353,7 @@ static int svq1_motion_inter_block(MpegEncContext *s, GetBitContext *bitbuf,
src = &previous[(x + (mv.x >> 1)) + (y + (mv.y >> 1)) * pitch];
dst = current;
s->dsp.put_pixels_tab[0][((mv.y & 1) << 1) | (mv.x & 1)](dst, src, pitch, 16);
s->dsp.put_pixels_tab[0][(mv.y & 1) << 1 | (mv.x & 1)](dst, src, pitch, 16);
return 0;
}
@ -452,12 +452,12 @@ static int svq1_decode_delta_block(MpegEncContext *s, GetBitContext *bitbuf,
/* reset motion vectors */
if (block_type == SVQ1_BLOCK_SKIP || block_type == SVQ1_BLOCK_INTRA) {
motion[0].x =
motion[0].y =
motion[(x / 8) + 2].x =
motion[(x / 8) + 2].y =
motion[(x / 8) + 3].x =
motion[(x / 8) + 3].y = 0;
motion[0].x =
motion[0].y =
motion[x / 8 + 2].x =
motion[x / 8 + 2].y =
motion[x / 8 + 3].x =
motion[x / 8 + 3].y = 0;
}
switch (block_type) {
@ -725,8 +725,8 @@ static av_cold int svq1_decode_init(AVCodecContext *avctx)
ff_MPV_decode_defaults(s);
s->avctx = avctx;
s->width = (avctx->width + 3) & ~3;
s->height = (avctx->height + 3) & ~3;
s->width = avctx->width + 3 & ~3;
s->height = avctx->height + 3 & ~3;
s->codec_id = avctx->codec->id;
avctx->pix_fmt = AV_PIX_FMT_YUV410P;
/* Not true, but DP frames and these behave like unidirectional B-frames. */

View File

@ -119,8 +119,8 @@ static int encode_block(SVQ1Context *s, uint8_t *src, uint8_t *ref,
int count, y, x, i, j, split, best_mean, best_score, best_count;
int best_vector[6];
int block_sum[7] = { 0, 0, 0, 0, 0, 0 };
int w = 2 << ((level + 2) >> 1);
int h = 2 << ((level + 1) >> 1);
int w = 2 << (level + 2 >> 1);
int h = 2 << (level + 1 >> 1);
int size = w * h;
int16_t block[7][256];
const int8_t *codebook_sum, *codebook;
@ -158,8 +158,8 @@ static int encode_block(SVQ1Context *s, uint8_t *src, uint8_t *ref,
}
best_count = 0;
best_score -= (int)(((unsigned)block_sum[0] * block_sum[0]) >> (level + 3));
best_mean = (block_sum[0] + (size >> 1)) >> (level + 3);
best_score -= (int)((unsigned)block_sum[0] * block_sum[0] >> (level + 3));
best_mean = block_sum[0] + (size >> 1) >> (level + 3);
if (level < 4) {
for (count = 1; count < 7; count++) {
@ -175,9 +175,9 @@ static int encode_block(SVQ1Context *s, uint8_t *src, uint8_t *ref,
vector = codebook + stage * size * 16 + i * size;
sqr = s->dsp.ssd_int8_vs_int16(vector, block[stage], size);
diff = block_sum[stage] - sum;
score = sqr - ((diff * (int64_t)diff) >> (level + 3)); // FIXME: 64bit slooow
score = sqr - (diff * (int64_t)diff >> (level + 3)); // FIXME: 64bit slooow
if (score < best_vector_score) {
int mean = (diff + (size >> 1)) >> (level + 3);
int mean = diff + (size >> 1) >> (level + 3);
assert(mean > -300 && mean < 300);
mean = av_clip(mean, intra ? 0 : -256, 255);
best_vector_score = score;
@ -207,7 +207,7 @@ static int encode_block(SVQ1Context *s, uint8_t *src, uint8_t *ref,
split = 0;
if (best_score > threshold && level) {
int score = 0;
int offset = (level & 1) ? stride * h / 2 : w / 2;
int offset = level & 1 ? stride * h / 2 : w / 2;
PutBitContext backup[6];
for (i = level - 1; i >= 0; i--)
@ -230,7 +230,7 @@ static int encode_block(SVQ1Context *s, uint8_t *src, uint8_t *ref,
put_bits(&s->reorder_pb[level], 1, split);
if (!split) {
assert((best_mean >= 0 && best_mean < 256) || !intra);
assert(best_mean >= 0 && best_mean < 256 || !intra);
assert(best_mean >= -256 && best_mean < 256);
assert(best_count >= 0 && best_count < 7);
assert(level < 4 || best_count == 0);
@ -303,11 +303,11 @@ static int svq1_encode_plane(SVQ1Context *s, int plane,
// s->m.out_format = FMT_H263;
// s->m.unrestricted_mv = 1;
s->m.lambda = s->picture.quality;
s->m.qscale = (s->m.lambda * 139 +
FF_LAMBDA_SCALE * 64) >>
(FF_LAMBDA_SHIFT + 7);
s->m.lambda2 = (s->m.lambda * s->m.lambda +
FF_LAMBDA_SCALE / 2) >>
s->m.qscale = s->m.lambda * 139 +
FF_LAMBDA_SCALE * 64 >>
FF_LAMBDA_SHIFT + 7;
s->m.lambda2 = s->m.lambda * s->m.lambda +
FF_LAMBDA_SCALE / 2 >>
FF_LAMBDA_SHIFT;
if (!s->motion_val8[plane]) {