Index: libswscale/output.c
===================================================================
--- libswscale/output.c	(revision 124)
+++ libswscale/output.c	(working copy)
@@ -124,119 +124,102 @@
 };
 #endif
 
-#define output_pixel(pos, val, bias, signedness) \
+#define output_pixel(big_endian, pos, val, bias, signedness)	\
     if (big_endian) { \
         AV_WB16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
     } else { \
         AV_WL16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
     }
 
-static av_always_inline void
-yuv2plane1_16_c_template(const int32_t *src, uint16_t *dest, int dstW,
-                         int big_endian, int output_bits)
-{
-    int i;
-    int shift = 3;
-    av_assert0(output_bits == 16);
-
-    for (i = 0; i < dstW; i++) {
-        int val = src[i] + (1 << (shift - 1));
-        output_pixel(&dest[i], val, 0, uint);
-    }
+#define yuv2NBPS16(bits, BE_LE, is_be, typeX_t) \
+static void yuv2plane1_ ## bits ## BE_LE ## _c(const int16_t *src, \
+                              uint8_t *dest, int dstW, \
+                              const uint8_t *dither, int offset) \
+{ \
+    int i; \
+    int shift = 3; \
+    av_assert0(bits == 16); \
+ \
+    for (i = 0; i < dstW; i++) { \
+	    int val = ((typeX_t *)src)[i] + (1 << (shift - 1)); \
+	    output_pixel(is_be, &((uint16_t *)dest)[i], val, 0, uint); \
+    } \
+} \
+static void yuv2planeX_ ## bits ## BE_LE ## _c(const int16_t *filter, int filterSize, \
+                              const int16_t **src, uint8_t *dest, int dstW, \
+                              const uint8_t *dither, int offset) \
+{ \
+    int i; \
+    int shift = 15; \
+    av_assert0(bits == 16); \
+ \
+    for (i = 0; i < dstW; i++) { \
+        int val = 1 << (shift - 1); \
+        int j; \
+ \
+        /* range of val is [0,0x7FFFFFFF], so 31 bits, but with lanczos/spline \
+         * filters (or anything with negative coeffs, the range can be slightly	\
+         * wider in both directions. To account for this overflow, we subtract \
+         * a constant so it always fits in the signed range (assuming a	\
+         * reasonable filterSize), and re-add that at the end. */ \
+        val -= 0x40000000; \
+        for (j = 0; j < filterSize; j++) \
+		val += ((typeX_t **)src)[j][i] * filter[j]; \
+ \
+        output_pixel(is_be, &((uint16_t *)dest)[i], val, 0x8000, int); \
+    } \
 }
 
-static av_always_inline void
-yuv2planeX_16_c_template(const int16_t *filter, int filterSize,
-                         const int32_t **src, uint16_t *dest, int dstW,
-                         int big_endian, int output_bits)
-{
-    int i;
-    int shift = 15;
-    av_assert0(output_bits == 16);
+yuv2NBPS16(16, BE, 1, int32_t)
+yuv2NBPS16(16, LE, 0, int32_t)
 
-    for (i = 0; i < dstW; i++) {
-        int val = 1 << (shift - 1);
-        int j;
-
-        /* range of val is [0,0x7FFFFFFF], so 31 bits, but with lanczos/spline
-         * filters (or anything with negative coeffs, the range can be slightly
-         * wider in both directions. To account for this overflow, we subtract
-         * a constant so it always fits in the signed range (assuming a
-         * reasonable filterSize), and re-add that at the end. */
-        val -= 0x40000000;
-        for (j = 0; j < filterSize; j++)
-            val += src[j][i] * filter[j];
-
-        output_pixel(&dest[i], val, 0x8000, int);
-    }
-}
-
 #undef output_pixel
 
-#define output_pixel(pos, val) \
+#define output_pixel(big_endian, output_bits, pos, val)	\
     if (big_endian) { \
         AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits)); \
     } else { \
         AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits)); \
     }
 
-static av_always_inline void
-yuv2plane1_10_c_template(const int16_t *src, uint16_t *dest, int dstW,
-                         int big_endian, int output_bits)
-{
-    int i;
-    int shift = 15 - output_bits;
-
-    for (i = 0; i < dstW; i++) {
-        int val = src[i] + (1 << (shift - 1));
-        output_pixel(&dest[i], val);
-    }
-}
-
-static av_always_inline void
-yuv2planeX_10_c_template(const int16_t *filter, int filterSize,
-                         const int16_t **src, uint16_t *dest, int dstW,
-                         int big_endian, int output_bits)
-{
-    int i;
-    int shift = 11 + 16 - output_bits;
-
-    for (i = 0; i < dstW; i++) {
-        int val = 1 << (shift - 1);
-        int j;
-
-        for (j = 0; j < filterSize; j++)
-            val += src[j][i] * filter[j];
-
-        output_pixel(&dest[i], val);
-    }
-}
-
-#undef output_pixel
-
-#define yuv2NBPS(bits, BE_LE, is_be, template_size, typeX_t) \
+#define yuv2NBPS10(bits, BE_LE, is_be, typeX_t) \
 static void yuv2plane1_ ## bits ## BE_LE ## _c(const int16_t *src, \
                               uint8_t *dest, int dstW, \
                               const uint8_t *dither, int offset)\
 { \
-    yuv2plane1_ ## template_size ## _c_template((const typeX_t *) src, \
-                         (uint16_t *) dest, dstW, is_be, bits); \
-}\
+    int i; \
+    int shift = 15 - bits; \
+ \
+    for (i = 0; i < dstW; i++) { \
+	    int val = ((const typeX_t *)src)[i] + (1 << (shift - 1)); \
+	    output_pixel(is_be, bits, &((uint16_t *)dest)[i], val); \
+    } \
+} \
 static void yuv2planeX_ ## bits ## BE_LE ## _c(const int16_t *filter, int filterSize, \
                               const int16_t **src, uint8_t *dest, int dstW, \
-                              const uint8_t *dither, int offset)\
+                              const uint8_t *dither, int offset) \
 { \
-    yuv2planeX_## template_size ## _c_template(filter, \
-                         filterSize, (const typeX_t **) src, \
-                         (uint16_t *) dest, dstW, is_be, bits); \
+    int i; \
+    int shift = 11 + 16 - bits; \
+ \
+    for (i = 0; i < dstW; i++) { \
+        int val = 1 << (shift - 1); \
+        int j; \
+ \
+        for (j = 0; j < filterSize; j++) \
+		val += ((const typeX_t **)src)[j][i] * filter[j]; \
+ \
+        output_pixel(is_be, bits, &((uint16_t *)dest)[i], val); \
+    } \
 }
-yuv2NBPS( 9, BE, 1, 10, int16_t)
-yuv2NBPS( 9, LE, 0, 10, int16_t)
-yuv2NBPS(10, BE, 1, 10, int16_t)
-yuv2NBPS(10, LE, 0, 10, int16_t)
-yuv2NBPS(16, BE, 1, 16, int32_t)
-yuv2NBPS(16, LE, 0, 16, int32_t)
 
+yuv2NBPS10( 9, BE, 1, int16_t)
+yuv2NBPS10( 9, LE, 0, int16_t)
+yuv2NBPS10(10, BE, 1, int16_t)
+yuv2NBPS10(10, LE, 0, int16_t)
+
+#undef output_pixel
+
 static void yuv2planeX_8_c(const int16_t *filter, int filterSize,
                            const int16_t **src, uint8_t *dest, int dstW,
                            const uint8_t *dither, int offset)
