Subject: [rohc] RFC 3095 scaled TS - Part II : Scaled RTP Timestamp encoding

From: "Lars-Erik Jonsson \(LU/EAB\)" <[email-masked]>
Date: Thu, 31 Aug 2006 15:04:24 +0200

ROHCers,

When reviewing the timestamp encoding part of the implementer's guide,
some inconsistencies and confusing details have been identified. This
mail is the second out of two addressing these issues.

Section 4.4 and 4.5 of the implementers guide (currently revision 19)
corrects two specific technical flaws in the algorithm for scaled TS
encoding defined by RFC 3095, more specifically the inconsistent
TS_STRIDE definition and the non-working procedure for handling TS
wraparound. There are no more known technical problems with the
algorithm specified, but the text is hard to parse and interpret with
inconsistent and undefined terminology. Therefore, it is suggested to
rewrite the whole algorithm part, i.e. also 1) and 3) in addition to
2) and 4) already covered. The suggestion below merges section 4.4 and
section 4.5 into one section 4.4 with subsections.

OLD 4.4 and 4.5:
---------------------------------------------------------
4.4. TS_STRIDE for scaled timestamp encoding

RFC 3095 defines the timestamp stride (TS_STRIDE) as the expected
increase in the timestamp value between two RTP packets with consecutive
sequence numbers. TS_STRIDE is set by the compressor and explicitly
communicated to the decompressor, and it is used either as the scaling
factor for scaled TS encoding, or constitutes the default-slope used
when decompressing an unscaled TS through a linear extrapolation from
the SN (see also section ‎4.2 of this document).

The relation between TS and TS_SCALED, given by the following equality
in section 4.5.3, defines the mathematical meaning of TS_STRIDE:

   TS = TS_SCALED * TS_STRIDE + TS_OFFSET

TS_SCALED is incorrectly written as TS / TS_STRIDE in the compression
step following the above core equality. This formula is incorrect both
because it excludes TS_OFFSET and because it would prevent a TS_STRIDE
value of 0, which is an alternative not excluded by the core equality
above. If "/" were a generally unambiguously defined operation meaning
"the integral part of the result from dividing X by Y", the absence of
TS_OFFSET could be explained, but the formula would still lack a proper
output for TS_STRIDE equal to 0. The formula of "2. Compression" is thus
invalid.

INCORRECT RFC 3095 TEXT (section 4.5.3):

   "2. Compression: After initialization, the compressor no longer
       compresses the original TS values. Instead, it compresses the
       downscaled values: TS_SCALED = TS / TS_STRIDE. The
       compression method could be either W-LSB encoding or the
       timer-based encoding described in the next section."

CORRECTED TEXT:

   "2. Compression: After initialization, the compressor no longer
       compresses the original TS values. Instead, it compresses the
       downscaled values. The compression method could be either
       W-LSB encoding or the timer-based encoding described in the
       next section."

4.5. TS wraparound with scaled timestamp encoding

Section 4.5.3 states in point 4 and 5 that the compressor is not
required to initialize TS_OFFSET at wraparound, but that it is required
to increase the number of bits sent for the scaled TS value when there
is a TS wraparound. The decompressor is also required to detect and cope
with TS wraparound, including updating TS_OFFSET.

This method is not interoperable and not robust. The gain is also
insignificant, as TS wraparound happens very seldom. Therefore, the
compressor reinitializes TS_OFFSET upon TS wraparound, by sending
unscaled TS.

INCORRECT RFC 3095 TEXT (section 4.5.3):

   "4. Offset at wraparound: Wraparound of the unscaled 32-bit TS
       will invalidate the current value of TS_OFFSET used in the
       equation above. For example, let us assume TS_STRIDE = 160 =
       0xA0 and the current TS = 0xFFFFFFF0. TS_OFFSET is then 0x50
       = 80.  Then if the next RTP TS = 0x00000130 (i.e., the
       increment is 160 * 2 = 320), the new TS_OFFSET should be
       0x00000130 modulo 0xA0 = 0x90 = 144.  The compressor is not
       required to re-initialize TS_OFFSET at wraparound. Instead,
       the decompressor MUST detect wraparound of the unscaled TS
       (which is trivial) and update TS_OFFSET to

       TS_OFFSET = (Wrapped around unscaled TS) modulo TS_STRIDE
 
CORRECTED TEXT:

   "4. Offset at wraparound: If the value of TS_STRIDE is not equal
       to a power of two, wraparound of the unscaled 32-bit TS will
       change the value of TS_OFFSET. When this happens, the
       compressor SHOULD reinitialize TS_OFFSET by sending unscaled
       TS, as in 1 above."

INCORRECT AND INVALIDATED RFC 3095 TEXT (section 4.5.3):

   The entire point 5, i.e. the entire text starting from "5.
   Interpretation interval at wraparound ...", down to and including
   the block of text that starts with "Let a be the number of LSBs"
   and that ends with "...interpretation interval is b." is incorrect 
   and is thus invalid.
---------------------------------------------------------

NEW:
---------------------------------------------------------
4.4. Scaled RTP timestamp encoding

This section redefines the algorithm for scaled RTP timestamp encoding,
defined as a 5-step procedure in section 4.5.3. Two formal errors have
been corrected, as described in subsections 4.4.1 and 4.4.2 below, and
the whole algorithm has been reworked to be more concise and use well-
defined terminology. The resulting text can be found in 4.4.3 below.

4.4.1. TS_STRIDE for scaled timestamp encoding

