| 107 | static void lr_term_source(j_decompress_ptr /*cinfo*/) {} |
| 108 | |
| 109 | static void lr_jpeg_src(j_decompress_ptr cinfo, LibRaw_abstract_datastream *inf) |
| 110 | { |
| 111 | lr_jpg_src_ptr src; |
| 112 | if (cinfo->src == NULL) |
| 113 | { /* first time for this JPEG object? */ |
| 114 | cinfo->src = (struct jpeg_source_mgr *)(*cinfo->mem->alloc_small)( |
| 115 | (j_common_ptr)cinfo, JPOOL_PERMANENT, sizeof(lr_jpg_source_mgr)); |
| 116 | src = (lr_jpg_src_ptr)cinfo->src; |
| 117 | src->buffer = (JOCTET *)(*cinfo->mem->alloc_small)( |
| 118 | (j_common_ptr)cinfo, JPOOL_PERMANENT, |
| 119 | LR_JPEG_INPUT_BUF_SIZE * sizeof(JOCTET)); |
| 120 | } |
| 121 | else if (cinfo->src->init_source != f_init_source) |
| 122 | { |
| 123 | ERREXIT(cinfo, JERR_BUFFER_SIZE); |
| 124 | } |
| 125 | |
| 126 | src = (lr_jpg_src_ptr)cinfo->src; |
| 127 | src->pub.init_source = f_init_source; |
| 128 | src->pub.fill_input_buffer = lr_fill_input_buffer; |
| 129 | src->pub.skip_input_data = lr_skip_input_data; |
| 130 | src->pub.resync_to_restart = jpeg_resync_to_restart; /* use default method */ |
| 131 | src->pub.term_source = lr_term_source; |
| 132 | src->instream = inf; |
| 133 | src->pub.bytes_in_buffer = 0; /* forces fill_input_buffer on first read */ |
| 134 | src->pub.next_input_byte = NULL; /* until buffer loaded */ |
| 135 | } |
| 136 | #endif |
| 137 | |
| 138 | int LibRaw_abstract_datastream::jpeg_src(void *jpegdata) |