Browse code

avcodec/error_resilience: Merge surrounding status checks

Simplifies code and is also faster

Signed-off-by: Michael Niedermayer <michael@niedermayer.cc>

Michael Niedermayer authored on 2016/12/26 04:22:06
Showing 1 changed files
... ...
@@ -376,7 +376,7 @@ static void v_block_filter(ERContext *s, uint8_t *dst, int w, int h,
376 376
 static void guess_mv(ERContext *s)
377 377
 {
378 378
     uint8_t *fixed = s->er_temp_buffer;
379
-#define MV_FROZEN    3
379
+#define MV_FROZEN    4
380 380
 #define MV_CHANGED   2
381 381
 #define MV_UNCHANGED 1
382 382
     const int mb_stride = s->mb_stride;
... ...
@@ -467,27 +467,19 @@ static void guess_mv(ERContext *s)
467 467
                     av_assert1(s->last_pic.f && s->last_pic.f->data[0]);
468 468
 
469 469
                     j = 0;
470
-                    if (mb_x > 0             && fixed[mb_xy - 1]         == MV_FROZEN)
471
-                        j = 1;
472
-                    if (mb_x + 1 < mb_width  && fixed[mb_xy + 1]         == MV_FROZEN)
473
-                        j = 1;
474
-                    if (mb_y > 0             && fixed[mb_xy - mb_stride] == MV_FROZEN)
475
-                        j = 1;
476
-                    if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride] == MV_FROZEN)
477
-                        j = 1;
478
-                    if (j == 0)
470
+                    if (mb_x > 0)
471
+                        j |= fixed[mb_xy - 1];
472
+                    if (mb_x + 1 < mb_width)
473
+                        j |= fixed[mb_xy + 1];
474
+                    if (mb_y > 0)
475
+                        j |= fixed[mb_xy - mb_stride];
476
+                    if (mb_y + 1 < mb_height)
477
+                        j |= fixed[mb_xy + mb_stride];
478
+
479
+                    if (!(j & MV_FROZEN))
479 480
                         continue;
480 481
 
481
-                    j = 0;
482
-                    if (mb_x > 0             && fixed[mb_xy - 1        ] == MV_CHANGED)
483
-                        j = 1;
484
-                    if (mb_x + 1 < mb_width  && fixed[mb_xy + 1        ] == MV_CHANGED)
485
-                        j = 1;
486
-                    if (mb_y > 0             && fixed[mb_xy - mb_stride] == MV_CHANGED)
487
-                        j = 1;
488
-                    if (mb_y + 1 < mb_height && fixed[mb_xy + mb_stride] == MV_CHANGED)
489
-                        j = 1;
490
-                    if (j == 0 && pass > 1)
482
+                    if (!(j & MV_CHANGED) && pass > 1)
491 483
                         continue;
492 484
 
493 485
                     none_left = 0;