ReactOS 0.4.16-dev-981-g80eb313
libjpeg.c
Go to the documentation of this file.
1/*
2 * Copyright 2009 Vincent Povirk for CodeWeavers
3 *
4 * This library is free software; you can redistribute it and/or
5 * modify it under the terms of the GNU Lesser General Public
6 * License as published by the Free Software Foundation; either
7 * version 2.1 of the License, or (at your option) any later version.
8 *
9 * This library is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 * Lesser General Public License for more details.
13 *
14 * You should have received a copy of the GNU Lesser General Public
15 * License along with this library; if not, write to the Free Software
16 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
17 */
18
19#include <stdarg.h>
20#include <stdio.h>
21#include <string.h>
22#include <setjmp.h>
23#include <basetsd.h>
24#include <jpeglib.h>
25
26#include "ntstatus.h"
27#define WIN32_NO_STATUS
28#include "windef.h"
29#include "winternl.h"
30#include "winbase.h"
31#include "objbase.h"
32
33#include "wincodecs_private.h"
34
35#include "wine/debug.h"
36
39
40static void error_exit_fn(j_common_ptr cinfo)
41{
43 if (ERR_ON(jpeg))
44 {
45 cinfo->err->format_message(cinfo, message);
46 ERR_(jpeg)("%s\n", message);
47 }
48 longjmp(*(jmp_buf*)cinfo->client_data, 1);
49}
50
51static void emit_message_fn(j_common_ptr cinfo, int msg_level)
52{
54
55 if (msg_level < 0 && ERR_ON(jpeg))
56 {
57 cinfo->err->format_message(cinfo, message);
58 ERR_(jpeg)("%s\n", message);
59 }
60 else if (msg_level == 0 && WARN_ON(jpeg))
61 {
62 cinfo->err->format_message(cinfo, message);
63 WARN_(jpeg)("%s\n", message);
64 }
65 else if (msg_level > 0 && TRACE_ON(jpeg))
66 {
67 cinfo->err->format_message(cinfo, message);
68 TRACE_(jpeg)("%s\n", message);
69 }
70}
71
83};
84
85static inline struct jpeg_decoder *impl_from_decoder(struct decoder* iface)
86{
87 return CONTAINING_RECORD(iface, struct jpeg_decoder, decoder);
88}
89
90static inline struct jpeg_decoder *decoder_from_decompress(j_decompress_ptr decompress)
91{
92 return CONTAINING_RECORD(decompress, struct jpeg_decoder, cinfo);
93}
94
95static void CDECL jpeg_decoder_destroy(struct decoder* iface)
96{
97 struct jpeg_decoder *This = impl_from_decoder(iface);
98
99 if (This->cinfo_initialized) jpeg_destroy_decompress(&This->cinfo);
100 free(This->image_data);
101 free(This);
102}
103
105{
106}
107
109{
111 HRESULT hr;
112 ULONG bytesread;
113
114 hr = stream_read(This->stream, This->source_buffer, 1024, &bytesread);
115
116 if (FAILED(hr) || bytesread == 0)
117 {
118 return FALSE;
119 }
120 else
121 {
122 This->source_mgr.next_input_byte = This->source_buffer;
123 This->source_mgr.bytes_in_buffer = bytesread;
124 return TRUE;
125 }
126}
127
129{
131
132 if (num_bytes > This->source_mgr.bytes_in_buffer)
133 {
134 stream_seek(This->stream, num_bytes - This->source_mgr.bytes_in_buffer, STREAM_SEEK_CUR, NULL);
135 This->source_mgr.bytes_in_buffer = 0;
136 }
137 else if (num_bytes > 0)
138 {
139 This->source_mgr.next_input_byte += num_bytes;
140 This->source_mgr.bytes_in_buffer -= num_bytes;
141 }
142}
143
145{
146}
147
149{
150 struct jpeg_decoder *This = impl_from_decoder(iface);
151 int ret;
153 UINT data_size, i;
154
155 if (This->cinfo_initialized)
157
158 jpeg_std_error(&This->jerr);
159
160 This->jerr.error_exit = error_exit_fn;
161 This->jerr.emit_message = emit_message_fn;
162
163 This->cinfo.err = &This->jerr;
164
165 This->cinfo.client_data = jmpbuf;
166
167 if (setjmp(jmpbuf))
168 return E_FAIL;
169
171
172 This->cinfo_initialized = TRUE;
173
174 This->stream = stream;
175
176 stream_seek(This->stream, 0, STREAM_SEEK_SET, NULL);
177
178 This->source_mgr.bytes_in_buffer = 0;
179 This->source_mgr.init_source = source_mgr_init_source;
180 This->source_mgr.fill_input_buffer = source_mgr_fill_input_buffer;
181 This->source_mgr.skip_input_data = source_mgr_skip_input_data;
182 This->source_mgr.resync_to_restart = jpeg_resync_to_restart;
183 This->source_mgr.term_source = source_mgr_term_source;
184
185 This->cinfo.src = &This->source_mgr;
186
187 ret = jpeg_read_header(&This->cinfo, TRUE);
188
189 if (ret != JPEG_HEADER_OK) {
190 WARN("Jpeg image in stream has bad format, read header returned %d.\n",ret);
191 return E_FAIL;
192 }
193
194 switch (This->cinfo.jpeg_color_space)
195 {
196 case JCS_GRAYSCALE:
197 This->cinfo.out_color_space = JCS_GRAYSCALE;
198 This->frame.bpp = 8;
199 This->frame.pixel_format = GUID_WICPixelFormat8bppGray;
200 break;
201 case JCS_RGB:
202 case JCS_YCbCr:
203 This->cinfo.out_color_space = JCS_RGB;
204 This->frame.bpp = 24;
205 This->frame.pixel_format = GUID_WICPixelFormat24bppBGR;
206 break;
207 case JCS_CMYK:
208 case JCS_YCCK:
209 This->cinfo.out_color_space = JCS_CMYK;
210 This->frame.bpp = 32;
211 This->frame.pixel_format = GUID_WICPixelFormat32bppCMYK;
212 break;
213 default:
214 ERR("Unknown JPEG color space %i\n", This->cinfo.jpeg_color_space);
215 return E_FAIL;
216 }
217
218 if (!jpeg_start_decompress(&This->cinfo))
219 {
220 ERR("jpeg_start_decompress failed\n");
221 return E_FAIL;
222 }
223
224 This->frame.width = This->cinfo.output_width;
225 This->frame.height = This->cinfo.output_height;
226
227 switch (This->cinfo.density_unit)
228 {
229 case 2: /* pixels per centimeter */
230 This->frame.dpix = This->cinfo.X_density * 2.54;
231 This->frame.dpiy = This->cinfo.Y_density * 2.54;
232 break;
233
234 case 1: /* pixels per inch */
235 This->frame.dpix = This->cinfo.X_density;
236 This->frame.dpiy = This->cinfo.Y_density;
237 break;
238
239 case 0: /* unknown */
240 default:
241 This->frame.dpix = This->frame.dpiy = 96.0;
242 break;
243 }
244
245 This->frame.num_color_contexts = 0;
246 This->frame.num_colors = 0;
247
248 This->stride = (This->frame.bpp * This->cinfo.output_width + 7) / 8;
249 data_size = This->stride * This->cinfo.output_height;
250
251 if (data_size / This->stride < This->cinfo.output_height)
252 /* overflow in multiplication */
253 return E_OUTOFMEMORY;
254
255 This->image_data = malloc(data_size);
256 if (!This->image_data)
257 return E_OUTOFMEMORY;
258
259 while (This->cinfo.output_scanline < This->cinfo.output_height)
260 {
261 UINT first_scanline = This->cinfo.output_scanline;
262 UINT max_rows;
263 JSAMPROW out_rows[4];
265
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);
269
270 ret = jpeg_read_scanlines(&This->cinfo, out_rows, max_rows);
271 if (ret == 0)
272 {
273 ERR("read_scanlines failed\n");
274 return E_FAIL;
275 }
276 }
277
278 if (This->frame.bpp == 24)
279 {
280 /* libjpeg gives us RGB data and we want BGR, so byteswap the data */
281 reverse_bgr8(3, This->image_data,
282 This->cinfo.output_width, This->cinfo.output_height,
283 This->stride);
284 }
285
286 if (This->cinfo.out_color_space == JCS_CMYK && This->cinfo.saw_Adobe_marker)
287 {
288 /* Adobe JPEG's have inverted CMYK data. */
289 for (i=0; i<data_size; i++)
290 This->image_data[i] ^= 0xff;
291 }
292
293 st->frame_count = 1;
298 return S_OK;
299}
300
302{
303 struct jpeg_decoder *This = impl_from_decoder(iface);
304 *info = This->frame;
305 return S_OK;
306}
307
309 const WICRect *prc, UINT stride, UINT buffersize, BYTE *buffer)
310{
311 struct jpeg_decoder *This = impl_from_decoder(iface);
312 return copy_pixels(This->frame.bpp, This->image_data,
313 This->frame.width, This->frame.height, This->stride,
314 prc, stride, buffersize, buffer);
315}
316
318 UINT *count, struct decoder_block **blocks)
319{
320 FIXME("stub\n");
321 *count = 0;
322 *blocks = NULL;
323 return S_OK;
324}
325
328{
329 /* This should never be called because we report 0 color contexts and the unsupported flag. */
330 FIXME("stub\n");
331 return E_NOTIMPL;
332}
333
334static const struct decoder_funcs jpeg_decoder_vtable = {
341};
342
344{
345 struct jpeg_decoder *This;
346
347 This = malloc(sizeof(struct jpeg_decoder));
348 if (!This) return E_OUTOFMEMORY;
349
350 This->decoder.vtable = &jpeg_decoder_vtable;
351 This->cinfo_initialized = FALSE;
352 This->stream = NULL;
353 This->image_data = NULL;
354 *result = &This->decoder;
355
356 info->container_format = GUID_ContainerFormatJpeg;
357 info->block_format = GUID_ContainerFormatJpeg;
358 info->clsid = CLSID_WICJpegDecoder;
359
360 return S_OK;
361}
362
363typedef struct jpeg_compress_format {
365 int bpp;
370
372 { &GUID_WICPixelFormat24bppBGR, 24, 3, JCS_RGB, 1 },
373 { &GUID_WICPixelFormat32bppCMYK, 32, 4, JCS_CMYK },
374 { &GUID_WICPixelFormat8bppGray, 8, 1, JCS_GRAYSCALE },
375 { 0 }
376};
377
379{
389};
390
391static inline struct jpeg_encoder *impl_from_encoder(struct encoder* iface)
392{
393 return CONTAINING_RECORD(iface, struct jpeg_encoder, encoder);
394}
395
397{
399}
400
402{
404
405 This->dest_mgr.next_output_byte = This->dest_buffer;
406 This->dest_mgr.free_in_buffer = sizeof(This->dest_buffer);
407}
408
410{
412 HRESULT hr;
413 ULONG byteswritten;
414
415 hr = stream_write(This->stream, This->dest_buffer,
416 sizeof(This->dest_buffer), &byteswritten);
417
418 if (hr != S_OK || byteswritten == 0)
419 {
420 ERR("Failed writing data, hr=%lx\n", hr);
421 return FALSE;
422 }
423
424 This->dest_mgr.next_output_byte = This->dest_buffer;
425 This->dest_mgr.free_in_buffer = sizeof(This->dest_buffer);
426 return TRUE;
427}
428
430{
432 ULONG byteswritten;
433 HRESULT hr;
434
435 if (This->dest_mgr.free_in_buffer != sizeof(This->dest_buffer))
436 {
437 hr = stream_write(This->stream, This->dest_buffer,
438 sizeof(This->dest_buffer) - This->dest_mgr.free_in_buffer, &byteswritten);
439
440 if (hr != S_OK || byteswritten == 0)
441 ERR("Failed writing data, hr=%lx\n", hr);
442 }
443}
444
446{
447 struct jpeg_encoder *This = impl_from_encoder(iface);
449
450 jpeg_std_error(&This->jerr);
451
452 This->jerr.error_exit = error_exit_fn;
453 This->jerr.emit_message = emit_message_fn;
454
455 This->cinfo.err = &This->jerr;
456
457 This->cinfo.client_data = jmpbuf;
458
459 if (setjmp(jmpbuf))
460 return E_FAIL;
461
463
464 This->stream = stream;
465
466 This->dest_mgr.next_output_byte = This->dest_buffer;
467 This->dest_mgr.free_in_buffer = sizeof(This->dest_buffer);
468
469 This->dest_mgr.init_destination = dest_mgr_init_destination;
470 This->dest_mgr.empty_output_buffer = dest_mgr_empty_output_buffer;
471 This->dest_mgr.term_destination = dest_mgr_term_destination;
472
473 This->cinfo.dest = &This->dest_mgr;
474
475 This->cinfo_initialized = TRUE;
476
477 return S_OK;
478}
479
481 DWORD *bpp, BOOL *indexed)
482{
483 int i;
484
485 for (i=0; compress_formats[i].guid; i++)
486 {
487 if (memcmp(compress_formats[i].guid, pixel_format, sizeof(GUID)) == 0)
488 break;
489 }
490
491 if (!compress_formats[i].guid) i = 0;
492
495 *indexed = FALSE;
496
497 return S_OK;
498}
499
500static HRESULT CDECL jpeg_encoder_create_frame(struct encoder* iface, const struct encoder_frame *frame)
501{
502 struct jpeg_encoder *This = impl_from_encoder(iface);
504 int i;
505
506 This->encoder_frame = *frame;
507
508 if (setjmp(jmpbuf))
509 return E_FAIL;
510
511 This->cinfo.client_data = jmpbuf;
512
513 for (i=0; compress_formats[i].guid; i++)
514 {
515 if (memcmp(compress_formats[i].guid, &frame->pixel_format, sizeof(GUID)) == 0)
516 break;
517 }
518 This->format = &compress_formats[i];
519
520 This->cinfo.image_width = frame->width;
521 This->cinfo.image_height = frame->height;
522 This->cinfo.input_components = This->format->num_components;
523 This->cinfo.in_color_space = This->format->color_space;
524
525 jpeg_set_defaults(&This->cinfo);
526
527 if (frame->dpix != 0.0 && frame->dpiy != 0.0)
528 {
529 This->cinfo.density_unit = 1; /* dots per inch */
530 This->cinfo.X_density = frame->dpix;
531 This->cinfo.Y_density = frame->dpiy;
532 }
533
534 jpeg_start_compress(&This->cinfo, TRUE);
535
536 return S_OK;
537}
538
540 DWORD line_count, DWORD stride)
541{
542 struct jpeg_encoder *This = impl_from_encoder(iface);
544 BYTE *swapped_data = NULL, *current_row;
545 UINT line;
546 int row_size;
547
548 if (setjmp(jmpbuf))
549 {
550 free(swapped_data);
551 return E_FAIL;
552 }
553
554 This->cinfo.client_data = jmpbuf;
555
556 row_size = This->format->bpp / 8 * This->encoder_frame.width;
557
558 if (This->format->swap_rgb)
559 {
560 swapped_data = malloc(row_size);
561 if (!swapped_data)
562 return E_OUTOFMEMORY;
563 }
564
565 for (line=0; line < line_count; line++)
566 {
567 if (This->format->swap_rgb)
568 {
569 UINT x;
570
571 memcpy(swapped_data, data + (stride * line), row_size);
572
573 for (x=0; x < This->encoder_frame.width; x++)
574 {
575 BYTE b;
576
577 b = swapped_data[x*3];
578 swapped_data[x*3] = swapped_data[x*3+2];
579 swapped_data[x*3+2] = b;
580 }
581
582 current_row = swapped_data;
583 }
584 else
585 current_row = data + (stride * line);
586
587 if (!jpeg_write_scanlines(&This->cinfo, &current_row, 1))
588 {
589 ERR("failed writing scanlines\n");
590 free(swapped_data);
591 return E_FAIL;
592 }
593 }
594
595 free(swapped_data);
596
597 return S_OK;
598}
599
601{
602 struct jpeg_encoder *This = impl_from_encoder(iface);
604
605 if (setjmp(jmpbuf))
606 return E_FAIL;
607
608 This->cinfo.client_data = jmpbuf;
609
610 jpeg_finish_compress(&This->cinfo);
611
612 return S_OK;
613}
614
616{
617 return S_OK;
618}
619
620static void CDECL jpeg_encoder_destroy(struct encoder* iface)
621{
622 struct jpeg_encoder *This = impl_from_encoder(iface);
623 if (This->cinfo_initialized)
625 free(This);
626};
627
628static const struct encoder_funcs jpeg_encoder_vtable = {
636};
637
639{
640 struct jpeg_encoder *This;
641
642 This = malloc(sizeof(struct jpeg_encoder));
643 if (!This) return E_OUTOFMEMORY;
644
645 This->encoder.vtable = &jpeg_encoder_vtable;
646 This->stream = NULL;
647 This->cinfo_initialized = FALSE;
648 *result = &This->encoder;
649
651 info->container_format = GUID_ContainerFormatJpeg;
652 info->clsid = CLSID_WICJpegEncoder;
653 info->encoder_options[0] = ENCODER_OPTION_IMAGE_QUALITY;
654 info->encoder_options[1] = ENCODER_OPTION_BITMAP_TRANSFORM;
655 info->encoder_options[2] = ENCODER_OPTION_LUMINANCE;
656 info->encoder_options[3] = ENCODER_OPTION_CHROMINANCE;
657 info->encoder_options[4] = ENCODER_OPTION_YCRCB_SUBSAMPLING;
658 info->encoder_options[5] = ENCODER_OPTION_SUPPRESS_APP0;
659 info->encoder_options[6] = ENCODER_OPTION_END;
660
661 return S_OK;
662}
static jmp_buf jmpbuf
Definition: NtContinue.c:24
int memcmp(void *Buffer1, void *Buffer2, ACPI_SIZE Count)
Definition: utclib.c:112
#define WINE_DEFAULT_DEBUG_CHANNEL(t)
Definition: precomp.h:23
#define FIXME(fmt,...)
Definition: precomp.h:53
#define WARN(fmt,...)
Definition: precomp.h:61
#define ERR(fmt,...)
Definition: precomp.h:57
static SIZE_T datasize
Definition: asm.c:30
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
Definition: surface.c:1700
#define E_OUTOFMEMORY
Definition: ddrawi.h:100
#define E_NOTIMPL
Definition: ddrawi.h:99
#define E_FAIL
Definition: ddrawi.h:102
#define free
Definition: debug_ros.c:5
#define malloc
Definition: debug_ros.c:4
#define NULL
Definition: types.h:112
#define TRUE
Definition: types.h:120
#define FALSE
Definition: types.h:117
DWORD bpp
Definition: surface.c:185
#define CDECL
Definition: compat.h:29
#define TRACE_(x)
Definition: compat.h:76
#define TRACE_ON(x)
Definition: compat.h:75
#define WINE_DECLARE_DEBUG_CHANNEL(x)
Definition: compat.h:45
unsigned int BOOL
Definition: ntddk_ex.h:94
unsigned long DWORD
Definition: ntddk_ex.h:95
GLint GLint GLint GLint GLint x
Definition: gl.h:1548
GLuint GLuint GLsizei count
Definition: gl.h:1545
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
GLsizei stride
Definition: glext.h:5848
GLuint buffer
Definition: glext.h:5915
GLboolean GLboolean GLboolean b
Definition: glext.h:6204
GLuint64EXT * result
Definition: glext.h:11304
GLuint GLuint num
Definition: glext.h:9618
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
Definition: glfuncs.h:248
#define S_OK
Definition: intsafe.h:52
#define FAILED(hr)
Definition: intsafe.h:51
jpeg_destroy_compress(j_compress_ptr cinfo)
Definition: jcapimin.c:96
jpeg_finish_compress(j_compress_ptr cinfo)
Definition: jcapimin.c:155
jpeg_CreateCompress(j_compress_ptr cinfo, int version, size_t structsize)
Definition: jcapimin.c:31
jpeg_write_scanlines(j_compress_ptr cinfo, JSAMPARRAY scanlines, JDIMENSION num_lines)
Definition: jcapistd.c:78
jpeg_start_compress(j_compress_ptr cinfo, boolean write_all_tables)
Definition: jcapistd.c:39
jpeg_set_defaults(j_compress_ptr cinfo)
Definition: jcparam.c:196
jpeg_CreateDecompress(j_decompress_ptr cinfo, int version, size_t structsize)
Definition: jdapimin.c:31
jpeg_destroy_decompress(j_decompress_ptr cinfo)
Definition: jdapimin.c:92
jpeg_read_header(j_decompress_ptr cinfo, boolean require_image)
Definition: jdapimin.c:245
jpeg_read_scanlines(j_decompress_ptr cinfo, JSAMPARRAY scanlines, JDIMENSION max_lines)
Definition: jdapistd.c:153
jpeg_resync_to_restart(j_decompress_ptr cinfo, int desired)
Definition: jdmarker.c:1338
jpeg_std_error(struct jpeg_error_mgr *err)
Definition: jerror.c:232
unsigned int JDIMENSION
Definition: jmorecfg.h:229
J_COLOR_SPACE
Definition: jpeglib.h:220
@ JCS_YCCK
Definition: jpeglib.h:226
@ JCS_YCbCr
Definition: jpeglib.h:224
@ JCS_CMYK
Definition: jpeglib.h:225
@ JCS_GRAYSCALE
Definition: jpeglib.h:222
@ JCS_RGB
Definition: jpeglib.h:223
#define JPEG_LIB_VERSION
Definition: jpeglib.h:40
JSAMPLE FAR * JSAMPROW
Definition: jpeglib.h:75
#define JPEG_HEADER_OK
Definition: jpeglib.h:1046
#define JMSG_LENGTH_MAX
Definition: jpeglib.h:711
#define b
Definition: ke_i.h:79
static HRESULT CDECL jpeg_encoder_write_lines(struct encoder *iface, BYTE *data, DWORD line_count, DWORD stride)
Definition: libjpeg.c:539
static HRESULT CDECL jpeg_encoder_initialize(struct encoder *iface, IStream *stream)
Definition: libjpeg.c:445
static HRESULT CDECL jpeg_encoder_commit_frame(struct encoder *iface)
Definition: libjpeg.c:600
static HRESULT CDECL jpeg_decoder_copy_pixels(struct decoder *iface, UINT frame, const WICRect *prc, UINT stride, UINT buffersize, BYTE *buffer)
Definition: libjpeg.c:308
static HRESULT CDECL jpeg_encoder_create_frame(struct encoder *iface, const struct encoder_frame *frame)
Definition: libjpeg.c:500
static const struct encoder_funcs jpeg_encoder_vtable
Definition: libjpeg.c:628
static void source_mgr_term_source(j_decompress_ptr cinfo)
Definition: libjpeg.c:144
static boolean source_mgr_fill_input_buffer(j_decompress_ptr cinfo)
Definition: libjpeg.c:108
static struct jpeg_encoder * encoder_from_compress(j_compress_ptr compress)
Definition: libjpeg.c:396
static void emit_message_fn(j_common_ptr cinfo, int msg_level)
Definition: libjpeg.c:51
static HRESULT CDECL jpeg_decoder_get_frame_info(struct decoder *iface, UINT frame, struct decoder_frame *info)
Definition: libjpeg.c:301
static void error_exit_fn(j_common_ptr cinfo)
Definition: libjpeg.c:40
static void CDECL jpeg_encoder_destroy(struct encoder *iface)
Definition: libjpeg.c:620
static struct jpeg_encoder * impl_from_encoder(struct encoder *iface)
Definition: libjpeg.c:391
static void source_mgr_skip_input_data(j_decompress_ptr cinfo, long num_bytes)
Definition: libjpeg.c:128
static const jpeg_compress_format compress_formats[]
Definition: libjpeg.c:371
static HRESULT CDECL jpeg_decoder_initialize(struct decoder *iface, IStream *stream, struct decoder_stat *st)
Definition: libjpeg.c:148
static struct jpeg_decoder * impl_from_decoder(struct decoder *iface)
Definition: libjpeg.c:85
static void source_mgr_init_source(j_decompress_ptr cinfo)
Definition: libjpeg.c:104
static HRESULT CDECL jpeg_encoder_commit_file(struct encoder *iface)
Definition: libjpeg.c:615
static HRESULT CDECL jpeg_decoder_get_metadata_blocks(struct decoder *iface, UINT frame, UINT *count, struct decoder_block **blocks)
Definition: libjpeg.c:317
static HRESULT CDECL jpeg_encoder_get_supported_format(struct encoder *iface, GUID *pixel_format, DWORD *bpp, BOOL *indexed)
Definition: libjpeg.c:480
static boolean dest_mgr_empty_output_buffer(j_compress_ptr cinfo)
Definition: libjpeg.c:409
static void dest_mgr_term_destination(j_compress_ptr cinfo)
Definition: libjpeg.c:429
static void CDECL jpeg_decoder_destroy(struct decoder *iface)
Definition: libjpeg.c:95
HRESULT CDECL jpeg_decoder_create(struct decoder_info *info, struct decoder **result)
Definition: libjpeg.c:343
static const struct decoder_funcs jpeg_decoder_vtable
Definition: libjpeg.c:334
static struct jpeg_decoder * decoder_from_decompress(j_decompress_ptr decompress)
Definition: libjpeg.c:90
HRESULT CDECL jpeg_encoder_create(struct encoder_info *info, struct encoder **result)
Definition: libjpeg.c:638
static void dest_mgr_init_destination(j_compress_ptr cinfo)
Definition: libjpeg.c:401
static HRESULT CDECL jpeg_decoder_get_color_context(struct decoder *This, UINT frame, UINT num, BYTE **data, DWORD *datasize)
Definition: libjpeg.c:326
const GUID * guid
static int blocks
Definition: mkdosfs.c:527
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define WARN_ON(c)
Definition: module.h:257
static int stream_read
Definition: htmldoc.c:205
#define min(a, b)
Definition: monoChain.cc:55
unsigned int UINT
Definition: ndis.h:50
_Out_ LPRECT prc
Definition: ntgdi.h:1658
#define ERR_(ch,...)
Definition: debug.h:156
#define WARN_(ch,...)
Definition: debug.h:157
#define ERR_ON(ch)
Definition: debug.h:412
int ZEXPORT compress(Bytef *dest, uLongf *destLen, const Bytef *source, uLong sourceLen)
Definition: compress.c:68
HRESULT hr
Definition: shlfolder.c:183
J_COLOR_SPACE color_space
Definition: libjpeg.c:367
const WICPixelFormatGUID * guid
Definition: libjpeg.c:364
struct jpeg_error_mgr jerr
Definition: libjpeg.c:78
UINT stride
Definition: libjpeg.c:81
struct jpeg_decompress_struct cinfo
Definition: libjpeg.c:77
struct jpeg_source_mgr source_mgr
Definition: libjpeg.c:79
struct decoder_frame frame
Definition: libjpeg.c:74
BOOL cinfo_initialized
Definition: libjpeg.c:75
BYTE source_buffer[1024]
Definition: libjpeg.c:80
IStream * stream
Definition: libjpeg.c:76
BYTE * image_data
Definition: libjpeg.c:82
BOOL cinfo_initialized
Definition: libjpeg.c:382
struct jpeg_destination_mgr dest_mgr
Definition: libjpeg.c:385
struct jpeg_compress_struct cinfo
Definition: libjpeg.c:383
BYTE dest_buffer[1024]
Definition: libjpeg.c:388
struct jpeg_error_mgr jerr
Definition: libjpeg.c:384
IStream * stream
Definition: libjpeg.c:381
const jpeg_compress_format * format
Definition: libjpeg.c:387
Definition: parser.c:49
Definition: tftpd.h:60
Definition: parse.h:23
#define CONTAINING_RECORD(address, type, field)
Definition: typedefs.h:260
uint32_t ULONG
Definition: typedefs.h:59
#define setjmp
Definition: setjmp.h:209
_JBTYPE jmp_buf[_JBLEN]
Definition: setjmp.h:186
int ret
@ WICBitmapDecoderCapabilityCanDecodeSomeImages
Definition: wincodec.idl:51
@ WICBitmapDecoderCapabilityCanEnumerateMetadata
Definition: wincodec.idl:52
@ WICBitmapDecoderCapabilityCanDecodeAllImages
Definition: wincodec.idl:50
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_END
@ ENCODER_OPTION_LUMINANCE
@ ENCODER_OPTION_SUPPRESS_APP0
@ ENCODER_OPTION_BITMAP_TRANSFORM
#define WINCODEC_ERR_WRONGSTATE
Definition: winerror.h:3281
unsigned char BYTE
Definition: xxhash.c:193