Re: Unpacking params in xferfaxlog
Lee Howard <[email protected]> Mon, 21 Jun 2010 22:02:53 -0700
| Newsgroups | gmane.comp.telephony.fax.hylafax.devel |
|---|---|
| Message-ID | <[email protected]> |
Models wrote:
> The man pages and docs indicate the job parameters such as speed,
> compression, etc., are stored in the params field in the xferfaxlog,
> and identifies them as:
>
> 2 bits for vertical resolution,
> 3 bits for signalling rate,
> 3 bits for page width,
> 2 bits for page length,
> 2 bits for data format,
> 1 bit for ECM use,
> 1 bit of BF use, and
> 3 bits for the min scanline time.
>
> Total of 17 bits, which should be a 6-digit integer.... but all the
> params values in my xferfaxlog are 7 digits, such as 2220072.
>
> I need to run a report that includes the baud rate, format, and ECM
> for each transmission, but for the life of me, I can't unpack the
> values from the params field. Are they documented anywhere? I've
> tried comparing the values from xferfaxlog with the doneq files, but
> still can't match the bits.
>
> Suggestions?
>
> I'm using 4.2.1 on Slackware (yes, it's old, but it has been running
> flawlessly for years and they don't want me to touch it!)
The xferfaxlog man page is wrong (and very outdated) there. VR was
originally only one bit, not two.
The method to decode is found in the source code in the
Class2Params::decode function. It looks like this:
void
Class2Params::decode(u_int v)
{
if (v>>21 == 1) { // check version
vr = ((v>>0) & 7); // VR is a bitmap
br = (v>>3) & 15;
wd = (v>>9) & 7;
ln = (v>>12) & 3;
if (ln == LN_LET) // force protocol value
ln = LN_A4;
df = (v>>14) & 3;
ec = (v>>16) & 1;
bf = (v>>17) & 1;
st = (v>>18) & 7;
} else { // original version
vr = (v>>0) & 1;
br = (v>>1) & 7;
wd = (v>>4) & 7;
ln = (v>>7) & 3;
if (ln == LN_LET) // force protocol value
ln = LN_A4;
df = (v>>9) & 3;
ec = (v>>11) & 1;
bf = (v>>12) & 1;
st = (v>>13) & 7;
}
}
The meanings of the values you'll need to extract from the source code
in util/class2.h.
So... because bit 22 (2220072 >> 21) is 1 it means that you have the new
version. (The new version began with 4.2.0.)
VR (resolution) is represented in bitmap format by the first three
bits. (2220072 >> 0 & 7) is 0. So the resolution was "normal".
BR (bitrate) is represented by bits 4-7. (2220072>>3 & 15) is 5. So
the bitrate was 14400 bps.
WD (page width) is represented by bits 10-12 (yes, bits 8-9 are
unused). (2220072>>9 & 7) is 0. So the page width was A4.
LN (page length) is represented by bits 13-14. (2220072>>12 & 3) is 2.
So the page length was "unlimited".
DF (data format) is represented by bits 15-16. (2220072>>14 & 3) is 3.
So the data format was MMR.
EC (error correction) is represented by bit 17. (2220072>>16 & 1) is
1. So ECM was used.
BF (binary format - unused feature) is represented by bit 18.
(2220072>>17 & 1) is 0. So no binary format was used, naturally.
ST (scanline time) is represented by bits 19-21. (2220072>>18 & 7) is
0. So scanline-time was 0 ms.
Be aware that in versions of HylaFAX 4.2.2 and later that FaxDCS
progressively begins to obsolete params as new versions are released. A
single 32-bit integer simply cannot hold all of the potential fax
parameters available. So in the newest HylaFAX and HylaFAX+ versions
features such as JBIG and JPEG are not reliably encoded in the params
value (to get them into params yet another version of the params
encoding would have been required), and must therefore be decoded from
the FaxDCS value. FaxDCS is decoded via ITU T.30 Table 2. It is the
DCS signal delivered by the sender to the receiver. But with 4.2.1
you'll not have to worry about this, and unless you ever employ JBIG or
JPEG fax support with later HylaFAX versions, then you'll not have to
worry about FaxDCS. The nice thing about FaxDCS, however, is that you
don't have to refer to HylaFAX code in order to parse it.
Thanks,
Lee.
____________________ HylaFAX(tm) Developers Mailing List ____________________
To subscribe/unsubscribe, click http://lists.hylafax.org/cgi-bin/lsg2.cgi
On UNIX: mail -s unsubscribe [email protected] < /dev/null