Blender  V2.93
avi_rgb32.c
Go to the documentation of this file.
1 /*
2  * This program is free software; you can redistribute it and/or
3  * modify it under the terms of the GNU General Public License
4  * as published by the Free Software Foundation; either version 2
5  * of the License, or (at your option) any later version.
6  *
7  * This program is distributed in the hope that it will be useful,
8  * but WITHOUT ANY WARRANTY; without even the implied warranty of
9  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10  * GNU General Public License for more details.
11  *
12  * You should have received a copy of the GNU General Public License
13  * along with this program; if not, write to the Free Software Foundation,
14  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
15  *
16  * The Original Code is Copyright (C) 2001-2002 by NaN Holding BV.
17  * All rights reserved.
18  */
19 
26 #include <stdlib.h>
27 #include <string.h>
28 
29 #include "MEM_guardedalloc.h"
30 
31 #include "IMB_imbuf.h"
32 
33 #include "AVI_avi.h"
34 #include "avi_rgb32.h"
35 
36 void *avi_converter_from_rgb32(AviMovie *movie, int stream, unsigned char *buffer, size_t *size)
37 {
38  unsigned char *buf;
39 
40  (void)stream; /* unused */
41 
42  *size = (size_t)movie->header->Height * (size_t)movie->header->Width * 3;
43  buf = imb_alloc_pixels(
44  movie->header->Height, movie->header->Width, 3, sizeof(unsigned char), "fromrgb32buf");
45  if (!buf) {
46  return NULL;
47  }
48 
49  size_t rowstridea = movie->header->Width * 3;
50  size_t rowstrideb = movie->header->Width * 4;
51 
52  for (size_t y = 0; y < movie->header->Height; y++) {
53  for (size_t x = 0; x < movie->header->Width; x++) {
54  buf[y * rowstridea + x * 3 + 0] = buffer[y * rowstrideb + x * 4 + 3];
55  buf[y * rowstridea + x * 3 + 1] = buffer[y * rowstrideb + x * 4 + 2];
56  buf[y * rowstridea + x * 3 + 2] = buffer[y * rowstrideb + x * 4 + 1];
57  }
58  }
59 
61 
62  return buf;
63 }
64 
65 void *avi_converter_to_rgb32(AviMovie *movie, int stream, unsigned char *buffer, size_t *size)
66 {
67  unsigned char *buf;
68  unsigned char *to, *from;
69 
70  (void)stream; /* unused */
71 
72  *size = (size_t)movie->header->Height * (size_t)movie->header->Width * 4;
73  buf = imb_alloc_pixels(
74  movie->header->Height, movie->header->Width, 4, sizeof(unsigned char), "torgb32buf");
75  if (!buf) {
76  return NULL;
77  }
78 
79  memset(buf, 255, *size);
80 
81  to = buf;
82  from = buffer;
83  size_t i = (size_t)movie->header->Height * (size_t)movie->header->Width;
84 
85  while (i--) {
86  memcpy(to, from, 3);
87  to += 4;
88  from += 3;
89  }
90 
92 
93  return buf;
94 }
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei GLfloat GLfloat GLfloat GLfloat const GLubyte *bitmap _GL_VOID_RET _GL_VOID GLenum const void *lists _GL_VOID_RET _GL_VOID const GLdouble *equation _GL_VOID_RET _GL_VOID GLdouble GLdouble blue _GL_VOID_RET _GL_VOID GLfloat GLfloat blue _GL_VOID_RET _GL_VOID GLint GLint blue _GL_VOID_RET _GL_VOID GLshort GLshort blue _GL_VOID_RET _GL_VOID GLubyte GLubyte blue _GL_VOID_RET _GL_VOID GLuint GLuint blue _GL_VOID_RET _GL_VOID GLushort GLushort blue _GL_VOID_RET _GL_VOID GLbyte GLbyte GLbyte alpha _GL_VOID_RET _GL_VOID GLdouble GLdouble GLdouble alpha _GL_VOID_RET _GL_VOID GLfloat GLfloat GLfloat alpha _GL_VOID_RET _GL_VOID GLint GLint GLint alpha _GL_VOID_RET _GL_VOID GLshort GLshort GLshort alpha _GL_VOID_RET _GL_VOID GLubyte GLubyte GLubyte alpha _GL_VOID_RET _GL_VOID GLuint GLuint GLuint alpha _GL_VOID_RET _GL_VOID GLushort GLushort GLushort alpha _GL_VOID_RET _GL_VOID GLenum mode _GL_VOID_RET _GL_VOID GLint y
void * imb_alloc_pixels(unsigned int x, unsigned int y, unsigned int channels, size_t typesize, const char *name)
Definition: allocimbuf.c:373
Read Guarded memory(de)allocation.
void * avi_converter_to_rgb32(AviMovie *movie, int stream, unsigned char *buffer, size_t *size)
Definition: avi_rgb32.c:65
void * avi_converter_from_rgb32(AviMovie *movie, int stream, unsigned char *buffer, size_t *size)
Definition: avi_rgb32.c:36
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
StackEntry * from
__kernel void ccl_constant KernelData ccl_global void ccl_global char ccl_global int ccl_global char ccl_global unsigned int ccl_global float * buffer
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:41
AviMainHeader * header
Definition: AVI_avi.h:187