diff options
Diffstat (limited to 'source/blender/avi/intern/avirgb.c')
-rw-r--r-- | source/blender/avi/intern/avirgb.c | 84 |
1 files changed, 42 insertions, 42 deletions
diff --git a/source/blender/avi/intern/avirgb.c b/source/blender/avi/intern/avirgb.c index 36e862708f4..78316990d54 100644 --- a/source/blender/avi/intern/avirgb.c +++ b/source/blender/avi/intern/avirgb.c @@ -42,108 +42,108 @@ /* implementation */ -void *avi_converter_from_avi_rgb (AviMovie *movie, int stream, unsigned char *buffer, int *size) +void *avi_converter_from_avi_rgb(AviMovie *movie, int stream, unsigned char *buffer, int *size) { int x, y, i, rowstride; unsigned char *buf; AviBitmapInfoHeader *bi; - short bits= 32; + short bits = 32; (void)size; /* unused */ - bi= (AviBitmapInfoHeader *) movie->streams[stream].sf; - if (bi) bits= bi->BitCount; + bi = (AviBitmapInfoHeader *) movie->streams[stream].sf; + if (bi) bits = bi->BitCount; - if (bits==16) { + if (bits == 16) { unsigned short *pxl; unsigned char *to; #ifdef __BIG_ENDIAN__ unsigned char *pxla; #endif - buf = MEM_mallocN (movie->header->Height * movie->header->Width * 3, "fromavirgbbuf"); + buf = MEM_mallocN(movie->header->Height * movie->header->Width * 3, "fromavirgbbuf"); - y= movie->header->Height; - to= buf; + y = movie->header->Height; + to = buf; while (y--) { - pxl= (unsigned short *) (buffer + y * movie->header->Width * 2); + pxl = (unsigned short *) (buffer + y * movie->header->Width * 2); #ifdef __BIG_ENDIAN__ - pxla= (unsigned char *)pxl; + pxla = (unsigned char *)pxl; #endif - x= movie->header->Width; + x = movie->header->Width; while (x--) { #ifdef __BIG_ENDIAN__ - i= pxla[0]; - pxla[0]= pxla[1]; - pxla[1]= i; + i = pxla[0]; + pxla[0] = pxla[1]; + pxla[1] = i; - pxla+=2; + pxla += 2; #endif - *(to++)= ((*pxl>>10)&0x1f)*8; - *(to++)= ((*pxl>>5)&0x1f)*8; - *(to++)= (*pxl&0x1f)*8; + *(to++) = ((*pxl >> 10) & 0x1f) * 8; + *(to++) = ((*pxl >> 5) & 0x1f) * 8; + *(to++) = (*pxl & 0x1f) * 8; pxl++; } } - MEM_freeN (buffer); + MEM_freeN(buffer); return buf; } else { - buf = MEM_mallocN (movie->header->Height * movie->header->Width * 3, "fromavirgbbuf"); + buf = MEM_mallocN(movie->header->Height * movie->header->Width * 3, "fromavirgbbuf"); - rowstride = movie->header->Width*3; - if (bits!=16) if (movie->header->Width%2) rowstride++; + rowstride = movie->header->Width * 3; + if (bits != 16) if (movie->header->Width % 2) rowstride++; - for (y=0; y < movie->header->Height; y++) { - memcpy (&buf[y*movie->header->Width*3], &buffer[((movie->header->Height-1)-y)*rowstride], movie->header->Width*3); + for (y = 0; y < movie->header->Height; y++) { + memcpy(&buf[y * movie->header->Width * 3], &buffer[((movie->header->Height - 1) - y) * rowstride], movie->header->Width * 3); } - for (y=0; y < movie->header->Height*movie->header->Width*3; y+=3) { + for (y = 0; y < movie->header->Height * movie->header->Width * 3; y += 3) { i = buf[y]; - buf[y] = buf[y+2]; - buf[y+2] = i; + buf[y] = buf[y + 2]; + buf[y + 2] = i; } - MEM_freeN (buffer); + MEM_freeN(buffer); return buf; } } -void *avi_converter_to_avi_rgb (AviMovie *movie, int stream, unsigned char *buffer, int *size) +void *avi_converter_to_avi_rgb(AviMovie *movie, int stream, unsigned char *buffer, int *size) { int y, x, i, rowstride; unsigned char *buf; (void)stream; /* unused */ - *size= movie->header->Height * movie->header->Width * 3; - if (movie->header->Width%2) *size+= movie->header->Height; + *size = movie->header->Height * movie->header->Width * 3; + if (movie->header->Width % 2) *size += movie->header->Height; - buf = MEM_mallocN (*size, "toavirgbbuf"); + buf = MEM_mallocN(*size, "toavirgbbuf"); - rowstride = movie->header->Width*3; - if (movie->header->Width%2) rowstride++; + rowstride = movie->header->Width * 3; + if (movie->header->Width % 2) rowstride++; - for (y=0; y < movie->header->Height; y++) { - memcpy (&buf[y*rowstride], &buffer[((movie->header->Height-1)-y)*movie->header->Width*3], movie->header->Width*3); + for (y = 0; y < movie->header->Height; y++) { + memcpy(&buf[y * rowstride], &buffer[((movie->header->Height - 1) - y) * movie->header->Width * 3], movie->header->Width * 3); } - for (y=0; y < movie->header->Height; y++) { - for (x=0; x < movie->header->Width*3; x+=3) { - i = buf[y*rowstride+x]; - buf[y*rowstride+x] = buf[y*rowstride+x+2]; - buf[y*rowstride+x+2] = i; + for (y = 0; y < movie->header->Height; y++) { + for (x = 0; x < movie->header->Width * 3; x += 3) { + i = buf[y * rowstride + x]; + buf[y * rowstride + x] = buf[y * rowstride + x + 2]; + buf[y * rowstride + x + 2] = i; } } - MEM_freeN (buffer); + MEM_freeN(buffer); return buf; } |