"library is 70, caller expects 62. " solution

If you've had any problems with Nexuiz, or would like to report bugs, post here.

Moderators: Nexuiz Moderators, Moderators

"library is 70, caller expects 62. " solution

Postby TonyG » Fri Jul 24, 2009 10:32 pm

This problem can be fixed by removing the code darkplaces copied from libjpeg's header and instead including it directly. Check out the latest darkplaces code and apply the following patch (yes, it's overkill for a simple change, but who knows).

Hope you find it useful :) .

Code: Select all
--- darkplaces/jpeg.c   2009-04-10 07:37:23.000000000 -0700
+++ darkplacesb/jpeg.c  2009-07-24 14:45:11.000000000 -0700
@@ -25,6 +25,7 @@
#include "quakedef.h"
#include "image.h"
#include "jpeg.h"
+#include <jpeglib.h>

cvar_t sv_writepicture_quality = {CVAR_SAVE, "sv_writepicture_quality", "10", "WritePicture quality offset (higher means better quality, but slower)"};

@@ -38,344 +39,7 @@

=================================================================
*/
-
-// jboolean is unsigned char instead of int on Win32
-#ifdef WIN32
typedef unsigned char jboolean;
-#else
-typedef int jboolean;
-#endif
-
-#define JPEG_LIB_VERSION  62  // Version 6b
-
-typedef void *j_common_ptr;
-typedef struct jpeg_compress_struct *j_compress_ptr;
-typedef struct jpeg_decompress_struct *j_decompress_ptr;
-typedef enum
-{
-       JCS_UNKNOWN,
-       JCS_GRAYSCALE,
-       JCS_RGB,
-       JCS_YCbCr,
-       JCS_CMYK,
-       JCS_YCCK
-} J_COLOR_SPACE;
-typedef enum {JPEG_DUMMY1} J_DCT_METHOD;
-typedef enum {JPEG_DUMMY2} J_DITHER_MODE;
-typedef unsigned int JDIMENSION;
-
-#define JPOOL_PERMANENT        0       // lasts until master record is destroyed
-#define JPOOL_IMAGE            1       // lasts until done with image/datastream
-
-#define JPEG_EOI       0xD9  // EOI marker code
-
-#define JMSG_STR_PARM_MAX  80
-
-#define DCTSIZE2 64
-#define NUM_QUANT_TBLS 4
-#define NUM_HUFF_TBLS 4
-#define NUM_ARITH_TBLS 16
-#define MAX_COMPS_IN_SCAN 4
-#define C_MAX_BLOCKS_IN_MCU 10
-#define D_MAX_BLOCKS_IN_MCU 10
-
-struct jpeg_memory_mgr
-{
-  void* (*alloc_small) (j_common_ptr cinfo, int pool_id, size_t sizeofobject);
-  void (*alloc_large) ();
-  void (*alloc_sarray) ();
-  void (*alloc_barray) ();
-  void (*request_virt_sarray) ();
-  void (*request_virt_barray) ();
-  void (*realize_virt_arrays) ();
-  void (*access_virt_sarray) ();
-  void (*access_virt_barray) ();
-  void (*free_pool) ();
-  void (*self_destruct) ();
-
-  long max_memory_to_use;
-  long max_alloc_chunk;
-};
-
-struct jpeg_error_mgr
-{
-       void (*error_exit) (j_common_ptr cinfo);
-       void (*emit_message) (j_common_ptr cinfo, int msg_level);
-       void (*output_message) (j_common_ptr cinfo);
-       void (*format_message) (j_common_ptr cinfo, char * buffer);
-       void (*reset_error_mgr) (j_common_ptr cinfo);
-       int msg_code;
-       union {
-               int i[8];
-               char s[JMSG_STR_PARM_MAX];
-       } msg_parm;
-       int trace_level;
-       long num_warnings;
-       const char * const * jpeg_message_table;
-       int last_jpeg_message;
-       const char * const * addon_message_table;
-       int first_addon_message;
-       int last_addon_message;
-};
-
-struct jpeg_source_mgr
-{
-       const unsigned char *next_input_byte;
-       size_t bytes_in_buffer;
-
-       void (*init_source) (j_decompress_ptr cinfo);
-       jboolean (*fill_input_buffer) (j_decompress_ptr cinfo);
-       void (*skip_input_data) (j_decompress_ptr cinfo, long num_bytes);
-       jboolean (*resync_to_restart) (j_decompress_ptr cinfo, int desired);
-       void (*term_source) (j_decompress_ptr cinfo);
-};
-
-typedef struct {
-  /* These values are fixed over the whole image. */
-  /* For compression, they must be supplied by parameter setup; */
-  /* for decompression, they are read from the SOF marker. */
-  int component_id;             /* identifier for this component (0..255) */
-  int component_index;          /* its index in SOF or cinfo->comp_info[] */
-  int h_samp_factor;            /* horizontal sampling factor (1..4) */
-  int v_samp_factor;            /* vertical sampling factor (1..4) */
-  int quant_tbl_no;             /* quantization table selector (0..3) */
-  /* These values may vary between scans. */
-  /* For compression, they must be supplied by parameter setup; */
-  /* for decompression, they are read from the SOS marker. */
-  /* The decompressor output side may not use these variables. */
-  int dc_tbl_no;                /* DC entropy table selector (0..3) */
-  int ac_tbl_no;                /* AC entropy table selector (0..3) */

-  /* Remaining fields should be treated as private by applications. */

-  /* These values are computed during compression or decompression startup: */
-  /* Component's size in DCT blocks.
-   * Any dummy blocks added to complete an MCU are not counted; therefore
-   * these values do not depend on whether a scan is interleaved or not.
-   */
-  JDIMENSION width_in_blocks;
-  JDIMENSION height_in_blocks;
-  /* Size of a DCT block in samples.  Always DCTSIZE for compression.
-   * For decompression this is the size of the output from one DCT block,
-   * reflecting any scaling we choose to apply during the IDCT step.
-   * Values of 1,2,4,8 are likely to be supported.  Note that different
-   * components may receive different IDCT scalings.
-   */
-  int DCT_scaled_size;
-  /* The downsampled dimensions are the component's actual, unpadded number
-   * of samples at the main buffer (preprocessing/compression interface), thus
-   * downsampled_width = ceil(image_width * Hi/Hmax)
-   * and similarly for height.  For decompression, IDCT scaling is included, so
-   * downsampled_width = ceil(image_width * Hi/Hmax * DCT_scaled_size/DCTSIZE)
-   */
-  JDIMENSION downsampled_width;  /* actual width in samples */
-  JDIMENSION downsampled_height; /* actual height in samples */
-  /* This flag is used only for decompression.  In cases where some of the
-   * components will be ignored (eg grayscale output from YCbCr image),
-   * we can skip most computations for the unused components.
-   */
-  jboolean component_needed;     /* do we need the value of this component? */
-
-  /* These values are computed before starting a scan of the component. */
-  /* The decompressor output side may not use these variables. */
-  int MCU_width;                /* number of blocks per MCU, horizontally */
-  int MCU_height;               /* number of blocks per MCU, vertically */
-  int MCU_blocks;               /* MCU_width * MCU_height */
-  int MCU_sample_width;         /* MCU width in samples, MCU_width*DCT_scaled_size */
-  int last_col_width;           /* # of non-dummy blocks across in last MCU */
-  int last_row_height;          /* # of non-dummy blocks down in last MCU */
-
-  /* Saved quantization table for component; NULL if none yet saved.
-   * See jdinput.c comments about the need for this information.
-   * This field is currently used only for decompression.
-   */
-  void *quant_table;
-
-  /* Private per-component storage for DCT or IDCT subsystem. */
-  void * dct_table;
-} jpeg_component_info;
-
-struct jpeg_decompress_struct
-{
-       struct jpeg_error_mgr *err;             // USED
-       struct jpeg_memory_mgr *mem;    // USED
-
-       void *progress;
-       void *client_data;
-       jboolean is_decompressor;
-       int global_state;
-
-       struct jpeg_source_mgr *src;    // USED
-       JDIMENSION image_width;                 // USED
-       JDIMENSION image_height;                // USED
-
-       int num_components;
-       J_COLOR_SPACE jpeg_color_space;
-       J_COLOR_SPACE out_color_space;
-       unsigned int scale_num, scale_denom;
-       double output_gamma;
-       jboolean buffered_image;
-       jboolean raw_data_out;
-       J_DCT_METHOD dct_method;
-       jboolean do_fancy_upsampling;
-       jboolean do_block_smoothing;
-       jboolean quantize_colors;
-       J_DITHER_MODE dither_mode;
-       jboolean two_pass_quantize;
-       int desired_number_of_colors;
-       jboolean enable_1pass_quant;
-       jboolean enable_external_quant;
-       jboolean enable_2pass_quant;
-       JDIMENSION output_width;
-
-       JDIMENSION output_height;       // USED
-
-       int out_color_components;
-
-       int output_components;          // USED
-
-       int rec_outbuf_height;
-       int actual_number_of_colors;
-       void *colormap;
-
-       JDIMENSION output_scanline;     // USED
-
-       int input_scan_number;
-       JDIMENSION input_iMCU_row;
-       int output_scan_number;
-       JDIMENSION output_iMCU_row;
-       int (*coef_bits)[DCTSIZE2];
-       void *quant_tbl_ptrs[NUM_QUANT_TBLS];
-       void *dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
-       void *ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
-       int data_precision;
-       jpeg_component_info *comp_info;
-       jboolean progressive_mode;
-       jboolean arith_code;
-       unsigned char arith_dc_L[NUM_ARITH_TBLS];
-       unsigned char arith_dc_U[NUM_ARITH_TBLS];
-       unsigned char arith_ac_K[NUM_ARITH_TBLS];
-       unsigned int restart_interval;
-       jboolean saw_JFIF_marker;
-       unsigned char JFIF_major_version;
-       unsigned char JFIF_minor_version;
-       unsigned char density_unit;
-       unsigned short X_density;
-       unsigned short Y_density;
-       jboolean saw_Adobe_marker;
-       unsigned char Adobe_transform;
-       jboolean CCIR601_sampling;
-       void *marker_list;
-       int max_h_samp_factor;
-       int max_v_samp_factor;
-       int min_DCT_scaled_size;
-       JDIMENSION total_iMCU_rows;
-       void *sample_range_limit;
-       int comps_in_scan;
-       jpeg_component_info *cur_comp_info[MAX_COMPS_IN_SCAN];
-       JDIMENSION MCUs_per_row;
-       JDIMENSION MCU_rows_in_scan;
-       int blocks_in_MCU;
-       int MCU_membership[D_MAX_BLOCKS_IN_MCU];
-       int Ss, Se, Ah, Al;
-       int unread_marker;
-       void *master;
-       void *main;
-       void *coef;
-       void *post;
-       void *inputctl;
-       void *marker;
-       void *entropy;
-       void *idct;
-       void *upsample;
-       void *cconvert;
-       void *cquantize;
-};
-
-
-struct jpeg_compress_struct
-{
-       struct jpeg_error_mgr *err;
-       struct jpeg_memory_mgr *mem;
-       void *progress;
-       void *client_data;
-       jboolean is_decompressor;
-       int global_state;
-
-       void *dest;
-       JDIMENSION image_width;
-       JDIMENSION image_height;
-       int input_components;
-       J_COLOR_SPACE in_color_space;
-       double input_gamma;
-       int data_precision;
-
-       int num_components;
-       J_COLOR_SPACE jpeg_color_space;
-       jpeg_component_info *comp_info;
-       void *quant_tbl_ptrs[NUM_QUANT_TBLS];
-       void *dc_huff_tbl_ptrs[NUM_HUFF_TBLS];
-       void *ac_huff_tbl_ptrs[NUM_HUFF_TBLS];
-       unsigned char arith_dc_L[NUM_ARITH_TBLS];
-       unsigned char arith_dc_U[NUM_ARITH_TBLS];
-       unsigned char arith_ac_K[NUM_ARITH_TBLS];
-
-       int num_scans;
-       const void *scan_info;
-       jboolean raw_data_in;
-       jboolean arith_code;
-       jboolean optimize_coding;
-       jboolean CCIR601_sampling;
-       int smoothing_factor;
-       J_DCT_METHOD dct_method;
-
-       unsigned int restart_interval;
-       int restart_in_rows;
-
-       jboolean write_JFIF_header;
-       unsigned char JFIF_major_version;
-       unsigned char JFIF_minor_version;
-       unsigned char density_unit;
-       unsigned short X_density;
-       unsigned short Y_density;
-       jboolean write_Adobe_marker;
-       JDIMENSION next_scanline;
-
-       jboolean progressive_mode;
-       int max_h_samp_factor;
-       int max_v_samp_factor;
-       JDIMENSION total_iMCU_rows;
-       int comps_in_scan;
-       jpeg_component_info *cur_comp_info[MAX_COMPS_IN_SCAN];
-       JDIMENSION MCUs_per_row;
-       JDIMENSION MCU_rows_in_scan;
-       int blocks_in_MCU;
-       int MCU_membership[C_MAX_BLOCKS_IN_MCU];
-       int Ss, Se, Ah, Al;
-
-       void *master;
-       void *main;
-       void *prep;
-       void *coef;
-       void *marker;
-       void *cconvert;
-       void *downsample;
-       void *fdct;
-       void *entropy;
-       void *script_space;
-       int script_space_size;
-};
-
-struct jpeg_destination_mgr
-{
-       unsigned char* next_output_byte;
-       size_t free_in_buffer;
-
-       void (*init_destination) (j_compress_ptr cinfo);
-       jboolean (*empty_output_buffer) (j_compress_ptr cinfo);
-       void (*term_destination) (j_compress_ptr cinfo);
-};
-

