BitMiracle.LibJpeg.Classic.Internal.huff_entropy_encoder.finish_pass_gather C# (CSharp) Méthode

finish_pass_gather() private méthode

Finish up a statistics-gathering pass and create the new Huffman tables.
private finish_pass_gather ( ) : void
Résultat void
        private void finish_pass_gather()
        {
            if (m_cinfo.m_progressive_mode)
            {
                /* Flush out buffered data (all we care about is counting the EOB symbol) */
                emit_eobrun();
            }

            /* It's important not to apply jpeg_gen_optimal_table more than once
             * per table, because it clobbers the input frequency counts!
             */
            bool[] did_dc = new bool[JpegConstants.NUM_HUFF_TBLS];
            bool[] did_ac = new bool[JpegConstants.NUM_HUFF_TBLS];

            for (int ci = 0; ci < m_cinfo.m_comps_in_scan; ci++)
            {
                jpeg_component_info compptr = m_cinfo.Component_info[m_cinfo.m_cur_comp_info[ci]];
                /* DC needs no table for refinement scan */
                if (m_cinfo.m_Ss == 0 && m_cinfo.m_Ah == 0)
                {
                    int dctbl = compptr.Dc_tbl_no;
                    if (!did_dc[dctbl])
                    {
                        if (m_cinfo.m_dc_huff_tbl_ptrs[dctbl] == null)
                            m_cinfo.m_dc_huff_tbl_ptrs[dctbl] = new JHUFF_TBL();

                        jpeg_gen_optimal_table(m_cinfo.m_dc_huff_tbl_ptrs[dctbl], m_dc_count_ptrs[dctbl]);
                        did_dc[dctbl] = true;
                    }
                }

                /* AC needs no table when not present */
                if (m_cinfo.m_Se != 0)
                {
                    int actbl = compptr.Ac_tbl_no;
                    if (!did_ac[actbl])
                    {
                        if (m_cinfo.m_ac_huff_tbl_ptrs[actbl] == null)
                            m_cinfo.m_ac_huff_tbl_ptrs[actbl] = new JHUFF_TBL();

                        jpeg_gen_optimal_table(m_cinfo.m_ac_huff_tbl_ptrs[actbl], m_ac_count_ptrs[actbl]);
                        did_ac[actbl] = true;
                    }
                }
            }
        }