NetSurf
|
implementation of content handling for image/jpeg More...
#include <stdbool.h>
#include <stdlib.h>
#include <setjmp.h>
#include "utils/utils.h"
#include "utils/log.h"
#include "utils/messages.h"
#include "netsurf/bitmap.h"
#include "content/llcache.h"
#include "content/content.h"
#include "content/content_protected.h"
#include "content/content_factory.h"
#include "desktop/gui_internal.h"
#include "desktop/bitmap.h"
#include "image/image_cache.h"
#include "jpeglib.h"
#include "jpeg.h"
Go to the source code of this file.
Macros | |
#define | JPEG_INTERNAL_OPTIONS |
#define | MIN_JPEG_SIZE 20 |
absolute minimum size of a jpeg below which it is not even worth trying to read header data More... | |
#define | DIV255(x) ((x) + 1 + ((x) >> 8)) >> 8 |
Functions | |
static nserror | nsjpeg_create (const content_handler *handler, lwc_string *imime_type, const struct http_parameter *params, llcache_handle *llcache, const char *fallback_charset, bool quirks, struct content **c) |
Content create entry point. More... | |
static void | nsjpeg_init_source (j_decompress_ptr cinfo) |
JPEG data source manager: initialize source. More... | |
static boolean | nsjpeg_fill_input_buffer (j_decompress_ptr cinfo) |
JPEG data source manager: fill the input buffer. More... | |
static void | nsjpeg_skip_input_data (j_decompress_ptr cinfo, long num_bytes) |
JPEG data source manager: skip num_bytes worth of data. More... | |
static void | nsjpeg_term_source (j_decompress_ptr cinfo) |
JPEG data source manager: terminate source. More... | |
static void | nsjpeg_error_log (j_common_ptr cinfo) |
Error output handler for JPEG library. More... | |
static void | nsjpeg_error_exit (j_common_ptr cinfo) |
Fatal error handler for JPEG library. More... | |
static void | nsjpeg__decode_cmyk (struct jpeg_decompress_struct *cinfo, uint8_t *volatile pixels, size_t rowstride) |
Convert scan lines from CMYK to core client bitmap layout. More... | |
static void | nsjpeg__decode_rgb (struct jpeg_decompress_struct *cinfo, uint8_t *volatile pixels, size_t rowstride) |
Convert scan lines from CMYK to core client bitmap layout. More... | |
static void | nsjpeg__decode_client_fmt (struct jpeg_decompress_struct *cinfo, uint8_t *volatile pixels, size_t rowstride) |
Convert scan lines from CMYK to core client bitmap layout. More... | |
static struct bitmap * | jpeg_cache_convert (struct content *c) |
create a bitmap from jpeg content. More... | |
static bool | nsjpeg_convert (struct content *c) |
Convert a CONTENT_JPEG for display. More... | |
static nserror | nsjpeg_clone (const struct content *old, struct content **newc) |
Clone content. More... | |
CONTENT_FACTORY_REGISTER_TYPES (nsjpeg, nsjpeg_types, nsjpeg_content_handler) | |
Variables | |
static char | nsjpeg_error_buffer [JMSG_LENGTH_MAX] |
static unsigned char | nsjpeg_eoi [] = { 0xff, JPEG_EOI } |
static const content_handler | nsjpeg_content_handler |
static const char * | nsjpeg_types [] |
implementation of content handling for image/jpeg
This implementation uses the IJG JPEG library.
Definition in file jpeg.c.
#define DIV255 | ( | x | ) | ((x) + 1 + ((x) >> 8)) >> 8 |
#define MIN_JPEG_SIZE 20 |
CONTENT_FACTORY_REGISTER_TYPES | ( | nsjpeg | , |
nsjpeg_types | , | ||
nsjpeg_content_handler | |||
) |
create a bitmap from jpeg content.
Definition at line 257 of file jpeg.c.
References netsurf_table::bitmap, bitmap(), BITMAP_LAYOUT_A8B8G8R8, BITMAP_LAYOUT_A8R8G8B8, BITMAP_LAYOUT_B8G8R8A8, BITMAP_LAYOUT_R8G8B8A8, BITMAP_OPAQUE, content__get_source_data(), gui_bitmap_table::create, gui_bitmap_table::destroy, gui_bitmap_table::get_buffer, gui_bitmap_table::get_rowstride, guit, bitmap_fmt::layout, MIN_JPEG_SIZE, gui_bitmap_table::modified, nsjpeg__decode_client_fmt(), nsjpeg__decode_cmyk(), nsjpeg__decode_rgb(), nsjpeg_error_exit(), nsjpeg_error_log(), nsjpeg_fill_input_buffer(), nsjpeg_init_source(), nsjpeg_skip_input_data(), nsjpeg_term_source(), NSLOG, and bitmap::rowstride.
Referenced by nsjpeg_convert().
|
inlinestatic |
Convert scan lines from CMYK to core client bitmap layout.
Definition at line 239 of file jpeg.c.
Referenced by jpeg_cache_convert().
|
inlinestatic |
Convert scan lines from CMYK to core client bitmap layout.
Definition at line 166 of file jpeg.c.
Referenced by jpeg_cache_convert().
|
inlinestatic |
Convert scan lines from CMYK to core client bitmap layout.
Definition at line 204 of file jpeg.c.
References width.
Referenced by jpeg_cache_convert().
Clone content.
Definition at line 456 of file jpeg.c.
References content__clone(), content_destroy(), CONTENT_STATUS_DONE, CONTENT_STATUS_READY, NSERROR_CLONE_FAILED, NSERROR_NOMEM, NSERROR_OK, nsjpeg_convert(), and content::status.
|
static |
Convert a CONTENT_JPEG for display.
Definition at line 386 of file jpeg.c.
References content__get_source_data(), content__set_title(), content_broadcast(), CONTENT_MSG_ERROR, content_set_done(), content_set_ready(), content_set_status(), content_msg_data::errorcode, content_msg_data::errordata, content_msg_data::errormsg, content::height, image_cache_add(), jpeg_cache_convert(), content::llcache, llcache_handle_get_url(), messages_get_buff(), NSERROR_UNKNOWN, nsjpeg_error_buffer, nsjpeg_error_exit(), nsjpeg_error_log(), nsjpeg_fill_input_buffer(), nsjpeg_init_source(), nsjpeg_skip_input_data(), nsjpeg_term_source(), nsurl_access_leaf(), content::size, content_msg_data::title, and content::width.
Referenced by nsjpeg_clone().
|
static |
Content create entry point.
Definition at line 64 of file jpeg.c.
References content__init(), content::fallback_charset, content::handler, llcache, NSERROR_NOMEM, NSERROR_OK, and content::quirks.
|
static |
Fatal error handler for JPEG library.
This prevents jpeglib calling exit() on a fatal error.
Definition at line 153 of file jpeg.c.
References nsjpeg_error_buffer, and NSLOG.
Referenced by jpeg_cache_convert(), and nsjpeg_convert().
|
static |
Error output handler for JPEG library.
This logs to NetSurf log instead of stderr. Warnings only - fatal errors are trapped by nsjpeg_error_exit and do not call the output handler.
Definition at line 141 of file jpeg.c.
References nsjpeg_error_buffer, and NSLOG.
Referenced by jpeg_cache_convert(), and nsjpeg_convert().
|
static |
JPEG data source manager: fill the input buffer.
This can only occur if the JPEG data was truncated or corrupted. Insert a fake EOI marker to allow the decompressor to output as much as possible.
Definition at line 102 of file jpeg.c.
References nsjpeg_eoi.
Referenced by jpeg_cache_convert(), and nsjpeg_convert().
|
static |
JPEG data source manager: initialize source.
Definition at line 91 of file jpeg.c.
Referenced by jpeg_cache_convert(), and nsjpeg_convert().
|
static |
JPEG data source manager: skip num_bytes worth of data.
Definition at line 114 of file jpeg.c.
Referenced by jpeg_cache_convert(), and nsjpeg_convert().
|
static |
JPEG data source manager: terminate source.
Definition at line 129 of file jpeg.c.
Referenced by jpeg_cache_convert(), and nsjpeg_convert().
|
static |
|
static |
Definition at line 59 of file jpeg.c.
Referenced by nsjpeg_fill_input_buffer().
|
static |
Definition at line 57 of file jpeg.c.
Referenced by nsjpeg_convert(), nsjpeg_error_exit(), and nsjpeg_error_log().