• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# JBLOCK类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中JBLOCK的典型用法代码示例。如果您正苦于以下问题:C# JBLOCK类的具体用法?C# JBLOCK怎么用?C# JBLOCK使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JBLOCK类属于命名空间,在下文中一共展示了JBLOCK类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: my_c_coef_controller

        public my_c_coef_controller(jpeg_compress_struct cinfo, bool need_full_buffer)
        {
            m_cinfo = cinfo;

            /* Create the coefficient buffer. */
            if (need_full_buffer)
            {
                /* Allocate a full-image virtual array for each component, */
                /* padded to a multiple of samp_factor DCT blocks in each direction. */
                for (int ci = 0; ci < cinfo.m_num_components; ci++)
                {
                    m_whole_image[ci] = jpeg_common_struct.CreateBlocksArray(
                        JpegUtils.jround_up(cinfo.Component_info[ci].Width_in_blocks, cinfo.Component_info[ci].H_samp_factor),
                        JpegUtils.jround_up(cinfo.Component_info[ci].height_in_blocks, cinfo.Component_info[ci].V_samp_factor));
                    m_whole_image[ci].ErrorProcessor = cinfo;
                }
            }
            else
            {
                /* We only need a single-MCU buffer. */
                JBLOCK[] buffer = new JBLOCK[JpegConstants.C_MAX_BLOCKS_IN_MCU];
                for (int i = 0; i < JpegConstants.C_MAX_BLOCKS_IN_MCU; i++)
                    buffer[i] = new JBLOCK();

                for (int i = 0; i < JpegConstants.C_MAX_BLOCKS_IN_MCU; i++)
                {
                    m_MCU_buffer[i] = new JBLOCK[JpegConstants.C_MAX_BLOCKS_IN_MCU - i];
                    for (int j = i; j < JpegConstants.C_MAX_BLOCKS_IN_MCU; j++)
                        m_MCU_buffer[i][j - i] = buffer[j];
                }

                /* flag for no virtual arrays */
                m_whole_image[0] = null;
            }
        }
开发者ID:lPinchol,项目名称:Reign-Unity-Plugin,代码行数:35,代码来源:my_c_coef_controller.cs


示例2: encode_mcu

        public override bool encode_mcu(JBLOCK[][] MCU_data)
        {
            if (m_gather_statistics)
                return encode_mcu_gather(MCU_data);

            return encode_mcu_huff(MCU_data);
        }
开发者ID:niken0793,项目名称:FacebookImageUpload,代码行数:7,代码来源:huff_entropy_encoder.cs


示例3: my_trans_c_coef_controller

        /// <summary>
        /// Initialize coefficient buffer controller.
        /// 
        /// Each passed coefficient array must be the right size for that
        /// coefficient: width_in_blocks wide and height_in_blocks high,
        /// with unit height at least v_samp_factor.
        /// </summary>
        public my_trans_c_coef_controller(jpeg_compress_struct cinfo, jvirt_array<JBLOCK>[] coef_arrays)
        {
            m_cinfo = cinfo;

            /* Save pointer to virtual arrays */
            m_whole_image = coef_arrays;

            /* Allocate and pre-zero space for dummy DCT blocks. */
            JBLOCK[] buffer = new JBLOCK[JpegConstants.C_MAX_BLOCKS_IN_MCU];
            for (int i = 0; i < JpegConstants.C_MAX_BLOCKS_IN_MCU; i++)
                buffer[i] = new JBLOCK();

            for (int i = 0; i < JpegConstants.C_MAX_BLOCKS_IN_MCU; i++)
            {
                m_dummy_buffer[i] = new JBLOCK[JpegConstants.C_MAX_BLOCKS_IN_MCU - i];
                for (int j = i; j < JpegConstants.C_MAX_BLOCKS_IN_MCU; j++)
                    m_dummy_buffer[i][j - i] = buffer[j];
            }
        }
开发者ID:lPinchol,项目名称:Reign-Unity-Plugin,代码行数:26,代码来源:my_trans_c_coef_controller.cs


