]> git.sesse.net Git - vlc/blobdiff - modules/codec/xvmc/slice.c
Removes trailing spaces. Removes tabs.
[vlc] / modules / codec / xvmc / slice.c
index f987f3c0bebbdea61b64ec05af91534c8c570a52..4c3f6baf8cbd705f7743fbdc754ae8a1a65f7e3b 100644 (file)
@@ -37,7 +37,7 @@ extern void (* mpeg2_cpu_state_restore) (cpu_state_t * state);
 #include "vlc.h"
 
 static inline int get_motion_delta( mpeg2_decoder_t * const decoder,
-                                   const int f_code )
+                    const int f_code )
 {
 #define bit_buf (decoder->bitstream_buf)
 #define bits (decoder->bitstream_bits)
@@ -112,292 +112,292 @@ static inline int get_dmv (mpeg2_decoder_t * const decoder)
 #undef bit_ptr
 }
 
-#define MOTION_420(table,ref,motion_x,motion_y,size,y)                       \
-    pos_x = 2 * decoder->offset + motion_x;                                  \
-    pos_y = 2 * decoder->v_offset + motion_y + 2 * y;                        \
-    if (unlikely (pos_x > decoder->limit_x)) {                               \
-       pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;                      \
-       motion_x = pos_x - 2 * decoder->offset;                               \
-    }                                                                        \
-    if (unlikely (pos_y > decoder->limit_y_ ## size)) {                              \
-       pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y_ ## size;             \
-       motion_y = pos_y - 2 * decoder->v_offset - 2 * y;                     \
-    }                                                                        \
-    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);                                      \
+#define MOTION_420(table,ref,motion_x,motion_y,size,y)                  \
+    pos_x = 2 * decoder->offset + motion_x;                      \
+    pos_y = 2 * decoder->v_offset + motion_y + 2 * y;                  \
+    if (unlikely (pos_x > decoder->limit_x)) {                      \
+    pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;              \
+    motion_x = pos_x - 2 * decoder->offset;                      \
+    }                                          \
+    if (unlikely (pos_y > decoder->limit_y_ ## size)) {                  \
+    pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y_ ## size;          \
+    motion_y = pos_y - 2 * decoder->v_offset - 2 * y;              \
+    }                                          \
+    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);                      \
     table[xy_half] (decoder->dest[0] + y * decoder->stride + decoder->offset, \
-                   ref[0] + (pos_x >> 1) + (pos_y >> 1) * decoder->stride,   \
-                   decoder->stride, size);                                   \
-    motion_x /= 2;     motion_y /= 2;                                        \
-    xy_half = ((motion_y & 1) << 1) | (motion_x & 1);                        \
-    offset = (((decoder->offset + motion_x) >> 1) +                          \
-             ((((decoder->v_offset + motion_y) >> 1) + y/2) *                \
-              decoder->uv_stride));                                          \
-    table[4+xy_half] (decoder->dest[1] + y/2 * decoder->uv_stride +          \
-                     (decoder->offset >> 1), ref[1] + offset,                \
-                     decoder->uv_stride, size/2);                            \
-    table[4+xy_half] (decoder->dest[2] + y/2 * decoder->uv_stride +          \
-                     (decoder->offset >> 1), ref[2] + offset,                \
-                     decoder->uv_stride, size/2)
+            ref[0] + (pos_x >> 1) + (pos_y >> 1) * decoder->stride,   \
+            decoder->stride, size);                      \
+    motion_x /= 2;    motion_y /= 2;                          \
+    xy_half = ((motion_y & 1) << 1) | (motion_x & 1);                  \
+    offset = (((decoder->offset + motion_x) >> 1) +                  \
+          ((((decoder->v_offset + motion_y) >> 1) + y/2) *              \
+           decoder->uv_stride));                          \
+    table[4+xy_half] (decoder->dest[1] + y/2 * decoder->uv_stride +          \
+              (decoder->offset >> 1), ref[1] + offset,              \
+              decoder->uv_stride, size/2);                  \
+    table[4+xy_half] (decoder->dest[2] + y/2 * decoder->uv_stride +          \
+              (decoder->offset >> 1), ref[2] + offset,              \
+              decoder->uv_stride, size/2)
 
 #define MOTION_FIELD_420(table,ref,motion_x,motion_y,dest_field,op,src_field) \
