mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-27 22:28:22 +01:00
Merge "Cleanup around jpegdec"
This commit is contained in:
commit
df7aa07605
@ -33,11 +33,14 @@
|
||||
|
||||
|
||||
#include "webp/encode.h"
|
||||
#include "./jpegdec.h"
|
||||
|
||||
#include "./metadata.h"
|
||||
#include "./pngdec.h"
|
||||
#include "./stopwatch.h"
|
||||
|
||||
#include "./jpegdec.h"
|
||||
#include "./pngdec.h"
|
||||
#include "./tiffdec.h"
|
||||
|
||||
#ifndef WEBP_DLL
|
||||
#if defined(__cplusplus) || defined(c_plusplus)
|
||||
extern "C" {
|
||||
|
@ -30,18 +30,17 @@ struct my_error_mgr {
|
||||
|
||||
static void my_error_exit(j_common_ptr dinfo) {
|
||||
struct my_error_mgr* myerr = (struct my_error_mgr*)dinfo->err;
|
||||
(*dinfo->err->output_message)(dinfo);
|
||||
dinfo->err->output_message(dinfo);
|
||||
longjmp(myerr->setjmp_buffer, 1);
|
||||
}
|
||||
|
||||
int ReadJPEG(FILE* in_file, WebPPicture* const pic) {
|
||||
int ok = 0;
|
||||
int stride, width, height;
|
||||
uint8_t* rgb = NULL;
|
||||
uint8_t* row_ptr = NULL;
|
||||
struct jpeg_decompress_struct dinfo;
|
||||
struct my_error_mgr jerr;
|
||||
JSAMPARRAY buffer;
|
||||
uint8_t* rgb = NULL;
|
||||
JSAMPROW buffer[1];
|
||||
|
||||
dinfo.err = jpeg_std_error(&jerr.pub);
|
||||
jerr.pub.error_exit = my_error_exit;
|
||||
@ -74,20 +73,13 @@ int ReadJPEG(FILE* in_file, WebPPicture* const pic) {
|
||||
if (rgb == NULL) {
|
||||
goto End;
|
||||
}
|
||||
row_ptr = rgb;
|
||||
|
||||
buffer = (*dinfo.mem->alloc_sarray)((j_common_ptr)&dinfo,
|
||||
JPOOL_IMAGE, stride, 1);
|
||||
if (buffer == NULL) {
|
||||
goto End;
|
||||
}
|
||||
buffer[0] = (JSAMPLE*)rgb;
|
||||
|
||||
while (dinfo.output_scanline < dinfo.output_height) {
|
||||
if (jpeg_read_scanlines(&dinfo, buffer, 1) != 1) {
|
||||
goto End;
|
||||
}
|
||||
memcpy(row_ptr, buffer[0], stride);
|
||||
row_ptr += stride;
|
||||
buffer[0] += stride;
|
||||
}
|
||||
|
||||
jpeg_finish_decompress(&dinfo);
|
||||
|
Loading…
Reference in New Issue
Block a user