2
* ***** BEGIN GPL LICENSE BLOCK *****
4
* This program is free software; you can redistribute it and/or
5
* modify it under the terms of the GNU General Public License
6
* as published by the Free Software Foundation; either version 2
7
* of the License, or (at your option) any later version.
9
* This program is distributed in the hope that it will be useful,
10
* but WITHOUT ANY WARRANTY; without even the implied warranty of
11
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12
* GNU General Public License for more details.
14
* You should have received a copy of the GNU General Public License
15
* along with this program; if not, write to the Free Software Foundation,
16
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18
* The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
19
* All rights reserved.
21
* The Original Code is: all of this file.
23
* Contributor(s): none yet.
25
* ***** END GPL LICENSE BLOCK *****
29
/** \file blender/avi/intern/avi_rgb.c
32
* This is external code. Converts rgb-type avi-s.
38
#include "MEM_guardedalloc.h"
45
void *avi_converter_from_avi_rgb(AviMovie *movie, int stream, unsigned char *buffer, int *size)
47
int x, y, i, rowstride;
49
AviBitmapInfoHeader *bi;
52
(void)size; /* unused */
54
bi = (AviBitmapInfoHeader *) movie->streams[stream].sf;
55
if (bi) bits = bi->BitCount;
64
buf = MEM_mallocN(movie->header->Height * movie->header->Width * 3, "fromavirgbbuf");
66
y = movie->header->Height;
70
pxl = (unsigned short *) (buffer + y * movie->header->Width * 2);
73
pxla = (unsigned char *)pxl;
76
x = movie->header->Width;
86
*(to++) = ((*pxl >> 10) & 0x1f) * 8;
87
*(to++) = ((*pxl >> 5) & 0x1f) * 8;
88
*(to++) = (*pxl & 0x1f) * 8;
98
buf = MEM_mallocN(movie->header->Height * movie->header->Width * 3, "fromavirgbbuf");
100
rowstride = movie->header->Width * 3;
101
if ((bits != 16) && (movie->header->Width % 2)) rowstride++;
103
for (y = 0; y < movie->header->Height; y++) {
104
memcpy(&buf[y * movie->header->Width * 3], &buffer[((movie->header->Height - 1) - y) * rowstride], movie->header->Width * 3);
107
for (y = 0; y < movie->header->Height * movie->header->Width * 3; y += 3) {
119
void *avi_converter_to_avi_rgb(AviMovie *movie, int stream, unsigned char *buffer, int *size)
121
int y, x, i, rowstride;
124
(void)stream; /* unused */
126
*size = movie->header->Height * movie->header->Width * 3;
127
if (movie->header->Width % 2) *size += movie->header->Height;
129
buf = MEM_mallocN(*size, "toavirgbbuf");
131
rowstride = movie->header->Width * 3;
132
if (movie->header->Width % 2) rowstride++;
134
for (y = 0; y < movie->header->Height; y++) {
135
memcpy(&buf[y * rowstride], &buffer[((movie->header->Height - 1) - y) * movie->header->Width * 3], movie->header->Width * 3);
138
for (y = 0; y < movie->header->Height; y++) {
139
for (x = 0; x < movie->header->Width * 3; x += 3) {
140
i = buf[y * rowstride + x];
141
buf[y * rowstride + x] = buf[y * rowstride + x + 2];
142
buf[y * rowstride + x + 2] = i;