[gs-cvs] rev 10249 - branches/icc_work/base

mvrhel at ghostscript.com mvrhel at ghostscript.com
Fri Oct 30 16:37:50 PDT 2009


Author: mvrhel
Date: 2009-10-30 16:37:49 -0700 (Fri, 30 Oct 2009)
New Revision: 10249

Modified:
   branches/icc_work/base/gdevp14.c
   branches/icc_work/base/gstrans.h
   branches/icc_work/base/gxclist.c
   branches/icc_work/base/gxclist.h
Log:
Fix of a few minor bugs in the clist writer code for the ICC profiles.  Primarily a change to write the ICC profiles into the cfile at the end of the writing process. 

Modified: branches/icc_work/base/gdevp14.c
===================================================================
--- branches/icc_work/base/gdevp14.c	2009-10-30 23:34:05 UTC (rev 10248)
+++ branches/icc_work/base/gdevp14.c	2009-10-30 23:37:49 UTC (rev 10249)
@@ -4378,8 +4378,9 @@
     int mask_size = 0;
     uint mask_id = 0;
     int code;
-    int64_t icc_position = 0;
+    bool found_icc;
     int icc_size;
+    int64_t hashcode = 0;
 
     *pbuf++ = opcode;			/* 1 byte */
     switch (opcode) {
@@ -4421,28 +4422,28 @@
                        the pseudoband location of the ICC profile.  We
                        will then read the serialized header in that case. */
 
-                    icc_position = -pparams->iccprofile->default_match;  
-                    put_value(pbuf, icc_position);
+                    hashcode = -pparams->iccprofile->default_match;
+                    put_value(pbuf, hashcode);
 
                 } else {
                 
                     /* If no, check if it is already in the ICC clist table */
 
-                    icc_position = clist_icc_searchtable(cdev, pparams->iccprofile->hashcode);
+                    hashcode = pparams->iccprofile->hashcode;
+                    found_icc = clist_icc_searchtable(cdev, hashcode);
                    
-                    if (icc_position < 0) {
+                    if (!found_icc) {
 
-                        /* Add it to the table and write out to the cfile */
+                        /* Add it to the table */
 
-                        icc_position = clist_icc_addprofile(cdev, pparams->iccprofile, &icc_size);  
-                        clist_icc_addentry(cdev, pparams->iccprofile->hashcode, icc_position, icc_size);
-                        put_value(pbuf, icc_position);
+                        clist_icc_addentry(cdev, hashcode, pparams->iccprofile);
+                        put_value(pbuf, hashcode);
 
                     } else {
 
-                        /* It is in the cache. Just write out the location */
+                        /* It will be in the clist. Just write out the hashcode */
 
-                        put_value(pbuf, icc_position);
+                        put_value(pbuf, hashcode);
 
                     }
 
@@ -4450,7 +4451,7 @@
 
             } else {
 
-                put_value(pbuf, icc_position);
+                put_value(pbuf, hashcode);
 
             }
 
@@ -4554,6 +4555,7 @@
     gs_pdf14trans_params_t params = {0};
     const byte * start = data;
     int used, code = 0;
+    int64_t icc_hash;
 
     if (size < 1)
 	return_error(gs_error_rangecheck);
@@ -4594,6 +4596,7 @@
 	    read_value(data, params.shape.alpha);
 	    read_value(data, params.bbox);
 	    read_value(data, params.mask_id);
+            read_value(data, params.icc_hash);
 	    break;
 	case PDF14_BEGIN_TRANS_MASK:
 		/* This is the largest transparency parameter at this time (potentially

Modified: branches/icc_work/base/gstrans.h
===================================================================
--- branches/icc_work/base/gstrans.h	2009-10-30 23:34:05 UTC (rev 10248)
+++ branches/icc_work/base/gstrans.h	2009-10-30 23:37:49 UTC (rev 10249)
@@ -108,6 +108,7 @@
     bool SMask_is_CIE;
     int group_color_numcomps;
     gs_transparency_color_t group_color;
+    int64_t icc_hash;
     cmm_profile_t *iccprofile;               /* The profile  */
 
 };

Modified: branches/icc_work/base/gxclist.c
===================================================================
--- branches/icc_work/base/gxclist.c	2009-10-30 23:34:05 UTC (rev 10248)
+++ branches/icc_work/base/gxclist.c	2009-10-30 23:37:49 UTC (rev 10249)
@@ -744,8 +744,8 @@
     int ecode = 0;
 
 
-    /* If we have ICC profiles present in the cfile save the table now.
-       Table is stored in band maxband + 1. */
+    /* If we have ICC profiles present in the cfile save the table now,
+       along with the ICC profiles. Table is stored in band maxband + 1. */
 
     if ( cldev->icc_table != NULL ) {
 
@@ -971,14 +971,14 @@
 
 /* This checks the table for a hash code entry */
 
-int64_t 
+bool 
 clist_icc_searchtable(gx_device_clist_writer *cdev, int64_t hashcode)
 {
     clist_icctable_t *icc_table = cdev->icc_table;
     clist_icctable_entry_t *curr_entry;
 
     if (icc_table == NULL)
-        return(-1);  /* No entry */
+        return(false);  /* No entry */
 
     curr_entry = icc_table->head;
 
@@ -986,7 +986,7 @@
     
         if (curr_entry->serial_data.hashcode == hashcode){
             
-            return(curr_entry->serial_data.file_position);
+            return(true);
 
         }
         
@@ -994,7 +994,7 @@
 
     }
 
-     return(-1);  /* No entry */
+     return(false);  /* No entry */
 }
 
 /* Free the table */
