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