DevSteven Services

Codecs

EVS Compact mode, Header-Full framing and CMR in Asterisk

Getting EVS to negotiate is the easy part. Operators send it in two different framings and steer the sender with Codec Mode Requests. A decoder that guesses the framing or ignores those requests produces silence, garbled audio or the wrong bit rate. This is what we changed to make it behave.

Two framings, one session

3GPP TS 26.445 Annex A defines how EVS (and AMR-WB IO mode, the interoperable AMR-WB format inside EVS) is carried in RTP:

  • Compact has no header. The payload size alone tells the decoder the bit rate.
  • Header-Full has a ToC byte, and optionally a CMR byte, in front of the speech bits.

With hf-only=0 (the default in the SDP) a peer may send both framings in the same session. With hf-only=1, or cmr=1 (a CMR in every packet), Header-Full is required. Treating a Header-Full packet as Compact decodes the header bytes as speech and produces silence.

What we changed

  • Per-packet detection of Compact versus Header-Full on receive, so a session that mixes both works.
  • Header-Full when the peer asked for it: the encoder sends Header-Full whenever the peer negotiated cmr=1 or hf-only=1, and Compact otherwise.
  • AMR-WB IO Compact: the 3-bit CMR is decoded correctly and the encoder builds the payload as 3-bit CMR, speech bits, with the first bit relocated, as the specification lays it out. A byte-order error in this path was fixed in version 3.4.1 after live testing.
  • CMR is honoured. When a peer requests a different mode, the encoder changes its bit rate and bandwidth. Earlier builds ignored every request because the check could never be true.
  • Hardened decoder input (version 3.4.3): a whitelist of bit rates valid in Compact mode, rejection of reserved ToC modes, and bounds checks on payload length. A malformed packet is dropped, not decoded.
  • Stability under load (version 3.4.2): library hardening that removed periodic Asterisk restarts under EVS load.

Behaviour change to know about

Because CMR is honoured, Asterisk now changes its encoder bit rate when the far side asks. If you compared call quality or bandwidth before and after, this is the cause. It is what the specification and most operators expect.

What you see in the SDP

a=rtpmap:100 EVS/16000/1
a=fmtp:100 br=13.2;bw=wb;hf-only=0;cmr=0

Delivery

The EVS library ships as two RPMs (library and headers, treated as one ABI unit) and codec_evs.so is rebuilt against those headers. The result is reproducible and identical on every server.

Reference3GPP TS 26.445, Annex A (RTP payload format)
StatusTested in production; in the master line since 3.4

Related

Need this on your platform? Tell us the Asterisk version and the interconnect, and we reply within 24 hours.

Request a quote