27#define WIN32_NO_STATUS
45 cinfo->err->format_message(cinfo,
message);
48 longjmp(*(
jmp_buf*)cinfo->client_data, 1);
55 if (msg_level < 0 &&
ERR_ON(jpeg))
57 cinfo->err->format_message(cinfo,
message);
60 else if (msg_level == 0 &&
WARN_ON(jpeg))
62 cinfo->err->format_message(cinfo,
message);
65 else if (msg_level > 0 &&
TRACE_ON(jpeg))
67 cinfo->err->format_message(cinfo,
message);
122 This->source_mgr.next_input_byte =
This->source_buffer;
123 This->source_mgr.bytes_in_buffer = bytesread;
132 if (num_bytes >
This->source_mgr.bytes_in_buffer)
135 This->source_mgr.bytes_in_buffer = 0;
137 else if (num_bytes > 0)
139 This->source_mgr.next_input_byte += num_bytes;
140 This->source_mgr.bytes_in_buffer -= num_bytes;
155 if (
This->cinfo_initialized)
178 This->source_mgr.bytes_in_buffer = 0;
185 This->cinfo.src = &
This->source_mgr;
190 WARN(
"Jpeg image in stream has bad format, read header returned %d.\n",
ret);
194 switch (
This->cinfo.jpeg_color_space)
199 This->frame.pixel_format = GUID_WICPixelFormat8bppGray;
204 This->frame.bpp = 24;
205 This->frame.pixel_format = GUID_WICPixelFormat24bppBGR;
210 This->frame.bpp = 32;
211 This->frame.pixel_format = GUID_WICPixelFormat32bppCMYK;
214 ERR(
"Unknown JPEG color space %i\n",
This->cinfo.jpeg_color_space);
218 if (!jpeg_start_decompress(&
This->cinfo))
220 ERR(
"jpeg_start_decompress failed\n");
224 This->frame.width =
This->cinfo.output_width;
225 This->frame.height =
This->cinfo.output_height;
227 switch (
This->cinfo.density_unit)
230 This->frame.dpix =
This->cinfo.X_density * 2.54;
231 This->frame.dpiy =
This->cinfo.Y_density * 2.54;
235 This->frame.dpix =
This->cinfo.X_density;
236 This->frame.dpiy =
This->cinfo.Y_density;
241 This->frame.dpix =
This->frame.dpiy = 96.0;
245 This->frame.num_color_contexts = 0;
246 This->frame.num_colors = 0;
248 This->stride = (
This->frame.bpp *
This->cinfo.output_width + 7) / 8;
249 data_size =
This->stride *
This->cinfo.output_height;
251 if (data_size /
This->stride <
This->cinfo.output_height)
256 if (!
This->image_data)
259 while (
This->cinfo.output_scanline <
This->cinfo.output_height)
261 UINT first_scanline =
This->cinfo.output_scanline;
266 max_rows =
min(
This->cinfo.output_height-first_scanline, 4);
267 for (
i=0;
i<max_rows;
i++)
268 out_rows[
i] =
This->image_data +
This->stride * (first_scanline+
i);
273 ERR(
"read_scanlines failed\n");
278 if (
This->frame.bpp == 24)
282 This->cinfo.output_width,
This->cinfo.output_height,
286 if (
This->cinfo.out_color_space ==
JCS_CMYK &&
This->cinfo.saw_Adobe_marker)
289 for (
i=0;
i<data_size;
i++)
290 This->image_data[
i] ^= 0xff;
356 info->container_format = GUID_ContainerFormatJpeg;
357 info->block_format = GUID_ContainerFormatJpeg;
358 info->clsid = CLSID_WICJpegDecoder;
372 { &GUID_WICPixelFormat24bppBGR, 24, 3,
JCS_RGB, 1 },
373 { &GUID_WICPixelFormat32bppCMYK, 32, 4,
JCS_CMYK },
405 This->dest_mgr.next_output_byte =
This->dest_buffer;
406 This->dest_mgr.free_in_buffer =
sizeof(
This->dest_buffer);
416 sizeof(
This->dest_buffer), &byteswritten);
418 if (
hr !=
S_OK || byteswritten == 0)
420 ERR(
"Failed writing data, hr=%lx\n",
hr);
424 This->dest_mgr.next_output_byte =
This->dest_buffer;
425 This->dest_mgr.free_in_buffer =
sizeof(
This->dest_buffer);
435 if (
This->dest_mgr.free_in_buffer !=
sizeof(
This->dest_buffer))
438 sizeof(
This->dest_buffer) -
This->dest_mgr.free_in_buffer, &byteswritten);
440 if (
hr !=
S_OK || byteswritten == 0)
441 ERR(
"Failed writing data, hr=%lx\n",
hr);
466 This->dest_mgr.next_output_byte =
This->dest_buffer;
467 This->dest_mgr.free_in_buffer =
sizeof(
This->dest_buffer);
506 This->encoder_frame = *frame;
522 This->cinfo.input_components =
This->format->num_components;
523 This->cinfo.in_color_space =
This->format->color_space;
527 if (frame->
dpix != 0.0 && frame->
dpiy != 0.0)
529 This->cinfo.density_unit = 1;
530 This->cinfo.X_density = frame->
dpix;
531 This->cinfo.Y_density = frame->
dpiy;
544 BYTE *swapped_data =
NULL, *current_row;
556 row_size =
This->format->bpp / 8 *
This->encoder_frame.width;
558 if (
This->format->swap_rgb)
560 swapped_data =
malloc(row_size);
567 if (
This->format->swap_rgb)
573 for (
x=0;
x <
This->encoder_frame.width;
x++)
577 b = swapped_data[
x*3];
578 swapped_data[
x*3] = swapped_data[
x*3+2];
579 swapped_data[
x*3+2] =
b;
582 current_row = swapped_data;
589 ERR(
"failed writing scanlines\n");
623 if (
This->cinfo_initialized)
651 info->container_format = GUID_ContainerFormatJpeg;
652 info->clsid = CLSID_WICJpegEncoder;
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
void copy_pixels(const BYTE *src, UINT src_row_pitch, UINT src_slice_pitch, BYTE *dst, UINT dst_row_pitch, UINT dst_slice_pitch, const struct volume *size, const struct pixel_format_desc *format) DECLSPEC_HIDDEN
#define WINE_DECLARE_DEBUG_CHANNEL(x)
GLint GLint GLint GLint GLint x
GLuint GLuint GLsizei count
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
GLboolean GLboolean GLboolean b
GLsizei GLenum const GLvoid GLsizei GLenum GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLint GLint GLint GLshort GLshort GLshort GLubyte GLubyte GLubyte GLuint GLuint GLuint GLushort GLushort GLushort GLbyte GLbyte GLbyte GLbyte GLdouble GLdouble GLdouble GLdouble GLfloat GLfloat GLfloat GLfloat GLint GLint GLint GLint GLshort GLshort GLshort GLshort GLubyte GLubyte GLubyte GLubyte GLuint GLuint GLuint GLuint GLushort GLushort GLushort GLushort GLboolean const GLdouble const GLfloat const GLint const GLshort const GLbyte const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLdouble const GLfloat const GLfloat const GLint const GLint const GLshort const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort const GLdouble const GLfloat const GLint const GLshort GLenum GLenum GLenum GLfloat GLenum GLint GLenum GLenum GLenum GLfloat GLenum GLenum GLint GLenum GLfloat GLenum GLint GLint GLushort GLenum GLenum GLfloat GLenum GLenum GLint GLfloat const GLubyte GLenum GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLint GLint GLsizei GLsizei GLint GLenum GLenum const GLvoid GLenum GLenum const GLfloat GLenum GLenum const GLint GLenum GLenum const GLdouble GLenum GLenum const GLfloat GLenum GLenum const GLint GLsizei GLuint GLfloat GLuint GLbitfield GLfloat GLint GLuint GLboolean GLenum GLfloat GLenum GLbitfield GLenum GLfloat GLfloat GLint GLint const GLfloat GLenum GLfloat GLfloat GLint GLint GLfloat GLfloat GLint GLint const GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat GLint GLfloat GLfloat const GLdouble const GLfloat const GLdouble const GLfloat GLint i
jpeg_destroy_compress(j_compress_ptr cinfo)
jpeg_finish_compress(j_compress_ptr cinfo)
jpeg_CreateCompress(j_compress_ptr cinfo, int version, size_t structsize)
jpeg_write_scanlines(j_compress_ptr cinfo, JSAMPARRAY scanlines, JDIMENSION num_lines)
jpeg_start_compress(j_compress_ptr cinfo, boolean write_all_tables)
jpeg_set_defaults(j_compress_ptr cinfo)
jpeg_CreateDecompress(j_decompress_ptr cinfo, int version, size_t structsize)
jpeg_destroy_decompress(j_decompress_ptr cinfo)
jpeg_read_header(j_decompress_ptr cinfo, boolean require_image)
jpeg_read_scanlines(j_decompress_ptr cinfo, JSAMPARRAY scanlines, JDIMENSION max_lines)
jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired)
jpeg_std_error(struct jpeg_error_mgr *err)
static HRESULT CDECL jpeg_encoder_write_lines(struct encoder *iface, BYTE *data, DWORD line_count, DWORD stride)
static HRESULT CDECL jpeg_encoder_initialize(struct encoder *iface, IStream *stream)
static HRESULT CDECL jpeg_encoder_commit_frame(struct encoder *iface)
static HRESULT CDECL jpeg_decoder_copy_pixels(struct decoder *iface, UINT frame, const WICRect *prc, UINT stride, UINT buffersize, BYTE *buffer)
static HRESULT CDECL jpeg_encoder_create_frame(struct encoder *iface, const struct encoder_frame *frame)
static const struct encoder_funcs jpeg_encoder_vtable
static void source_mgr_term_source(j_decompress_ptr cinfo)
static boolean source_mgr_fill_input_buffer(j_decompress_ptr cinfo)
static struct jpeg_encoder * encoder_from_compress(j_compress_ptr compress)
static void emit_message_fn(j_common_ptr cinfo, int msg_level)
static HRESULT CDECL jpeg_decoder_get_frame_info(struct decoder *iface, UINT frame, struct decoder_frame *info)
static void error_exit_fn(j_common_ptr cinfo)
static void CDECL jpeg_encoder_destroy(struct encoder *iface)
static struct jpeg_encoder * impl_from_encoder(struct encoder *iface)
static void source_mgr_skip_input_data(j_decompress_ptr cinfo, long num_bytes)
static const jpeg_compress_format compress_formats[]
static HRESULT CDECL jpeg_decoder_initialize(struct decoder *iface, IStream *stream, struct decoder_stat *st)
static struct jpeg_decoder * impl_from_decoder(struct decoder *iface)
static void source_mgr_init_source(j_decompress_ptr cinfo)
static HRESULT CDECL jpeg_encoder_commit_file(struct encoder *iface)
static HRESULT CDECL jpeg_decoder_get_metadata_blocks(struct decoder *iface, UINT frame, UINT *count, struct decoder_block **blocks)
static HRESULT CDECL jpeg_encoder_get_supported_format(struct encoder *iface, GUID *pixel_format, DWORD *bpp, BOOL *indexed)
static boolean dest_mgr_empty_output_buffer(j_compress_ptr cinfo)
static void dest_mgr_term_destination(j_compress_ptr cinfo)
static void CDECL jpeg_decoder_destroy(struct decoder *iface)
HRESULT CDECL jpeg_decoder_create(struct decoder_info *info, struct decoder **result)
static const struct decoder_funcs jpeg_decoder_vtable
static struct jpeg_decoder * decoder_from_decompress(j_decompress_ptr decompress)
HRESULT CDECL jpeg_encoder_create(struct encoder_info *info, struct encoder **result)
static void dest_mgr_init_destination(j_compress_ptr cinfo)
static HRESULT CDECL jpeg_decoder_get_color_context(struct decoder *This, UINT frame, UINT num, BYTE **data, DWORD *datasize)
#define memcpy(s1, s2, n)
int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
struct jpeg_error_mgr jerr
struct jpeg_decompress_struct cinfo
struct jpeg_source_mgr source_mgr
struct decoder_frame frame
struct jpeg_destination_mgr dest_mgr
struct jpeg_compress_struct cinfo
struct jpeg_error_mgr jerr
const jpeg_compress_format * format
#define CONTAINING_RECORD(address, type, field)
@ WICBitmapDecoderCapabilityCanDecodeSomeImages
@ WICBitmapDecoderCapabilityCanEnumerateMetadata
@ WICBitmapDecoderCapabilityCanDecodeAllImages
HRESULT CDECL stream_write(IStream *stream, const void *buffer, ULONG write, ULONG *bytes_written)
HRESULT CDECL stream_seek(IStream *stream, LONGLONG ofs, DWORD origin, ULONGLONG *new_position)
void reverse_bgr8(UINT bytesperpixel, LPBYTE bits, UINT width, UINT height, INT stride)
#define DECODER_FLAGS_UNSUPPORTED_COLOR_CONTEXT
#define ENCODER_FLAGS_SUPPORTS_METADATA
@ ENCODER_OPTION_CHROMINANCE
@ ENCODER_OPTION_YCRCB_SUBSAMPLING
@ ENCODER_OPTION_IMAGE_QUALITY
@ ENCODER_OPTION_LUMINANCE
@ ENCODER_OPTION_SUPPRESS_APP0
@ ENCODER_OPTION_BITMAP_TRANSFORM
#define WINCODEC_ERR_WRONGSTATE