decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) { phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; int Al = cinfo->Al; register int s, r; int blkn, ci; JBLOCKROW block; BITREAD_STATE_VARS; savable_state state; d_derived_tbl * tbl; jpeg_component_info * compptr; /* Process restart marker if needed; may have to suspend */ if (cinfo->restart_interval) { if (entropy->restarts_to_go == 0) if (! process_restart(cinfo)) return FALSE; } /* Load up working state */ BITREAD_LOAD_STATE(cinfo,entropy->bitstate); ASSIGN_STATE(state, entropy->saved); /* Outer loop handles each block in the MCU */ for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { block = MCU_data[blkn]; ci = cinfo->MCU_membership[blkn]; compptr = cinfo->cur_comp_info[ci]; tbl = entropy->derived_tbls[compptr->dc_tbl_no]; /* Decode a single block's worth of coefficients */ /* Section F.2.2.1: decode the DC coefficient difference */ HUFF_DECODE(s, br_state, tbl, return FALSE, label1); if (s) { CHECK_BIT_BUFFER(br_state, s, return FALSE); r = GET_BITS(s); s = HUFF_EXTEND(r, s); } /* Convert DC difference to actual value, update last_dc_val */ s += state.last_dc_val[ci]; state.last_dc_val[ci] = s; /* Scale and output the DC coefficient (assumes jpeg_natural_order[0]=0) */ (*block)[0] = (JCOEF) (s << Al); } /* Completed MCU, so update state */ BITREAD_SAVE_STATE(cinfo,entropy->bitstate); ASSIGN_STATE(entropy->saved, state); /* Account for restart interval (no-op if not using restarts) */ entropy->restarts_to_go--; return TRUE; }
jpeg_get_huffman_decoder_configuration(j_decompress_ptr cinfo, huffman_offset_data *offset) { huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; if (cinfo->restart_interval) { // We are at the end of a data segment if (entropy->restarts_to_go == 0) if (! process_restart(cinfo)) return; } // Save restarts_to_go and next_restart_num offset->restarts_to_go = (unsigned short) entropy->restarts_to_go; offset->next_restart_num = cinfo->marker->next_restart_num; offset->bitstream_offset = (jget_input_stream_position(cinfo) << LOG_TWO_BIT_BUF_SIZE) + entropy->bitstate.bits_left; offset->get_buffer = entropy->bitstate.get_buffer; }
METHODDEF boolean decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) { huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; register int s, k, r; int blkn, ci; JBLOCKROW block; working_state state; D_DERIVED_TBL * dctbl; D_DERIVED_TBL * actbl; jpeg_component_info * compptr; /* Process restart marker if needed; may have to suspend */ if (cinfo->restart_interval) { if (entropy->restarts_to_go == 0) if (! process_restart(cinfo)) return FALSE; } /* Load up working state */ state.unread_marker = cinfo->unread_marker; state.next_input_byte = cinfo->src->next_input_byte; state.bytes_in_buffer = cinfo->src->bytes_in_buffer; ASSIGN_STATE(state.cur, entropy->saved); state.cinfo = cinfo; /* Outer loop handles each block in the MCU */ for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { block = MCU_data[blkn]; ci = cinfo->MCU_membership[blkn]; compptr = cinfo->cur_comp_info[ci]; dctbl = entropy->dc_derived_tbls[compptr->dc_tbl_no]; actbl = entropy->ac_derived_tbls[compptr->ac_tbl_no]; /* Decode a single block's worth of coefficients */ /* Section F.2.2.1: decode the DC coefficient difference */ huff_DECODE(s, state, dctbl, label1); if (s) { check_bit_buffer(state, s, return FALSE); r = get_bits(state, s); s = huff_EXTEND(r, s); } /* Shortcut if component's values are not interesting */ if (! compptr->component_needed) goto skip_ACs; /* Convert DC difference to actual value, update last_dc_val */ s += state.cur.last_dc_val[ci]; state.cur.last_dc_val[ci] = s; /* Output the DC coefficient (assumes ZAG[0] = 0) */ (*block)[0] = (JCOEF) s; /* Do we need to decode the AC coefficients for this component? */ if (compptr->DCT_scaled_size > 1) { /* Section F.2.2.2: decode the AC coefficients */ /* Since zeroes are skipped, output area must be cleared beforehand */ for (k = 1; k < DCTSIZE2; k++) { huff_DECODE(s, state, actbl, label2); r = s >> 4; s &= 15; if (s) { k += r; check_bit_buffer(state, s, return FALSE); r = get_bits(state, s); s = huff_EXTEND(r, s); /* Output coefficient in natural (dezigzagged) order */ (*block)[ZAG[k]] = (JCOEF) s; } else { if (r != 15) break; k += 15; } } } else {
decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) { huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; int blkn; BITREAD_STATE_VARS; savable_state state; /* Process restart marker if needed; may have to suspend */ if (cinfo->restart_interval) { if (entropy->restarts_to_go == 0) if (! process_restart(cinfo)) return FALSE; } /* If we've run out of data, just leave the MCU set to zeroes. * This way, we return uniform gray for the remainder of the segment. */ if (! entropy->pub.insufficient_data) { /* Load up working state */ BITREAD_LOAD_STATE(cinfo,entropy->bitstate); ASSIGN_STATE(state, entropy->saved); /* Outer loop handles each block in the MCU */ for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { JBLOCKROW block = MCU_data[blkn]; d_derived_tbl * dctbl = entropy->dc_cur_tbls[blkn]; d_derived_tbl * actbl = entropy->ac_cur_tbls[blkn]; register int s, k, r; /* Decode a single block's worth of coefficients */ /* Section F.2.2.1: decode the DC coefficient difference */ HUFF_DECODE(s, br_state, dctbl, return FALSE, label1); if (s) { CHECK_BIT_BUFFER(br_state, s, return FALSE); r = GET_BITS(s); s = HUFF_EXTEND(r, s); } if (entropy->dc_needed[blkn]) { /* Convert DC difference to actual value, update last_dc_val */ int ci = cinfo->MCU_membership[blkn]; s += state.last_dc_val[ci]; state.last_dc_val[ci] = s; /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */ (*block)[0] = (JCOEF) s; } if (entropy->ac_needed[blkn]) { /* Section F.2.2.2: decode the AC coefficients */ /* Since zeroes are skipped, output area must be cleared beforehand */ for (k = 1; k < DCTSIZE2; k++) { HUFF_DECODE(s, br_state, actbl, return FALSE, label2); r = s >> 4; s &= 15; if (s) { k += r; CHECK_BIT_BUFFER(br_state, s, return FALSE); r = GET_BITS(s); s = HUFF_EXTEND(r, s); /* Output coefficient in natural (dezigzagged) order. * Note: the extra entries in jpeg_natural_order[] will save us * if k >= DCTSIZE2, which could happen if the data is corrupted. */ (*block)[jpeg_natural_order[k]] = (JCOEF) s; } else { if (r != 15) break; k += 15; } } } else { /* Section F.2.2.2: decode the AC coefficients */ /* In this path we just discard the values */ for (k = 1; k < DCTSIZE2; k++) {
METHODDEF boolean decode_mcu_AC_first(j_decompress_ptr cinfo, JBLOCKROW * MCU_data) { phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; int Se = cinfo->Se; int Al = cinfo->Al; register int s, k, r; unsigned int EOBRUN; JBLOCKROW block; BITREAD_STATE_VARS; d_derived_tbl *tbl; /* Process restart marker if needed; may have to suspend */ if(cinfo->restart_interval) { if(entropy->restarts_to_go == 0) if(!process_restart(cinfo)) return FALSE; } /* Load up working state. * We can avoid loading/saving bitread state if in an EOB run. */ EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we care about */ /* There is always only one block per MCU */ if(EOBRUN > 0) /* if it's a band of zeroes... */ EOBRUN--; /* ...process it now (we do nothing) */ else { BITREAD_LOAD_STATE(cinfo, entropy->bitstate); block = MCU_data[0]; tbl = entropy->ac_derived_tbl; for(k = cinfo->Ss; k <= Se; k++) { HUFF_DECODE(s, br_state, tbl, return FALSE, label2); r = s >> 4; s &= 15; if(s) { k += r; CHECK_BIT_BUFFER(br_state, s, return FALSE); r = GET_BITS(s); s = HUFF_EXTEND(r, s); /* Scale and output coefficient in natural (dezigzagged) order */ (*block)[jpeg_natural_order[k]] = (JCOEF) (s << Al); } else { if(r == 15) { /* ZRL */ k += 15; /* skip 15 zeroes in band */ } else { /* EOBr, run length is 2^r + appended bits */ EOBRUN = 1 << r; if(r) { /* EOBr, r > 0 */ CHECK_BIT_BUFFER(br_state, r, return FALSE); r = GET_BITS(r); EOBRUN += r; } EOBRUN--; /* this band is processed at this moment */ break; /* force end-of-band */ } } } BITREAD_SAVE_STATE(cinfo, entropy->bitstate); }
decompress_data (j_decompress_ptr cinfo, JSAMPIMAGE output_buf) { j_lossless_d_ptr losslsd = (j_lossless_d_ptr) cinfo->codec; d_diff_ptr diff = (d_diff_ptr) losslsd->diff_private; JDIMENSION MCU_col_num; /* index of current MCU within row */ JDIMENSION MCU_count; /* number of MCUs decoded */ JDIMENSION last_iMCU_row = cinfo->total_iMCU_rows - 1; int comp, ci, yoffset, row, prev_row; jpeg_component_info *compptr; /* Loop to process as much as one whole iMCU row */ for (yoffset = diff->MCU_vert_offset; yoffset < (int)diff->MCU_rows_per_iMCU_row; yoffset++) { /* Process restart marker if needed; may have to suspend */ if (cinfo->restart_interval) { if (diff->restart_rows_to_go == 0) if (! process_restart(cinfo)) return JPEG_SUSPENDED; } MCU_col_num = diff->MCU_ctr; /* Try to fetch an MCU-row (or remaining portion of suspended MCU-row). */ MCU_count = (*losslsd->entropy_decode_mcus) (cinfo, diff->diff_buf, yoffset, MCU_col_num, cinfo->MCUs_per_row - MCU_col_num); if (MCU_count != cinfo->MCUs_per_row - MCU_col_num) { /* Suspension forced; update state counters and exit */ diff->MCU_vert_offset = yoffset; diff->MCU_ctr += MCU_count; return JPEG_SUSPENDED; } /* Account for restart interval (no-op if not using restarts) */ diff->restart_rows_to_go--; /* Completed an MCU row, but perhaps not an iMCU row */ diff->MCU_ctr = 0; } /* * Undifference and scale each scanline of the disassembled MCU-row * separately. We do not process dummy samples at the end of a scanline * or dummy rows at the end of the image. */ for (comp = 0; comp < cinfo->comps_in_scan; comp++) { compptr = cinfo->cur_comp_info[comp]; ci = compptr->component_index; for (row = 0, prev_row = compptr->v_samp_factor - 1; row < (cinfo->input_iMCU_row == last_iMCU_row ? compptr->last_row_height : compptr->v_samp_factor); prev_row = row, row++) { (*losslsd->predict_undifference[ci]) (cinfo, ci, diff->diff_buf[ci][row], diff->undiff_buf[ci][prev_row], diff->undiff_buf[ci][row], compptr->width_in_data_units); (*losslsd->scaler_scale) (cinfo, diff->undiff_buf[ci][row], output_buf[ci][row], compptr->width_in_data_units); } } /* Completed the iMCU row, advance counters for next one. * * NB: output_data will increment output_iMCU_row. * This counter is not needed for the single-pass case * or the input side of the multi-pass case. */ if (++(cinfo->input_iMCU_row) < cinfo->total_iMCU_rows) { start_iMCU_row(cinfo); return JPEG_ROW_COMPLETED; } /* Completed the scan */ (*cinfo->inputctl->finish_input_pass) (cinfo); return JPEG_SCAN_COMPLETED; }
decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) { huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; register int s, k, r; int blkn, ci; JBLOCKROW block; BITREAD_STATE_VARS; savable_state state; d_derived_tbl * dctbl; d_derived_tbl * actbl; jpeg_component_info * compptr; /* Process restart marker if needed; may have to suspend */ if (cinfo->restart_interval) { if (entropy->restarts_to_go == 0) if (! process_restart(cinfo)) return FALSE; } /* Load up working state */ BITREAD_LOAD_STATE(cinfo,entropy->bitstate); ASSIGN_STATE(state, entropy->saved); /* Outer loop handles each block in the MCU */ for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { block = MCU_data[blkn]; ci = cinfo->MCU_membership[blkn]; compptr = cinfo->cur_comp_info[ci]; dctbl = entropy->dc_derived_tbls[compptr->dc_tbl_no]; actbl = entropy->ac_derived_tbls[compptr->ac_tbl_no]; /* Decode a single block's worth of coefficients */ /* Section F.2.2.1: decode the DC coefficient difference */ HUFF_DECODE(s, br_state, dctbl, return FALSE, label1); if (s) { CHECK_BIT_BUFFER(br_state, s, return FALSE); r = GET_BITS(s); s = HUFF_EXTEND(r, s); } /* Shortcut if component's values are not interesting */ if (! compptr->component_needed) goto skip_ACs; /* Convert DC difference to actual value, update last_dc_val */ s += state.last_dc_val[ci]; state.last_dc_val[ci] = s; /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */ (*block)[0] = (JCOEF) s; /* Do we need to decode the AC coefficients for this component? */ if (compptr->DCT_scaled_size > 1) { /* Section F.2.2.2: decode the AC coefficients */ /* Since zeroes are skipped, output area must be cleared beforehand */ for (k = 1; k < DCTSIZE2; k++) { HUFF_DECODE(s, br_state, actbl, return FALSE, label2); r = s >> 4; s &= 15; if (s) { k += r; CHECK_BIT_BUFFER(br_state, s, return FALSE); r = GET_BITS(s); s = HUFF_EXTEND(r, s); /* Output coefficient in natural (dezigzagged) order. * Note: the extra entries in jpeg_natural_order[] will save us * if k >= DCTSIZE2, which could happen if the data is corrupted. */ (*block)[jpeg_natural_order[k]] = (JCOEF) s; } else { if (r != 15) break; k += 15; } } } else {
decode_mcu (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) { huff_entropy_ptr entropy = (huff_entropy_ptr) cinfo->entropy; __boundcheck_metadata_store((void *)(&entropy),(void *)((size_t)(&entropy)+sizeof(entropy)*8-1)); register int s, k, r; int blkn; __boundcheck_metadata_store((void *)(&blkn),(void *)((size_t)(&blkn)+sizeof(blkn)*8-1)); int ci; __boundcheck_metadata_store((void *)(&ci),(void *)((size_t)(&ci)+sizeof(ci)*8-1)); JBLOCKROW block; __boundcheck_metadata_store((void *)(&block),(void *)((size_t)(&block)+sizeof(block)*8-1)); BITREAD_STATE_VARS; __boundcheck_metadata_store((void *)(&br_state),(void *)((size_t)(&br_state)+sizeof(br_state)*8-1)); savable_state state; __boundcheck_metadata_store((void *)(&state),(void *)((size_t)(&state)+sizeof(state)*8-1)); d_derived_tbl * dctbl; __boundcheck_metadata_store((void *)(&dctbl),(void *)((size_t)(&dctbl)+sizeof(dctbl)*8-1)); d_derived_tbl * actbl; __boundcheck_metadata_store((void *)(&actbl),(void *)((size_t)(&actbl)+sizeof(actbl)*8-1)); jpeg_component_info * compptr; __boundcheck_metadata_store((void *)(&compptr),(void *)((size_t)(&compptr)+sizeof(compptr)*8-1)); /* Process restart marker if needed; may have to suspend */ if (cinfo->restart_interval) { if (entropy->restarts_to_go == 0) if (! process_restart(cinfo)) return FALSE; } /* Load up working state */ BITREAD_LOAD_STATE(cinfo,entropy->bitstate); ASSIGN_STATE(state, entropy->saved); /* Outer loop handles each block in the MCU */ for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { block = (*(JBLOCKROW *)(__boundcheck_ptr_reference(463,13,"decode_mcu",(void *)(&MCU_data[0]),(void *)(&MCU_data[blkn])))); ci = cinfo->MCU_membership[_RV_insert_check(0,10,464,10,"decode_mcu",blkn)]; compptr = cinfo->cur_comp_info[_RV_insert_check(0,4,465,15,"decode_mcu",ci)]; dctbl = entropy->dc_derived_tbls[_RV_insert_check(0,4,466,13,"decode_mcu",compptr->dc_tbl_no)]; actbl = entropy->ac_derived_tbls[_RV_insert_check(0,4,467,13,"decode_mcu",compptr->ac_tbl_no)]; /* Decode a single block's worth of coefficients */ /* Section F.2.2.1: decode the DC coefficient difference */ HUFF_DECODE(s, br_state, dctbl, return FALSE, label1); if (s) { CHECK_BIT_BUFFER(br_state, s, return FALSE); r = GET_BITS(s); s = HUFF_EXTEND(r, s); } /* Shortcut if component's values are not interesting */ if (! compptr->component_needed) goto skip_ACs; /* Convert DC difference to actual value, update last_dc_val */ s += state.last_dc_val[_RV_insert_check(0,4,484,10,"decode_mcu",ci)]; state.last_dc_val[_RV_insert_check(0,4,485,5,"decode_mcu",ci)] = s; /* Output the DC coefficient (assumes jpeg_natural_order[0] = 0) */ (*(JBLOCKROW)(__boundcheck_ptr_reference(487,7,"decode_mcu",(void *)(block),(void *)(block))))[0] = (JCOEF) s; /* Do we need to decode the AC coefficients for this component? */ if (compptr->DCT_scaled_size > 1) { /* Section F.2.2.2: decode the AC coefficients */ /* Since zeroes are skipped, output area must be cleared beforehand */ for (k = 1; k < DCTSIZE2; k++) { HUFF_DECODE(s, br_state, actbl, return FALSE, label2); r = s >> 4; s &= 15; if (s) { k += r; CHECK_BIT_BUFFER(br_state, s, return FALSE); r = GET_BITS(s); s = HUFF_EXTEND(r, s); /* Output coefficient in natural (dezigzagged) order. * Note: the extra entries in jpeg_natural_order[] will save us * if k >= DCTSIZE2, which could happen if the data is corrupted. */ (*(JBLOCKROW)(__boundcheck_ptr_reference(509,6,"decode_mcu",(void *)(block),(void *)(block))))[(*(const int *)(__boundcheck_ptr_reference(509,13,"decode_mcu",(void *)(&jpeg_natural_order[0]),(void *)(&jpeg_natural_order[k]))))] = (JCOEF) s; } else { if (r != 15) break; k += 15; } } } else {
boolean decode_mcu_AC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) { phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; int Se = cinfo->Se; int Al = cinfo->Al; register int s, k, r; unsigned int EOBRUN; JBLOCKROW block; BITREAD_STATE_VARS; d_derived_tbl * tbl; /* Process restart marker if needed; may have to suspend */ if (cinfo->restart_interval) { if (entropy->restarts_to_go == 0) if (! process_restart(cinfo)) return FALSE; } /* If we've run out of data, just leave the MCU set to zeroes. * This way, we return uniform gray for the remainder of the segment. */ if (! entropy->pub.insufficient_data) { /* Load up working state. * We can avoid loading/saving bitread state if in an EOB run. */ EOBRUN = entropy->saved.EOBRUN; /* only part of saved state we need */ /* There is always only one block per MCU */ if (EOBRUN > 0) /* if it's a band of zeroes... */ EOBRUN--; /* ...process it now (we do nothing) */ else { BITREAD_LOAD_STATE(cinfo,entropy->bitstate); block = MCU_data[0]; tbl = entropy->ac_derived_tbl; for (k = cinfo->Ss; k <= Se; k++) { if ( ! br_state.HUFF_DECODE(s, bits_left, get_buffer, tbl) ) return FALSE; r = s >> 4; s &= 15; if (s) { k += r; if ( ! br_state.CHECK_BIT_BUFFER(s, bits_left, get_buffer) ) return FALSE; r = GET_BITS(s); s = HUFF_EXTEND(r, s); /* Scale and output coefficient in natural (dezigzagged) order */ (*block)[jpeg_natural_order[k]] = (JCOEF) (s << Al); } else { if (r == 15) /* ZRL */ { k += 15; /* skip 15 zeroes in band */ } else /* EOBr, run length is 2^r + appended bits */ { EOBRUN = 1 << r; if (r) /* EOBr, r > 0 */ { if ( ! br_state.CHECK_BIT_BUFFER(r, bits_left, get_buffer) ) return FALSE; r = GET_BITS(r); EOBRUN += r; } EOBRUN--; /* this band is processed at this moment */ break; /* force end-of-band */ } } } BITREAD_SAVE_STATE(cinfo,entropy->bitstate); } /* Completed MCU, so update state */ entropy->saved.EOBRUN = EOBRUN; /* only part of saved state we need */ }
decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) { phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; __boundcheck_metadata_store((void *)(&entropy),(void *)((size_t)(&entropy)+sizeof(entropy)*8-1)); int Al = cinfo->Al; __boundcheck_metadata_store((void *)(&Al),(void *)((size_t)(&Al)+sizeof(Al)*8-1)); register int s, r; int blkn; __boundcheck_metadata_store((void *)(&blkn),(void *)((size_t)(&blkn)+sizeof(blkn)*8-1)); int ci; __boundcheck_metadata_store((void *)(&ci),(void *)((size_t)(&ci)+sizeof(ci)*8-1)); JBLOCKROW block; __boundcheck_metadata_store((void *)(&block),(void *)((size_t)(&block)+sizeof(block)*8-1)); BITREAD_STATE_VARS; __boundcheck_metadata_store((void *)(&br_state),(void *)((size_t)(&br_state)+sizeof(br_state)*8-1)); savable_state state; __boundcheck_metadata_store((void *)(&state),(void *)((size_t)(&state)+sizeof(state)*8-1)); d_derived_tbl * tbl; __boundcheck_metadata_store((void *)(&tbl),(void *)((size_t)(&tbl)+sizeof(tbl)*8-1)); jpeg_component_info * compptr; __boundcheck_metadata_store((void *)(&compptr),(void *)((size_t)(&compptr)+sizeof(compptr)*8-1)); /* Process restart marker if needed; may have to suspend */ if (cinfo->restart_interval) { if (entropy->restarts_to_go == 0) if (! process_restart(cinfo)) return FALSE; } /* Load up working state */ BITREAD_LOAD_STATE(cinfo,entropy->bitstate); ASSIGN_STATE(state, entropy->saved); /* Outer loop handles each block in the MCU */ for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { block = (*(JBLOCKROW *)(__boundcheck_ptr_reference(307,13,"decode_mcu_DC_first",(void *)(&MCU_data[0]),(void *)(&MCU_data[blkn])))); ci = cinfo->MCU_membership[_RV_insert_check(0,10,308,10,"decode_mcu_DC_first",blkn)]; compptr = cinfo->cur_comp_info[_RV_insert_check(0,4,309,15,"decode_mcu_DC_first",ci)]; tbl = entropy->derived_tbls[_RV_insert_check(0,4,310,11,"decode_mcu_DC_first",compptr->dc_tbl_no)]; /* Decode a single block's worth of coefficients */ /* Section F.2.2.1: decode the DC coefficient difference */ HUFF_DECODE(s, br_state, tbl, return FALSE, label1); if (s) { CHECK_BIT_BUFFER(br_state, s, return FALSE); r = GET_BITS(s); s = HUFF_EXTEND(r, s); } /* Convert DC difference to actual value, update last_dc_val */ s += state.last_dc_val[_RV_insert_check(0,4,323,10,"decode_mcu_DC_first",ci)]; state.last_dc_val[_RV_insert_check(0,4,324,5,"decode_mcu_DC_first",ci)] = s; /* Scale and output the DC coefficient (assumes jpeg_natural_order[0]=0) */ (*(JBLOCKROW)(__boundcheck_ptr_reference(326,7,"decode_mcu_DC_first",(void *)(block),(void *)(block))))[0] = (JCOEF) (s << Al); } /* Completed MCU, so update state */ BITREAD_SAVE_STATE(cinfo,entropy->bitstate); ASSIGN_STATE(entropy->saved, state); /* Account for restart interval (no-op if not using restarts) */ entropy->restarts_to_go--; return TRUE; }
decode_mcu_DC_first (j_decompress_ptr cinfo, JBLOCKROW *MCU_data) { phuff_entropy_ptr entropy = (phuff_entropy_ptr) cinfo->entropy; int Al = cinfo->Al; int blkn; BITREAD_STATE_VARS; savable_state state; /* Process restart marker if needed; may have to suspend */ if (cinfo->restart_interval) { if (entropy->restarts_to_go == 0) if (! process_restart(cinfo)) return FALSE; } /* If we've run out of data, just leave the MCU set to zeroes. * This way, we return uniform gray for the remainder of the segment. */ if (! entropy->pub.insufficient_data) { /* Load up working state */ BITREAD_LOAD_STATE(cinfo,entropy->bitstate); ASSIGN_STATE(state, entropy->saved); /* Outer loop handles each block in the MCU */ for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { JBLOCKROW block = MCU_data[blkn]; int ci = cinfo->MCU_membership[blkn]; d_derived_tbl * tbl = entropy->dc_derived_tbls[ci]; register int s; /* Decode a single block's worth of coefficients */ /* Section F.2.2.1: decode the DC coefficient difference */ { /* HUFFX_DECODE */ register int nb, look, t; if (bits_left < HUFFX_LOOKAHEAD) { register const JOCTET * next_input_byte = br_state.next_input_byte; register size_t bytes_in_buffer = br_state.bytes_in_buffer; if (cinfo->unread_marker == 0) { while (bits_left < MIN_GET_BITS) { register int c; if (bytes_in_buffer == 0 || (c = GETJOCTET(*next_input_byte)) == 0xFF) { goto label11; } bytes_in_buffer--; next_input_byte++; get_buffer = (get_buffer << 8) | c; bits_left += 8; } br_state.next_input_byte = next_input_byte; br_state.bytes_in_buffer = bytes_in_buffer; } else { label11: br_state.next_input_byte = next_input_byte; br_state.bytes_in_buffer = bytes_in_buffer; if (! jpeg_fill_bit_buffer(&br_state,get_buffer,bits_left, 0)) { return FALSE; } get_buffer = br_state.get_buffer; bits_left = br_state.bits_left; if (bits_left < HUFFX_LOOKAHEAD) { nb = 1; goto label1; } } } look = PEEK_BITS(HUFFX_LOOKAHEAD); if ((nb = tbl->lookx_nbits[look]) != 0) { s = tbl->lookx_val[look]; if (nb <= HUFFX_LOOKAHEAD) { DROP_BITS(nb); } else { DROP_BITS(HUFFX_LOOKAHEAD); nb -= HUFFX_LOOKAHEAD; CHECK_BIT_BUFFER(br_state, nb, return FALSE); s += GET_BITS(nb); } } else { nb = HUFFX_LOOKAHEAD; label1: if ((s=jpeg_huff_decode(&br_state,get_buffer,bits_left,tbl,nb)) < 0) { return FALSE; } get_buffer = br_state.get_buffer; bits_left = br_state.bits_left; if (s) { CHECK_BIT_BUFFER(br_state, s, return FALSE); t = GET_BITS(s); s = HUFF_EXTEND(t, s); } } }
decode_mcu_DC_first(j_decompress_ptr cinfo, JBLOCKROW *MCU_data) { phuff_entropy_ptr entropy = (phuff_entropy_ptr)cinfo->entropy; int Al = cinfo->Al; register int s, r; int blkn, ci; JBLOCKROW block; BITREAD_STATE_VARS; savable_state state; d_derived_tbl *tbl; jpeg_component_info *compptr; /* Process restart marker if needed; may have to suspend */ if (cinfo->restart_interval) { if (entropy->restarts_to_go == 0) if (!process_restart(cinfo)) return FALSE; } /* If we've run out of data, just leave the MCU set to zeroes. * This way, we return uniform gray for the remainder of the segment. */ if (!entropy->pub.insufficient_data) { /* Load up working state */ BITREAD_LOAD_STATE(cinfo, entropy->bitstate); ASSIGN_STATE(state, entropy->saved); /* Outer loop handles each block in the MCU */ for (blkn = 0; blkn < cinfo->blocks_in_MCU; blkn++) { block = MCU_data[blkn]; ci = cinfo->MCU_membership[blkn]; compptr = cinfo->cur_comp_info[ci]; tbl = entropy->derived_tbls[compptr->dc_tbl_no]; /* Decode a single block's worth of coefficients */ /* Section F.2.2.1: decode the DC coefficient difference */ HUFF_DECODE(s, br_state, tbl, return FALSE, label1); if (s) { CHECK_BIT_BUFFER(br_state, s, return FALSE); r = GET_BITS(s); s = HUFF_EXTEND(r, s); } /* Convert DC difference to actual value, update last_dc_val */ if ((state.last_dc_val[ci] >= 0 && s > INT_MAX - state.last_dc_val[ci]) || (state.last_dc_val[ci] < 0 && s < INT_MIN - state.last_dc_val[ci])) ERREXIT(cinfo, JERR_BAD_DCT_COEF); s += state.last_dc_val[ci]; state.last_dc_val[ci] = s; /* Scale and output the coefficient (assumes jpeg_natural_order[0]=0) */ (*block)[0] = (JCOEF)LEFT_SHIFT(s, Al); } /* Completed MCU, so update state */ BITREAD_SAVE_STATE(cinfo, entropy->bitstate); ASSIGN_STATE(entropy->saved, state); }