Blender  V2.93
avi_mjpeg.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 "AVI_avi.h"
30 
31 #include "MEM_guardedalloc.h"
32 
33 #include "BLI_math_base.h"
34 #include "IMB_imbuf.h"
35 
36 #include "jerror.h"
37 #include "jpeglib.h"
38 
39 #include "avi_mjpeg.h"
40 
41 static void jpegmemdestmgr_build(j_compress_ptr cinfo, unsigned char *buffer, size_t bufsize);
42 static void jpegmemsrcmgr_build(j_decompress_ptr dinfo,
43  const unsigned char *buffer,
44  size_t bufsize);
45 
46 static size_t numbytes;
47 
48 static void add_huff_table(j_decompress_ptr dinfo,
49  JHUFF_TBL **htblptr,
50  const UINT8 *bits,
51  const size_t bits_size,
52  const UINT8 *val,
53  const size_t val_size)
54 {
55  if (*htblptr == NULL) {
56  *htblptr = jpeg_alloc_huff_table((j_common_ptr)dinfo);
57  }
58 
59  memcpy((*htblptr)->bits, bits, min_zz(sizeof((*htblptr)->bits), bits_size));
60  memcpy((*htblptr)->huffval, val, min_zz(sizeof((*htblptr)->huffval), val_size));
61 
62  /* Initialize sent_table false so table will be written to JPEG file. */
63  (*htblptr)->sent_table = false;
64 }
65 
66 /* Set up the standard Huffman tables (cf. JPEG standard section K.3) */
67 /* IMPORTANT: these are only valid for 8-bit data precision! */
68 
69 static void std_huff_tables(j_decompress_ptr dinfo)
70 {
71  static const UINT8 bits_dc_luminance[17] = {
72  /* 0-base */
73  0,
74  0,
75  1,
76  5,
77  1,
78  1,
79  1,
80  1,
81  1,
82  1,
83  0,
84  0,
85  0,
86  0,
87  0,
88  0,
89  0,
90  };
91  static const UINT8 val_dc_luminance[] = {
92  0,
93  1,
94  2,
95  3,
96  4,
97  5,
98  6,
99  7,
100  8,
101  9,
102  10,
103  11,
104  };
105 
106  static const UINT8 bits_dc_chrominance[17] = {
107  /* 0-base */
108  0,
109  0,
110  3,
111  1,
112  1,
113  1,
114  1,
115  1,
116  1,
117  1,
118  1,
119  1,
120  0,
121  0,
122  0,
123  0,
124  0,
125  };
126  static const UINT8 val_dc_chrominance[] = {
127  0,
128  1,
129  2,
130  3,
131  4,
132  5,
133  6,
134  7,
135  8,
136  9,
137  10,
138  11,
139  };
140 
141  static const UINT8 bits_ac_luminance[17] = {
142  /* 0-base */
143  0,
144  0,
145  2,
146  1,
147  3,
148  3,
149  2,
150  4,
151  3,
152  5,
153  5,
154  4,
155  4,
156  0,
157  0,
158  1,
159  0x7d,
160  };
161  static const UINT8 val_ac_luminance[] = {
162  0x01, 0x02, 0x03, 0x00, 0x04, 0x11, 0x05, 0x12, 0x21, 0x31, 0x41, 0x06, 0x13, 0x51, 0x61,
163  0x07, 0x22, 0x71, 0x14, 0x32, 0x81, 0x91, 0xa1, 0x08, 0x23, 0x42, 0xb1, 0xc1, 0x15, 0x52,
164  0xd1, 0xf0, 0x24, 0x33, 0x62, 0x72, 0x82, 0x09, 0x0a, 0x16, 0x17, 0x18, 0x19, 0x1a, 0x25,
165  0x26, 0x27, 0x28, 0x29, 0x2a, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44, 0x45,
166  0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63, 0x64,
167  0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a, 0x83,
168  0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97, 0x98, 0x99,
169  0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4, 0xb5, 0xb6,
170  0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca, 0xd2, 0xd3,
171  0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe1, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7, 0xe8,
172  0xe9, 0xea, 0xf1, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa,
173  };
174  static const UINT8 bits_ac_chrominance[17] = {
175  /* 0-base */
176  0,
177  0,
178  2,
179  1,
180  2,
181  4,
182  4,
183  3,
184  4,
185  7,
186  5,
187  4,
188  4,
189  0,
190  1,
191  2,
192  0x77,
193  };
194  static const UINT8 val_ac_chrominance[] = {
195  0x00, 0x01, 0x02, 0x03, 0x11, 0x04, 0x05, 0x21, 0x31, 0x06, 0x12, 0x41, 0x51, 0x07, 0x61,
196  0x71, 0x13, 0x22, 0x32, 0x81, 0x08, 0x14, 0x42, 0x91, 0xa1, 0xb1, 0xc1, 0x09, 0x23, 0x33,
197  0x52, 0xf0, 0x15, 0x62, 0x72, 0xd1, 0x0a, 0x16, 0x24, 0x34, 0xe1, 0x25, 0xf1, 0x17, 0x18,
198  0x19, 0x1a, 0x26, 0x27, 0x28, 0x29, 0x2a, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x43, 0x44,
199  0x45, 0x46, 0x47, 0x48, 0x49, 0x4a, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58, 0x59, 0x5a, 0x63,
200  0x64, 0x65, 0x66, 0x67, 0x68, 0x69, 0x6a, 0x73, 0x74, 0x75, 0x76, 0x77, 0x78, 0x79, 0x7a,
201  0x82, 0x83, 0x84, 0x85, 0x86, 0x87, 0x88, 0x89, 0x8a, 0x92, 0x93, 0x94, 0x95, 0x96, 0x97,
202  0x98, 0x99, 0x9a, 0xa2, 0xa3, 0xa4, 0xa5, 0xa6, 0xa7, 0xa8, 0xa9, 0xaa, 0xb2, 0xb3, 0xb4,
203  0xb5, 0xb6, 0xb7, 0xb8, 0xb9, 0xba, 0xc2, 0xc3, 0xc4, 0xc5, 0xc6, 0xc7, 0xc8, 0xc9, 0xca,
204  0xd2, 0xd3, 0xd4, 0xd5, 0xd6, 0xd7, 0xd8, 0xd9, 0xda, 0xe2, 0xe3, 0xe4, 0xe5, 0xe6, 0xe7,
205  0xe8, 0xe9, 0xea, 0xf2, 0xf3, 0xf4, 0xf5, 0xf6, 0xf7, 0xf8, 0xf9, 0xfa,
206  };
207 
208  add_huff_table(dinfo,
209  &dinfo->dc_huff_tbl_ptrs[0],
210  bits_dc_luminance,
211  sizeof(bits_dc_luminance),
212  val_dc_luminance,
213  sizeof(val_dc_luminance));
214  add_huff_table(dinfo,
215  &dinfo->ac_huff_tbl_ptrs[0],
216  bits_ac_luminance,
217  sizeof(bits_ac_luminance),
218  val_ac_luminance,
219  sizeof(val_ac_luminance));
220  add_huff_table(dinfo,
221  &dinfo->dc_huff_tbl_ptrs[1],
222  bits_dc_chrominance,
223  sizeof(bits_dc_chrominance),
224  val_dc_chrominance,
225  sizeof(val_dc_chrominance));
226  add_huff_table(dinfo,
227  &dinfo->ac_huff_tbl_ptrs[1],
228  bits_ac_chrominance,
229  sizeof(bits_ac_chrominance),
230  val_ac_chrominance,
231  sizeof(val_ac_chrominance));
232 }
233 
234 static int Decode_JPEG(unsigned char *inBuffer,
235  unsigned char *outBuffer,
236  unsigned int width,
237  unsigned int height,
238  size_t bufsize)
239 {
240  struct jpeg_decompress_struct dinfo;
241  struct jpeg_error_mgr jerr;
242 
243  (void)width; /* unused */
244 
245  numbytes = 0;
246 
247  dinfo.err = jpeg_std_error(&jerr);
248  jpeg_create_decompress(&dinfo);
249  jpegmemsrcmgr_build(&dinfo, inBuffer, bufsize);
250  jpeg_read_header(&dinfo, true);
251  if (dinfo.dc_huff_tbl_ptrs[0] == NULL) {
252  std_huff_tables(&dinfo);
253  }
254  dinfo.out_color_space = JCS_RGB;
255  dinfo.dct_method = JDCT_IFAST;
256 
257  jpeg_start_decompress(&dinfo);
258 
259  size_t rowstride = dinfo.output_width * dinfo.output_components;
260  for (size_t y = 0; y < dinfo.output_height; y++) {
261  jpeg_read_scanlines(&dinfo, (JSAMPARRAY)&outBuffer, 1);
262  outBuffer += rowstride;
263  }
264  jpeg_finish_decompress(&dinfo);
265 
266  if (dinfo.output_height >= height) {
267  return 0;
268  }
269 
270  inBuffer += numbytes;
271  jpegmemsrcmgr_build(&dinfo, inBuffer, bufsize - numbytes);
272 
273  numbytes = 0;
274  jpeg_read_header(&dinfo, true);
275  if (dinfo.dc_huff_tbl_ptrs[0] == NULL) {
276  std_huff_tables(&dinfo);
277  }
278 
279  jpeg_start_decompress(&dinfo);
280  rowstride = dinfo.output_width * dinfo.output_components;
281  for (size_t y = 0; y < dinfo.output_height; y++) {
282  jpeg_read_scanlines(&dinfo, (JSAMPARRAY)&outBuffer, 1);
283  outBuffer += rowstride;
284  }
285  jpeg_finish_decompress(&dinfo);
286  jpeg_destroy_decompress(&dinfo);
287 
288  return 1;
289 }
290 
291 static void Compress_JPEG(int quality,
292  unsigned char *outbuffer,
293  const unsigned char *inBuffer,
294  int width,
295  int height,
296  size_t bufsize)
297 {
298  struct jpeg_compress_struct cinfo;
299  struct jpeg_error_mgr jerr;
300  unsigned char marker[60];
301 
302  cinfo.err = jpeg_std_error(&jerr);
303  jpeg_create_compress(&cinfo);
304  jpegmemdestmgr_build(&cinfo, outbuffer, bufsize);
305 
306  cinfo.image_width = width;
307  cinfo.image_height = height;
308  cinfo.input_components = 3;
309  cinfo.in_color_space = JCS_RGB;
310 
311  jpeg_set_defaults(&cinfo);
312  jpeg_set_colorspace(&cinfo, JCS_YCbCr);
313 
314  jpeg_set_quality(&cinfo, quality, true);
315 
316  cinfo.dc_huff_tbl_ptrs[0]->sent_table = true;
317  cinfo.dc_huff_tbl_ptrs[1]->sent_table = true;
318  cinfo.ac_huff_tbl_ptrs[0]->sent_table = true;
319  cinfo.ac_huff_tbl_ptrs[1]->sent_table = true;
320 
321  cinfo.comp_info[0].component_id = 0;
322  cinfo.comp_info[0].v_samp_factor = 1;
323  cinfo.comp_info[1].component_id = 1;
324  cinfo.comp_info[2].component_id = 2;
325 
326  cinfo.write_JFIF_header = false;
327 
328  jpeg_start_compress(&cinfo, false);
329 
330  int i = 0;
331  marker[i++] = 'A';
332  marker[i++] = 'V';
333  marker[i++] = 'I';
334  marker[i++] = '1';
335  marker[i++] = 0;
336  while (i < 60) {
337  marker[i++] = 32;
338  }
339 
340  jpeg_write_marker(&cinfo, JPEG_APP0, marker, 60);
341 
342  i = 0;
343  while (i < 60) {
344  marker[i++] = 0;
345  }
346 
347  jpeg_write_marker(&cinfo, JPEG_COM, marker, 60);
348 
349  size_t rowstride = cinfo.image_width * cinfo.input_components;
350  for (size_t y = 0; y < cinfo.image_height; y++) {
351  jpeg_write_scanlines(&cinfo, (JSAMPARRAY)&inBuffer, 1);
352  inBuffer += rowstride;
353  }
354  jpeg_finish_compress(&cinfo);
355  jpeg_destroy_compress(&cinfo);
356 }
357 
358 static void interlace(unsigned char *to, unsigned char *from, int width, int height)
359 {
360  size_t i, rowstride = width * 3;
361 
362  for (i = 0; i < height; i++) {
363  if (i & 1) {
364  memcpy(&to[i * rowstride], &from[(i / 2 + height / 2) * rowstride], rowstride);
365  }
366  else {
367  memcpy(&to[i * rowstride], &from[(i / 2) * rowstride], rowstride);
368  }
369  }
370 }
371 
372 static void deinterlace(int odd, unsigned char *to, unsigned char *from, int width, int height)
373 {
374  size_t i, rowstride = width * 3;
375 
376  for (i = 0; i < height; i++) {
377  if ((i & 1) == odd) {
378  memcpy(&to[(i / 2 + height / 2) * rowstride], &from[i * rowstride], rowstride);
379  }
380  else {
381  memcpy(&to[(i / 2) * rowstride], &from[i * rowstride], rowstride);
382  }
383  }
384 }
385 
387  int stream,
388  unsigned char *buffer,
389  const size_t *size)
390 {
391  int deint;
392  unsigned char *buf;
393 
394  (void)stream; /* unused */
395 
396  buf = imb_alloc_pixels(movie->header->Height,
397  movie->header->Width,
398  3,
399  sizeof(unsigned char),
400  "avi.avi_converter_from_mjpeg 1");
401  if (!buf) {
402  return NULL;
403  }
404 
405  deint = Decode_JPEG(buffer, buf, movie->header->Width, movie->header->Height, *size);
406 
407  MEM_freeN(buffer);
408 
409  if (deint) {
411  movie->header->Width,
412  3,
413  sizeof(unsigned char),
414  "avi.avi_converter_from_mjpeg 2");
415  if (buffer) {
416  interlace(buffer, buf, movie->header->Width, movie->header->Height);
417  }
418  MEM_freeN(buf);
419 
420  buf = buffer;
421  }
422 
423  return buf;
424 }
425 
426 void *avi_converter_to_mjpeg(AviMovie *movie, int stream, unsigned char *buffer, size_t *size)
427 {
428  unsigned char *buf;
429  size_t bufsize = *size;
430 
431  numbytes = 0;
432  *size = 0;
433 
434  buf = imb_alloc_pixels(movie->header->Height,
435  movie->header->Width,
436  3,
437  sizeof(unsigned char),
438  "avi.avi_converter_to_mjpeg 1");
439  if (!buf) {
440  return NULL;
441  }
442 
443  if (!movie->interlace) {
444  Compress_JPEG(movie->streams[stream].sh.Quality / 100,
445  buf,
446  buffer,
447  movie->header->Width,
448  movie->header->Height,
449  bufsize);
450  *size += numbytes;
451  }
452  else {
453  deinterlace(movie->odd_fields, buf, buffer, movie->header->Width, movie->header->Height);
454  MEM_freeN(buffer);
455 
456  buffer = buf;
457  buf = imb_alloc_pixels(movie->header->Height,
458  movie->header->Width,
459  3,
460  sizeof(unsigned char),
461  "avi.avi_converter_to_mjpeg 1");
462 
463  if (buf) {
464  Compress_JPEG(movie->streams[stream].sh.Quality / 100,
465  buf,
466  buffer,
467  movie->header->Width,
468  movie->header->Height / 2,
469  bufsize / 2);
470  *size += numbytes;
471  numbytes = 0;
472  Compress_JPEG(movie->streams[stream].sh.Quality / 100,
473  buf + *size,
474  buffer +
475  (size_t)(movie->header->Height / 2) * (size_t)movie->header->Width * 3,
476  movie->header->Width,
477  movie->header->Height / 2,
478  bufsize / 2);
479  *size += numbytes;
480  }
481  }
482 
483  MEM_freeN(buffer);
484  return buf;
485 }
486 
487 /* Compression from memory */
488 
489 static void jpegmemdestmgr_init_destination(j_compress_ptr cinfo)
490 {
491  (void)cinfo; /* unused */
492 }
493 
494 static boolean jpegmemdestmgr_empty_output_buffer(j_compress_ptr cinfo)
495 {
496  (void)cinfo; /* unused */
497  return true;
498 }
499 
500 static void jpegmemdestmgr_term_destination(j_compress_ptr cinfo)
501 {
502  numbytes -= cinfo->dest->free_in_buffer;
503 
504  MEM_freeN(cinfo->dest);
505 }
506 
507 static void jpegmemdestmgr_build(j_compress_ptr cinfo, unsigned char *buffer, size_t bufsize)
508 {
509  cinfo->dest = MEM_mallocN(sizeof(*(cinfo->dest)), "avi.jpegmemdestmgr_build");
510 
511  cinfo->dest->init_destination = jpegmemdestmgr_init_destination;
512  cinfo->dest->empty_output_buffer = jpegmemdestmgr_empty_output_buffer;
513  cinfo->dest->term_destination = jpegmemdestmgr_term_destination;
514 
515  cinfo->dest->next_output_byte = buffer;
516  cinfo->dest->free_in_buffer = bufsize;
517 
518  numbytes = bufsize;
519 }
520 
521 /* Decompression from memory */
522 
523 static void jpegmemsrcmgr_init_source(j_decompress_ptr dinfo)
524 {
525  (void)dinfo;
526 }
527 
528 static boolean jpegmemsrcmgr_fill_input_buffer(j_decompress_ptr dinfo)
529 {
530  unsigned char *buf = (unsigned char *)dinfo->src->next_input_byte - 2;
531 
532  /* if we get called, must have run out of data */
533  WARNMS(dinfo, JWRN_JPEG_EOF);
534 
535  buf[0] = (JOCTET)0xFF;
536  buf[1] = (JOCTET)JPEG_EOI;
537 
538  dinfo->src->next_input_byte = buf;
539  dinfo->src->bytes_in_buffer = 2;
540 
541  return true;
542 }
543 
544 static void jpegmemsrcmgr_skip_input_data(j_decompress_ptr dinfo, long skipcnt)
545 {
546  if (dinfo->src->bytes_in_buffer < skipcnt) {
547  skipcnt = dinfo->src->bytes_in_buffer;
548  }
549 
550  dinfo->src->next_input_byte += skipcnt;
551  dinfo->src->bytes_in_buffer -= skipcnt;
552 }
553 
554 static void jpegmemsrcmgr_term_source(j_decompress_ptr dinfo)
555 {
556  numbytes -= dinfo->src->bytes_in_buffer;
557 
558  MEM_freeN(dinfo->src);
559 }
560 
561 static void jpegmemsrcmgr_build(j_decompress_ptr dinfo,
562  const unsigned char *buffer,
563  size_t bufsize)
564 {
565  dinfo->src = MEM_mallocN(sizeof(*(dinfo->src)), "avi.jpegmemsrcmgr_build");
566 
567  dinfo->src->init_source = jpegmemsrcmgr_init_source;
568  dinfo->src->fill_input_buffer = jpegmemsrcmgr_fill_input_buffer;
569  dinfo->src->skip_input_data = jpegmemsrcmgr_skip_input_data;
570  dinfo->src->resync_to_restart = jpeg_resync_to_restart;
571  dinfo->src->term_source = jpegmemsrcmgr_term_source;
572 
573  dinfo->src->bytes_in_buffer = bufsize;
574  dinfo->src->next_input_byte = buffer;
575 
576  numbytes = bufsize;
577 }
MINLINE size_t min_zz(size_t a, size_t b)
_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 GLsizei width
_GL_VOID GLfloat value _GL_VOID_RET _GL_VOID const GLuint GLboolean *residences _GL_BOOL_RET _GL_VOID GLsizei height
_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_mjpeg(AviMovie *movie, int stream, unsigned char *buffer, size_t *size)
Definition: avi_mjpeg.c:426
static int Decode_JPEG(unsigned char *inBuffer, unsigned char *outBuffer, unsigned int width, unsigned int height, size_t bufsize)
Definition: avi_mjpeg.c:234
static void jpegmemdestmgr_init_destination(j_compress_ptr cinfo)
Definition: avi_mjpeg.c:489
static void jpegmemdestmgr_term_destination(j_compress_ptr cinfo)
Definition: avi_mjpeg.c:500
static size_t numbytes
Definition: avi_mjpeg.c:46
static boolean jpegmemsrcmgr_fill_input_buffer(j_decompress_ptr dinfo)
Definition: avi_mjpeg.c:528
static void jpegmemsrcmgr_term_source(j_decompress_ptr dinfo)
Definition: avi_mjpeg.c:554
static boolean jpegmemdestmgr_empty_output_buffer(j_compress_ptr cinfo)
Definition: avi_mjpeg.c:494
static void jpegmemdestmgr_build(j_compress_ptr cinfo, unsigned char *buffer, size_t bufsize)
Definition: avi_mjpeg.c:507
static void Compress_JPEG(int quality, unsigned char *outbuffer, const unsigned char *inBuffer, int width, int height, size_t bufsize)
Definition: avi_mjpeg.c:291
static void std_huff_tables(j_decompress_ptr dinfo)
Definition: avi_mjpeg.c:69
static void jpegmemsrcmgr_skip_input_data(j_decompress_ptr dinfo, long skipcnt)
Definition: avi_mjpeg.c:544
static void jpegmemsrcmgr_build(j_decompress_ptr dinfo, const unsigned char *buffer, size_t bufsize)
Definition: avi_mjpeg.c:561
static void jpegmemsrcmgr_init_source(j_decompress_ptr dinfo)
Definition: avi_mjpeg.c:523
static void add_huff_table(j_decompress_ptr dinfo, JHUFF_TBL **htblptr, const UINT8 *bits, const size_t bits_size, const UINT8 *val, const size_t val_size)
Definition: avi_mjpeg.c:48
static void interlace(unsigned char *to, unsigned char *from, int width, int height)
Definition: avi_mjpeg.c:358
static void deinterlace(int odd, unsigned char *to, unsigned char *from, int width, int height)
Definition: avi_mjpeg.c:372
void * avi_converter_from_mjpeg(AviMovie *movie, int stream, unsigned char *buffer, const size_t *size)
Definition: avi_mjpeg.c:386
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
void *(* MEM_mallocN)(size_t len, const char *str)
Definition: mallocn.c:47
int odd_fields
Definition: AVI_avi.h:198
int interlace
Definition: AVI_avi.h:197
AviMainHeader * header
Definition: AVI_avi.h:187
AviStreamRec * streams
Definition: AVI_avi.h:188
AviStreamHeader sh
Definition: AVI_avi.h:172