Ticket #1479: 1479-small.diff

File 1479-small.diff, 6.5 KB (added by Mike Z, 14 years ago)

This patch allows the build to finish if --disable-optimizations --enable-small is turned on.

  • libswscale/output.c

     
    124124};
    125125#endif
    126126
    127 #define output_pixel(pos, val, bias, signedness) \
     127#define output_pixel(big_endian, pos, val, bias, signedness)    \
    128128    if (big_endian) { \
    129129        AV_WB16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
    130130    } else { \
    131131        AV_WL16(pos, bias + av_clip_ ## signedness ## 16(val >> shift)); \
    132132    }
    133133
    134 static av_always_inline void
    135 yuv2plane1_16_c_template(const int32_t *src, uint16_t *dest, int dstW,
    136                          int big_endian, int output_bits)
    137 {
    138     int i;
    139     int shift = 3;
    140     av_assert0(output_bits == 16);
    141 
    142     for (i = 0; i < dstW; i++) {
    143         int val = src[i] + (1 << (shift - 1));
    144         output_pixel(&dest[i], val, 0, uint);
    145     }
     134#define yuv2NBPS16(bits, BE_LE, is_be, typeX_t) \
     135static void yuv2plane1_ ## bits ## BE_LE ## _c(const int16_t *src, \
     136                              uint8_t *dest, int dstW, \
     137                              const uint8_t *dither, int offset) \
     138{ \
     139    int i; \
     140    int shift = 3; \
     141    av_assert0(bits == 16); \
     142 \
     143    for (i = 0; i < dstW; i++) { \
     144            int val = ((typeX_t *)src)[i] + (1 << (shift - 1)); \
     145            output_pixel(is_be, &((uint16_t *)dest)[i], val, 0, uint); \
     146    } \
     147} \
     148static void yuv2planeX_ ## bits ## BE_LE ## _c(const int16_t *filter, int filterSize, \
     149                              const int16_t **src, uint8_t *dest, int dstW, \
     150                              const uint8_t *dither, int offset) \
     151{ \
     152    int i; \
     153    int shift = 15; \
     154    av_assert0(bits == 16); \
     155 \
     156    for (i = 0; i < dstW; i++) { \
     157        int val = 1 << (shift - 1); \
     158        int j; \
     159 \
     160        /* range of val is [0,0x7FFFFFFF], so 31 bits, but with lanczos/spline \
     161         * filters (or anything with negative coeffs, the range can be slightly \
     162         * wider in both directions. To account for this overflow, we subtract \
     163         * a constant so it always fits in the signed range (assuming a \
     164         * reasonable filterSize), and re-add that at the end. */ \
     165        val -= 0x40000000; \
     166        for (j = 0; j < filterSize; j++) \
     167                val += ((typeX_t **)src)[j][i] * filter[j]; \
     168 \
     169        output_pixel(is_be, &((uint16_t *)dest)[i], val, 0x8000, int); \
     170    } \
    146171}
    147172
    148 static av_always_inline void
    149 yuv2planeX_16_c_template(const int16_t *filter, int filterSize,
    150                          const int32_t **src, uint16_t *dest, int dstW,
    151                          int big_endian, int output_bits)
    152 {
    153     int i;
    154     int shift = 15;
    155     av_assert0(output_bits == 16);
     173yuv2NBPS16(16, BE, 1, int32_t)
     174yuv2NBPS16(16, LE, 0, int32_t)
    156175
    157     for (i = 0; i < dstW; i++) {
    158         int val = 1 << (shift - 1);
    159         int j;
    160 
    161         /* range of val is [0,0x7FFFFFFF], so 31 bits, but with lanczos/spline
    162          * filters (or anything with negative coeffs, the range can be slightly
    163          * wider in both directions. To account for this overflow, we subtract
    164          * a constant so it always fits in the signed range (assuming a
    165          * reasonable filterSize), and re-add that at the end. */
    166         val -= 0x40000000;
    167         for (j = 0; j < filterSize; j++)
    168             val += src[j][i] * filter[j];
    169 
    170         output_pixel(&dest[i], val, 0x8000, int);
    171     }
    172 }
    173 
    174176#undef output_pixel
    175177
    176 #define output_pixel(pos, val) \
     178#define output_pixel(big_endian, output_bits, pos, val) \
    177179    if (big_endian) { \
    178180        AV_WB16(pos, av_clip_uintp2(val >> shift, output_bits)); \
    179181    } else { \
    180182        AV_WL16(pos, av_clip_uintp2(val >> shift, output_bits)); \
    181183    }
    182184
    183 static av_always_inline void
    184 yuv2plane1_10_c_template(const int16_t *src, uint16_t *dest, int dstW,
    185                          int big_endian, int output_bits)
    186 {
    187     int i;
    188     int shift = 15 - output_bits;
    189 
    190     for (i = 0; i < dstW; i++) {
    191         int val = src[i] + (1 << (shift - 1));
    192         output_pixel(&dest[i], val);
    193     }
    194 }
    195 
    196 static av_always_inline void
    197 yuv2planeX_10_c_template(const int16_t *filter, int filterSize,
    198                          const int16_t **src, uint16_t *dest, int dstW,
    199                          int big_endian, int output_bits)
    200 {
    201     int i;
    202     int shift = 11 + 16 - output_bits;
    203 
    204     for (i = 0; i < dstW; i++) {
    205         int val = 1 << (shift - 1);
    206         int j;
    207 
    208         for (j = 0; j < filterSize; j++)
    209             val += src[j][i] * filter[j];
    210 
    211         output_pixel(&dest[i], val);
    212     }
    213 }
    214 
    215 #undef output_pixel
    216 
    217 #define yuv2NBPS(bits, BE_LE, is_be, template_size, typeX_t) \
     185#define yuv2NBPS10(bits, BE_LE, is_be, typeX_t) \
    218186static void yuv2plane1_ ## bits ## BE_LE ## _c(const int16_t *src, \
    219187                              uint8_t *dest, int dstW, \
    220188                              const uint8_t *dither, int offset)\
    221189{ \
    222     yuv2plane1_ ## template_size ## _c_template((const typeX_t *) src, \
    223                          (uint16_t *) dest, dstW, is_be, bits); \
    224 }\
     190    int i; \
     191    int shift = 15 - bits; \
     192 \
     193    for (i = 0; i < dstW; i++) { \
     194            int val = ((const typeX_t *)src)[i] + (1 << (shift - 1)); \
     195            output_pixel(is_be, bits, &((uint16_t *)dest)[i], val); \
     196    } \
     197} \
    225198static void yuv2planeX_ ## bits ## BE_LE ## _c(const int16_t *filter, int filterSize, \
    226199                              const int16_t **src, uint8_t *dest, int dstW, \
    227                               const uint8_t *dither, int offset)\
     200                              const uint8_t *dither, int offset) \
    228201{ \
    229     yuv2planeX_## template_size ## _c_template(filter, \
    230                          filterSize, (const typeX_t **) src, \
    231                          (uint16_t *) dest, dstW, is_be, bits); \
     202    int i; \
     203    int shift = 11 + 16 - bits; \
     204 \
     205    for (i = 0; i < dstW; i++) { \
     206        int val = 1 << (shift - 1); \
     207        int j; \
     208 \
     209        for (j = 0; j < filterSize; j++) \
     210                val += ((const typeX_t **)src)[j][i] * filter[j]; \
     211 \
     212        output_pixel(is_be, bits, &((uint16_t *)dest)[i], val); \
     213    } \
    232214}
    233 yuv2NBPS( 9, BE, 1, 10, int16_t)
    234 yuv2NBPS( 9, LE, 0, 10, int16_t)
    235 yuv2NBPS(10, BE, 1, 10, int16_t)
    236 yuv2NBPS(10, LE, 0, 10, int16_t)
    237 yuv2NBPS(16, BE, 1, 16, int32_t)
    238 yuv2NBPS(16, LE, 0, 16, int32_t)
    239215
     216yuv2NBPS10( 9, BE, 1, int16_t)
     217yuv2NBPS10( 9, LE, 0, int16_t)
     218yuv2NBPS10(10, BE, 1, int16_t)
     219yuv2NBPS10(10, LE, 0, int16_t)
     220
     221#undef output_pixel
     222
    240223static void yuv2planeX_8_c(const int16_t *filter, int filterSize,
    241224                           const int16_t **src, uint8_t *dest, int dstW,
    242225                           const uint8_t *dither, int offset)