00001 #include <stdio.h> 00002 #include <stdlib.h> 00003 #include "jpeglib.h" 00004 #include "jerror.h" 00005 00006 typedef struct { 00007 struct jpeg_source_mgr pub; /* public fields */ 00008 00009 JOCTET * buffer; /* start of buffer */ 00010 int bytes; /* total size of buffer */ 00011 } my_source_mgr; 00012 00013 typedef my_source_mgr * my_src_ptr; 00014 00015 METHODDEF(void) 00016 quicktime_jpeg_init_source (j_decompress_ptr cinfo) 00017 { 00018 my_src_ptr src = (my_src_ptr) cinfo->src; 00019 } 00020 00021 METHODDEF(boolean) 00022 quicktime_jpeg_fill_input_buffer (j_decompress_ptr cinfo) 00023 { 00024 my_src_ptr src = (my_src_ptr) cinfo->src; 00025 00026 src->buffer[0] = (JOCTET) 0xFF; 00027 src->buffer[1] = (JOCTET) JPEG_EOI; 00028 src->pub.next_input_byte = src->buffer; 00029 src->pub.bytes_in_buffer = 2; 00030 00031 return TRUE; 00032 } 00033 00034 00035 METHODDEF(void) 00036 quicktime_jpeg_skip_input_data (j_decompress_ptr cinfo, long num_bytes) 00037 { 00038 my_src_ptr src = (my_src_ptr) cinfo->src; 00039 00040 src->pub.next_input_byte += (size_t) num_bytes; 00041 src->pub.bytes_in_buffer -= (size_t) num_bytes; 00042 } 00043 00044 00045 METHODDEF(void) 00046 quicktime_jpeg_term_source (j_decompress_ptr cinfo) 00047 { 00048 } 00049 00050 GLOBAL(void) 00051 jpeg_buffer_src (j_decompress_ptr cinfo, unsigned char *buffer, long bytes) 00052 { 00053 my_src_ptr src; 00054 00055 if (cinfo->src == NULL) { /* first time for this JPEG object? */ 00056 cinfo->src = (struct jpeg_source_mgr *) 00057 (*cinfo->mem->alloc_small) ((j_common_ptr) cinfo, JPOOL_PERMANENT, 00058 sizeof(my_source_mgr)); 00059 src = (my_src_ptr) cinfo->src; 00060 } 00061 00062 src = (my_src_ptr) cinfo->src; 00063 src->pub.init_source = quicktime_jpeg_init_source; 00064 src->pub.fill_input_buffer = quicktime_jpeg_fill_input_buffer; 00065 src->pub.skip_input_data = quicktime_jpeg_skip_input_data; 00066 src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */ 00067 src->pub.term_source = quicktime_jpeg_term_source; 00068 src->pub.bytes_in_buffer = bytes; 00069 src->pub.next_input_byte = buffer; 00070 src->buffer = buffer; 00071 src->bytes = bytes; 00072 }
1.5.5