Blender  V3.3
avi_rgb32.c
Go to the documentation of this file.
1 /* SPDX-License-Identifier: GPL-2.0-or-later
2  * Copyright 2001-2002 NaN Holding BV. All rights reserved. */
3 
10 #include <stdlib.h>
11 #include <string.h>
12 
13 #include "MEM_guardedalloc.h"
14 
15 #include "IMB_imbuf.h"
16 
17 #include "AVI_avi.h"
18 #include "avi_rgb32.h"
19 
20 void *avi_converter_from_rgb32(AviMovie *movie, int stream, unsigned char *buffer, size_t *size)
21 {
22  unsigned char *buf;
23 
24  (void)stream; /* unused */
25 
26  *size = (size_t)movie->header->Height * (size_t)movie->header->Width * 3;
27  buf = imb_alloc_pixels(
28  movie->header->Height, movie->header->Width, 3, sizeof(unsigned char), "fromrgb32buf");
29  if (!buf) {
30  return NULL;
31  }
32 
33  size_t rowstridea = movie->header->Width * 3;
34  size_t rowstrideb = movie->header->Width * 4;
35 
36  for (size_t y = 0; y < movie->header->Height; y++) {
37  for (size_t x = 0; x < movie->header->Width; x++) {
38  buf[y * rowstridea + x * 3 + 0] = buffer[y * rowstrideb + x * 4 + 3];
39  buf[y * rowstridea + x * 3 + 1] = buffer[y * rowstrideb + x * 4 + 2];
40  buf[y * rowstridea + x * 3 + 2] = buffer[y * rowstrideb + x * 4 + 1];
41  }
42  }
43 
45 
46  return buf;
47 }
48 
49 void *avi_converter_to_rgb32(AviMovie *movie, int stream, unsigned char *buffer, size_t *size)
50 {
51  unsigned char *buf;
52  unsigned char *to, *from;
53 
54  (void)stream; /* unused */
55 
56  *size = (size_t)movie->header->Height * (size_t)movie->header->Width * 4;
57  buf = imb_alloc_pixels(
58  movie->header->Height, movie->header->Width, 4, sizeof(unsigned char), "torgb32buf");
59  if (!buf) {
60  return NULL;
61  }
62 
63  memset(buf, 255, *size);
64 
65  to = buf;
66  from = buffer;
67  size_t i = (size_t)movie->header->Height * (size_t)movie->header->Width;
68 
69  while (i--) {
70  memcpy(to, from, 3);
71  to += 4;
72  from += 3;
73  }
74 
76 
77  return buf;
78 }
_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:354
Read Guarded memory(de)allocation.
void * avi_converter_to_rgb32(AviMovie *movie, int stream, unsigned char *buffer, size_t *size)
Definition: avi_rgb32.c:49
void * avi_converter_from_rgb32(AviMovie *movie, int stream, unsigned char *buffer, size_t *size)
Definition: avi_rgb32.c:20
static DBVT_INLINE btScalar size(const btDbvtVolume &a)
Definition: btDbvt.cpp:52
StackEntry * from
SyclQueue void void size_t num_bytes void
ccl_global float * buffer
void(* MEM_freeN)(void *vmemh)
Definition: mallocn.c:27
AviMainHeader * header
Definition: AVI_avi.h:171