Mercurial > libavcodec.hg
comparison iff.c @ 11660:dd10b0c7d0de libavcodec
Make two functions out of #define hackery.
Patch by Sebastian Vater, cdgs D basty A googlemail
author | cehoyos |
---|---|
date | Mon, 26 Apr 2010 22:00:57 +0000 |
parents | 7dd2a45249a9 |
children | 7a5f3c94b9ad |
comparison
equal
deleted
inserted
replaced
11659:45512d8b6b35 | 11660:dd10b0c7d0de |
---|---|
85 return avctx->bits_per_coded_sample <= 8 ? | 85 return avctx->bits_per_coded_sample <= 8 ? |
86 ff_cmap_read_palette(avctx, (uint32_t*)s->frame.data[1]) : 0; | 86 ff_cmap_read_palette(avctx, (uint32_t*)s->frame.data[1]) : 0; |
87 } | 87 } |
88 | 88 |
89 /** | 89 /** |
90 * Decode interleaved plane buffer | 90 * Decode interleaved plane buffer up to 8bpp |
91 * @param dst Destination buffer | |
92 * @param buf Source buffer | |
93 * @param buf_size | |
94 * @param bps bits_per_coded_sample (must be <= 8) | |
95 * @param plane plane number to decode as | |
96 */ | |
97 static void decodeplane8(uint8_t *dst, const uint8_t *const buf, int buf_size, int bps, int plane) | |
98 { | |
99 GetBitContext gb; | |
100 int i, b; | |
101 init_get_bits(&gb, buf, buf_size * 8); | |
102 for(i = 0; i < (buf_size * 8 + bps - 1) / bps; i++) { | |
103 for (b = 0; b < bps; b++) { | |
104 dst[ i*bps + b ] |= get_bits1(&gb) << plane; | |
105 } | |
106 } | |
107 } | |
108 | |
109 /** | |
110 * Decode interleaved plane buffer up to 24bpp | |
91 * @param dst Destination buffer | 111 * @param dst Destination buffer |
92 * @param buf Source buffer | 112 * @param buf Source buffer |
93 * @param buf_size | 113 * @param buf_size |
94 * @param bps bits_per_coded_sample | 114 * @param bps bits_per_coded_sample |
95 * @param plane plane number to decode as | 115 * @param plane plane number to decode as |
96 */ | 116 */ |
97 #define DECLARE_DECODEPLANE(suffix, type) \ | 117 static void decodeplane32(uint32_t *dst, const uint8_t *const buf, int buf_size, int bps, int plane) |
98 static void decodeplane##suffix(void *dst, const uint8_t *const buf, int buf_size, int bps, int plane) \ | 118 { |
99 { \ | 119 GetBitContext gb; |
100 GetBitContext gb; \ | 120 int i, b; |
101 int i, b; \ | 121 init_get_bits(&gb, buf, buf_size * 8); |
102 init_get_bits(&gb, buf, buf_size * 8); \ | 122 for(i = 0; i < (buf_size * 8 + bps - 1) / bps; i++) { |
103 for(i = 0; i < (buf_size * 8 + bps - 1) / bps; i++) { \ | 123 for (b = 0; b < bps; b++) { |
104 for (b = 0; b < bps; b++) { \ | 124 dst[ i*bps + b ] |= get_bits1(&gb) << plane; |
105 ((type *)dst)[ i*bps + b ] |= get_bits1(&gb) << plane; \ | 125 } |
106 } \ | 126 } |
107 } \ | 127 } |
108 } | |
109 DECLARE_DECODEPLANE(8, uint8_t) | |
110 DECLARE_DECODEPLANE(32, uint32_t) | |
111 | 128 |
112 static int decode_frame_ilbm(AVCodecContext *avctx, | 129 static int decode_frame_ilbm(AVCodecContext *avctx, |
113 void *data, int *data_size, | 130 void *data, int *data_size, |
114 AVPacket *avpkt) | 131 AVPacket *avpkt) |
115 { | 132 { |