jpeg_idct_islow_intellib( j_decompress_ptr cinfo, jpeg_component_info* compptr, JCOEFPTR coef_block, JSAMPARRAY output_buf, JDIMENSION output_col) { int ctr; JCOEFPTR inptr; Ipp16u* quantptr; Ipp8u* wsptr; Ipp8u workspace[DCTSIZE2]; JSAMPROW outptr; inptr = coef_block; quantptr = (Ipp16u*)compptr->dct_table; wsptr = workspace; ippiDCTQuantInv8x8LS_JPEG_16s8u_C1R(inptr,workspace,8,quantptr); for(ctr = 0; ctr < DCTSIZE; ctr++) { outptr = output_buf[ctr] + output_col; outptr[0] = wsptr[0]; outptr[1] = wsptr[1]; outptr[2] = wsptr[2]; outptr[3] = wsptr[3]; outptr[4] = wsptr[4]; outptr[5] = wsptr[5]; outptr[6] = wsptr[6]; outptr[7] = wsptr[7]; wsptr += DCTSIZE; /* advance pointer to next row */ } return; } /* jpeg_idct_islow_intellib() */
int jpeg_decompress_8u_rgb_IPP (const uint8_t * src, int src_size, uint8_t * dest, int width, int height, int stride) { struct jpeg_decompress_struct cinfo; struct jpeg_error_mgr jerr; struct jpeg_source_mgr jsrc; cinfo.err = jpeg_std_error (&jerr); jpeg_create_decompress (&cinfo); jsrc.next_input_byte = src; jsrc.bytes_in_buffer = src_size; jsrc.init_source = init_source; jsrc.fill_input_buffer = fill_input_buffer; jsrc.skip_input_data = skip_input_data; jsrc.resync_to_restart = jpeg_resync_to_restart; jsrc.term_source = term_source; cinfo.src = &jsrc; jpeg_read_header (&cinfo, TRUE); cinfo.out_color_space = JCS_RGB; jpeg_calc_output_dimensions (&cinfo); if (cinfo.output_height < height || cinfo.output_width < width) { fprintf (stderr, "Error: Buffer is %dx%d but JPEG image is %dx%d\n", width, height, cinfo.output_width, cinfo.output_height); jpeg_destroy_decompress (&cinfo); return -1; } jvirt_barray_ptr * dct_planes = jpeg_read_coefficients (&cinfo); uint8_t * tmp_plane = NULL; uint8_t * full_plane[cinfo.num_components]; int full_stride; int tmp_stride; int max_h_samp=1, max_v_samp=1; int c, i, j; jpeg_component_info * c0 = cinfo.cur_comp_info[0]; for (c = 0; c < cinfo.num_components; c++) { full_plane[c] = ippiMalloc_8u_C1 (c0->width_in_blocks*8, c0->height_in_blocks*8, &full_stride); jpeg_component_info * comp = cinfo.cur_comp_info[c]; if (comp->h_samp_factor > max_h_samp) max_h_samp = comp->h_samp_factor; if (comp->v_samp_factor > max_v_samp) max_v_samp = comp->v_samp_factor; } for (c = 0; c < cinfo.num_components; c++) { jpeg_component_info * comp = cinfo.cur_comp_info[c]; uint8_t * plane; int pstride, offset; int h_samp = max_h_samp / comp->h_samp_factor; int v_samp = max_v_samp / comp->v_samp_factor; if (h_samp == 2 && v_samp == 2) { if (!tmp_plane) tmp_plane = ippiMalloc_8u_C1 (comp->width_in_blocks*8 + 16, comp->height_in_blocks*8 + 2, &tmp_stride); plane = tmp_plane; pstride = tmp_stride; offset = tmp_stride + 8; } else if (h_samp == 1 && v_samp == 1) { plane = full_plane[c]; pstride = full_stride; offset = 0; } for (i = 0; i < comp->height_in_blocks; i++) { JBLOCKARRAY bar = cinfo.mem->access_virt_barray ( (j_common_ptr) &cinfo, dct_planes[c], i, 1, FALSE); JBLOCKROW row = bar[0]; uint8_t * drow = plane + 8*i*pstride + offset; for (j = 0; j < comp->width_in_blocks; j++) { JBLOCK * blk = row + j; ippiDCTQuantInv8x8LS_JPEG_16s8u_C1R (*blk, drow + j*8, pstride, cinfo.quant_tbl_ptrs[comp->quant_tbl_no]->quantval); } } if (h_samp == 2 && v_samp == 2) { IppiSize srcroi = { 8*comp->width_in_blocks, 8*comp->height_in_blocks }; IppiSize dstroi = { 8*comp->width_in_blocks + 2, 8*comp->height_in_blocks + 2 }; ippiCopyReplicateBorder_8u_C1IR (tmp_plane + tmp_stride + 8, tmp_stride, srcroi, dstroi, 1, 1); dstroi.width = width; dstroi.height = height; ippiSampleUpH2V2_JPEG_8u_C1R (tmp_plane + tmp_stride + 8, tmp_stride, srcroi, full_plane[c], full_stride, dstroi); } } IppiSize dstroi = { width, height }; ippiYCbCrToRGB_JPEG_8u_P3C3R ((const uint8_t **)full_plane, full_stride, dest, stride, dstroi); for (c = 0; c < cinfo.num_components; c++) ippiFree (full_plane[c]); if (tmp_plane) ippiFree (tmp_plane); jpeg_finish_decompress (&cinfo); jpeg_destroy_decompress (&cinfo); return 0; }