-    pos_x = 2 * decoder->offset + motion_x;                                  \
-    pos_y = decoder->v_offset + motion_y;                                    \
-    if (unlikely (pos_x > decoder->limit_x)) {                               \
-       pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;                      \
-       motion_x = pos_x - 2 * decoder->offset;                               \
-    }                                                                        \
-    if (unlikely (pos_y > decoder->limit_y)) {                               \
-       pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y;                      \
-       motion_y = pos_y - decoder->v_offset;                                 \
-    }                                                                        \
-    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);                                      \
-    table[xy_half] (decoder->dest[0] + dest_field * decoder->stride +        \
-                   decoder->offset,                                          \
-                   (ref[0] + (pos_x >> 1) +                                  \
-                    ((pos_y op) + src_field) * decoder->stride),             \
-                   2 * decoder->stride, 8);                                  \
-    motion_x /= 2;     motion_y /= 2;                                        \
-    xy_half = ((motion_y & 1) << 1) | (motion_x & 1);                        \
-    offset = (((decoder->offset + motion_x) >> 1) +                          \
-             (((decoder->v_offset >> 1) + (motion_y op) + src_field) *       \
-              decoder->uv_stride));                                          \
+    pos_x = 2 * decoder->offset + motion_x;                      \
+    pos_y = decoder->v_offset + motion_y;                      \
+    if (unlikely (pos_x > decoder->limit_x)) {                      \
+    pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;              \
+    motion_x = pos_x - 2 * decoder->offset;                      \
+    }                                          \
+    if (unlikely (pos_y > decoder->limit_y)) {                      \
+    pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y;              \
+    motion_y = pos_y - decoder->v_offset;                      \
+    }                                          \
+    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);                      \
+    table[xy_half] (decoder->dest[0] + dest_field * decoder->stride +          \
+            decoder->offset,                          \
+            (ref[0] + (pos_x >> 1) +                      \
+             ((pos_y op) + src_field) * decoder->stride),          \
+            2 * decoder->stride, 8);                      \
+    motion_x /= 2;    motion_y /= 2;                          \
+    xy_half = ((motion_y & 1) << 1) | (motion_x & 1);                  \
+    offset = (((decoder->offset + motion_x) >> 1) +                  \
+          (((decoder->v_offset >> 1) + (motion_y op) + src_field) *          \
+           decoder->uv_stride));                          \
     table[4+xy_half] (decoder->dest[1] + dest_field * decoder->uv_stride +    \
-                     (decoder->offset >> 1), ref[1] + offset,                \
-                     2 * decoder->uv_stride, 4);                             \
+              (decoder->offset >> 1), ref[1] + offset,              \
+              2 * decoder->uv_stride, 4);                  \
     table[4+xy_half] (decoder->dest[2] + dest_field * decoder->uv_stride +    \
-                     (decoder->offset >> 1), ref[2] + offset,                \
-                     2 * decoder->uv_stride, 4)
-
-#define MOTION_DMV_420(table,ref,motion_x,motion_y)                          \
-    pos_x = 2 * decoder->offset + motion_x;                                  \
-    pos_y = decoder->v_offset + motion_y;                                    \
-    if (unlikely (pos_x > decoder->limit_x)) {                               \
-       pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;                      \
-       motion_x = pos_x - 2 * decoder->offset;                               \
-    }                                                                        \
-    if (unlikely (pos_y > decoder->limit_y)) {                               \
-       pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y;                      \
-       motion_y = pos_y - decoder->v_offset;                                 \
-    }                                                                        \
-    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);                                      \
-    offset = (pos_x >> 1) + (pos_y & ~1) * decoder->stride;                  \
-    table[xy_half] (decoder->dest[0] + decoder->offset,                              \
-                   ref[0] + offset, 2 * decoder->stride, 8);                 \
+              (decoder->offset >> 1), ref[2] + offset,              \
+              2 * decoder->uv_stride, 4)
+
+#define MOTION_DMV_420(table,ref,motion_x,motion_y)                  \
+    pos_x = 2 * decoder->offset + motion_x;                      \
+    pos_y = decoder->v_offset + motion_y;                      \
+    if (unlikely (pos_x > decoder->limit_x)) {                      \
+    pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;              \
+    motion_x = pos_x - 2 * decoder->offset;                      \
+    }                                          \
+    if (unlikely (pos_y > decoder->limit_y)) {                      \
+    pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y;              \
+    motion_y = pos_y - decoder->v_offset;                      \
+    }                                          \
+    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);                      \
+    offset = (pos_x >> 1) + (pos_y & ~1) * decoder->stride;              \
+    table[xy_half] (decoder->dest[0] + decoder->offset,                  \
+            ref[0] + offset, 2 * decoder->stride, 8);              \
     table[xy_half] (decoder->dest[0] + decoder->stride + decoder->offset,     \
-                   ref[0] + decoder->stride + offset,                        \
-                   2 * decoder->stride, 8);                                  \
-    motion_x /= 2;     motion_y /= 2;                                        \
-    xy_half = ((motion_y & 1) << 1) | (motion_x & 1);                        \
-    offset = (((decoder->offset + motion_x) >> 1) +                          \
-             (((decoder->v_offset >> 1) + (motion_y & ~1)) *                 \
-              decoder->uv_stride));                                          \
-    table[4+xy_half] (decoder->dest[1] + (decoder->offset >> 1),             \
-                     ref[1] + offset, 2 * decoder->uv_stride, 4);            \
-    table[4+xy_half] (decoder->dest[1] + decoder->uv_stride +                \
-                     (decoder->offset >> 1),                                 \
-                     ref[1] + decoder->uv_stride + offset,                   \
-                     2 * decoder->uv_stride, 4);                             \
-    table[4+xy_half] (decoder->dest[2] + (decoder->offset >> 1),             \
-                     ref[2] + offset, 2 * decoder->uv_stride, 4);            \
-    table[4+xy_half] (decoder->dest[2] + decoder->uv_stride +                \
-                     (decoder->offset >> 1),                                 \
-                     ref[2] + decoder->uv_stride + offset,                   \
-                     2 * decoder->uv_stride, 4)
-
-#define MOTION_ZERO_420(table,ref)                                           \
-    table[0] (decoder->dest[0] + decoder->offset,                            \
-             (ref[0] + decoder->offset +                                     \
-              decoder->v_offset * decoder->stride), decoder->stride, 16);    \
-    offset = ((decoder->offset >> 1) +                                       \
-             (decoder->v_offset >> 1) * decoder->uv_stride);                 \
-    table[4] (decoder->dest[1] + (decoder->offset >> 1),                     \
-             ref[1] + offset, decoder->uv_stride, 8);                        \
-    table[4] (decoder->dest[2] + (decoder->offset >> 1),                     \
-             ref[2] + offset, decoder->uv_stride, 8)
-
-#define MOTION_422(table,ref,motion_x,motion_y,size,y)                       \
-    pos_x = 2 * decoder->offset + motion_x;                                  \
-    pos_y = 2 * decoder->v_offset + motion_y + 2 * y;                        \
-    if (unlikely (pos_x > decoder->limit_x)) {                               \
-       pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;                      \
-       motion_x = pos_x - 2 * decoder->offset;                               \
-    }                                                                        \
-    if (unlikely (pos_y > decoder->limit_y_ ## size)) {                              \
-       pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y_ ## size;             \
-       motion_y = pos_y - 2 * decoder->v_offset - 2 * y;                     \
-    }                                                                        \
-    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);                                      \
-    offset = (pos_x >> 1) + (pos_y >> 1) * decoder->stride;                  \
+            ref[0] + decoder->stride + offset,                  \
+            2 * decoder->stride, 8);                      \
+    motion_x /= 2;    motion_y /= 2;                          \
+    xy_half = ((motion_y & 1) << 1) | (motion_x & 1);                  \
+    offset = (((decoder->offset + motion_x) >> 1) +                  \
+          (((decoder->v_offset >> 1) + (motion_y & ~1)) *              \
+           decoder->uv_stride));                          \
+    table[4+xy_half] (decoder->dest[1] + (decoder->offset >> 1),          \
+              ref[1] + offset, 2 * decoder->uv_stride, 4);          \
+    table[4+xy_half] (decoder->dest[1] + decoder->uv_stride +              \
+              (decoder->offset >> 1),                      \
+              ref[1] + decoder->uv_stride + offset,              \
+              2 * decoder->uv_stride, 4);                  \
+    table[4+xy_half] (decoder->dest[2] + (decoder->offset >> 1),          \
+              ref[2] + offset, 2 * decoder->uv_stride, 4);          \
+    table[4+xy_half] (decoder->dest[2] + decoder->uv_stride +              \
+              (decoder->offset >> 1),                      \
+              ref[2] + decoder->uv_stride + offset,              \
+              2 * decoder->uv_stride, 4)
+
+#define MOTION_ZERO_420(table,ref)                          \
+    table[0] (decoder->dest[0] + decoder->offset,                  \
+          (ref[0] + decoder->offset +                      \
+           decoder->v_offset * decoder->stride), decoder->stride, 16);    \
+    offset = ((decoder->offset >> 1) +                          \
+          (decoder->v_offset >> 1) * decoder->uv_stride);              \
+    table[4] (decoder->dest[1] + (decoder->offset >> 1),              \
+          ref[1] + offset, decoder->uv_stride, 8);                  \
+    table[4] (decoder->dest[2] + (decoder->offset >> 1),              \
+          ref[2] + offset, decoder->uv_stride, 8)
+
+#define MOTION_422(table,ref,motion_x,motion_y,size,y)                  \
+    pos_x = 2 * decoder->offset + motion_x;                      \
+    pos_y = 2 * decoder->v_offset + motion_y + 2 * y;                  \
+    if (unlikely (pos_x > decoder->limit_x)) {                      \
+    pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;              \
+    motion_x = pos_x - 2 * decoder->offset;                      \
+    }                                          \
+    if (unlikely (pos_y > decoder->limit_y_ ## size)) {                  \
+    pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y_ ## size;          \
+    motion_y = pos_y - 2 * decoder->v_offset - 2 * y;              \
+    }                                          \
+    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);                      \
+    offset = (pos_x >> 1) + (pos_y >> 1) * decoder->stride;              \
     table[xy_half] (decoder->dest[0] + y * decoder->stride + decoder->offset, \
-                   ref[0] + offset, decoder->stride, size);                  \
-    offset = (offset + (motion_x & (motion_x < 0))) >> 1;                    \
-    motion_x /= 2;                                                           \
-    xy_half = ((pos_y & 1) << 1) | (motion_x & 1);                           \
-    table[4+xy_half] (decoder->dest[1] + y * decoder->uv_stride +            \
-                     (decoder->offset >> 1), ref[1] + offset,                \
-                     decoder->uv_stride, size);                              \
-    table[4+xy_half] (decoder->dest[2] + y * decoder->uv_stride +            \
-                     (decoder->offset >> 1), ref[2] + offset,                \
-                     decoder->uv_stride, size)
+            ref[0] + offset, decoder->stride, size);              \
+    offset = (offset + (motion_x & (motion_x < 0))) >> 1;              \
+    motion_x /= 2;                                  \
+    xy_half = ((pos_y & 1) << 1) | (motion_x & 1);                  \
+    table[4+xy_half] (decoder->dest[1] + y * decoder->uv_stride +          \
+              (decoder->offset >> 1), ref[1] + offset,              \
+              decoder->uv_stride, size);                  \
+    table[4+xy_half] (decoder->dest[2] + y * decoder->uv_stride +          \
+              (decoder->offset >> 1), ref[2] + offset,              \
+              decoder->uv_stride, size)
 
 #define MOTION_FIELD_422(table,ref,motion_x,motion_y,dest_field,op,src_field) \
