From 2bdc0425df6d014a9f64549da4f7c2a4aa6b82b3 Mon Sep 17 00:00:00 2001 From: DRC Date: Fri, 7 Mar 2014 03:52:57 +0000 Subject: [PATCH] Go ahead and call jinit_master_decompress() rather than trying to reproduce its functionality. That function does a few things that we were missing, including allocating the range limit table used by the plain C color conversion code. git-svn-id: svn+ssh://svn.code.sf.net/p/libjpeg-turbo/code/trunk@1139 632fc199-4ca6-4c93-a231-07263d6284db --- turbojpeg.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/turbojpeg.c b/turbojpeg.c index ec85eb5..edcf882 100644 --- a/turbojpeg.c +++ b/turbojpeg.c @@ -1255,16 +1255,15 @@ static int setDecodeDefaults(struct jpeg_decompress_struct *dinfo, (*dinfo->mem->alloc_small)((j_common_ptr)dinfo, JPOOL_IMAGE, dinfo->num_components*SIZEOF(jpeg_component_info)); - dinfo->comp_info[0].h_samp_factor=tjMCUWidth[subsamp]/8; - dinfo->comp_info[0].v_samp_factor=tjMCUHeight[subsamp]/8; - dinfo->comp_info[0].component_index=0; - dinfo->cur_comp_info[0]=&dinfo->comp_info[0]; - for(i=1; inum_components; i++) + for(i=0; inum_components; i++) { - dinfo->comp_info[i].h_samp_factor=1; - dinfo->comp_info[i].v_samp_factor=1; - dinfo->comp_info[i].component_index=i; - dinfo->cur_comp_info[i]=&dinfo->comp_info[i]; + jpeg_component_info *compptr=&dinfo->comp_info[i]; + compptr->h_samp_factor=(i==0)? tjMCUWidth[subsamp]/8:1; + compptr->v_samp_factor=(i==0)? tjMCUHeight[subsamp]/8:1; + compptr->component_index=i; + compptr->quant_tbl_no=compptr->dc_tbl_no=compptr->ac_tbl_no= + (i==0)? 0:1; + dinfo->cur_comp_info[i]=compptr; } return 0; @@ -1358,21 +1357,14 @@ DLLEXPORT int DLLCALL tjDecodeYUV(tjhandle handle, unsigned char *srcBuf, { retval=-1; goto bailout; } - jpeg_calc_output_dimensions(dinfo); if(flags&TJFLAG_FASTUPSAMPLE) { dinfo->do_fancy_upsampling=FALSE; if((subsamp==TJSAMP_422 || subsamp==TJSAMP_420) && pixelFormat!=TJPF_GRAY) useMerged=1; } - if(useMerged) - jinit_merged_upsampler(dinfo); - else - { - jinit_color_deconverter(dinfo); - jinit_upsampler(dinfo); - (*dinfo->cconvert->start_pass)(dinfo); - } + jinit_master_decompress(dinfo); + if(!useMerged) (*dinfo->cconvert->start_pass)(dinfo); (*dinfo->upsample->start_pass)(dinfo); pw=PAD(width, dinfo->max_h_samp_factor); -- 2.40.0