summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOliver Schinagl <oliver@schinagl.nl>2005-06-09 13:44:35 (GMT)
committerOliver Schinagl <oliver@schinagl.nl>2005-06-09 13:44:35 (GMT)
commit9f50142960b7d77dd1d8a3bb1b228b3b69770dc3 (patch)
treecef6961923547c32d92d7d304ab5de106b0e4981
parent27cb66aecf2e121c6f77f8c7d7176dca278f30f2 (diff)
download5kk53-9f50142960b7d77dd1d8a3bb1b228b3b69770dc3.zip
5kk53-9f50142960b7d77dd1d8a3bb1b228b3b69770dc3.tar.gz
5kk53-9f50142960b7d77dd1d8a3bb1b228b3b69770dc3.tar.bz2
Added one function to write file
-rw-r--r--src/c_marker.c47
1 files changed, 10 insertions, 37 deletions
diff --git a/src/c_marker.c b/src/c_marker.c
index c6e1837..20d828b 100644
--- a/src/c_marker.c
+++ b/src/c_marker.c
@@ -14,34 +14,6 @@
#include "morecfg.h"
#include "jpeglib.h"
-/*
- * jpeg_natural_order[i] is the natural-order position of the i'th element
- * of zigzag order.
- *
- * When reading corrupted data, the Huffman decoders could attempt
- * to reference an entry beyond the end of this array (if the decoded
- * zero run length reaches past the end of the block). To prevent
- * wild stores without adding an inner-loop test, we put some extra
- * "63"s after the real entries. This will cause the extra coefficient
- * to be stored in location 63 of the block, not somewhere random.
- * The worst case would be a run-length of 15, which means we need 16
- * fake entries.
- */
-
-const int jpeg_natural_order[DCTSIZE2+16] = {
- 0, 1, 8, 16, 9, 2, 3, 10,
- 17, 24, 32, 25, 18, 11, 4, 5,
- 12, 19, 26, 33, 40, 48, 41, 34,
- 27, 20, 13, 6, 7, 14, 21, 28,
- 35, 42, 49, 56, 57, 50, 43, 36,
- 29, 22, 15, 23, 30, 37, 44, 51,
- 58, 59, 52, 45, 38, 31, 39, 46,
- 53, 60, 61, 54, 47, 55, 62, 63,
- 63, 63, 63, 63, 63, 63, 63, 63, /* extra entries for safety in decoder */
- 63, 63, 63, 63, 63, 63, 63, 63
-};
-
-
typedef enum { /* JPEG marker codes */
M_SOF0 = 0xc0,
M_SOF1 = 0xc1,
@@ -207,6 +179,7 @@ int emit_dqt (my_destination_mgr *destination, int index)
{
/* Quantization table is externally globally defined */
extern JQUANT_TBL qtbl;
+ extern const int jpeg_natural_order[];
int prec;
int i;
@@ -230,7 +203,7 @@ int emit_dqt (my_destination_mgr *destination, int index)
for (i = 0; i < DCTSIZE2; i++) {
/* The table entries must be emitted in zigzag order. */
- unsigned int qval = qtbl.quantval[i];
+ unsigned int qval = qtbl.quantval[jpeg_natural_order[i]];
if (prec) {
emit_byte(destination, (int) (qval >> 8));
@@ -670,12 +643,11 @@ void jinit_marker_writer (j_compress_ptr cinfo) {
}
#endif
-int main(void) {
- int retval;
+#endif
+void write_jpeg_file(JOCTET *entropy_data, int nsymbols) {
my_destination_mgr destination;
size_t datacount;
-
- retval = 0;
+ int symbol_index;
/* Initialize destination structure */
destination.pub.next_output_byte = destination.buffer;
@@ -688,6 +660,10 @@ int main(void) {
write_frame_header(&destination, 640, 480);
write_scan_header(&destination);
/* write image here */
+ for (symbol_index = nsymbols ;symbol_index < nsymbols; symbol_index++) {
+ emit_byte(&destination, entropy_data[symbol_index]);
+ }
+ /*
emit_byte(&destination, 0xa6);
emit_byte(&destination, 0x17);
emit_byte(&destination, 0x11);
@@ -700,7 +676,7 @@ int main(void) {
emit_byte(&destination, 0xe4);
emit_byte(&destination, 0xce);
emit_byte(&destination, 0x6b);
-
+*/
/* finish up */
write_file_trailer(&destination);
@@ -718,7 +694,4 @@ int main(void) {
exit(1);
}
fclose(destination.outfile);
-
- return retval;
}
-#endif