Ejemplo n.º 1
0
/* Send the header for a block using dynamic Huffman trees: the counts, the
 * lengths of the bit length codes, the literal tree and the distance tree.
 * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4. */
void CodeTree::send_all_trees(int lcodes, int dcodes, int blcodes)
{
   int rank;                    /* index in bl_order */

   assert (lcodes >= 257 && dcodes >= 1 && blcodes >= 4);
   assert (lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES);
//   Tracev((stderr, "\nbl counts: "));
   send_bits(lcodes-257, 5);
   /* not +255 as stated in appnote.txt 1.93a or -256 in 2.04c */
   send_bits(dcodes-1,   5);
   /* not -3 as stated in appnote.txt */
   send_bits(blcodes-4,  4);
   for (rank = 0; rank < blcodes; rank++) {
//      Tracev((stderr, "\nbl code %2d ", bl_order[rank]));
	  send_bits(bl_tree[bl_order[rank]].Len, 3);
   }
//   Tracev((stderr, "\nbl tree: sent %ld", bits_sent));

   /* send the literal tree */
   send_tree(dyn_ltree, lcodes-1);
//   Tracev((stderr, "\nlit tree: sent %ld", bits_sent));

   /* send the distance tree */
   send_tree(dyn_dtree, dcodes-1);
//   Tracev((stderr, "\ndist tree: sent %ld", bits_sent));
}
Ejemplo n.º 2
0
static void send_all_trees(
    z_stream&	s,
    int			lcodes,
    int			dcodes,
    int			blcodes )
{
    send_bits( s, lcodes - 257, 5 );
    send_bits( s, dcodes - 1, 5 );
    send_bits( s, blcodes - 4, 4 );

    for( int rank = 0 ; rank < blcodes ; rank++ )
        send_bits( s, s.bl_tree[ bl_order[ rank ] ].Len, 3 );

    send_tree( s, (ct_data*) s.dyn_ltree, lcodes - 1 );
    send_tree( s, (ct_data*) s.dyn_dtree, dcodes - 1 );
}
Ejemplo n.º 3
0
/* ===========================================================================
 * Send the header for a block using dynamic Huffman trees: the counts, the
 * lengths of the bit length codes, the literal tree and the distance tree.
 * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
 */
void send_all_trees(int lcodes, int dcodes, int blcodes)
    //int lcodes, dcodes, blcodes; /* number of codes for each tree */
{
    int rank;                    /* index in bl_order */

    Assert(lcodes >= 257 && dcodes >= 1 && blcodes >= 4);//, "not enough codes");
    Assert(lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES);//,
            //"too many codes");

    send_bits(lcodes-257, 5);
    /* not +255 as stated in appnote.txt 1.93a or -256 in 2.04c */
    send_bits(dcodes-1,   5);
    send_bits(blcodes-4,  4); /* not -3 as stated in appnote.txt */
    for (rank = 0; rank < blcodes; rank++) {
        send_bits(bl_tree[bl_order[rank]].Len, 3);
    }

    send_tree((ct_data near *)dyn_ltree, lcodes-1); /* send the literal tree */

    send_tree((ct_data near *)dyn_dtree, dcodes-1); /* send the distance tree */
}
Ejemplo n.º 4
0
/* ===========================================================================
 * Send the header for a block using dynamic Huffman trees: the counts, the
 * lengths of the bit length codes, the literal tree and the distance tree.
 * IN assertion: lcodes >= 257, dcodes >= 1, blcodes >= 4.
 */
void send_all_trees(TState &state,int lcodes, int dcodes, int blcodes)
{
    int rank;                    /* index in bl_order */

    Assert(state,lcodes >= 257 && dcodes >= 1 && blcodes >= 4, "not enough codes");
    Assert(state,lcodes <= L_CODES && dcodes <= D_CODES && blcodes <= BL_CODES,
            "too many codes");
    Trace("\nbl counts: ");
    send_bits(state,lcodes-257, 5);
    /* not +255 as stated in appnote.txt 1.93a or -256 in 2.04c */
    send_bits(state,dcodes-1,   5);
    send_bits(state,blcodes-4,  4); /* not -3 as stated in appnote.txt */
    for (rank = 0; rank < blcodes; rank++) {
        Trace("\nbl code %2d ", bl_order[rank]);
        send_bits(state,state.ts.bl_tree[bl_order[rank]].dl.len, 3);
    }    
    Trace("\nbl tree: sent %ld", state.bs.bits_sent);

    send_tree(state,(ct_data *)state.ts.dyn_ltree, lcodes-1); /* send the literal tree */
    Trace("\nlit tree: sent %ld", state.bs.bits_sent);

    send_tree(state,(ct_data *)state.ts.dyn_dtree, dcodes-1); /* send the distance tree */
    Trace("\ndist tree: sent %ld", state.bs.bits_sent);
}