@@ -1035,12 +1035,27 @@
     unsigned char *pbuf, *buf;
     clist_icctable_t *icc_table = cldev->icc_table;
     int number_entries = icc_table->tablesize;
-    int k;
     clist_icctable_entry_t *curr_entry;
     int size_data;
+    int k;
 
-    /* First serialize the data */
+    /* First we need to write out the ICC profiles themselves and update
+       in the table where they will be stored and their size. */
 
+    curr_entry = icc_table->head;
+
+    for ( k = 0; k < number_entries; k++ ){
+    
+        curr_entry->serial_data.file_position = clist_icc_addprofile(cldev, curr_entry->icc_profile, &size_data);
+        curr_entry->serial_data.size = size_data;
+        rc_decrement(curr_entry->icc_profile, "clist_icc_writetable");
+        curr_entry->icc_profile = NULL;
+        curr_entry = curr_entry->next;
+
+    }
+
+    /* Now serialize the table data */
+
     size_data = number_entries*sizeof(clist_icc_serial_entry_t) + sizeof(number_entries);
 
     buf = gs_alloc_bytes(cldev->memory, size_data, "clist_icc_writetable");
@@ -1063,7 +1078,7 @@
 
     }
 
-    /* Now go ahead and put it out */
+    /* Now go ahead and save the table data */
 
     cmd_write_icctable(cldev, buf, size_data);
 
@@ -1109,7 +1124,7 @@
 /* This add a new entry into the table */
 
 int
-clist_icc_addentry(gx_device_clist_writer *cdev, int64_t hashcode, int64_t position, int size)
+clist_icc_addentry(gx_device_clist_writer *cdev, int64_t hashcode, cmm_profile_t *icc_profile)
 {
 
     clist_icctable_entry_t *entry = gs_alloc_struct(cdev->memory, 
@@ -1120,8 +1135,10 @@
 
     entry->next = NULL;
     entry->serial_data.hashcode = hashcode;
-    entry->serial_data.size = size;
-    entry->serial_data.file_position = position;
+    entry->serial_data.size = -1;
+    entry->serial_data.file_position = -1;
+    entry->icc_profile = icc_profile;
+    rc_increment(icc_profile);
 
     if (entry == NULL) 
         return gs_rethrow(-1, "insufficient memory to allocate entry in icc table");

Modified: branches/icc_work/base/gxclist.h
===================================================================
--- branches/icc_work/base/gxclist.h	2009-10-30 23:34:05 UTC (rev 10248)
+++ branches/icc_work/base/gxclist.h	2009-10-30 23:37:49 UTC (rev 10249)
@@ -244,14 +244,15 @@
 struct clist_icctable_entry_s {
 
     clist_icc_serial_entry_t serial_data;
-    clist_icctable_entry_t *next;  /* The next entry in the table */   
+    clist_icctable_entry_t *next;  /* The next entry in the table */ 
+    cmm_profile_t *icc_profile;    /* The profile.  This is written out at the end of the writer phase */
 
 };
 
 #define private_st_clist_icctable_entry()\
-  gs_private_st_ptrs1(st_clist_icctable_entry,\
+  gs_private_st_ptrs2(st_clist_icctable_entry,\
 		clist_icctable_entry_t, "clist_icctable_entry",\
-		clist_icctable_entry_enum_ptrs, clist_icctable_entry_reloc_ptrs, next)
+		clist_icctable_entry_enum_ptrs, clist_icctable_entry_reloc_ptrs, next, icc_profile)
 
 typedef struct clist_icctable_s clist_icctable_t;
 
@@ -508,10 +509,11 @@
 int64_t clist_icc_addprofile(gx_device_clist_writer *cdev, cmm_profile_t *iccprofile, int *iccsize);
 
 /* Seach the table to see if we already have a profile in the cfile */
-int64_t clist_icc_searchtable(gx_device_clist_writer *cdev, int64_t hashcode);
+bool clist_icc_searchtable(gx_device_clist_writer *cdev, int64_t hashcode);
 
 /* Add another entry into the icc profile table */
-int clist_icc_addentry(gx_device_clist_writer *cdev, int64_t hashcode, int64_t position, int size);
+int clist_icc_addentry(gx_device_clist_writer *cdev, int64_t hashcode, 
+                       cmm_profile_t *icc_profile);
 
 /* Free the table and its entries */
 int clist_icc_freetable(clist_icctable_t *icc_table, gs_memory_t *memory);



More information about the gs-cvs mailing list