mirror of
https://github.com/webmproject/libwebp.git
synced 2024-11-19 20:08:28 +01:00
Cleanup around jpegdec
* change some (*func_ptr) construct to func_ptr simply. * remove one memcpy * group #include related to decoding together Change-Id: If751cfbd9e78be75c57fb60fc9c937900c2c8fe0
This commit is contained in:
parent
9145567982
commit
1bd287a6e4
@ -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