Revision 90226a43 postproc/rgb2rgb.c

View differences:

postproc/rgb2rgb.c
216 216

  
217 217
void rgb32to16(const uint8_t *src, uint8_t *dst, unsigned src_size)
218 218
{
219
	unsigned i,num_pixels=src_size/4;
220
	for(i=0; i<num_pixels; i+=4)
219
	unsigned j,i,num_pixels=src_size/4;
220
	uint16_t *d = (uint16_t *)dst;
221
	for(i=0,j=0; j<num_pixels; i+=4,j++)
221 222
	{
222 223
		const int b= src[i+0];
223 224
		const int g= src[i+1];
224 225
		const int r= src[i+2];
225 226

  
226
		((uint16_t *)dst)[i]= (b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8);
227
		d[j]= (b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8);
227 228
	}
228 229
}
229 230

  
230 231
void rgb32to15(const uint8_t *src, uint8_t *dst, unsigned src_size)
231 232
{
232
	unsigned i,num_pixels=src_size/4;
233
	for(i=0; i<num_pixels; i+=4)
233
	unsigned j,i,num_pixels=src_size/4;
234
	uint16_t *d = (uint16_t *)dst;
235
	for(i=0,j=0; j<num_pixels; i+=4,j++)
234 236
	{
235 237
		const int b= src[i+0];
236 238
		const int g= src[i+1];
237 239
		const int r= src[i+2];
238 240

  
239
		((uint16_t *)dst)[i]= (b>>3) | ((g&0xF8)<<3) | ((r&0xF8)<<7);
241
		d[j]= (b>>3) | ((g&0xF8)<<3) | ((r&0xF8)<<7);
240 242
	}
241 243
}
242 244

  
243 245
void rgb24to16(const uint8_t *src, uint8_t *dst, unsigned src_size)
244 246
{
245
	unsigned i,num_pixels=src_size/3;
246
	for(i=0; i<num_pixels; i+=3)
247
	unsigned j,i,num_pixels=src_size/3;
248
	uint16_t *d = (uint16_t *)dst;
249
	for(i=0,j=0; j<num_pixels; i+=3,j++)
247 250
	{
248 251
		const int b= src[i+0];
249 252
		const int g= src[i+1];
250 253
		const int r= src[i+2];
251 254

  
252
		((uint16_t *)dst)[i]= (b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8);
255
		d[j]= (b>>3) | ((g&0xFC)<<3) | ((r&0xF8)<<8);
253 256
	}
254 257
}
255 258

  
256 259
void rgb24to15(const uint8_t *src, uint8_t *dst, unsigned src_size)
257 260
{
258
	unsigned i,num_pixels=src_size/3;
259
	for(i=0; i<num_pixels; i+=3)
261
	unsigned j,i,num_pixels=src_size/3;
262
	uint16_t *d = (uint16_t *)dst;
263
	for(i=0,j=0; j<num_pixels; i+=3,j++)
260 264
	{
261 265
		const int b= src[i+0];
262 266
		const int g= src[i+1];
263 267
		const int r= src[i+2];
264 268

  
265
		((uint16_t *)dst)[i]= (b>>3) | ((g&0xF8)<<3) | ((r&0xF8)<<7);
269
		d[j]= (b>>3) | ((g&0xF8)<<3) | ((r&0xF8)<<7);
266 270
	}
267 271
}
268 272

  

Also available in: Unified diff