RFC 3095 defines the timestamp stride (TS_STRIDE) as the expected
increase in the timestamp value between two RTP packets with consecutive
sequence numbers. TS_STRIDE is set by the compressor and explicitly
communicated to the decompressor, and it is used as the scaling factor
for scaled TS encoding.

The relation between TS and TS_SCALED, given by the following equality
in section 4.5.3, defines the mathematical meaning of TS_STRIDE:

   TS = TS_SCALED * TS_STRIDE + TS_OFFSET

TS_SCALED is incorrectly written as TS / TS_STRIDE in the compression
step following the above core equality. This formula is incorrect both
because it excludes TS_OFFSET and because it would prevent a TS_STRIDE
value of 0, which is an alternative not excluded by the definition or by
the core equality above. If "/" were a generally unambiguously defined
operation meaning "the integral part of the result from dividing X by
Y", the absence of TS_OFFSET could be explained, but the formula would
still lack a proper output for TS_STRIDE equal to 0. The formula of
"2. Compression" is thus invalid.

4.4.2. TS wraparound with scaled timestamp encoding

Section 4.5.3 states in point 4 and 5 that the compressor is not
required to initialize TS_OFFSET at wraparound, but that it is required
to increase the number of bits sent for the scaled TS value when there
is a TS wraparound. The decompressor is also required to detect and cope
with TS wraparound, including updating TS_OFFSET.

This method is not interoperable and not robust. The gain is also
insignificant, as TS wraparound happens very seldom. Therefore, the
compressor reinitializes TS_OFFSET upon TS wraparound, by sending
unscaled TS.

4.4.3. Algorithm for scaled timestamp encoding

INCORRECT RFC 3095 TEXT (section 4.5.3):

   "1. Initialization: The compressor sends to the decompressor the
       value of TS_STRIDE and the absolute value of one or several TS
       fields. The latter are used by the decompressor to initialize
       TS_OFFSET to (absolute value) modulo TS_STRIDE. Note that
       TS_OFFSET is the same regardless of which absolute value is used,
       as long as the unscaled TS value does not wrap around; see 4)
       below.

    2. Compression: After initialization, the compressor no longer
       compresses the original TS values. Instead, it compresses the
       downscaled values: TS_SCALED = TS / TS_STRIDE. The
       compression method could be either W-LSB encoding or the
       timer-based encoding described in the next section.

    3. Decompression: When receiving the compressed value of TS_SCALED,
       the decompressor first derives the value of the original
       TS_SCALED.  The original RTP TS is then calculated as TS =
       TS_SCALED * TS_STRIDE + TS_OFFSET.

    4. Offset at wraparound: Wraparound of the unscaled 32-bit TS
       will invalidate the current value of TS_OFFSET used in the
       equation above. For example, let us assume TS_STRIDE = 160 =
       0xA0 and the current TS = 0xFFFFFFF0. TS_OFFSET is then 0x50
       = 80.  Then if the next RTP TS = 0x00000130 (i.e., the
       increment is 160 * 2 = 320), the new TS_OFFSET should be
       0x00000130 modulo 0xA0 = 0x90 = 144.  The compressor is not
       required to re-initialize TS_OFFSET at wraparound. Instead,
       the decompressor MUST detect wraparound of the unscaled TS
       (which is trivial) and update TS_OFFSET to

       TS_OFFSET = (Wrapped around unscaled TS) modulo TS_STRIDE
 
CORRECTED TEXT:

   "1. Initialization and updating of RTP TS scaling function:
       The compressor sends to the decompressor the value of TS_STRIDE
       along with an unscaled TS. These are both needed by the
       decompressor to initialize TS_OFFSET as hdr(TS) modulo
       field(TS_STRIDE). Note that TS_OFFSET is the same for any TS as
       long as TS_STRIDE does not change and as long as the unscaled TS
       	value does not wrap around; see 4) below.

    2. Compression: After initialization, the compressor no longer
       compresses the unscaled TS values. Instead, it compresses the
       scaled values. The compression method can be either W-LSB
       encoding or timer-based encoding.

    3. Decompression: When receiving a (compressed) TS_SCALED, the
       field is first decompressed, and the unscaled RTP TS is then
       calculated as TS = TS_SCALED * TS_STRIDE + TS_OFFSET.

    4. Offset at wraparound: If the value of TS_STRIDE is not equal
       to a power of two, wraparound of the unscaled 32-bit TS will
       change the value of TS_OFFSET. When this happens, the
       compressor SHOULD reinitialize TS_OFFSET by sending unscaled
       TS, as in 1 above."

INCORRECT AND INVALIDATED RFC 3095 TEXT (section 4.5.3):

   The entire point 5, i.e. the entire text starting from "5.
   Interpretation interval at wraparound ...", down to and including
   the block of text that starts with "Let a be the number of LSBs"
   and that ends with "...interpretation interval is b." is incorrect 
   and is thus invalid.
---------------------------------------------------------

Any comments on these changes?
/L-E

-----------------------------------
Lars-Erik Jonsson, M.Sc.
Senior Research Engineer
Wireless IP Optimizations
AWARE - Advanced Wireless Algorithm Research
Ericsson Research, Corporate Unit
Ericsson AB
Box 920, S-971 28 Luleå, Sweden
E-mail: [email-masked]                      /"\
Phone: +46 8 404 29 61                                      \ /
Fax: +46 920 996 21               ASCII Ribbon Campaign      X
Home: +46 63 355 24            against HTML email & vCards  / \

My opinions are my personal opinions and should not be considered
as the opinions of my employer, if not explicitly stated.
_______________________________________________
Rohc mailing list
[email-masked]
https://www1.ietf.org/mailman/listinfo/rohc