63 #define INPUT_BUF_SIZE 4096 65 #define GetColourIndex(r, g, b, a) \ 66 OSD_FindNearestColourIndex((a << 24) | (r << 16) | (g << 8) | b ) 79 struct jpeg_error_mgr pub;
89 struct jpeg_source_mgr pub;
101 static void my_error_exit( j_common_ptr cinfo )
108 (*cinfo->err->output_message)(cinfo);
114 #if JPEG_LIB_VERSION == 62 116 size_t pseudo_fread(
void *buf,
size_t size,
size_t count, FILE *file )
183 nbytes = pseudo_file->left;
188 ERREXIT(cinfo, JERR_INPUT_EMPTY);
190 WARNMS(cinfo, JWRN_JPEG_EOF);
192 src->
buffer[0] = (UINT8) 0xFF;
193 src->
buffer[1] = (UINT8) JPEG_EOI;
197 memcpy( src->
buffer, pseudo_file->data + pseudo_file->posn, nbytes );
198 pseudo_file->posn += nbytes;
199 pseudo_file->left -= nbytes;
202 src->
pub.bytes_in_buffer = nbytes;
232 while (num_bytes > (
long) src->
pub.bytes_in_buffer)
234 num_bytes -= (long) src->
pub.bytes_in_buffer;
240 src->
pub.next_input_byte += (size_t) num_bytes;
241 src->
pub.bytes_in_buffer -= (size_t) num_bytes;
289 if (cinfo->src == NULL)
291 cinfo->src = (
struct jpeg_source_mgr *)
292 (*cinfo->mem->alloc_small)((j_common_ptr) cinfo, JPOOL_PERMANENT,
296 (*cinfo->mem->alloc_small)((j_common_ptr) cinfo, JPOOL_PERMANENT,
304 src->
pub.resync_to_restart = jpeg_resync_to_restart;
307 src->
pub.bytes_in_buffer = 0;
308 src->
pub.next_input_byte = NULL;
328 struct jpeg_decompress_struct cinfo;
337 pseudo_file.
posn = 0;
339 cinfo.err = jpeg_std_error(&jerr.
pub);
340 jerr.
pub.error_exit = my_error_exit;
346 jpeg_destroy_decompress(&cinfo);
352 jpeg_create_decompress(&cinfo);
354 (void)jpeg_read_header(&cinfo,
TRUE);
357 cinfo.out_color_space = JCS_RGB;
359 (void)jpeg_start_decompress(&cinfo);
360 assert(cinfo.output_components == 3);
371 r_bytes = cinfo.output_width * cinfo.output_components;
377 j_bmp->
width = cinfo.output_width;
378 j_bmp->
height = cinfo.output_height;
385 while (cinfo.output_scanline < cinfo.output_height)
387 (void)jpeg_read_scanlines( &cinfo, &row_ptr, 1 );
388 for (r_ndx = 0; r_ndx != r_bytes; r_ndx += cinfo.output_components)
390 *s_buff++ =
GetColourIndex(row_ptr[r_ndx], row_ptr[r_ndx + 1], row_ptr[r_ndx + 2], 0xff);
401 WARNMS1(&cinfo, JERR_OUT_OF_MEMORY, 0);
414 #if defined(OSD_16_BIT) || defined(OSD_31_BIT) || defined(OSD_32_BIT) 416 r_bytes = cinfo.output_width * cinfo.output_components;
422 if (!cinfo.saw_JFIF_marker)
428 density_unit = cinfo.density_unit;
429 if ((cinfo.Y_density != cinfo.X_density) ||
430 (density_unit < 1) || (density_unit > 2))
436 resolution = cinfo.Y_density;
438 if (density_unit == 1)
441 resolution = (resolution * 5000 + 63) / 127;
443 else if (density_unit == 2)
446 switch (cinfo.Y_density)
448 case 53: resolution = 5315;
break;
449 case 35: resolution = 3543;
break;
450 case 28: resolution = 2835;
break;
451 default: resolution = resolution * 100;
462 row_ptr =
OSD_MemAlloc( r_bytes * cinfo.output_height );
468 WARNMS1(&cinfo, JERR_OUT_OF_MEMORY, 0);
473 j_bmp->
width = cinfo.output_width;
474 j_bmp->
height = cinfo.output_height;
478 while (cinfo.output_scanline < cinfo.output_height)
480 (void)jpeg_read_scanlines( &cinfo, &row_ptr, 1 );
488 (void)jpeg_finish_decompress(&cinfo);
489 jpeg_destroy_decompress(&cinfo);
struct jpeg_error_mgr pub
void DEC_FreeJpg(S_IMAGE *data)
Free memory allocated for JPEG bitmap.
jobs_stdio_src(j_decompress_ptr cinfo, myfile_t *infile)
S_IMAGE * DEC_DecodeJpg(U8BIT *data, U32BIT len)
Allocate memory for JPG and decode bitmap.
#define GetColourIndex(r, g, b, a)
init_source(j_decompress_ptr cinfo)
skip_input_data(j_decompress_ptr cinfo, long num_bytes)
my_source_mgr * my_src_ptr
The functions in this file are OPTIONALLY provided by Receiver Platform *.
fill_input_buffer(j_decompress_ptr cinfo)
struct my_error_mgr * my_error_ptr
#define SD_METRIC_RESOLUTION
term_source(j_decompress_ptr cinfo)
#define COLOUR_FORMAT_PALETTE
struct jpeg_source_mgr pub
#define COMPLETELY_OPAQUE