示例4: encode_mcu_AC_first

        /// <summary>
        /// MCU encoding for AC initial scan (either spectral selection,
        /// or first pass of successive approximation).
        /// </summary>
        private bool encode_mcu_AC_first(JBLOCK[][] MCU_data)
        {
            /* Emit restart marker if needed */
            if (m_cinfo.m_restart_interval != 0)
            {
                if (m_restarts_to_go == 0)
                    emit_restart(m_next_restart_num);
            }

            /* Encode the AC coefficients per section G.1.2.2, fig. G.3 */
            /* r = run length of zeros */
            int r = 0;
            for (int k = m_cinfo.m_Ss; k <= m_cinfo.m_Se; k++)
            {
                int temp = MCU_data[0][0][JpegUtils.jpeg_natural_order[k]];
                if (temp == 0)
                {
                    r++;
                    continue;
                }

                /* We must apply the point transform by Al.  For AC coefficients this
                 * is an integer division with rounding towards 0.  To do this portably
                 * in C, we shift after obtaining the absolute value; so the code is
                 * interwoven with finding the abs value (temp) and output bits (temp2).
                 */
                int temp2;
                if (temp < 0)
                {
                    temp = -temp;       /* temp is abs value of input */
                    temp >>= m_cinfo.m_Al;        /* apply the point transform */
                    /* For a negative coef, want temp2 = bitwise complement of abs(coef) */
                    temp2 = ~temp;
                }
                else
                {
                    temp >>= m_cinfo.m_Al;        /* apply the point transform */
                    temp2 = temp;
                }

                /* Watch out for case that nonzero coef is zero after point transform */
                if (temp == 0)
                {
                    r++;
                    continue;
                }

                /* Emit any pending EOBRUN */
                if (m_EOBRUN > 0)
                    emit_eobrun();

                /* if run length > 15, must emit special run-length-16 codes (0xF0) */
                while (r > 15)
                {
                    emit_symbol(m_ac_tbl_no, 0xF0);
                    r -= 16;
                }

                /* Find the number of bits needed for the magnitude of the coefficient */
                int nbits = 1;          /* there must be at least one 1 bit */
                while ((temp >>= 1) != 0)
                    nbits++;

                /* Check for out-of-range coefficient values */
                if (nbits > MAX_HUFFMAN_COEF_BITS)
                    m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_BAD_DCT_COEF);

                /* Count/emit Huffman symbol for run length / number of bits */
                emit_symbol(m_ac_tbl_no, (r << 4) + nbits);

                /* Emit that number of bits of the value, if positive, */
                /* or the complement of its magnitude, if negative. */
                emit_bits(temp2, nbits);

                r = 0;          /* reset zero run length */
            }

            if (r > 0)
            {
                /* If there are trailing zeroes, */
                m_EOBRUN++;      /* count an EOB */
                if (m_EOBRUN == 0x7FFF)
                    emit_eobrun();   /* force it out to avoid overflow */
            }

            /* Update restart-interval state too */
            if (m_cinfo.m_restart_interval != 0)
            {
                if (m_restarts_to_go == 0)
                {
                    m_restarts_to_go = m_cinfo.m_restart_interval;
                    m_next_restart_num++;
                    m_next_restart_num &= 7;
                }
                m_restarts_to_go--;
            }
//.........这里部分代码省略.........
开发者ID:Daramkun,项目名称:Misty,代码行数:101,代码来源:phuff_entropy_encoder.cs


示例5: encode_mcu

        public override bool encode_mcu(JBLOCK[][] MCU_data)
        {
            switch (m_MCUEncoder)
            {
                case MCUEncoder.mcu_DC_first_encoder:
                    return encode_mcu_DC_first(MCU_data);
                case MCUEncoder.mcu_AC_first_encoder:
                    return encode_mcu_AC_first(MCU_data);
                case MCUEncoder.mcu_DC_refine_encoder:
                    return encode_mcu_DC_refine(MCU_data);
                case MCUEncoder.mcu_AC_refine_encoder:
                    return encode_mcu_AC_refine(MCU_data);
            }

            m_cinfo.ERREXIT(J_MESSAGE_CODE.JERR_NOTIMPL);
            return false;
        }
开发者ID:Daramkun,项目名称:Misty,代码行数:17,代码来源:phuff_entropy_encoder.cs