-    pos_x = 2 * decoder->offset + motion_x;                                  \
-    pos_y = decoder->v_offset + motion_y;                                    \
-    if (unlikely (pos_x > decoder->limit_x)) {                               \
-       pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;                      \
-       motion_x = pos_x - 2 * decoder->offset;                               \
-    }                                                                        \
-    if (unlikely (pos_y > decoder->limit_y)) {                               \
-       pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y;                      \
-       motion_y = pos_y - decoder->v_offset;                                 \
-    }                                                                        \
-    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);                                      \
-    offset = (pos_x >> 1) + ((pos_y op) + src_field) * decoder->stride;              \
-    table[xy_half] (decoder->dest[0] + dest_field * decoder->stride +        \
-                   decoder->offset, ref[0] + offset,                         \
-                   2 * decoder->stride, 8);                                  \
-    offset = (offset + (motion_x & (motion_x < 0))) >> 1;                    \
-    motion_x /= 2;                                                           \
-    xy_half = ((pos_y & 1) << 1) | (motion_x & 1);                           \
+    pos_x = 2 * decoder->offset + motion_x;                      \
+    pos_y = decoder->v_offset + motion_y;                      \
+    if (unlikely (pos_x > decoder->limit_x)) {                      \
+    pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;              \
+    motion_x = pos_x - 2 * decoder->offset;                      \
+    }                                          \
+    if (unlikely (pos_y > decoder->limit_y)) {                      \
+    pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y;              \
+    motion_y = pos_y - decoder->v_offset;                      \
+    }                                          \
+    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);                      \
+    offset = (pos_x >> 1) + ((pos_y op) + src_field) * decoder->stride;          \
+    table[xy_half] (decoder->dest[0] + dest_field * decoder->stride +          \
+            decoder->offset, ref[0] + offset,                  \
+            2 * decoder->stride, 8);                      \
+    offset = (offset + (motion_x & (motion_x < 0))) >> 1;              \
+    motion_x /= 2;                                  \
+    xy_half = ((pos_y & 1) << 1) | (motion_x & 1);                  \
     table[4+xy_half] (decoder->dest[1] + dest_field * decoder->uv_stride +    \
-                     (decoder->offset >> 1), ref[1] + offset,                \
-                     2 * decoder->uv_stride, 8);                             \
+              (decoder->offset >> 1), ref[1] + offset,              \
+              2 * decoder->uv_stride, 8);                  \
     table[4+xy_half] (decoder->dest[2] + dest_field * decoder->uv_stride +    \
-                     (decoder->offset >> 1), ref[2] + offset,                \
-                     2 * decoder->uv_stride, 8)
-
-#define MOTION_DMV_422(table,ref,motion_x,motion_y)                          \
-    pos_x = 2 * decoder->offset + motion_x;                                  \
-    pos_y = decoder->v_offset + motion_y;                                    \
-    if (unlikely (pos_x > decoder->limit_x)) {                               \
-       pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;                      \
-       motion_x = pos_x - 2 * decoder->offset;                               \
-    }                                                                        \
-    if (unlikely (pos_y > decoder->limit_y)) {                               \
-       pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y;                      \
-       motion_y = pos_y - decoder->v_offset;                                 \
-    }                                                                        \
-    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);                                      \
-    offset = (pos_x >> 1) + (pos_y & ~1) * decoder->stride;                  \
-    table[xy_half] (decoder->dest[0] + decoder->offset,                              \
-                   ref[0] + offset, 2 * decoder->stride, 8);                 \
+              (decoder->offset >> 1), ref[2] + offset,              \
+              2 * decoder->uv_stride, 8)
+
+#define MOTION_DMV_422(table,ref,motion_x,motion_y)                  \
+    pos_x = 2 * decoder->offset + motion_x;                      \
+    pos_y = decoder->v_offset + motion_y;                      \
+    if (unlikely (pos_x > decoder->limit_x)) {                      \
+    pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;              \
+    motion_x = pos_x - 2 * decoder->offset;                      \
+    }                                          \
+    if (unlikely (pos_y > decoder->limit_y)) {                      \
+    pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y;              \
+    motion_y = pos_y - decoder->v_offset;                      \
+    }                                          \
+    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);                      \
+    offset = (pos_x >> 1) + (pos_y & ~1) * decoder->stride;              \
+    table[xy_half] (decoder->dest[0] + decoder->offset,                  \
+            ref[0] + offset, 2 * decoder->stride, 8);              \
     table[xy_half] (decoder->dest[0] + decoder->stride + decoder->offset,     \
-                   ref[0] + decoder->stride + offset,                        \
-                   2 * decoder->stride, 8);                                  \
-    offset = (offset + (motion_x & (motion_x < 0))) >> 1;                    \
-    motion_x /= 2;                                                           \
-    xy_half = ((pos_y & 1) << 1) | (motion_x & 1);                           \
-    table[4+xy_half] (decoder->dest[1] + (decoder->offset >> 1),             \
-                     ref[1] + offset, 2 * decoder->uv_stride, 8);            \
-    table[4+xy_half] (decoder->dest[1] + decoder->uv_stride +                \
-                     (decoder->offset >> 1),                                 \
-                     ref[1] + decoder->uv_stride + offset,                   \
-                     2 * decoder->uv_stride, 8);                             \
-    table[4+xy_half] (decoder->dest[2] + (decoder->offset >> 1),             \
-                     ref[2] + offset, 2 * decoder->uv_stride, 8);            \
-    table[4+xy_half] (decoder->dest[2] + decoder->uv_stride +                \
-                     (decoder->offset >> 1),                                 \
-                     ref[2] + decoder->uv_stride + offset,                   \
-                     2 * decoder->uv_stride, 8)
-
-#define MOTION_ZERO_422(table,ref)                                           \
-    offset = decoder->offset + decoder->v_offset * decoder->stride;          \
-    table[0] (decoder->dest[0] + decoder->offset,                            \
-             ref[0] + offset, decoder->stride, 16);                          \
-    offset >>= 1;                                                            \
-    table[4] (decoder->dest[1] + (decoder->offset >> 1),                     \
-             ref[1] + offset, decoder->uv_stride, 16);                       \
-    table[4] (decoder->dest[2] + (decoder->offset >> 1),                     \
-             ref[2] + offset, decoder->uv_stride, 16)
-
-#define MOTION_444(table,ref,motion_x,motion_y,size,y)                       \
-    pos_x = 2 * decoder->offset + motion_x;                                  \
-    pos_y = 2 * decoder->v_offset + motion_y + 2 * y;                        \
-    if (unlikely (pos_x > decoder->limit_x)) {                               \
-       pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;                      \
-       motion_x = pos_x - 2 * decoder->offset;                               \
-    }                                                                        \
-    if (unlikely (pos_y > decoder->limit_y_ ## size)) {                              \
-       pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y_ ## size;             \
-       motion_y = pos_y - 2 * decoder->v_offset - 2 * y;                     \
-    }                                                                        \
-    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);                                      \
-    offset = (pos_x >> 1) + (pos_y >> 1) * decoder->stride;                  \
+            ref[0] + decoder->stride + offset,                  \
+            2 * decoder->stride, 8);                      \
+    offset = (offset + (motion_x & (motion_x < 0))) >> 1;              \
+    motion_x /= 2;                                  \
+    xy_half = ((pos_y & 1) << 1) | (motion_x & 1);                  \
+    table[4+xy_half] (decoder->dest[1] + (decoder->offset >> 1),          \
+              ref[1] + offset, 2 * decoder->uv_stride, 8);          \
+    table[4+xy_half] (decoder->dest[1] + decoder->uv_stride +              \
+              (decoder->offset >> 1),                      \
+              ref[1] + decoder->uv_stride + offset,              \
+              2 * decoder->uv_stride, 8);                  \
+    table[4+xy_half] (decoder->dest[2] + (decoder->offset >> 1),          \
+              ref[2] + offset, 2 * decoder->uv_stride, 8);          \
+    table[4+xy_half] (decoder->dest[2] + decoder->uv_stride +              \
+              (decoder->offset >> 1),                      \
+              ref[2] + decoder->uv_stride + offset,              \
+              2 * decoder->uv_stride, 8)
+
+#define MOTION_ZERO_422(table,ref)                          \
+    offset = decoder->offset + decoder->v_offset * decoder->stride;          \
+    table[0] (decoder->dest[0] + decoder->offset,                  \
+          ref[0] + offset, decoder->stride, 16);                  \
+    offset >>= 1;                                  \
+    table[4] (decoder->dest[1] + (decoder->offset >> 1),              \
+          ref[1] + offset, decoder->uv_stride, 16);                  \
+    table[4] (decoder->dest[2] + (decoder->offset >> 1),              \
+          ref[2] + offset, decoder->uv_stride, 16)
+
+#define MOTION_444(table,ref,motion_x,motion_y,size,y)                  \
+    pos_x = 2 * decoder->offset + motion_x;                      \
+    pos_y = 2 * decoder->v_offset + motion_y + 2 * y;                  \
+    if (unlikely (pos_x > decoder->limit_x)) {                      \
+    pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;              \
+    motion_x = pos_x - 2 * decoder->offset;                      \
+    }                                          \
+    if (unlikely (pos_y > decoder->limit_y_ ## size)) {                  \
+    pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y_ ## size;          \
+    motion_y = pos_y - 2 * decoder->v_offset - 2 * y;              \
+    }                                          \
+    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);                      \
+    offset = (pos_x >> 1) + (pos_y >> 1) * decoder->stride;              \
     table[xy_half] (decoder->dest[0] + y * decoder->stride + decoder->offset, \
-                   ref[0] + offset, decoder->stride, size);                  \
+            ref[0] + offset, decoder->stride, size);              \
     table[xy_half] (decoder->dest[1] + y * decoder->stride + decoder->offset, \
-                   ref[1] + offset, decoder->stride, size);                  \
+            ref[1] + offset, decoder->stride, size);              \
     table[xy_half] (decoder->dest[2] + y * decoder->stride + decoder->offset, \
-                   ref[2] + offset, decoder->stride, size)
+            ref[2] + offset, decoder->stride, size)
 
 #define MOTION_FIELD_444(table,ref,motion_x,motion_y,dest_field,op,src_field) \
