00001 #ifndef QUICKTIME_JPEG_H
00002 #define QUICKTIME_JPEG_H
00003
00004 #define QUICKTIME_JPEG_MARKSIZE 40
00005 #define QUICKTIME_JPEG_TAG 0x6d6a7067
00006 #define TOTAL_MJPA_COMPRESSORS 2
00007
00008
00009 #ifdef __cplusplus
00010 extern "C" {
00011 #endif
00012
00013
00014 #include <jpeglib.h>
00015 #include <png.h>
00016 #include "pthread.h"
00017
00018 struct my_error_mgr {
00019 struct jpeg_error_mgr pub;
00020
00021 jmp_buf setjmp_buffer;
00022 };
00023
00024 typedef struct my_error_mgr* my_error_ptr;
00025
00026 typedef struct
00027 {
00028 int field_size;
00029 int padded_field_size;
00030 int next_offset;
00031 int quant_offset;
00032 int huffman_offset;
00033 int image_offset;
00034 int scan_offset;
00035 int data_offset;
00036 char mjpeg_marker[QUICKTIME_JPEG_MARKSIZE];
00037 int mjpg_kludge;
00038 } quicktime_mjpeg_hdr;
00039
00040 typedef struct
00041 {
00042 char *output_buffer;
00043 long output_size;
00044 int output_allocated;
00045 struct jpeg_compress_struct jpeg_compress;
00046 struct jpeg_error_mgr jpeg_error;
00047 unsigned char **row_pointers;
00048 int row_offset;
00049 int mjpg_kludge;
00050 int is_mjpa;
00051 quicktime_mjpeg_hdr mjpeg_hdr;
00052 int width;
00053 int height;
00054 int interlaced;
00055 int write_next_offset;
00056
00057 pthread_t tid;
00058 pthread_mutex_t input_lock, output_lock;
00059 int done;
00060 } mjpa_compress_engine;
00061
00062 typedef struct
00063 {
00064 struct jpeg_decompress_struct jpeg_decompress;
00065 struct my_error_mgr jpeg_error;
00066 int is_mjpa;
00067 unsigned char **row_pointers;
00068 char *input_ptr;
00069 long input_size;
00070 void *codec;
00071 long field_offset;
00072 int markers_only;
00073 quicktime_mjpeg_hdr mjpeg_hdr;
00074 int interlaced;
00075 int width;
00076 int height;
00077
00078 pthread_t tid;
00079 pthread_mutex_t input_lock, output_lock;
00080 int done;
00081 } mjpa_decompress_engine;
00082
00083 typedef struct
00084 {
00085 int quality;
00086 int use_float;
00087 int jpeg_type;
00088 char *input_buffer;
00089 long output_size;
00090 int buffer_size;
00091 mjpa_compress_engine *compressors[TOTAL_MJPA_COMPRESSORS];
00092 mjpa_decompress_engine *decompressors[TOTAL_MJPA_COMPRESSORS];
00093 int total_compressors;
00094 int total_decompressors;
00095 } quicktime_jpeg_codec_t;
00096
00097
00098
00099
00100 mjpa_compress_engine* quicktime_jpeg_new_compress_engine(int width,
00101 int height,
00102 int quality,
00103 int use_float,
00104 int interlaced,
00105 int is_mjpa,
00106 int field_number);
00107 void quicktime_jpeg_delete_compress_engine(mjpa_compress_engine *compressor);
00108
00109 unsigned char* quicktime_compress_jpeg(mjpa_compress_engine *engine, unsigned char **row_pointers, long *image_size, int write_next_offset);
00110 int quicktime_fixmarker_jpeg(quicktime_mjpeg_hdr *mjpeg_hdr, char *buffer, long output_size, int write_next_offset);
00111
00112 #ifdef __cplusplus
00113 }
00114 #endif
00115
00116 #endif