![]() |
DarkPlaces
Game engine based on the Quake 1 engine by id Software, developed by LadyHavoc
|
|
#include "darkplaces.h"
#include "cl_screen.h"
#include "image.h"
#include "jpeg.h"
#include "image_png.h"
Go to the source code of this file.
Data Structures | |
struct | CompressedImageCacheItem |
struct | j_compress_ptr |
struct | j_decompress_ptr |
struct | jpeg_component_info |
struct | jpeg_destination_mgr |
struct | jpeg_error_mgr |
struct | jpeg_memory_mgr |
struct | jpeg_source_mgr |
struct | my_destination_mgr |
Macros | |
#define | C_MAX_BLOCKS_IN_MCU 10 |
#define | COMPRESSEDIMAGECACHE_SIZE 4096 |
#define | D_MAX_BLOCKS_IN_MCU 10 |
#define | DCTSIZE2 64 |
#define | JMSG_STR_PARM_MAX 80 |
#define | JPEG_EOI 0xD9 |
#define | JPEG_LIB_VERSION 62 |
#define | JPEG_OUTPUT_BUF_SIZE 4096 |
#define | JPOOL_IMAGE 1 |
#define | JPOOL_PERMANENT 0 |
#define | MAX_COMPS_IN_SCAN 4 |
#define | NUM_ARITH_TBLS 16 |
#define | NUM_HUFF_TBLS 4 |
#define | NUM_QUANT_TBLS 4 |
#define | qjpeg_create_compress(cinfo) |
#define | qjpeg_create_decompress(cinfo) |
Typedefs | |
typedef void * | j_common_ptr |
typedef int | jboolean |
typedef unsigned int | JDIMENSION |
typedef my_destination_mgr * | my_dest_ptr |
Enumerations | |
enum | J_COLOR_SPACE { JCS_UNKNOWN , JCS_GRAYSCALE , JCS_RGB , JCS_YCbCr , JCS_CMYK , JCS_YCCK } |
enum | J_DCT_METHOD { JPEG_DUMMY1 } |
enum | J_DITHER_MODE { JPEG_DUMMY2 } |
Functions | |
static void | CompressedImageCache_Add (const char *imagename, size_t maxsize, void *compressed, size_t compressed_size) |
static CompressedImageCacheItem * | CompressedImageCache_Find (const char *imagename, size_t maxsize) |
qbool | Image_Compress (const char *imagename, size_t maxsize, void **buf, size_t *size) |
void | JPEG_CloseLibrary (void) |
static jboolean | JPEG_EmptyOutputBuffer (j_compress_ptr cinfo) |
static void | JPEG_ErrorExit (j_common_ptr cinfo) |
static void | JPEG_FileDest (j_compress_ptr cinfo, qfile_t *outfile) |
static jboolean | JPEG_FillInputBuffer (j_decompress_ptr cinfo) |
static void | JPEG_InitDestination (j_compress_ptr cinfo) |
unsigned char * | JPEG_LoadImage_BGRA (const unsigned char *f, int filesize, int *miplevel) |
static jboolean | JPEG_Mem_EmptyOutputBuffer (j_compress_ptr cinfo) |
static void | JPEG_Mem_InitDestination (j_compress_ptr cinfo) |
static void | JPEG_Mem_TermDestination (j_compress_ptr cinfo) |
static void | JPEG_MemDest (j_compress_ptr cinfo, void *buf, size_t bufsize) |
static void | JPEG_MemSrc (j_decompress_ptr cinfo, const unsigned char *buffer, size_t filesize) |
static void | JPEG_Noop (j_decompress_ptr cinfo) |
qbool | JPEG_OpenLibrary (void) |
qbool | JPEG_SaveImage_preflipped (const char *filename, int width, int height, unsigned char *data) |
size_t | JPEG_SaveImage_to_Buffer (char *jpegbuf, size_t jpegsize, int width, int height, unsigned char *data) |
static void | JPEG_SkipInputData (j_decompress_ptr cinfo, long num_bytes) |
static void | JPEG_TermDestination (j_compress_ptr cinfo) |
static size_t | JPEG_try_SaveImage_to_Buffer (struct jpeg_compress_struct *cinfo, char *jpegbuf, size_t jpegsize, int quality, int width, int height, unsigned char *data) |
Variables | |
static CompressedImageCacheItem * | CompressedImageCache [COMPRESSEDIMAGECACHE_SIZE] |
static jmp_buf | error_in_jpeg |
dllhandle_t | jpeg_dll = NULL |
static unsigned char | jpeg_eoi_marker [2] = {0xFF, JPEG_EOI} |
static qbool | jpeg_toolarge |
qbool | jpeg_tried_loading = 0 |
static dllfunction_t | jpegfuncs [] |
static void(* | qjpeg_CreateCompress )(j_compress_ptr cinfo, int version, size_t structsize) |
static void(* | qjpeg_CreateDecompress )(j_decompress_ptr cinfo, int version, size_t structsize) |
static void(* | qjpeg_destroy_compress )(j_compress_ptr cinfo) |
static void(* | qjpeg_destroy_decompress )(j_decompress_ptr cinfo) |
static void(* | qjpeg_finish_compress )(j_compress_ptr cinfo) |
static jboolean(* | qjpeg_finish_decompress )(j_decompress_ptr cinfo) |
static int(* | qjpeg_read_header )(j_decompress_ptr cinfo, jboolean require_image) |
static JDIMENSION(* | qjpeg_read_scanlines )(j_decompress_ptr cinfo, unsigned char **scanlines, JDIMENSION max_lines) |
static jboolean(* | qjpeg_resync_to_restart )(j_decompress_ptr cinfo, int desired) |
static void(* | qjpeg_set_defaults )(j_compress_ptr cinfo) |
static void(* | qjpeg_set_quality )(j_compress_ptr cinfo, int quality, jboolean force_baseline) |
static void(* | qjpeg_simple_progression )(j_compress_ptr cinfo) |
static jboolean(* | qjpeg_start_compress )(j_compress_ptr cinfo, jboolean write_all_tables) |
static jboolean(* | qjpeg_start_decompress )(j_decompress_ptr cinfo) |
static struct jpeg_error_mgr *(* | qjpeg_std_error )(struct jpeg_error_mgr *err) |
static JDIMENSION(* | qjpeg_write_scanlines )(j_compress_ptr cinfo, unsigned char **scanlines, JDIMENSION num_lines) |
cvar_t | r_texture_jpeg_fastpicmip = {CF_CLIENT | CF_ARCHIVE, "r_texture_jpeg_fastpicmip", "1", "perform gl_picmip during decompression for JPEG files (faster)"} |
cvar_t | sv_writepicture_quality |
#define COMPRESSEDIMAGECACHE_SIZE 4096 |
Definition at line 1008 of file jpeg.c.
Referenced by CompressedImageCache_Add(), and CompressedImageCache_Find().
#define JPEG_OUTPUT_BUF_SIZE 4096 |
Definition at line 724 of file jpeg.c.
Referenced by JPEG_EmptyOutputBuffer(), JPEG_InitDestination(), and JPEG_TermDestination().
#define JPOOL_IMAGE 1 |
Definition at line 92 of file jpeg.c.
Referenced by JPEG_InitDestination().
#define JPOOL_PERMANENT 0 |
Definition at line 91 of file jpeg.c.
Referenced by JPEG_FileDest(), JPEG_MemDest(), and JPEG_MemSrc().
#define qjpeg_create_compress | ( | cinfo | ) |
Definition at line 413 of file jpeg.c.
Referenced by JPEG_SaveImage_preflipped(), and JPEG_SaveImage_to_Buffer().
#define qjpeg_create_decompress | ( | cinfo | ) |
Definition at line 415 of file jpeg.c.
Referenced by JPEG_LoadImage_BGRA().
typedef void* j_common_ptr |
typedef unsigned int JDIMENSION |
typedef my_destination_mgr* my_dest_ptr |
enum J_COLOR_SPACE |
Enumerator | |
---|---|
JCS_UNKNOWN | |
JCS_GRAYSCALE | |
JCS_RGB | |
JCS_YCbCr | |
JCS_CMYK | |
JCS_YCCK |
Definition at line 78 of file jpeg.c.
enum J_DCT_METHOD |
enum J_DITHER_MODE |
|
static |
Definition at line 1011 of file jpeg.c.
References CompressedImageCacheItem::compressed, CompressedImageCacheItem::compressed_size, CompressedImageCache, COMPRESSEDIMAGECACHE_SIZE, CRC_Block(), dp_strlcpy, i, CompressedImageCacheItem::imagename, MAX_QPATH, CompressedImageCacheItem::maxsize, strlen(), va(), and Z_Malloc.
Referenced by Image_Compress().
|
static |
Definition at line 1030 of file jpeg.c.
References CompressedImageCache, COMPRESSEDIMAGECACHE_SIZE, CRC_Block(), i, CompressedImageCacheItem::imagename, CompressedImageCacheItem::maxsize, NULL, strlen(), and va().
Referenced by Image_Compress().
Definition at line 1047 of file jpeg.c.
References buf, CompressedImageCache_Add(), CompressedImageCache_Find(), Con_Print(), Con_Printf(), i, Image_CopyMux(), image_height, Image_MipReduce32(), image_width, CompressedImageCacheItem::imagename, jpeg_dll, JPEG_OpenLibrary(), JPEG_SaveImage_to_Buffer(), loadimagepixelsbgra(), CompressedImageCacheItem::maxsize, Mem_Alloc, Mem_Free, NULL, PNG_OpenLibrary(), size, tempmempool, Z_Free, and Z_Malloc.
Referenced by VM_SV_WritePicture().
Definition at line 538 of file jpeg.c.
References jpeg_dll, jpeg_tried_loading, and Sys_FreeLibrary().
Referenced by r_textures_shutdown().
|
static |
Definition at line 733 of file jpeg.c.
References my_destination_mgr::buffer, error_in_jpeg, jpeg_destination_mgr::free_in_buffer, FS_Write(), JPEG_OUTPUT_BUF_SIZE, jpeg_destination_mgr::next_output_byte, my_destination_mgr::outfile, and my_destination_mgr::pub.
Referenced by JPEG_FileDest().
|
static |
Definition at line 592 of file jpeg.c.
References j_decompress_ptr::err, error_in_jpeg, and jpeg_error_mgr::output_message.
Referenced by JPEG_LoadImage_BGRA(), JPEG_SaveImage_preflipped(), and JPEG_SaveImage_to_Buffer().
|
static |
Definition at line 756 of file jpeg.c.
References jpeg_destination_mgr::empty_output_buffer, jpeg_destination_mgr::init_destination, JPEG_EmptyOutputBuffer(), JPEG_InitDestination(), JPEG_TermDestination(), JPOOL_PERMANENT, NULL, my_destination_mgr::outfile, outfile, my_destination_mgr::pub, and jpeg_destination_mgr::term_destination.
Referenced by JPEG_SaveImage_preflipped().
|
static |
Definition at line 557 of file jpeg.c.
References jpeg_eoi_marker.
Referenced by JPEG_MemSrc().
|
static |
Definition at line 725 of file jpeg.c.
References my_destination_mgr::buffer, jpeg_destination_mgr::free_in_buffer, JPEG_OUTPUT_BUF_SIZE, JPOOL_IMAGE, jpeg_destination_mgr::next_output_byte, and my_destination_mgr::pub.
Referenced by JPEG_FileDest().
Definition at line 606 of file jpeg.c.
References bound, Con_Printf(), j_decompress_ptr::err, jpeg_error_mgr::error_exit, error_in_jpeg, f, image_height, image_width, cvar_t::integer, jpeg_dll, JPEG_ErrorExit(), JPEG_MemSrc(), Mem_Alloc, Mem_Free, NULL, j_decompress_ptr::output_components, j_decompress_ptr::output_height, j_decompress_ptr::output_scanline, j_decompress_ptr::output_width, qjpeg_create_decompress, qjpeg_destroy_decompress, qjpeg_finish_decompress, qjpeg_read_header, qjpeg_read_scanlines, qjpeg_start_decompress, qjpeg_std_error, r_texture_jpeg_fastpicmip, j_decompress_ptr::scale_denom, j_decompress_ptr::scale_num, and tempmempool.
Referenced by decode_image(), loadimagepixelsbgra(), and VM_CL_ReadPicture().
|
static |
Definition at line 778 of file jpeg.c.
References my_destination_mgr::buffer, my_destination_mgr::bufsize, jpeg_destination_mgr::free_in_buffer, jpeg_toolarge, jpeg_destination_mgr::next_output_byte, and my_destination_mgr::pub.
Referenced by JPEG_MemDest().
|
static |
Definition at line 771 of file jpeg.c.
References my_destination_mgr::buffer, my_destination_mgr::bufsize, jpeg_destination_mgr::free_in_buffer, jpeg_destination_mgr::next_output_byte, and my_destination_mgr::pub.
Referenced by JPEG_MemDest().
|
static |
Definition at line 787 of file jpeg.c.
References my_destination_mgr::buffer, my_destination_mgr::bufsize, jpeg_destination_mgr::next_output_byte, and my_destination_mgr::pub.
Referenced by JPEG_MemDest().
Definition at line 792 of file jpeg.c.
References buf, my_destination_mgr::buffer, my_destination_mgr::bufsize, jpeg_destination_mgr::empty_output_buffer, jpeg_destination_mgr::init_destination, JPEG_Mem_EmptyOutputBuffer(), JPEG_Mem_InitDestination(), JPEG_Mem_TermDestination(), JPOOL_PERMANENT, NULL, my_destination_mgr::outfile, my_destination_mgr::pub, and jpeg_destination_mgr::term_destination.
Referenced by JPEG_try_SaveImage_to_Buffer().
|
static |
Definition at line 578 of file jpeg.c.
References buffer, JPEG_FillInputBuffer(), JPEG_Noop(), JPEG_SkipInputData(), JPOOL_PERMANENT, and qjpeg_resync_to_restart.
Referenced by JPEG_LoadImage_BGRA().
|
static |
Definition at line 492 of file jpeg.c.
References Con_Printf(), jpeg_dll, jpeg_tried_loading, jpegfuncs, NULL, and Sys_LoadDependency().
Referenced by Image_Compress(), and r_textures_start().
qbool JPEG_SaveImage_preflipped | ( | const char * | filename, |
int | width, | ||
int | height, | ||
unsigned char * | data ) |
Definition at line 818 of file jpeg.c.
References j_compress_ptr::comp_info, Con_Print(), data, j_compress_ptr::err, jpeg_error_mgr::error_exit, error_in_jpeg, FS_Close(), FS_OpenRealFile(), jpeg_component_info::h_samp_factor, height, j_compress_ptr::image_height, j_compress_ptr::image_width, j_compress_ptr::in_color_space, j_compress_ptr::input_components, JCS_RGB, jpeg_dll, JPEG_ErrorExit(), JPEG_FileDest(), j_compress_ptr::next_scanline, offset, j_compress_ptr::optimize_coding, qjpeg_create_compress, qjpeg_destroy_compress, qjpeg_finish_compress, qjpeg_set_defaults, qjpeg_set_quality, qjpeg_simple_progression, qjpeg_start_compress, qjpeg_std_error, qjpeg_write_scanlines, scr_screenshot_jpeg_quality, jpeg_component_info::v_samp_factor, cvar_t::value, and width.
Referenced by SCR_ScreenShot().
size_t JPEG_SaveImage_to_Buffer | ( | char * | jpegbuf, |
size_t | jpegsize, | ||
int | width, | ||
int | height, | ||
unsigned char * | data ) |
Definition at line 931 of file jpeg.c.
References bound, buf, Con_DPrintf(), Con_Print(), Con_Printf(), data, j_compress_ptr::err, jpeg_error_mgr::error_exit, error_in_jpeg, height, i, img, int(), cvar_t::integer, jpeg_dll, JPEG_ErrorExit(), JPEG_try_SaveImage_to_Buffer(), Mem_Alloc, Mem_Free, qjpeg_create_compress, qjpeg_destroy_compress, qjpeg_std_error, sv_writepicture_quality, tempmempool, and width.
Referenced by Image_Compress().
|
static |
Definition at line 566 of file jpeg.c.
Referenced by JPEG_MemSrc().
|
static |
Definition at line 745 of file jpeg.c.
References my_destination_mgr::buffer, error_in_jpeg, jpeg_destination_mgr::free_in_buffer, FS_Write(), JPEG_OUTPUT_BUF_SIZE, my_destination_mgr::outfile, and my_destination_mgr::pub.
Referenced by JPEG_FileDest().
|
static |
Definition at line 888 of file jpeg.c.
References j_compress_ptr::comp_info, data, j_compress_ptr::dest, jpeg_component_info::h_samp_factor, height, j_compress_ptr::image_height, j_compress_ptr::image_width, j_compress_ptr::in_color_space, j_compress_ptr::input_components, JCS_RGB, JPEG_MemDest(), jpeg_toolarge, j_compress_ptr::next_scanline, j_compress_ptr::optimize_coding, qjpeg_finish_compress, qjpeg_set_defaults, qjpeg_set_quality, qjpeg_start_compress, qjpeg_write_scanlines, jpeg_component_info::v_samp_factor, and width.
Referenced by JPEG_SaveImage_to_Buffer().
|
static |
Definition at line 1009 of file jpeg.c.
Referenced by CompressedImageCache_Add(), and CompressedImageCache_Find().
|
static |
Definition at line 462 of file jpeg.c.
Referenced by JPEG_EmptyOutputBuffer(), JPEG_ErrorExit(), JPEG_LoadImage_BGRA(), JPEG_SaveImage_preflipped(), JPEG_SaveImage_to_Buffer(), and JPEG_TermDestination().
dllhandle_t jpeg_dll = NULL |
Definition at line 457 of file jpeg.c.
Referenced by Image_Compress(), JPEG_CloseLibrary(), JPEG_LoadImage_BGRA(), JPEG_OpenLibrary(), JPEG_SaveImage_preflipped(), and JPEG_SaveImage_to_Buffer().
|
static |
|
static |
Definition at line 463 of file jpeg.c.
Referenced by JPEG_Mem_EmptyOutputBuffer(), and JPEG_try_SaveImage_to_Buffer().
qbool jpeg_tried_loading = 0 |
Definition at line 458 of file jpeg.c.
Referenced by JPEG_CloseLibrary(), and JPEG_OpenLibrary().
|
static |
Definition at line 435 of file jpeg.c.
Referenced by JPEG_OpenLibrary().
|
static |
Definition at line 420 of file jpeg.c.
Referenced by JPEG_SaveImage_preflipped(), and JPEG_SaveImage_to_Buffer().
|
static |
Definition at line 421 of file jpeg.c.
Referenced by JPEG_LoadImage_BGRA().
|
static |
Definition at line 422 of file jpeg.c.
Referenced by JPEG_SaveImage_preflipped(), and JPEG_try_SaveImage_to_Buffer().
|
static |
Definition at line 423 of file jpeg.c.
Referenced by JPEG_LoadImage_BGRA().
|
static |
Definition at line 425 of file jpeg.c.
Referenced by JPEG_LoadImage_BGRA().
|
static |
Definition at line 426 of file jpeg.c.
Referenced by JPEG_LoadImage_BGRA().
|
static |
Definition at line 424 of file jpeg.c.
Referenced by JPEG_MemSrc().
|
static |
Definition at line 427 of file jpeg.c.
Referenced by JPEG_SaveImage_preflipped(), and JPEG_try_SaveImage_to_Buffer().
|
static |
Definition at line 428 of file jpeg.c.
Referenced by JPEG_SaveImage_preflipped(), and JPEG_try_SaveImage_to_Buffer().
|
static |
Definition at line 433 of file jpeg.c.
Referenced by JPEG_SaveImage_preflipped().
|
static |
Definition at line 429 of file jpeg.c.
Referenced by JPEG_SaveImage_preflipped(), and JPEG_try_SaveImage_to_Buffer().
|
static |
Definition at line 430 of file jpeg.c.
Referenced by JPEG_LoadImage_BGRA().
|
static |
Definition at line 430 of file jpeg.c.
Referenced by JPEG_LoadImage_BGRA(), JPEG_SaveImage_preflipped(), and JPEG_SaveImage_to_Buffer().
|
static |
Definition at line 432 of file jpeg.c.
Referenced by JPEG_SaveImage_preflipped(), and JPEG_try_SaveImage_to_Buffer().
cvar_t r_texture_jpeg_fastpicmip = {CF_CLIENT | CF_ARCHIVE, "r_texture_jpeg_fastpicmip", "1", "perform gl_picmip during decompression for JPEG files (faster)"} |
Definition at line 32 of file jpeg.c.
Referenced by Host_InitLocal(), and JPEG_LoadImage_BGRA().
|
extern |
Definition at line 219 of file sv_main.c.
Referenced by JPEG_SaveImage_to_Buffer(), and SV_Init().