aboutsummaryrefslogtreecommitdiff
path: root/src/jpeg.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/jpeg.c')
-rw-r--r--src/jpeg.c25
1 files changed, 13 insertions, 12 deletions
diff --git a/src/jpeg.c b/src/jpeg.c
index 9e548a7c..db30c13f 100644
--- a/src/jpeg.c
+++ b/src/jpeg.c
@@ -84,7 +84,6 @@ typedef struct DilloJpeg {
static DilloJpeg *Jpeg_new(DilloImage *Image, DilloUrl *url, int version);
static void Jpeg_callback(int Op, CacheClient_t *Client);
static void Jpeg_write(DilloJpeg *jpeg, void *Buf, uint_t BufSize);
-static void Jpeg_close(DilloJpeg *jpeg, CacheClient_t *Client);
METHODDEF(void) Jpeg_errorexit (j_common_ptr cinfo);
/* exported function */
@@ -103,7 +102,8 @@ METHODDEF(void) Jpeg_errorexit (j_common_ptr cinfo)
/*
* MIME handler for "image/jpeg" type
- * (Sets Jpeg_callback or a_Dicache_callback as the cache-client)
+ * Sets a_Dicache_callback as the cache-client,
+ * and Jpeg_callback as the image decoder.
*/
void *a_Jpeg_image(const char *Type, void *P, CA_Callback_t *Call,
void **Data)
@@ -117,20 +117,20 @@ void *a_Jpeg_image(const char *Type, void *P, CA_Callback_t *Call,
/* Add an extra reference to the Image (for dicache usage) */
a_Image_ref(web->Image);
- DicEntry = a_Dicache_get_entry(web->url);
+ DicEntry = a_Dicache_get_entry(web->url, DIC_Last);
if (!DicEntry) {
/* Let's create an entry for this image... */
DicEntry = a_Dicache_add_entry(web->url);
-
- /* ... and let the decoder feed it! */
- *Data = Jpeg_new(web->Image, DicEntry->url, DicEntry->version);
- *Call = (CA_Callback_t) Jpeg_callback;
+ DicEntry->DecoderData =
+ Jpeg_new(web->Image, DicEntry->url, DicEntry->version);
} else {
- /* Let's feed our client from the dicache */
+ /* Repeated image */
a_Dicache_ref(DicEntry->url, DicEntry->version);
- *Data = web->Image;
- *Call = (CA_Callback_t) a_Dicache_callback;
}
+ DicEntry->Decoder = Jpeg_callback;
+ *Data = DicEntry->DecoderData;
+ *Call = (CA_Callback_t) a_Dicache_callback;
+
return (web->Image->dw);
}
@@ -139,6 +139,7 @@ void *a_Jpeg_image(const char *Type, void *P, CA_Callback_t *Call,
*/
static void Jpeg_close(DilloJpeg *jpeg, CacheClient_t *Client)
{
+ _MSG("Jpeg_close\n");
a_Dicache_close(jpeg->url, jpeg->version, Client);
jpeg_destroy_decompress(&(jpeg->cinfo));
dFree(jpeg);
@@ -330,7 +331,7 @@ static void Jpeg_write(DilloJpeg *jpeg, void *Buf, uint_t BufSize)
if (jpeg->state == DILLO_JPEG_READ_BEGIN_SCAN) {
if (jpeg_start_output(&jpeg->cinfo, jpeg->cinfo.input_scan_number)) {
- a_Dicache_new_scan(jpeg->Image, jpeg->url, jpeg->version);
+ a_Dicache_new_scan(jpeg->url, jpeg->version);
jpeg->state = DILLO_JPEG_READ_IN_SCAN;
}
}
@@ -389,7 +390,7 @@ static void Jpeg_write(DilloJpeg *jpeg, void *Buf, uint_t BufSize)
/* out of input */
break;
}
- a_Dicache_new_scan(jpeg->Image, jpeg->url, jpeg->version);
+ a_Dicache_new_scan(jpeg->url, jpeg->version);
jpeg->state = DILLO_JPEG_READ_IN_SCAN;
}
}