示例6: decode_mcu

        /// <summary>
        /// Decode and return one MCU's worth of Huffman-compressed coefficients.
        /// The coefficients are reordered from zigzag order into natural array order,
        /// but are not dequantized.
        /// 
        /// The i'th block of the MCU is stored into the block pointed to by
        /// MCU_data[i].  WE ASSUME THIS AREA HAS BEEN ZEROED BY THE CALLER.
        /// (Wholesale zeroing is usually a little faster than retail...)
        /// 
        /// Returns false if data source requested suspension.  In that case no
        /// changes have been made to permanent state.  (Exception: some output
        /// coefficients may already have been assigned.  This is harmless for
        /// this module, since we'll just re-assign them on the next call.)
        /// </summary>
        public override bool decode_mcu(JBLOCK[] MCU_data)
        {
            /* Process restart marker if needed; may have to suspend */
            if (m_cinfo.m_restart_interval != 0)
            {
                if (m_restarts_to_go == 0)
                {
                    if (!process_restart())
                        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 (!m_insufficient_data)
            {
                /* Load up working state */
                int get_buffer;
                int bits_left;
                bitread_working_state br_state = new bitread_working_state();
                BITREAD_LOAD_STATE(m_bitstate, out get_buffer, out bits_left, ref br_state);
                savable_state state = new savable_state();
                state.Assign(m_saved);

                /* Outer loop handles each block in the MCU */

                for (int blkn = 0; blkn < m_cinfo.m_blocks_in_MCU; blkn++)
                {
                    /* Decode a single block's worth of coefficients */

                    /* Section F.2.2.1: decode the DC coefficient difference */
                    int s;
                    if (!HUFF_DECODE(out s, ref br_state, m_dc_cur_tbls[blkn], ref get_buffer, ref bits_left))
                        return false;

                    if (s != 0)
                    {
                        if (!CHECK_BIT_BUFFER(ref br_state, s, ref get_buffer, ref bits_left))
                            return false;

                        int r = GET_BITS(s, get_buffer, ref bits_left);
                        s = HUFF_EXTEND(r, s);
                    }

                    if (m_dc_needed[blkn])
                    {
                        /* Convert DC difference to actual value, update last_dc_val */
                        int ci = m_cinfo.m_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) */
                        MCU_data[blkn][0] = (short) s;
                    }

                    if (m_ac_needed[blkn])
                    {
                        /* Section F.2.2.2: decode the AC coefficients */
                        /* Since zeroes are skipped, output area must be cleared beforehand */
                        for (int k = 1; k < JpegConstants.DCTSIZE2; k++)
                        {
                            if (!HUFF_DECODE(out s, ref br_state, m_ac_cur_tbls[blkn], ref get_buffer, ref bits_left))
                                return false;

                            int r = s >> 4;
                            s &= 15;

                            if (s != 0)
                            {
                                k += r;
                                if (!CHECK_BIT_BUFFER(ref br_state, s, ref get_buffer, ref bits_left))
                                    return false;
                                r = GET_BITS(s, get_buffer, ref bits_left);
                                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.
                                   */
                                MCU_data[blkn][JpegUtils.jpeg_natural_order[k]] = (short) s;
                            }
                            else
                            {
                                if (r != 15)
                                    break;
//.........这里部分代码省略.........
开发者ID:niken0793,项目名称:FacebookImageUpload,代码行数:101,代码来源:huff_entropy_decoder.cs


示例7: decode_mcu_AC_first

        /// <summary>
        /// MCU decoding for AC initial scan (either spectral selection,
        /// or first pass of successive approximation).
        /// </summary>
        private bool decode_mcu_AC_first(JBLOCK[] MCU_data)
        {
            /* Process restart marker if needed; may have to suspend */
            if (m_cinfo.m_restart_interval != 0)
            {
                if (m_restarts_to_go == 0)
                {
                    if (!process_restart())
                        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 (!m_insufficient_data)
            {
                /* Load up working state.
                 * We can avoid loading/saving bitread state if in an EOB run.
                 */
                int EOBRUN = m_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... */
                    /* ...process it now (we do nothing) */
                    EOBRUN--;
                }
                else
                {
                    int get_buffer;
                    int bits_left;
                    bitread_working_state br_state = new bitread_working_state();
                    BITREAD_LOAD_STATE(m_bitstate, out get_buffer, out bits_left, ref br_state);

                    for (int k = m_cinfo.m_Ss; k <= m_cinfo.m_Se; k++)
                    {
                        int s;
                        if (!HUFF_DECODE(out s, ref br_state, m_ac_derived_tbl, ref get_buffer, ref bits_left))
                            return false;

                        int r = s >> 4;
                        s &= 15;
                        if (s != 0)
                        {
                            k += r;

                            if (!CHECK_BIT_BUFFER(ref br_state, s, ref get_buffer, ref bits_left))
                                return false;

                            r = GET_BITS(s, get_buffer, ref bits_left);
                            s = HUFF_EXTEND(r, s);

                            /* Scale and output coefficient in natural (dezigzagged) order */
                            MCU_data[0][JpegUtils.jpeg_natural_order[k]] = (short)(s << m_cinfo.m_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 != 0)
                                {
                                    /* EOBr, r > 0 */
                                    if (!CHECK_BIT_BUFFER(ref br_state, r, ref get_buffer, ref bits_left))
                                        return false;

                                    r = GET_BITS(r, get_buffer, ref bits_left);
                                    EOBRUN += r;
                                }

                                EOBRUN--;       /* this band is processed at this moment */
                                break;      /* force end-of-band */
                            }
                        }
                    }

                    BITREAD_SAVE_STATE(ref m_bitstate, get_buffer, bits_left);
                }

                /* Completed MCU, so update state */
                m_saved.EOBRUN = EOBRUN; /* only part of saved state we need */
            }

            /* Account for restart interval (no-op if not using restarts) */
            m_restarts_to_go--;

            return true;
//.........这里部分代码省略.........
开发者ID:joaonlopes,项目名称:ThumbnailCreator,代码行数:101,代码来源:phuff_entropy_decoder.cs


示例8: decompress_smooth_data

        /// <summary>
        /// Variant of decompress_data for use when doing block smoothing.
        /// </summary>
        private ReadResult decompress_smooth_data(ComponentBuffer[] output_buf)
        {
            /* Force some input to be done if we are getting ahead of the input. */
            while (m_cinfo.m_input_scan_number <= m_cinfo.m_output_scan_number && !m_cinfo.m_inputctl.EOIReached())
            {
                if (m_cinfo.m_input_scan_number == m_cinfo.m_output_scan_number)
                {
                    /* If input is working on current scan, we ordinarily want it to
                     * have completed the current row.  But if input scan is DC,
                     * we want it to keep one row ahead so that next block row's DC
                     * values are up to date.
                     */
                    int delta = (m_cinfo.m_Ss == 0) ? 1 : 0;
                    if (m_cinfo.m_input_iMCU_row > m_cinfo.m_output_iMCU_row + delta)
                        break;
                }

                if (m_cinfo.m_inputctl.consume_input() == ReadResult.JPEG_SUSPENDED)
                    return ReadResult.JPEG_SUSPENDED;
            }

            int last_iMCU_row = m_cinfo.m_total_iMCU_rows - 1;

            /* OK, output from the virtual arrays. */
            for (int ci = 0; ci < m_cinfo.m_num_components; ci++)
            {
                jpeg_component_info componentInfo = m_cinfo.Comp_info[ci];

                /* Don't bother to IDCT an uninteresting component. */
                if (!componentInfo.component_needed)
                    continue;

                int block_rows;
                int access_rows;
                bool last_row;
                /* Count non-dummy DCT block rows in this iMCU row. */
                if (m_cinfo.m_output_iMCU_row < last_iMCU_row)
                {
                    block_rows = componentInfo.V_samp_factor;
                    access_rows = block_rows * 2; /* this and next iMCU row */
                    last_row = false;
                }
                else
                {
                    /* NB: can't use last_row_height here; it is input-side-dependent! */
                    block_rows = componentInfo.height_in_blocks % componentInfo.V_samp_factor;
                    if (block_rows == 0)
                        block_rows = componentInfo.V_samp_factor;
                    access_rows = block_rows; /* this iMCU row only */
                    last_row = true;
                }

                /* Align the virtual buffer for this component. */
                JBLOCK[][] buffer = null;
                bool first_row;
                int bufferRowOffset = 0;
                if (m_cinfo.m_output_iMCU_row > 0)
                {
                    access_rows += componentInfo.V_samp_factor; /* prior iMCU row too */
                    buffer = m_whole_image[ci].Access((m_cinfo.m_output_iMCU_row - 1) * componentInfo.V_samp_factor, access_rows);
                    bufferRowOffset = componentInfo.V_samp_factor; /* point to current iMCU row */
                    first_row = false;
                }
                else
                {
                    buffer = m_whole_image[ci].Access(0, access_rows);
                    first_row = true;
                }

                /* Fetch component-dependent info */
                int coefBitsOffset = ci * SAVED_COEFS;
                int Q00 = componentInfo.quant_table.quantval[0];
                int Q01 = componentInfo.quant_table.quantval[Q01_POS];
                int Q10 = componentInfo.quant_table.quantval[Q10_POS];
                int Q20 = componentInfo.quant_table.quantval[Q20_POS];
                int Q11 = componentInfo.quant_table.quantval[Q11_POS];
                int Q02 = componentInfo.quant_table.quantval[Q02_POS];
                int outputIndex = ci;

                /* Loop over all DCT blocks to be processed. */
                for (int block_row = 0; block_row < block_rows; block_row++)
                {
                    int bufferIndex = bufferRowOffset + block_row;

                    int prev_block_row = 0;
                    if (first_row && block_row == 0)
                        prev_block_row = bufferIndex;
                    else
                        prev_block_row = bufferIndex - 1;

                    int next_block_row = 0;
                    if (last_row && block_row == block_rows - 1)
                        next_block_row = bufferIndex;
                    else
                        next_block_row = bufferIndex + 1;

                    /* We fetch the surrounding DC values using a sliding-register approach.
//.........这里部分代码省略.........
开发者ID:Daramkun,项目名称:Misty,代码行数:101,代码来源:jpeg_d_coef_controller.cs


示例9: decode_mcu_DC_first

        /*
         * Huffman MCU decoding.
         * Each of these routines decodes and returns one MCU's worth of
         * Huffman-compressed coefficients.
         * The coefficients are reordered from zigzag order into natural array order,
         * but are not dequantized.
         *
         * The i'th block of the MCU is stored into the block pointed to by
         * MCU_data[i].  WE ASSUME THIS AREA IS INITIALLY ZEROED BY THE CALLER.
         *
         * We return false if data source requested suspension.  In that case no
         * changes have been made to permanent state.  (Exception: some output
         * coefficients may already have been assigned.  This is harmless for
         * spectral selection, since we'll just re-assign them on the next call.
         * Successive approximation AC refinement has to be more careful, however.)
         */
        /// <summary>
        /// MCU decoding for DC initial scan (either spectral selection,
        /// or first pass of successive approximation).
        /// </summary>
        private bool decode_mcu_DC_first(JBLOCK[] MCU_data)
        {
            /* Process restart marker if needed; may have to suspend */
            if (m_cinfo.m_restart_interval != 0)
            {
                if (m_restarts_to_go == 0)
                {
                    if (!process_restart())
                        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 (!m_insufficient_data)
            {
                /* Load up working state */
                int get_buffer;
                int bits_left;
                bitread_working_state br_state = new bitread_working_state();
                BITREAD_LOAD_STATE(m_bitstate, out get_buffer, out bits_left, ref br_state);
                savable_state state = new savable_state();
                state.Assign(m_saved);

                /* Outer loop handles each block in the MCU */
                for (int blkn = 0; blkn < m_cinfo.m_blocks_in_MCU; blkn++)
                {
                    int ci = m_cinfo.m_MCU_membership[blkn];

                    /* Decode a single block's worth of coefficients */

                    /* Section F.2.2.1: decode the DC coefficient difference */
                    int s;
                    if (!HUFF_DECODE(out s, ref br_state, m_derived_tbls[m_cinfo.Comp_info[m_cinfo.m_cur_comp_info[ci]].Dc_tbl_no], ref get_buffer, ref bits_left))
                        return false;

                    if (s != 0)
                    {
                        if (!CHECK_BIT_BUFFER(ref br_state, s, ref get_buffer, ref bits_left))
                            return false;

                        int r = GET_BITS(s, get_buffer, ref bits_left);
                        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 coefficient (assumes jpeg_natural_order[0]=0) */
                    MCU_data[blkn][0] = (short)(s << m_cinfo.m_Al);
                }

                /* Completed MCU, so update state */
                BITREAD_SAVE_STATE(ref m_bitstate, get_buffer, bits_left);
                m_saved.Assign(state);
            }

            /* Account for restart interval (no-op if not using restarts) */
            m_restarts_to_go--;

            return true;
        }
开发者ID:joaonlopes,项目名称:ThumbnailCreator,代码行数:84,代码来源:phuff_entropy_decoder.cs


示例10: encode_mcu_DC_refine

        /// <summary>
        /// MCU encoding for DC successive approximation refinement scan.
        /// Note: we assume such scans can be multi-component, although the spec
        /// is not very clear on the point.
        /// </summary>
        private bool encode_mcu_DC_refine(JBLOCK[][] MCU_data)
        {
            /* Emit restart marker if needed */
            if (m_cinfo.m_restart_interval != 0)
            {
                if (m_restarts_to_go == 0)
                    emit_restart(m_next_restart_num);
            }

            /* Encode the MCU data blocks */
            for (int blkn = 0; blkn < m_cinfo.m_blocks_in_MCU; blkn++)
            {
                /* We simply emit the Al'th bit of the DC coefficient value. */
                int temp = MCU_data[blkn][0][0];
                emit_bits(temp >> m_cinfo.m_Al, 1);
            }

            /* Update restart-interval state too */
            if (m_cinfo.m_restart_interval != 0)
            {
                if (m_restarts_to_go == 0)
                {
                    m_restarts_to_go = m_cinfo.m_restart_interval;
                    m_next_restart_num++;
                    m_next_restart_num &= 7;
                }
                m_restarts_to_go--;
            }

            return true;
        }
开发者ID:Daramkun,项目名称:Misty,代码行数:36,代码来源:phuff_entropy_encoder.cs


示例11: compressOutput

        /// <summary>
        /// Process some data in subsequent passes of a multi-pass case.
        /// We process the equivalent of one fully interleaved MCU row ("iMCU" row)
        /// per call, ie, v_samp_factor block rows for each component in the scan.
        /// The data is obtained from the virtual arrays and fed to the entropy coder.
        /// Returns true if the iMCU row is completed, false if suspended.
        /// </summary>
        private bool compressOutput()
        {
            /* Align the virtual buffers for the components used in this scan.
             */
            JBLOCK[][][] buffer = new JBLOCK[JpegConstants.MAX_COMPS_IN_SCAN][][];
            for (int ci = 0; ci < m_cinfo.m_comps_in_scan; ci++)
            {
                jpeg_component_info componentInfo = m_cinfo.Component_info[m_cinfo.m_cur_comp_info[ci]];
                buffer[ci] = m_whole_image[componentInfo.Component_index].Access(
                    m_iMCU_row_num * componentInfo.V_samp_factor, componentInfo.V_samp_factor);
            }

            /* Loop to process one whole iMCU row */
            for (int yoffset = m_MCU_vert_offset; yoffset < m_MCU_rows_per_iMCU_row; yoffset++)
            {
                for (int MCU_col_num = m_mcu_ctr; MCU_col_num < m_cinfo.m_MCUs_per_row; MCU_col_num++)
                {
                    /* Construct list of pointers to DCT blocks belonging to this MCU */
                    int blkn = 0;           /* index of current DCT block within MCU */
                    for (int ci = 0; ci < m_cinfo.m_comps_in_scan; ci++)
                    {
                        jpeg_component_info componentInfo = m_cinfo.Component_info[m_cinfo.m_cur_comp_info[ci]];
                        int start_col = MCU_col_num * componentInfo.MCU_width;
                        for (int yindex = 0; yindex < componentInfo.MCU_height; yindex++)
                        {
                            for (int xindex = 0; xindex < componentInfo.MCU_width; xindex++)
                            {
                                int bufLength = buffer[ci][yindex + yoffset].Length;
                                int start = start_col + xindex;
                                m_MCU_buffer[blkn] = new JBLOCK[bufLength - start];
                                for (int j = start; j < bufLength; j++)
                                    m_MCU_buffer[blkn][j - start] = buffer[ci][yindex + yoffset][j];

                                blkn++;
                            }
                        }
                    }

                    /* Try to write the MCU. */
                    if (!m_cinfo.m_entropy.encode_mcu(m_MCU_buffer))
                    {
                        /* Suspension forced; update state counters and exit */
                        m_MCU_vert_offset = yoffset;
                        m_mcu_ctr = MCU_col_num;
                        return false;
                    }
                }
            
                /* Completed an MCU row, but perhaps not an iMCU row */
                m_mcu_ctr = 0;
            }

            /* Completed the iMCU row, advance counters for next one */
            m_iMCU_row_num++;
            start_iMCU_row();
            return true;
        }
开发者ID:lPinchol,项目名称:Reign-Unity-Plugin,代码行数:64,代码来源:my_c_coef_controller.cs


示例12: forwardDCTFloatImpl

        // This version is used for floating-point DCT implementations.
        private void forwardDCTFloatImpl(jpeg_component_info compptr, byte[][] sample_data, JBLOCK[] coef_blocks, int start_row, int start_col, int num_blocks)
        {
            /* This routine is heavily used, so it's worth coding it tightly. */
            float_DCT_method_ptr do_dct = do_float_dct[compptr.Component_index];
            float[] divisors = m_dctTables[compptr.Component_index].float_array;
            float[] workspace = new float[JpegConstants.DCTSIZE2]; /* work area for FDCT subroutine */
            for (int bi = 0; bi < num_blocks; bi++, start_col += compptr.DCT_h_scaled_size)
            {
                /* Perform the DCT */
                do_dct(workspace, sample_data, start_row, start_col);

                /* Quantize/descale the coefficients, and store into coef_blocks[] */
                for (int i = 0; i < JpegConstants.DCTSIZE2; i++)
                {
                    /* Apply the quantization and scaling factor */
                    float temp = workspace[i] * divisors[i];

                    /* Round to nearest integer.
                     * Since C does not specify the direction of rounding for negative
                     * quotients, we have to force the dividend positive for portability.
                     * The maximum coefficient size is +-16K (for 12-bit data), so this
                     * code should work for either 16-bit or 32-bit ints.
                     */
                    coef_blocks[bi][i] = (short)((int)(temp + (float)16384.5) - 16384);
                }
            }
        }
开发者ID:prepare,项目名称:HTML-Renderer,代码行数:28,代码来源:jpeg_forward_dct.cs


示例13: forwardDCTImpl

        // This version is used for integer DCT implementations.
        private void forwardDCTImpl(jpeg_component_info compptr, byte[][] sample_data, JBLOCK[] coef_blocks, int start_row, int start_col, int num_blocks)
        {
            /* This routine is heavily used, so it's worth coding it tightly. */
            forward_DCT_method_ptr do_dct = this.do_dct[compptr.Component_index];
            int[] divisors = m_dctTables[compptr.Component_index].int_array;
            int[] workspace = new int[JpegConstants.DCTSIZE2];    /* work area for FDCT subroutine */
            for (int bi = 0; bi < num_blocks; bi++, start_col += compptr.DCT_h_scaled_size)
            {
                /* Perform the DCT */
                do_dct(workspace, sample_data, start_row, start_col);

                /* Quantize/descale the coefficients, and store into coef_blocks[] */
                for (int i = 0; i < JpegConstants.DCTSIZE2; i++)
                {
                    int qval = divisors[i];
                    int temp = workspace[i];

                    if (temp < 0)
                    {
                        temp = -temp;
                        temp += qval >> 1;  /* for rounding */

                        if (temp >= qval)
                            temp /= qval;
                        else
                            temp = 0;

                        temp = -temp;
                    }
                    else
                    {
                        temp += qval >> 1;  /* for rounding */

                        if (temp >= qval)
                            temp /= qval;
                        else
                            temp = 0;
                    }

                    coef_blocks[bi][i] = (short)temp;
                }
            }
        }
开发者ID:prepare,项目名称:HTML-Renderer,代码行数:44,代码来源:jpeg_forward_dct.cs


示例14: compress_data

        /// <summary>
        /// Process some data.
        /// We process the equivalent of one fully interleaved MCU row ("iMCU" row)
        /// per call, ie, v_samp_factor block rows for each component in the scan.
        /// The data is obtained from the virtual arrays and fed to the entropy coder.
        /// Returns true if the iMCU row is completed, false if suspended.
        /// 
        /// NB: input_buf is ignored; it is likely to be a null pointer.
        /// </summary>
        public virtual bool compress_data(byte[][][] input_buf)
        {
            /* Align the virtual buffers for the components used in this scan. */
            JBLOCK[][][] buffer = new JBLOCK[JpegConstants.MAX_COMPS_IN_SCAN][][];
            for (int ci = 0; ci < m_cinfo.m_comps_in_scan; ci++)
            {
                jpeg_component_info componentInfo = m_cinfo.Component_info[m_cinfo.m_cur_comp_info[ci]];
                buffer[ci] = m_whole_image[componentInfo.Component_index].Access(
                    m_iMCU_row_num * componentInfo.V_samp_factor, componentInfo.V_samp_factor);
            }

            /* Loop to process one whole iMCU row */
            int last_MCU_col = m_cinfo.m_MCUs_per_row - 1;
            int last_iMCU_row = m_cinfo.m_total_iMCU_rows - 1;
            JBLOCK[][] MCU_buffer = new JBLOCK[JpegConstants.C_MAX_BLOCKS_IN_MCU][];
            for (int yoffset = m_MCU_vert_offset; yoffset < m_MCU_rows_per_iMCU_row; yoffset++)
            {
                for (int MCU_col_num = m_mcu_ctr; MCU_col_num < m_cinfo.m_MCUs_per_row; MCU_col_num++)
                {
                    /* Construct list of pointers to DCT blocks belonging to this MCU */
                    int blkn = 0;           /* index of current DCT block within MCU */
                    for (int ci = 0; ci < m_cinfo.m_comps_in_scan; ci++)
                    {
                        jpeg_component_info componentInfo = m_cinfo.Component_info[m_cinfo.m_cur_comp_info[ci]];
                        int start_col = MCU_col_num * componentInfo.MCU_width;
                        int blockcnt = (MCU_col_num < last_MCU_col) ? componentInfo.MCU_width : componentInfo.last_col_width;
                        for (int yindex = 0; yindex < componentInfo.MCU_height; yindex++)
                        {
                            int xindex = 0;
                            if (m_iMCU_row_num < last_iMCU_row || yindex + yoffset < componentInfo.last_row_height)
                            {
                                /* Fill in pointers to real blocks in this row */
                                for (xindex = 0; xindex < blockcnt; xindex++)
                                {
                                    int bufLength = buffer[ci][yindex + yoffset].Length;
                                    int start = start_col + xindex;
                                    MCU_buffer[blkn] = new JBLOCK[bufLength - start];
                                    for (int j = start; j < bufLength; j++)
                                        MCU_buffer[blkn][j - start] = buffer[ci][yindex + yoffset][j];

                                    blkn++;
                                }
                            }
                            else
                            {
                                /* At bottom of image, need a whole row of dummy blocks */
                                xindex = 0;
                            }

                            /* Fill in any dummy blocks needed in this row.
                            * Dummy blocks are filled in the same way as in jccoefct.c:
                            * all zeroes in the AC entries, DC entries equal to previous
                            * block's DC value.  The init routine has already zeroed the
                            * AC entries, so we need only set the DC entries correctly.
                            */
                            for (; xindex < componentInfo.MCU_width; xindex++)
                            {
                                MCU_buffer[blkn] = m_dummy_buffer[blkn];
                                MCU_buffer[blkn][0][0] = MCU_buffer[blkn - 1][0][0];
                                blkn++;
                            }
                        }
                    }
                
                    /* Try to write the MCU. */
                    if (!m_cinfo.m_entropy.encode_mcu(MCU_buffer))
                    {
                        /* Suspension forced; update state counters and exit */
                        m_MCU_vert_offset = yoffset;
                        m_mcu_ctr = MCU_col_num;
                        return false;
                    }
                }

                /* Completed an MCU row, but perhaps not an iMCU row */
                m_mcu_ctr = 0;
            }

            /* Completed the iMCU row, advance counters for next one */
            m_iMCU_row_num++;
            start_iMCU_row();
            return true;
        }
开发者ID:lPinchol,项目名称:Reign-Unity-Plugin,代码行数:92,代码来源:my_trans_c_coef_controller.cs


示例15: decode_mcu_DC_refine

        /// <summary>
        /// MCU decoding for DC successive approximation refinement scan.
        /// Note: we assume such scans can be multi-component, although the spec
        /// is not very clear on the point.
        /// </summary>
        private bool decode_mcu_DC_refine(JBLOCK[] MCU_data)
        {
            /* Process restart marker if needed; may have to suspend */
            if (m_cinfo.m_restart_interval != 0)
            {
                if (m_restarts_to_go == 0)
                {
                    if (!process_restart())
                        return false;
                }
            }

            /* Not worth the cycles to check insufficient_data here,
             * since we will not change the data anyway if we read zeroes.
             */

            /* Load up working state */
            int get_buffer;
            int bits_left;
            bitread_working_state br_state = new bitread_working_state();
            BITREAD_LOAD_STATE(m_bitstate, out get_buffer, out bits_left, ref br_state);

            /* Outer loop handles each block in the MCU */

            for (int blkn = 0; blkn < m_cinfo.m_blocks_in_MCU; blkn++)
            {
                /* Encoded data is simply the next bit of the two's-complement DC value */
                if (!CHECK_BIT_BUFFER(ref br_state, 1, ref get_buffer, ref bits_left))
                    return false;

                if (GET_BITS(1, get_buffer, ref bits_left) != 0)
                {
                    /* 1 in the bit position being coded */
                    MCU_data[blkn][0] = (short)((ushort)MCU_data[blkn][0] | (ushort)(1 << m_cinfo.m_Al));
                }

                /* Note: since we use |=, repeating the assignment later is safe */
            }

            /* Completed MCU, so update state */
            BITREAD_SAVE_STATE(ref m_bitstate, get_buffer, bits_left);

            /* Account for restart interval (no-op if not using restarts) */
            m_restarts_to_go--;

            return true;
        }
开发者ID:joaonlopes,项目名称:ThumbnailCreator,代码行数:52,代码来源:phuff_entropy_decoder.cs


示例16: encode_mcu_AC_refine

        /// <summary>
        /// MCU encoding for AC successive approximation refinement scan.
        /// </summary>
        private bool encode_mcu_AC_refine(JBLOCK[][] MCU_data)
        {
            /* Emit restart marker if needed */
            if (m_cinfo.m_restart_interval != 0)
            {
                if (m_restarts_to_go == 0)
                    emit_restart(m_next_restart_num);
            }

            /* Encode the MCU data block */

            /* It is convenient to make a pre-pass to determine the transformed
             * coefficients' absolute values and the EOB position.
             */
            int EOB = 0;
            int[] absvalues = new int[JpegConstants.DCTSIZE2];
            for (int k = m_cinfo.m_Ss; k <= m_cinfo.m_Se; k++)
            {
                int temp = MCU_data[0][0][JpegUtils.jpeg_natural_order[k]];

                /* We must apply the point transform by Al.  For AC coefficients this
                 * is an integer division with rounding towards 0.  To do this portably
                 * in C, we shift after obtaining the absolute value.
                 */
                if (temp < 0)
                    temp = -temp;       /* temp is abs value of input */

                temp >>= m_cinfo.m_Al;        /* apply the point transform */
                absvalues[k] = temp;    /* save abs value for main pass */

                if (temp == 1)
                {
                    /* EOB = index of last newly-nonzero coef */
                    EOB = k;
                }
            }

            /* Enco 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# JContainer类代码示例发布时间:2022-05-24
下一篇:
C# JArray类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap