Browse code

svq1: Drop a bunch of useless parentheses

Diego Biurrun authored on 2012/10/10 21:08:21
Showing 2 changed files
... ...
@@ -105,56 +105,56 @@ static const uint8_t string_table[256] = {
105 105
         /* add child nodes */                                           \
106 106
         list[n++] = list[i];                                            \
107 107
         list[n++] = list[i] +                                           \
108
-                    (((level & 1) ? pitch : 1) << ((level / 2) + 1));   \
108
+                    (((level & 1) ? pitch : 1) << (level / 2 + 1));     \
109 109
     }
110 110
 
111 111
 #define SVQ1_ADD_CODEBOOK()                                             \
112 112
     /* add codebook entries to vector */                                \
113 113
     for (j = 0; j < stages; j++) {                                      \
114 114
         n3  = codebook[entries[j]] ^ 0x80808080;                        \
115
-        n1 += ((n3 & 0xFF00FF00) >> 8);                                 \
116
-        n2 +=  (n3 & 0x00FF00FF);                                       \
115
+        n1 += (n3 & 0xFF00FF00) >> 8;                                   \
116
+        n2 +=  n3 & 0x00FF00FF;                                         \
117 117
     }                                                                   \
118 118
                                                                         \
119 119
     /* clip to [0..255] */                                              \
120 120
     if (n1 & 0xFF00FF00) {                                              \
121
-        n3  = (((n1 >> 15)  & 0x00010001) | 0x01000100) - 0x00010001;   \
121
+        n3  = (n1 >> 15  & 0x00010001 | 0x01000100) - 0x00010001;       \
122 122
         n1 += 0x7F007F00;                                               \
123
-        n1 |= (((~n1 >> 15) & 0x00010001) | 0x01000100) - 0x00010001;   \
124
-        n1 &= (n3 & 0x00FF00FF);                                        \
123
+        n1 |= (~n1 >> 15 & 0x00010001 | 0x01000100) - 0x00010001;       \
124
+        n1 &= n3 & 0x00FF00FF;                                          \
125 125
     }                                                                   \
126 126
                                                                         \
127 127
     if (n2 & 0xFF00FF00) {                                              \
128
-        n3  = (((n2 >> 15)  & 0x00010001) | 0x01000100) - 0x00010001;   \
128
+        n3  = (n2 >> 15  & 0x00010001 | 0x01000100) - 0x00010001;       \
129 129
         n2 += 0x7F007F00;                                               \
130
-        n2 |= (((~n2 >> 15) & 0x00010001) | 0x01000100) - 0x00010001;   \
131
-        n2 &= (n3 & 0x00FF00FF);                                        \
130
+        n2 |= (~n2 >> 15 & 0x00010001 | 0x01000100) - 0x00010001;       \
131
+        n2 &= n3 & 0x00FF00FF;                                          \
132 132
     }
133 133
 
134 134
 #define SVQ1_DO_CODEBOOK_INTRA()                                        \
