summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2005-05-18 22:36:07 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2005-05-18 22:36:07 (GMT)
commit412e0da9ab53163072fdf88919d650e42767cd65 (patch)
tree66e4d60806da2cd6e6758b20797404491e74e75e
parent290eed30711dd83edcf881f4d7053dfa6c971f3d (diff)
download5kk53-412e0da9ab53163072fdf88919d650e42767cd65.zip
5kk53-412e0da9ab53163072fdf88919d650e42767cd65.tar.gz
5kk53-412e0da9ab53163072fdf88919d650e42767cd65.tar.bz2
added init stuff, more research needed on what we need.
-rw-r--r--src/c_huffman.c64
1 files changed, 64 insertions, 0 deletions
diff --git a/src/c_huffman.c b/src/c_huffman.c
index acfcc92..22dda6e 100644
--- a/src/c_huffman.c
+++ b/src/c_huffman.c
@@ -20,6 +20,29 @@ typedef struct {
int last_dc_val[MAX_COMPS_IN_SCAN]; /* last DC coef for each component */
} savable_state;
+
+typedef struct {
+ struct jpeg_entropy_encoder pub; /* public fields */
+
+ savable_state saved; /* Bit buffer & DC state at start of MCU */
+
+ /* These fields are NOT loaded into local working state. */
+ unsigned int restarts_to_go; /* MCUs left in this restart interval */
+ int next_restart_num; /* next restart number to write (0-7) */
+
+ /* Pointers to derived tables (these workspaces have image lifespan) */
+ c_derived_tbl * dc_derived_tbls[NUM_HUFF_TBLS];
+ c_derived_tbl * ac_derived_tbls[NUM_HUFF_TBLS];
+
+#ifdef ENTROPY_OPT_SUPPORTED /* Statistics tables for optimization */
+ long * dc_count_ptrs[NUM_HUFF_TBLS];
+ long * ac_count_ptrs[NUM_HUFF_TBLS];
+#endif
+} huff_entropy_encoder;
+
+typedef huff_entropy_encoder * huff_entropy_ptr;
+
+
/* Working state while writing an MCU.
* This struct contains all the fields that are needed by subroutines.
*/
@@ -101,6 +124,25 @@ inline static boolean emit_bits(working_state * state, unsigned int code, int si
return TRUE;
}
+/*
+ * Initialize for a Huffman-compressed scan.
+ */
+
+void start_pass_huff (j_compress_ptr cinfo) {
+ huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy;
+
+ entropy->pub.encode_mcu = encode_mcu_huff;
+ entropy->pub.finish_pass = finish_pass_huff;
+
+ /* Initialize bit buffer to empty */
+ entropy->saved.put_buffer = 0;
+ entropy->saved.put_bits = 0;
+
+ /* Initialize restart stuff */
+ entropy->restarts_to_go = cinfo->restart_interval;
+ entropy->next_restart_num = 0;
+}
+
int encode_one_block(working_state *state, JCOEFPTR block, int last_dc_val, c_derived_tbl *dctbl, c_derived_tbl *actbl) {
register int temp, temp2;
@@ -205,3 +247,25 @@ int encode_one_block(working_state *state, JCOEFPTR block, int last_dc_val, c_de
}
return TRUE;
}
+
+/*
+ * Module initialization routine for Huffman entropy encoding.
+ */
+
+void jinit_huff_encoder(j_compress_ptr cinfo) {
+ huff_entropy_ptr entropy;
+ int i;
+
+ entropy = (huff_entropy_ptr) malloc((size_t) sizeof(huff_entropy_encoder));
+
+ cinfo->entropy = (struct jpeg_entropy_encoder *) entropy;
+ entropy->pub.start_pass = start_pass_huff;
+
+ /* Mark tables unallocated */
+ for (i = 0; i < NUM_HUFF_TBLS; i++) {
+ entropy->dc_derived_tbls[i] = entropy->ac_derived_tbls[i] = NULL;
+#ifdef ENTROPY_OPT_SUPPORTED
+ entropy->dc_count_ptrs[i] = entropy->ac_count_ptrs[i] = NULL;
+#endif
+ }
+}