/*
=================================================================
TonyG
Newbie
 
Posts: 3
Joined: Fri Jul 24, 2009 10:21 pm

Postby divVerent » Fri Jul 24, 2009 10:45 pm

Problem is, compiled binaries then do not work with the more widespread jpeg library 6.2.

Also, if you check out REALLY current source, you should just do make DP_LINK_TO_LIBJPEG=1.
1. Open Notepad
2. Paste: ÿþMSMSMS
3. Save
4. Open the file in Notepad again

You can vary the number of "MS", so you can clearly see it's MS which is causing it.
divVerent
Site admin and keyboard killer
 
Posts: 3809
Joined: Thu Mar 02, 2006 4:46 pm
Location: BRLOGENSHFEGLE

Postby TonyG » Fri Jul 24, 2009 10:53 pm

I don't see why they wouldn't. Darkplaces will just fall back to loading symbols from "libjpeg.so" if "libjpeg.so.62" isn't found. I know for a fact libjpeg 7 is API compatible, and I'm pretty sure it's ABI compatible with stuff using 6.2.

Edit: Ah, I just took a look at SVN HEAD. Nice
TonyG
Newbie
 
Posts: 3
Joined: Fri Jul 24, 2009 10:21 pm


Return to Nexuiz - Support / Bugs

Who is online

Users browsing this forum: No registered users and 1 guest

cron