-    pos_x = 2 * decoder->offset + motion_x;                                  \
-    pos_y = decoder->v_offset + motion_y;                                    \
-    if (unlikely (pos_x > decoder->limit_x)) {                               \
-       pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;                      \
-       motion_x = pos_x - 2 * decoder->offset;                               \
-    }                                                                        \
-    if (unlikely (pos_y > decoder->limit_y)) {                               \
-       pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y;                      \
-       motion_y = pos_y - decoder->v_offset;                                 \
-    }                                                                        \
-    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);                                      \
-    offset = (pos_x >> 1) + ((pos_y op) + src_field) * decoder->stride;              \
-    table[xy_half] (decoder->dest[0] + dest_field * decoder->stride +        \
-                   decoder->offset, ref[0] + offset,                         \
-                   2 * decoder->stride, 8);                                  \
-    table[xy_half] (decoder->dest[1] + dest_field * decoder->stride +        \
-                   decoder->offset, ref[1] + offset,                         \
-                   2 * decoder->stride, 8);                                  \
-    table[xy_half] (decoder->dest[2] + dest_field * decoder->stride +        \
-                   decoder->offset, ref[2] + offset,                         \
-                   2 * decoder->stride, 8)
-
-#define MOTION_DMV_444(table,ref,motion_x,motion_y)                          \
-    pos_x = 2 * decoder->offset + motion_x;                                  \
-    pos_y = decoder->v_offset + motion_y;                                    \
-    if (unlikely (pos_x > decoder->limit_x)) {                               \
-       pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;                      \
-       motion_x = pos_x - 2 * decoder->offset;                               \
-    }                                                                        \
-    if (unlikely (pos_y > decoder->limit_y)) {                               \
-       pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y;                      \
-       motion_y = pos_y - decoder->v_offset;                                 \
-    }                                                                        \
-    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);                                      \
-    offset = (pos_x >> 1) + (pos_y & ~1) * decoder->stride;                  \
-    table[xy_half] (decoder->dest[0] + decoder->offset,                              \
-                   ref[0] + offset, 2 * decoder->stride, 8);                 \
+    pos_x = 2 * decoder->offset + motion_x;                      \
+    pos_y = decoder->v_offset + motion_y;                      \
+    if (unlikely (pos_x > decoder->limit_x)) {                      \
+    pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;              \
+    motion_x = pos_x - 2 * decoder->offset;                      \
+    }                                          \
+    if (unlikely (pos_y > decoder->limit_y)) {                      \
+    pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y;              \
+    motion_y = pos_y - decoder->v_offset;                      \
+    }                                          \
+    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);                      \
+    offset = (pos_x >> 1) + ((pos_y op) + src_field) * decoder->stride;          \
+    table[xy_half] (decoder->dest[0] + dest_field * decoder->stride +          \
+            decoder->offset, ref[0] + offset,                  \
+            2 * decoder->stride, 8);                      \
+    table[xy_half] (decoder->dest[1] + dest_field * decoder->stride +          \
+            decoder->offset, ref[1] + offset,                  \
+            2 * decoder->stride, 8);                      \
+    table[xy_half] (decoder->dest[2] + dest_field * decoder->stride +          \
+            decoder->offset, ref[2] + offset,                  \
+            2 * decoder->stride, 8)
+
+#define MOTION_DMV_444(table,ref,motion_x,motion_y)                  \
+    pos_x = 2 * decoder->offset + motion_x;                      \
+    pos_y = decoder->v_offset + motion_y;                      \
+    if (unlikely (pos_x > decoder->limit_x)) {                      \
+    pos_x = ((int)pos_x < 0) ? 0 : decoder->limit_x;              \
+    motion_x = pos_x - 2 * decoder->offset;                      \
+    }                                          \
+    if (unlikely (pos_y > decoder->limit_y)) {                      \
+    pos_y = ((int)pos_y < 0) ? 0 : decoder->limit_y;              \
+    motion_y = pos_y - decoder->v_offset;                      \
+    }                                          \
+    xy_half = ((pos_y & 1) << 1) | (pos_x & 1);                      \
+    offset = (pos_x >> 1) + (pos_y & ~1) * decoder->stride;              \
+    table[xy_half] (decoder->dest[0] + decoder->offset,                  \
+            ref[0] + offset, 2 * decoder->stride, 8);              \
     table[xy_half] (decoder->dest[0] + decoder->stride + decoder->offset,     \
-                   ref[0] + decoder->stride + offset,                        \
-                   2 * decoder->stride, 8);                                  \
-    table[xy_half] (decoder->dest[1] + decoder->offset,                              \
-                   ref[1] + offset, 2 * decoder->stride, 8);                 \
+            ref[0] + decoder->stride + offset,                  \
+            2 * decoder->stride, 8);                      \
+    table[xy_half] (decoder->dest[1] + decoder->offset,                  \
+            ref[1] + offset, 2 * decoder->stride, 8);              \
     table[xy_half] (decoder->dest[1] + decoder->stride + decoder->offset,     \
-                   ref[1] + decoder->stride + offset,                        \
-                   2 * decoder->stride, 8);                                  \
-    table[xy_half] (decoder->dest[2] + decoder->offset,                              \
-                   ref[2] + offset, 2 * decoder->stride, 8);                 \
+            ref[1] + decoder->stride + offset,                  \
+            2 * decoder->stride, 8);                      \
+    table[xy_half] (decoder->dest[2] + decoder->offset,                  \
+            ref[2] + offset, 2 * decoder->stride, 8);              \
     table[xy_half] (decoder->dest[2] + decoder->stride + decoder->offset,     \
-                   ref[2] + decoder->stride + offset,                        \
-                   2 * decoder->stride, 8)
-
-#define MOTION_ZERO_444(table,ref)                                           \
-    offset = decoder->offset + decoder->v_offset * decoder->stride;          \
-    table[0] (decoder->dest[0] + decoder->offset,                            \
-             ref[0] + offset, decoder->stride, 16);                          \
-    table[4] (decoder->dest[1] + decoder->offset,                            \
-             ref[1] + offset, decoder->stride, 16);                          \
-    table[4] (decoder->dest[2] + (decoder->offset >> 1),                     \
-             ref[2] + offset, decoder->stride, 16)
+            ref[2] + decoder->stride + offset,                  \
+            2 * decoder->stride, 8)
+
+#define MOTION_ZERO_444(table,ref)                          \
+    offset = decoder->offset + decoder->v_offset * decoder->stride;          \
+    table[0] (decoder->dest[0] + decoder->offset,                  \
+          ref[0] + offset, decoder->stride, 16);                  \
+    table[4] (decoder->dest[1] + decoder->offset,                  \
+          ref[1] + offset, decoder->stride, 16);                  \
+    table[4] (decoder->dest[2] + (decoder->offset >> 1),              \
+          ref[2] + offset, decoder->stride, 16)
 
 #define bit_buf (decoder->bitstream_buf)
 #define bits (decoder->bitstream_bits)
 #define bit_ptr (decoder->bitstream_ptr)
 
 static void motion_mp1 (mpeg2_decoder_t * const decoder,
-                       motion_t * const motion,
-                       mpeg2_mc_fct * const * const table)
+            motion_t * const motion,
+            mpeg2_mc_fct * const * const table)
 {
     int motion_x, motion_y;
     unsigned int pos_x, pos_y, xy_half, offset;
@@ -421,231 +421,231 @@ static void motion_mp1 (mpeg2_decoder_t * const decoder,
 }
 
 #define MOTION_FUNCTIONS(FORMAT,MOTION,MOTION_FIELD,MOTION_DMV,MOTION_ZERO)   \
-                                                                             \
-static void motion_fr_frame_##FORMAT (mpeg2_decoder_t * const decoder,       \
-                                     motion_t * const motion,                \
-                                     mpeg2_mc_fct * const * const table)     \
-{                                                                            \
-    int motion_x, motion_y;                                                  \
-    unsigned int pos_x, pos_y, xy_half, offset;                                      \
-                                                                             \
-    NEEDBITS (bit_buf, bits, bit_ptr);                                       \
-    motion_x = motion->pmv[0][0] + get_motion_delta (decoder,                \
-                                                    motion->f_code[0]);      \
-    motion_x = bound_motion_vector (motion_x, motion->f_code[0]);            \
-    motion->pmv[1][0] = motion->pmv[0][0] = motion_x;                        \
-                                                                             \
-    NEEDBITS (bit_buf, bits, bit_ptr);                                       \
-    motion_y = motion->pmv[0][1] + get_motion_delta (decoder,                \
-                                                    motion->f_code[1]);      \
-    motion_y = bound_motion_vector (motion_y, motion->f_code[1]);            \
-    motion->pmv[1][1] = motion->pmv[0][1] = motion_y;                        \
-                                                                             \
-    MOTION (table, motion->ref[0], motion_x, motion_y, 16, 0);               \
-}                                                                            \
-                                                                             \
-static void motion_fr_field_##FORMAT (mpeg2_decoder_t * const decoder,       \
-                                     motion_t * const motion,                \
-                                     mpeg2_mc_fct * const * const table)     \
-{                                                                            \
-    int motion_x, motion_y, field;                                           \
-    unsigned int pos_x, pos_y, xy_half, offset;                                      \
-                                                                             \
-    NEEDBITS (bit_buf, bits, bit_ptr);                                       \
-    field = UBITS (bit_buf, 1);                                                      \
-    DUMPBITS (bit_buf, bits, 1);                                             \
-                                                                             \
-    motion_x = motion->pmv[0][0] + get_motion_delta (decoder,                \
-                                                    motion->f_code[0]);      \
-    motion_x = bound_motion_vector (motion_x, motion->f_code[0]);            \
-    motion->pmv[0][0] = motion_x;                                            \
-                                                                             \
-    NEEDBITS (bit_buf, bits, bit_ptr);                                       \
-    motion_y = ((motion->pmv[0][1] >> 1) +                                   \
-               get_motion_delta (decoder, motion->f_code[1]));               \
-    /* motion_y = bound_motion_vector (motion_y, motion->f_code[1]); */              \
-    motion->pmv[0][1] = motion_y << 1;                                       \
-                                                                             \
+                                          \
+static void motion_fr_frame_##FORMAT (mpeg2_decoder_t * const decoder,          \
+                      motion_t * const motion,              \
+                      mpeg2_mc_fct * const * const table)     \
+{                                          \
+    int motion_x, motion_y;                              \
+    unsigned int pos_x, pos_y, xy_half, offset;                      \
+                                          \
+    NEEDBITS (bit_buf, bits, bit_ptr);                          \
+    motion_x = motion->pmv[0][0] + get_motion_delta (decoder,              \
+                             motion->f_code[0]);      \
+    motion_x = bound_motion_vector (motion_x, motion->f_code[0]);          \
+    motion->pmv[1][0] = motion->pmv[0][0] = motion_x;                  \
+                                          \
+    NEEDBITS (bit_buf, bits, bit_ptr);                          \
+    motion_y = motion->pmv[0][1] + get_motion_delta (decoder,              \
+                             motion->f_code[1]);      \
+    motion_y = bound_motion_vector (motion_y, motion->f_code[1]);          \
+    motion->pmv[1][1] = motion->pmv[0][1] = motion_y;                  \
+                                          \
+    MOTION (table, motion->ref[0], motion_x, motion_y, 16, 0);              \
+}                                          \
+                                          \
+static void motion_fr_field_##FORMAT (mpeg2_decoder_t * const decoder,          \
+                      motion_t * const motion,              \
+                      mpeg2_mc_fct * const * const table)     \
+{                                          \
+    int motion_x, motion_y, field;                          \
+    unsigned int pos_x, pos_y, xy_half, offset;                      \
+                                          \
+    NEEDBITS (bit_buf, bits, bit_ptr);                          \
+    field = UBITS (bit_buf, 1);                              \
+    DUMPBITS (bit_buf, bits, 1);                          \
+                                          \
+    motion_x = motion->pmv[0][0] + get_motion_delta (decoder,              \
+                             motion->f_code[0]);      \
+    motion_x = bound_motion_vector (motion_x, motion->f_code[0]);          \
+    motion->pmv[0][0] = motion_x;                          \
+                                          \
+    NEEDBITS (bit_buf, bits, bit_ptr);                          \
+    motion_y = ((motion->pmv[0][1] >> 1) +                      \
+        get_motion_delta (decoder, motion->f_code[1]));              \
+    /* motion_y = bound_motion_vector (motion_y, motion->f_code[1]); */          \
+    motion->pmv[0][1] = motion_y << 1;                          \
+                                          \
     MOTION_FIELD (table, motion->ref[0], motion_x, motion_y, 0, & ~1, field); \
-                                                                             \
-    NEEDBITS (bit_buf, bits, bit_ptr);                                       \
-    field = UBITS (bit_buf, 1);                                                      \
-    DUMPBITS (bit_buf, bits, 1);                                             \
-                                                                             \
-    motion_x = motion->pmv[1][0] + get_motion_delta (decoder,                \
-                                                    motion->f_code[0]);      \
-    motion_x = bound_motion_vector (motion_x, motion->f_code[0]);            \
-    motion->pmv[1][0] = motion_x;                                            \
-                                                                             \
-    NEEDBITS (bit_buf, bits, bit_ptr);                                       \
-    motion_y = ((motion->pmv[1][1] >> 1) +                                   \
-               get_motion_delta (decoder, motion->f_code[1]));               \
-    /* motion_y = bound_motion_vector (motion_y, motion->f_code[1]); */              \
-    motion->pmv[1][1] = motion_y << 1;                                       \
-                                                                             \
+                                          \
+    NEEDBITS (bit_buf, bits, bit_ptr);                          \
+    field = UBITS (bit_buf, 1);                              \
+    DUMPBITS (bit_buf, bits, 1);                          \
+                                          \
+    motion_x = motion->pmv[1][0] + get_motion_delta (decoder,              \
+                             motion->f_code[0]);      \
+    motion_x = bound_motion_vector (motion_x, motion->f_code[0]);          \
+    motion->pmv[1][0] = motion_x;                          \
+                                          \
+    NEEDBITS (bit_buf, bits, bit_ptr);                          \
+    motion_y = ((motion->pmv[1][1] >> 1) +                      \
+        get_motion_delta (decoder, motion->f_code[1]));              \
+    /* motion_y = bound_motion_vector (motion_y, motion->f_code[1]); */          \
+    motion->pmv[1][1] = motion_y << 1;                          \
+                                          \
     MOTION_FIELD (table, motion->ref[0], motion_x, motion_y, 1, & ~1, field); \
-}                                                                            \
-                                                                             \
-static void motion_fr_dmv_##FORMAT (mpeg2_decoder_t * const decoder,         \
-                                   motion_t * const motion,                  \
-                                   mpeg2_mc_fct * const * const table)       \
-{                                                                            \
-    int motion_x, motion_y, dmv_x, dmv_y, m, other_x, other_y;               \
-    unsigned int pos_x, pos_y, xy_half, offset;                                      \
-                                                                             \
-    NEEDBITS (bit_buf, bits, bit_ptr);                                       \
-    motion_x = motion->pmv[0][0] + get_motion_delta (decoder,                \
-                                                    motion->f_code[0]);      \
-    motion_x = bound_motion_vector (motion_x, motion->f_code[0]);            \
-    motion->pmv[1][0] = motion->pmv[0][0] = motion_x;                        \
-    NEEDBITS (bit_buf, bits, bit_ptr);                                       \
-    dmv_x = get_dmv (decoder);                                               \
-                                                                             \
-    motion_y = ((motion->pmv[0][1] >> 1) +                                   \
-               get_motion_delta (decoder, motion->f_code[1]));               \
-    /* motion_y = bound_motion_vector (motion_y, motion->f_code[1]); */              \
-    motion->pmv[1][1] = motion->pmv[0][1] = motion_y << 1;                   \
-    dmv_y = get_dmv (decoder);                                               \
-                                                                             \
-    m = decoder->top_field_first ? 1 : 3;                                    \
-    other_x = ((motion_x * m + (motion_x > 0)) >> 1) + dmv_x;                \
-    other_y = ((motion_y * m + (motion_y > 0)) >> 1) + dmv_y - 1;            \
+}                                          \
+                                          \
+static void motion_fr_dmv_##FORMAT (mpeg2_decoder_t * const decoder,          \
+                    motion_t * const motion,              \
+                    mpeg2_mc_fct * const * const table)          \
+{                                          \
+    int motion_x, motion_y, dmv_x, dmv_y, m, other_x, other_y;              \
+    unsigned int pos_x, pos_y, xy_half, offset;                      \
+                                          \
+    NEEDBITS (bit_buf, bits, bit_ptr);                          \
+    motion_x = motion->pmv[0][0] + get_motion_delta (decoder,              \
+                             motion->f_code[0]);      \
+    motion_x = bound_motion_vector (motion_x, motion->f_code[0]);          \
+    motion->pmv[1][0] = motion->pmv[0][0] = motion_x;                  \
+    NEEDBITS (bit_buf, bits, bit_ptr);                          \
+    dmv_x = get_dmv (decoder);                              \
+                                          \
+    motion_y = ((motion->pmv[0][1] >> 1) +                      \
+        get_motion_delta (decoder, motion->f_code[1]));              \
+    /* motion_y = bound_motion_vector (motion_y, motion->f_code[1]); */          \
+    motion->pmv[1][1] = motion->pmv[0][1] = motion_y << 1;              \
+    dmv_y = get_dmv (decoder);                              \
+                                          \
+    m = decoder->top_field_first ? 1 : 3;                      \
+    other_x = ((motion_x * m + (motion_x > 0)) >> 1) + dmv_x;              \
+    other_y = ((motion_y * m + (motion_y > 0)) >> 1) + dmv_y - 1;          \
     MOTION_FIELD (mpeg2_mc.put, motion->ref[0], other_x, other_y, 0, | 1, 0); \
-                                                                             \
-    m = decoder->top_field_first ? 3 : 1;                                    \
-    other_x = ((motion_x * m + (motion_x > 0)) >> 1) + dmv_x;                \
-    other_y = ((motion_y * m + (motion_y > 0)) >> 1) + dmv_y + 1;            \
+                                          \
+    m = decoder->top_field_first ? 3 : 1;                      \
+    other_x = ((motion_x * m + (motion_x > 0)) >> 1) + dmv_x;              \
+    other_y = ((motion_y * m + (motion_y > 0)) >> 1) + dmv_y + 1;          \
     MOTION_FIELD (mpeg2_mc.put, motion->ref[0], other_x, other_y, 1, & ~1, 0);\
-                                                                             \
-    MOTION_DMV (mpeg2_mc.avg, motion->ref[0], motion_x, motion_y);           \
-}                                                                            \
-                                                                             \
-static void motion_reuse_##FORMAT (mpeg2_decoder_t * const decoder,          \
-                                  motion_t * const motion,                   \
-                                  mpeg2_mc_fct * const * const table)        \
-{                                                                            \
-    int motion_x, motion_y;                                                  \
-    unsigned int pos_x, pos_y, xy_half, offset;                                      \
-                                                                             \
-    motion_x = motion->pmv[0][0];                                            \
-    motion_y = motion->pmv[0][1];                                            \
-                                                                             \
-    MOTION (table, motion->ref[0], motion_x, motion_y, 16, 0);               \
-}                                                                            \
-                                                                             \
-static void motion_zero_##FORMAT (mpeg2_decoder_t * const decoder,           \
-                                 motion_t * const motion,                    \
-                                 mpeg2_mc_fct * const * const table)         \
-{                                                                            \
-    unsigned int offset;                                                     \
-                                                                             \
-    motion->pmv[0][0] = motion->pmv[0][1] = 0;                               \
-    motion->pmv[1][0] = motion->pmv[1][1] = 0;                               \
-                                                                             \
-    MOTION_ZERO (table, motion->ref[0]);                                     \
-}                                                                            \
-                                                                             \
-static void motion_fi_field_##FORMAT (mpeg2_decoder_t * const decoder,       \
-                                     motion_t * const motion,                \
-                                     mpeg2_mc_fct * const * const table)     \
-{                                                                            \
-    int motion_x, motion_y;                                                  \
-    uint8_t ** ref_field;                                                    \
-    unsigned int pos_x, pos_y, xy_half, offset;                                      \
-                                                                             \
-    NEEDBITS (bit_buf, bits, bit_ptr);                                       \
-    ref_field = motion->ref2[UBITS (bit_buf, 1)];                            \
-    DUMPBITS (bit_buf, bits, 1);                                             \
-                                                                             \
-    motion_x = motion->pmv[0][0] + get_motion_delta (decoder,                \
-                                                    motion->f_code[0]);      \
-    motion_x = bound_motion_vector (motion_x, motion->f_code[0]);            \
-    motion->pmv[1][0] = motion->pmv[0][0] = motion_x;                        \
-                                                                             \
-    NEEDBITS (bit_buf, bits, bit_ptr);                                       \
-    motion_y = motion->pmv[0][1] + get_motion_delta (decoder,                \
-                                                    motion->f_code[1]);      \
-    motion_y = bound_motion_vector (motion_y, motion->f_code[1]);            \
-    motion->pmv[1][1] = motion->pmv[0][1] = motion_y;                        \
-                                                                             \
-    MOTION (table, ref_field, motion_x, motion_y, 16, 0);                    \
-}                                                                            \
-                                                                             \
-static void motion_fi_16x8_##FORMAT (mpeg2_decoder_t * const decoder,        \
-                                    motion_t * const motion,                 \
-                                    mpeg2_mc_fct * const * const table)      \
-{                                                                            \
-    int motion_x, motion_y;                                                  \
-    uint8_t ** ref_field;                                                    \
-    unsigned int pos_x, pos_y, xy_half, offset;                                      \
-                                                                             \
-    NEEDBITS (bit_buf, bits, bit_ptr);                                       \
-    ref_field = motion->ref2[UBITS (bit_buf, 1)];                            \
-    DUMPBITS (bit_buf, bits, 1);                                             \
-                                                                             \
-    motion_x = motion->pmv[0][0] + get_motion_delta (decoder,                \
-                                                    motion->f_code[0]);      \
-    motion_x = bound_motion_vector (motion_x, motion->f_code[0]);            \
-    motion->pmv[0][0] = motion_x;                                            \
-                                                                             \
-    NEEDBITS (bit_buf, bits, bit_ptr);                                       \
-    motion_y = motion->pmv[0][1] + get_motion_delta (decoder,                \
-                                                    motion->f_code[1]);      \
-    motion_y = bound_motion_vector (motion_y, motion->f_code[1]);            \
-    motion->pmv[0][1] = motion_y;                                            \
-                                                                             \
-    MOTION (table, ref_field, motion_x, motion_y, 8, 0);                     \
-                                                                             \
-    NEEDBITS (bit_buf, bits, bit_ptr);                                       \
-    ref_field = motion->ref2[UBITS (bit_buf, 1)];                            \
-    DUMPBITS (bit_buf, bits, 1);                                             \
-                                                                             \
-    motion_x = motion->pmv[1][0] + get_motion_delta (decoder,                \
-                                                    motion->f_code[0]);      \
-    motion_x = bound_motion_vector (motion_x, motion->f_code[0]);            \
-    motion->pmv[1][0] = motion_x;                                            \
-                                                                             \
-    NEEDBITS (bit_buf, bits, bit_ptr);                                       \
-    motion_y = motion->pmv[1][1] + get_motion_delta (decoder,                \
-                                                    motion->f_code[1]);      \
-    motion_y = bound_motion_vector (motion_y, motion->f_code[1]);            \
-    motion->pmv[1][1] = motion_y;                                            \
-                                                                             \
-    MOTION (table, ref_field, motion_x, motion_y, 8, 8);                     \
-}                                                                            \
-                                                                             \
-static void motion_fi_dmv_##FORMAT (mpeg2_decoder_t * const decoder,         \
-                                   motion_t * const motion,                  \
-                                   mpeg2_mc_fct * const * const table)       \
-{                                                                            \
-    int motion_x, motion_y, other_x, other_y;                                \
-    unsigned int pos_x, pos_y, xy_half, offset;                                      \
-                                                                             \
-    NEEDBITS (bit_buf, bits, bit_ptr);                                       \
-    motion_x = motion->pmv[0][0] + get_motion_delta (decoder,                \
-                                                    motion->f_code[0]);      \
-    motion_x = bound_motion_vector (motion_x, motion->f_code[0]);            \
-    motion->pmv[1][0] = motion->pmv[0][0] = motion_x;                        \
-    NEEDBITS (bit_buf, bits, bit_ptr);                                       \
-    other_x = ((motion_x + (motion_x > 0)) >> 1) + get_dmv (decoder);        \
-                                                                             \
-    motion_y = motion->pmv[0][1] + get_motion_delta (decoder,                \
-                                                    motion->f_code[1]);      \
-    motion_y = bound_motion_vector (motion_y, motion->f_code[1]);            \
-    motion->pmv[1][1] = motion->pmv[0][1] = motion_y;                        \
-    other_y = (((motion_y + (motion_y > 0)) >> 1) + get_dmv (decoder) +              \
-              decoder->dmv_offset);                                          \
-                                                                             \
-    MOTION (mpeg2_mc.put, motion->ref[0], motion_x, motion_y, 16, 0);        \
-    MOTION (mpeg2_mc.avg, motion->ref[1], other_x, other_y, 16, 0);          \
-}                                                                            \
+                                          \
+    MOTION_DMV (mpeg2_mc.avg, motion->ref[0], motion_x, motion_y);          \
+}                                          \
+                                          \
+static void motion_reuse_##FORMAT (mpeg2_decoder_t * const decoder,          \
+                   motion_t * const motion,              \
+                   mpeg2_mc_fct * const * const table)          \
+{                                          \
+    int motion_x, motion_y;                              \
+    unsigned int pos_x, pos_y, xy_half, offset;                      \
+                                          \
+    motion_x = motion->pmv[0][0];                          \
+    motion_y = motion->pmv[0][1];                          \
+                                          \
+    MOTION (table, motion->ref[0], motion_x, motion_y, 16, 0);              \
+}                                          \
+                                          \
+static void motion_zero_##FORMAT (mpeg2_decoder_t * const decoder,          \
+                  motion_t * const motion,              \
+                  mpeg2_mc_fct * const * const table)          \
+{                                          \
+    unsigned int offset;                              \
+                                          \
+    motion->pmv[0][0] = motion->pmv[0][1] = 0;                      \
+    motion->pmv[1][0] = motion->pmv[1][1] = 0;                      \
+                                          \
+    MOTION_ZERO (table, motion->ref[0]);                      \
+}                                          \
+                                          \
+static void motion_fi_field_##FORMAT (mpeg2_decoder_t * const decoder,          \
+                      motion_t * const motion,              \
+                      mpeg2_mc_fct * const * const table)     \
+{                                          \
+    int motion_x, motion_y;                              \
+    uint8_t ** ref_field;                              \
+    unsigned int pos_x, pos_y, xy_half, offset;                      \
+                                          \
+    NEEDBITS (bit_buf, bits, bit_ptr);                          \
+    ref_field = motion->ref2[UBITS (bit_buf, 1)];                  \
+    DUMPBITS (bit_buf, bits, 1);                          \
+                                          \
+    motion_x = motion->pmv[0][0] + get_motion_delta (decoder,              \
+                             motion->f_code[0]);      \
+    motion_x = bound_motion_vector (motion_x, motion->f_code[0]);          \
+    motion->pmv[1][0] = motion->pmv[0][0] = motion_x;                  \
+                                          \
+    NEEDBITS (bit_buf, bits, bit_ptr);                          \
+    motion_y = motion->pmv[0][1] + get_motion_delta (decoder,              \
+                             motion->f_code[1]);      \
+    motion_y = bound_motion_vector (motion_y, motion->f_code[1]);          \
+    motion->pmv[1][1] = motion->pmv[0][1] = motion_y;                  \
+                                          \
+    MOTION (table, ref_field, motion_x, motion_y, 16, 0);              \
+}                                          \
+                                          \
+static void motion_fi_16x8_##FORMAT (mpeg2_decoder_t * const decoder,          \
+                     motion_t * const motion,              \
+                     mpeg2_mc_fct * const * const table)      \
+{                                          \
+    int motion_x, motion_y;                              \
+    uint8_t ** ref_field;                              \
+    unsigned int pos_x, pos_y, xy_half, offset;                      \
+                                          \
+    NEEDBITS (bit_buf, bits, bit_ptr);                          \
+    ref_field = motion->ref2[UBITS (bit_buf, 1)];                  \
+    DUMPBITS (bit_buf, bits, 1);                          \
+                                          \
+    motion_x = motion->pmv[0][0] + get_motion_delta (decoder,              \
+                             motion->f_code[0]);      \
+    motion_x = bound_motion_vector (motion_x, motion->f_code[0]);          \
+    motion->pmv[0][0] = motion_x;                          \
+                                          \
+    NEEDBITS (bit_buf, bits, bit_ptr);                          \
+    motion_y = motion->pmv[0][1] + get_motion_delta (decoder,              \
+                             motion->f_code[1]);      \
+    motion_y = bound_motion_vector (motion_y, motion->f_code[1]);          \
+    motion->pmv[0][1] = motion_y;                          \
+                                          \
+    MOTION (table, ref_field, motion_x, motion_y, 8, 0);              \
+                                          \
+    NEEDBITS (bit_buf, bits, bit_ptr);                          \
+    ref_field = motion->ref2[UBITS (bit_buf, 1)];                  \
+    DUMPBITS (bit_buf, bits, 1);                          \
+                                          \
+    motion_x = motion->pmv[1][0] + get_motion_delta (decoder,              \
+                             motion->f_code[0]);      \
+    motion_x = bound_motion_vector (motion_x, motion->f_code[0]);          \
+    motion->pmv[1][0] = motion_x;                          \
+                                          \
+    NEEDBITS (bit_buf, bits, bit_ptr);                          \
+    motion_y = motion->pmv[1][1] + get_motion_delta (decoder,              \
+                             motion->f_code[1]);      \
+    motion_y = bound_motion_vector (motion_y, motion->f_code[1]);          \
+    motion->pmv[1][1] = motion_y;                          \
+                                          \
+    MOTION (table, ref_field, motion_x, motion_y, 8, 8);              \
+}                                          \
+                                          \
+static void motion_fi_dmv_##FORMAT (mpeg2_decoder_t * const decoder,          \
+                    motion_t * const motion,              \
+                    mpeg2_mc_fct * const * const table)          \
+{                                          \
+    int motion_x, motion_y, other_x, other_y;                      \
+    unsigned int pos_x, pos_y, xy_half, offset;                      \
+                                          \
+    NEEDBITS (bit_buf, bits, bit_ptr);                          \
+    motion_x = motion->pmv[0][0] + get_motion_delta (decoder,              \
+                             motion->f_code[0]);      \
+    motion_x = bound_motion_vector (motion_x, motion->f_code[0]);          \
+    motion->pmv[1][0] = motion->pmv[0][0] = motion_x;                  \
+    NEEDBITS (bit_buf, bits, bit_ptr);                          \
+    other_x = ((motion_x + (motion_x > 0)) >> 1) + get_dmv (decoder);          \
+                                          \
+    motion_y = motion->pmv[0][1] + get_motion_delta (decoder,              \
+                             motion->f_code[1]);      \
+    motion_y = bound_motion_vector (motion_y, motion->f_code[1]);          \
+    motion->pmv[1][1] = motion->pmv[0][1] = motion_y;                  \
+    other_y = (((motion_y + (motion_y > 0)) >> 1) + get_dmv (decoder) +          \
+           decoder->dmv_offset);                          \
+                                          \
+    MOTION (mpeg2_mc.put, motion->ref[0], motion_x, motion_y, 16, 0);          \
+    MOTION (mpeg2_mc.avg, motion->ref[1], other_x, other_y, 16, 0);          \
+}                                          \
 
 MOTION_FUNCTIONS (420, MOTION_420, MOTION_FIELD_420, MOTION_DMV_420,
-                 MOTION_ZERO_420)
+          MOTION_ZERO_420)
 MOTION_FUNCTIONS (422, MOTION_422, MOTION_FIELD_422, MOTION_DMV_422,
-                 MOTION_ZERO_422)
+          MOTION_ZERO_422)
 MOTION_FUNCTIONS (444, MOTION_444, MOTION_FIELD_444, MOTION_DMV_444,
-                 MOTION_ZERO_444)
+          MOTION_ZERO_444)
 
 /* like motion_frame, but parsing without actual motion compensation */
 static void motion_fr_conceal (mpeg2_decoder_t * const decoder)
