Revision dce2f7d3 libavcodec/iff.c

View differences:

libavcodec/iff.c
79 79
    LUT8(4), LUT8(5), LUT8(6), LUT8(7),
80 80
};
81 81

  
82
#define LUT32(plane) {                                \
83
             0,          0,          0,          0,   \
84
             0,          0,          0, 1 << plane,   \
85
             0,          0, 1 << plane,          0,   \
86
             0,          0, 1 << plane, 1 << plane,   \
87
             0, 1 << plane,          0,          0,   \
88
             0, 1 << plane,          0, 1 << plane,   \
89
             0, 1 << plane, 1 << plane,          0,   \
90
             0, 1 << plane, 1 << plane, 1 << plane,   \
91
    1 << plane,          0,          0,          0,   \
92
    1 << plane,          0,          0, 1 << plane,   \
93
    1 << plane,          0, 1 << plane,          0,   \
94
    1 << plane,          0, 1 << plane, 1 << plane,   \
95
    1 << plane, 1 << plane,          0,          0,   \
96
    1 << plane, 1 << plane,          0, 1 << plane,   \
97
    1 << plane, 1 << plane, 1 << plane,          0,   \
98
    1 << plane, 1 << plane, 1 << plane, 1 << plane,   \
99
}
100

  
101
// 32 planes * 4-bit mask * 4 lookup tables each
102
static const uint32_t plane32_lut[32][16*4] = {
103
    LUT32( 0), LUT32( 1), LUT32( 2), LUT32( 3),
104
    LUT32( 4), LUT32( 5), LUT32( 6), LUT32( 7),
105
    LUT32( 8), LUT32( 9), LUT32(10), LUT32(11),
106
    LUT32(12), LUT32(13), LUT32(14), LUT32(15),
107
    LUT32(16), LUT32(17), LUT32(18), LUT32(19),
108
    LUT32(20), LUT32(21), LUT32(22), LUT32(23),
109
    LUT32(24), LUT32(25), LUT32(26), LUT32(27),
110
    LUT32(28), LUT32(29), LUT32(30), LUT32(31),
111
};
112

  
82 113
/**
83 114
 * Convert CMAP buffer (stored in extradata) to lavc palette format
84 115
 */
......
156 187
 * @param buf_size
157 188
 * @param plane plane number to decode as
158 189
 */
159
static void decodeplane32(uint32_t *dst, const uint8_t *const buf, int buf_size, int plane)
190
static void decodeplane32(uint32_t *dst, const uint8_t *buf, int buf_size, int plane)
160 191
{
161
    GetBitContext gb;
162
    int i;
163
    const int b = buf_size * 8;
164
    init_get_bits(&gb, buf, buf_size * 8);
165
    for(i = 0; i < b; i++) {
166
        dst[i] |= get_bits1(&gb) << plane;
167
    }
192
    const uint32_t *lut = plane32_lut[plane];
193
    do {
194
        unsigned mask = (*buf >> 2) & ~3;
195
        dst[0] |= lut[mask++];
196
        dst[1] |= lut[mask++];
197
        dst[2] |= lut[mask++];
198
        dst[3] |= lut[mask];
199
        mask = (*buf++ << 2) & 0x3F;
200
        dst[4] |= lut[mask++];
201
        dst[5] |= lut[mask++];
202
        dst[6] |= lut[mask++];
203
        dst[7] |= lut[mask];
204
        dst += 8;
205
    } while (--buf_size);
168 206
}
169 207

  
170 208
static int decode_frame_ilbm(AVCodecContext *avctx,

Also available in: Unified diff