> bitstream, but I think that a two pass encoding would do it: the first > to generate the symbols after fDCT/quantization and generate statistics > and a second to generate the optimal tables and encode the huffman This is exactly what the rehuff example does. Nothing has to be applied "by hand".