Mercurial > libavcodec.hg
comparison iff.c @ 11700:6bdec2a0e7e1 libavcodec
Optimize decodeplane32().
Patch by Sebastian Vater <cdgs basty googlemail com>.
author | rbultje |
---|---|
date | Mon, 10 May 2010 17:18:09 +0000 |
parents | 83b49b0997e8 |
children | 269ce565c70b |
comparison
equal
deleted
inserted
replaced
11699:83b49b0997e8 | 11700:6bdec2a0e7e1 |
---|---|
77 static const uint64_t plane8_lut[8][256] = { | 77 static const uint64_t plane8_lut[8][256] = { |
78 LUT8(0), LUT8(1), LUT8(2), LUT8(3), | 78 LUT8(0), LUT8(1), LUT8(2), LUT8(3), |
79 LUT8(4), LUT8(5), LUT8(6), LUT8(7), | 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 * Convert CMAP buffer (stored in extradata) to lavc palette format | 114 * Convert CMAP buffer (stored in extradata) to lavc palette format |
84 */ | 115 */ |
85 int ff_cmap_read_palette(AVCodecContext *avctx, uint32_t *pal) | 116 int ff_cmap_read_palette(AVCodecContext *avctx, uint32_t *pal) |
86 { | 117 { |
154 * @param dst Destination buffer | 185 * @param dst Destination buffer |
155 * @param buf Source buffer | 186 * @param buf Source buffer |
156 * @param buf_size | 187 * @param buf_size |
157 * @param plane plane number to decode as | 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; | 192 const uint32_t *lut = plane32_lut[plane]; |
162 int i; | 193 do { |
163 const int b = buf_size * 8; | 194 unsigned mask = (*buf >> 2) & ~3; |
164 init_get_bits(&gb, buf, buf_size * 8); | 195 dst[0] |= lut[mask++]; |
165 for(i = 0; i < b; i++) { | 196 dst[1] |= lut[mask++]; |
166 dst[i] |= get_bits1(&gb) << plane; | 197 dst[2] |= lut[mask++]; |
167 } | 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 static int decode_frame_ilbm(AVCodecContext *avctx, | 208 static int decode_frame_ilbm(AVCodecContext *avctx, |
171 void *data, int *data_size, | 209 void *data, int *data_size, |
172 AVPacket *avpkt) | 210 AVPacket *avpkt) |