135 135
     for (y = 0; y < height; y++) {                                      \
136
-        for (x = 0; x < (width / 4); x++, codebook++) {                 \
136
+        for (x = 0; x < width / 4; x++, codebook++) {                   \
137 137
             n1 = n4;                                                    \
138 138
             n2 = n4;                                                    \
139 139
             SVQ1_ADD_CODEBOOK()                                         \
140 140
             /* store result */                                          \
141
-            dst[x] = (n1 << 8) | n2;                                    \
141
+            dst[x] = n1 << 8 | n2;                                      \
142 142
         }                                                               \
143
-        dst += (pitch / 4);                                             \
143
+        dst += pitch / 4;                                               \
144 144
     }
145 145
 
146 146
 #define SVQ1_DO_CODEBOOK_NONINTRA()                                     \
147 147
     for (y = 0; y < height; y++) {                                      \
148
-        for (x = 0; x < (width / 4); x++, codebook++) {                 \
148
+        for (x = 0; x < width / 4; x++, codebook++) {                   \
149 149
             n3 = dst[x];                                                \
150 150
             /* add mean value to vector */                              \
151 151
             n1 = n4 + ((n3 & 0xFF00FF00) >> 8);                         \
152 152
             n2 = n4 +  (n3 & 0x00FF00FF);                               \
153 153
             SVQ1_ADD_CODEBOOK()                                         \
154 154
             /* store result */                                          \
155
-            dst[x] = (n1 << 8) | n2;                                    \
155
+            dst[x] = n1 << 8 | n2;                                      \
156 156
         }                                                               \
157
-        dst += (pitch / 4);                                             \
157
+        dst += pitch / 4;                                               \
158 158
     }
159 159
 
160 160
 #define SVQ1_CALC_CODEBOOK_ENTRIES(cbook)                               \
... ...
@@ -166,8 +166,8 @@ static const uint8_t string_table[256] = {
166 166
         entries[j] = (((bit_cache >> (4 * (stages - j - 1))) & 0xF) +   \
167 167
                       16 * j) << (level + 1);                           \
168 168
     }                                                                   \
169
-    mean -= (stages * 128);                                             \
170
-    n4    = ((mean + (mean >> 31)) << 16) | (mean & 0xFFFF);
169
+    mean -= stages * 128;                                               \
170
+    n4    = mean + (mean >> 31) << 16 | (mean & 0xFFFF);
171 171
 
172 172
 static int svq1_decode_block_intra(GetBitContext *bitbuf, uint8_t *pixels,
173 173
                                    int pitch)
... ...
@@ -203,7 +203,7 @@ static int svq1_decode_block_intra(GetBitContext *bitbuf, uint8_t *pixels,
203 203
             continue;   /* skip vector */
204 204
         }
205 205
 
206
-        if ((stages > 0) && (level >= 4)) {
206
+        if (stages > 0 && level >= 4) {
207 207
             av_dlog(NULL,
208 208
                     "Error (svq1_decode_block_intra): invalid vector: stages=%i level=%i\n",
209 209
                     stages, level);
... ...
@@ -329,8 +329,8 @@ static int svq1_motion_inter_block(MpegEncContext *s, GetBitContext *bitbuf,
329 329
         pmv[1] =
330 330
         pmv[2] = pmv[0];
331 331
     } else {
332
-        pmv[1] = &motion[(x / 8) + 2];
333
-        pmv[2] = &motion[(x / 8) + 4];
332
+        pmv[1] = &motion[x / 8 + 2];
333
+        pmv[2] = &motion[x / 8 + 4];
334 334
     }
335 335
 
336 336
     result = svq1_decode_motion_vector(bitbuf, &mv, pmv);
... ...
@@ -338,12 +338,12 @@ static int svq1_motion_inter_block(MpegEncContext *s, GetBitContext *bitbuf,
338 338
     if (result != 0)
339 339
         return result;
340 340
 
341
-    motion[0].x           =
342
-    motion[(x / 8) + 2].x =
343
-    motion[(x / 8) + 3].x = mv.x;
344
-    motion[0].y           =
345
-    motion[(x / 8) + 2].y =
346
-    motion[(x / 8) + 3].y = mv.y;
341
+    motion[0].x         =
342
+    motion[x / 8 + 2].x =
343
+    motion[x / 8 + 3].x = mv.x;
344
+    motion[0].y         =
345
+    motion[x / 8 + 2].y =
346
+    motion[x / 8 + 3].y = mv.y;
347 347
 
348 348
     if (y + (mv.y >> 1) < 0)
349 349
         mv.y = 0;
... ...
@@ -353,7 +353,7 @@ static int svq1_motion_inter_block(MpegEncContext *s, GetBitContext *bitbuf,
353 353
     src = &previous[(x + (mv.x >> 1)) + (y + (mv.y >> 1)) * pitch];
354 354
     dst = current;
355 355
 
356
-    s->dsp.put_pixels_tab[0][((mv.y & 1) << 1) | (mv.x & 1)](dst, src, pitch, 16);
356
+    s->dsp.put_pixels_tab[0][(mv.y & 1) << 1 | (mv.x & 1)](dst, src, pitch, 16);
357 357
 
358 358
     return 0;
359 359
 }
... ...
@@ -452,12 +452,12 @@ static int svq1_decode_delta_block(MpegEncContext *s, GetBitContext *bitbuf,
452 452
 
453 453
     /* reset motion vectors */
454 454
     if (block_type == SVQ1_BLOCK_SKIP || block_type == SVQ1_BLOCK_INTRA) {
455
-        motion[0].x           =
456
-        motion[0].y           =
457
-        motion[(x / 8) + 2].x =
458
-        motion[(x / 8) + 2].y =
459
-        motion[(x / 8) + 3].x =
460
-        motion[(x / 8) + 3].y = 0;
455
+        motion[0].x         =
456
+        motion[0].y         =
457
+        motion[x / 8 + 2].x =
458
+        motion[x / 8 + 2].y =
459
+        motion[x / 8 + 3].x =
460
+        motion[x / 8 + 3].y = 0;
461 461
     }
462 462
 
463 463
     switch (block_type) {
... ...
@@ -725,8 +725,8 @@ static av_cold int svq1_decode_init(AVCodecContext *avctx)
725 725
     ff_MPV_decode_defaults(s);
726 726
 
727 727
     s->avctx            = avctx;
728
-    s->width            = (avctx->width  + 3) & ~3;
729
-    s->height           = (avctx->height + 3) & ~3;
728
+    s->width            = avctx->width  + 3 & ~3;
729
+    s->height           = avctx->height + 3 & ~3;
730 730
     s->codec_id         = avctx->codec->id;
731 731
     avctx->pix_fmt      = AV_PIX_FMT_YUV410P;
732 732
     /* Not true, but DP frames and these behave like unidirectional B-frames. */
... ...
@@ -119,8 +119,8 @@ static int encode_block(SVQ1Context *s, uint8_t *src, uint8_t *ref,
119 119
     int count, y, x, i, j, split, best_mean, best_score, best_count;
120 120
     int best_vector[6];
121 121
     int block_sum[7] = { 0, 0, 0, 0, 0, 0 };
122
-    int w            = 2 << ((level + 2) >> 1);
123
-    int h            = 2 << ((level + 1) >> 1);
122
+    int w            = 2 << (level + 2 >> 1);
123
+    int h            = 2 << (level + 1 >> 1);
124 124
     int size         = w * h;
125 125
     int16_t block[7][256];
126 126
     const int8_t *codebook_sum, *codebook;
... ...
@@ -158,8 +158,8 @@ static int encode_block(SVQ1Context *s, uint8_t *src, uint8_t *ref,
158 158
     }
159 159
 
160 160
     best_count  = 0;
161
-    best_score -= (int)(((unsigned)block_sum[0] * block_sum[0]) >> (level + 3));
162
-    best_mean   = (block_sum[0] + (size >> 1)) >> (level + 3);
161
+    best_score -= (int)((unsigned)block_sum[0] * block_sum[0] >> (level + 3));
162
+    best_mean   = block_sum[0] + (size >> 1) >> (level + 3);
163 163
 
164 164
     if (level < 4) {
165 165
         for (count = 1; count < 7; count++) {
... ...
@@ -175,9 +175,9 @@ static int encode_block(SVQ1Context *s, uint8_t *src, uint8_t *ref,
175 175
                 vector = codebook + stage * size * 16 + i * size;
176 176
                 sqr    = s->dsp.ssd_int8_vs_int16(vector, block[stage], size);
177 177
                 diff   = block_sum[stage] - sum;
178
-                score  = sqr - ((diff * (int64_t)diff) >> (level + 3)); // FIXME: 64bit slooow
178
+                score  = sqr - (diff * (int64_t)diff >> (level + 3)); // FIXME: 64bit slooow
179 179
                 if (score < best_vector_score) {
180
-                    int mean = (diff + (size >> 1)) >> (level + 3);
180
+                    int mean = diff + (size >> 1) >> (level + 3);
181 181
                     assert(mean > -300 && mean < 300);
182 182
                     mean               = av_clip(mean, intra ? 0 : -256, 255);
183 183
                     best_vector_score  = score;
... ...
@@ -207,7 +207,7 @@ static int encode_block(SVQ1Context *s, uint8_t *src, uint8_t *ref,
207 207
     split = 0;
208 208
     if (best_score > threshold && level) {
209 209
         int score  = 0;
210
-        int offset = (level & 1) ? stride * h / 2 : w / 2;
210
+        int offset = level & 1 ? stride * h / 2 : w / 2;
211 211
         PutBitContext backup[6];
212 212
 
213 213
         for (i = level - 1; i >= 0; i--)
... ...
@@ -230,7 +230,7 @@ static int encode_block(SVQ1Context *s, uint8_t *src, uint8_t *ref,
230 230
         put_bits(&s->reorder_pb[level], 1, split);
231 231
 
232 232
     if (!split) {
233
-        assert((best_mean >= 0 && best_mean < 256) || !intra);
233
+        assert(best_mean >= 0 && best_mean < 256 || !intra);
234 234
         assert(best_mean >= -256 && best_mean < 256);
235 235
         assert(best_count >= 0 && best_count < 7);
236 236
         assert(level < 4 || best_count == 0);
... ...
@@ -303,11 +303,11 @@ static int svq1_encode_plane(SVQ1Context *s, int plane,
303 303
         // s->m.out_format                    = FMT_H263;
304 304
         // s->m.unrestricted_mv               = 1;
305 305
         s->m.lambda                        = s->picture.quality;
306
-        s->m.qscale                        = (s->m.lambda * 139 +
307
-                                              FF_LAMBDA_SCALE * 64) >>
308
-                                             (FF_LAMBDA_SHIFT + 7);
309
-        s->m.lambda2                       = (s->m.lambda * s->m.lambda +
310
-                                              FF_LAMBDA_SCALE / 2) >>
306
+        s->m.qscale                        = s->m.lambda * 139 +
307
+                                             FF_LAMBDA_SCALE * 64 >>
308
+                                             FF_LAMBDA_SHIFT + 7;
309
+        s->m.lambda2                       = s->m.lambda * s->m.lambda +
310
+                                             FF_LAMBDA_SCALE / 2 >>
311 311
                                              FF_LAMBDA_SHIFT;
312 312
 
313 313
         if (!s->motion_val8[plane]) {