@@ -692,43 +692,43 @@ static void motion_fi_conceal (mpeg2_decoder_t * const decoder)
 #undef bits
 #undef bit_ptr
 
-#define MOTION_CALL(routine,direction)                         \
-do {                                                           \
-    if ((direction) & MACROBLOCK_MOTION_FORWARD)               \
-       routine (decoder, &(decoder->f_motion), mpeg2_mc.put);  \
-    if ((direction) & MACROBLOCK_MOTION_BACKWARD)              \
-       routine (decoder, &(decoder->b_motion),                 \
-                ((direction) & MACROBLOCK_MOTION_FORWARD ?     \
-                 mpeg2_mc.avg : mpeg2_mc.put));                \
+#define MOTION_CALL(routine,direction)                \
+do {                                \
+    if ((direction) & MACROBLOCK_MOTION_FORWARD)        \
+    routine (decoder, &(decoder->f_motion), mpeg2_mc.put);    \
+    if ((direction) & MACROBLOCK_MOTION_BACKWARD)        \
+    routine (decoder, &(decoder->b_motion),            \
+         ((direction) & MACROBLOCK_MOTION_FORWARD ?    \
+          mpeg2_mc.avg : mpeg2_mc.put));        \
 } while (0)
 
-#define NEXT_MACROBLOCK                                                        \
-do {                                                                   \
-    decoder->offset += 16;                                             \
-    if (decoder->offset == decoder->width) {                           \
-       do { /* just so we can use the break statement */               \
-           if (decoder->convert) {                                     \
-               decoder->convert (decoder->convert_id, decoder->dest,   \
-                                 decoder->v_offset);                   \
-               if (decoder->coding_type == B_TYPE)                     \
-                   break;                                              \
-           }                                                           \
-           decoder->dest[0] += decoder->slice_stride;                  \
-           decoder->dest[1] += decoder->slice_uv_stride;               \
-           decoder->dest[2] += decoder->slice_uv_stride;               \
-       } while (0);                                                    \
-       decoder->v_offset += 16;                                        \
-       if (decoder->v_offset > decoder->limit_y) {                     \
-           if (mpeg2_cpu_state_restore)                                \
-               mpeg2_cpu_state_restore (&cpu_state);                   \
-           return;                                                     \
-       }                                                               \
-       decoder->offset = 0;                                            \
-    }                                                                  \
+#define NEXT_MACROBLOCK                            \
+do {                                    \
+    decoder->offset += 16;                        \
+    if (decoder->offset == decoder->width) {                \
+    do { /* just so we can use the break statement */        \
+        if (decoder->convert) {                    \
+        decoder->convert (decoder->convert_id, decoder->dest,    \
+                  decoder->v_offset);            \
+        if (decoder->coding_type == B_TYPE)            \
+            break;                        \
+        }                                \
+        decoder->dest[0] += decoder->slice_stride;            \
+        decoder->dest[1] += decoder->slice_uv_stride;        \
+        decoder->dest[2] += decoder->slice_uv_stride;        \
+    } while (0);                            \
+    decoder->v_offset += 16;                    \
+    if (decoder->v_offset > decoder->limit_y) {            \
+        if (mpeg2_cpu_state_restore)                \
+        mpeg2_cpu_state_restore (&cpu_state);            \
+        return;                            \
+    }                                \
+    decoder->offset = 0;                        \
+    }                                    \
 } while (0)
 
 void mpeg2_init_fbuf (mpeg2_decoder_t * decoder, uint8_t * current_fbuf[3],
-                     uint8_t * forward_fbuf[3], uint8_t * backward_fbuf[3])
+              uint8_t * forward_fbuf[3], uint8_t * backward_fbuf[3])
 {
     int offset, stride, height, bottom_field;