1 #ifndef QUICKTIME_JPEG_H
2 #define QUICKTIME_JPEG_H
4 #define QUICKTIME_JPEG_MARKSIZE 40
5 #define QUICKTIME_JPEG_TAG 0x6d6a7067
6 #define TOTAL_MJPA_COMPRESSORS 2
15 #include <png.h> /* Need setjmp.h included by png.h */
19 struct jpeg_error_mgr pub
; /* "public" fields */
21 jmp_buf setjmp_buffer
; /* for return to caller */
24 typedef struct my_error_mgr
* my_error_ptr
;
29 int padded_field_size
;
36 char mjpeg_marker
[QUICKTIME_JPEG_MARKSIZE
];
38 } quicktime_mjpeg_hdr
;
42 char *output_buffer
; /* Buffer for MJPEG output */
43 long output_size
; /* Size of image stored in buffer */
44 int output_allocated
; /* Allocated size of output buffer */
45 struct jpeg_compress_struct jpeg_compress
;
46 struct jpeg_error_mgr jpeg_error
;
47 unsigned char **row_pointers
;
51 quicktime_mjpeg_hdr mjpeg_hdr
;
52 int width
; /* Total dimensions of the frame */
55 int write_next_offset
;
57 pthread_t tid
; /* ID of thread */
58 pthread_mutex_t input_lock
, output_lock
;
59 int done
; /* Flag to end */
60 } mjpa_compress_engine
;
64 struct jpeg_decompress_struct jpeg_decompress
;
65 struct my_error_mgr jpeg_error
;
67 unsigned char **row_pointers
;
71 long field_offset
; /* offset of next field read by the first field */
72 int markers_only
; /* Get the field offset and wait */
73 quicktime_mjpeg_hdr mjpeg_hdr
;
75 int width
; /* Total dimensions of the frame */
78 pthread_t tid
; /* ID of thread */
79 pthread_mutex_t input_lock
, output_lock
;
80 int done
; /* Flag to end */
81 } mjpa_decompress_engine
;
87 int jpeg_type
; /* 0 - QUICKTIME_JPEG, 1 - QUICKTIME_MJPA, 2 - QUICKTIME_MJPB */
88 char *input_buffer
; /* Buffer for MJPEG output */
89 long output_size
; /* Size of image stored in buffer */
90 int buffer_size
; /* Allocated size of input buffer */
91 mjpa_compress_engine
*compressors
[TOTAL_MJPA_COMPRESSORS
];
92 mjpa_decompress_engine
*decompressors
[TOTAL_MJPA_COMPRESSORS
];
93 int total_compressors
; /* Number of compressors created */
94 int total_decompressors
; /* Number of decompressors created */
95 } quicktime_jpeg_codec_t
;
97 /* These functions are called from Broadcast 2000 directly to achieve */
98 /* massively parallel compression. */
100 mjpa_compress_engine
* quicktime_jpeg_new_compress_engine(int width
,
107 void quicktime_jpeg_delete_compress_engine(mjpa_compress_engine
*compressor
);
108 /* This returns the output buffer. */
109 unsigned char* quicktime_compress_jpeg(mjpa_compress_engine
*engine
, unsigned char **row_pointers
, long *image_size
, int write_next_offset
);
110 int quicktime_fixmarker_jpeg(quicktime_mjpeg_hdr
*mjpeg_hdr
, char *buffer
, long output_size
, int write_next_offset
);