rcsa 0.2.1

DVB Common Scrambling Algorithm (CSA) descrambler and scrambler for MPEG-TS
Documentation
  • Coverage
  • 55.56%
    5 out of 9 items documented0 out of 0 items with examples
  • Size
  • Source code size: 227.0 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 635.9 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 2s Average build duration of successful builds.
  • all releases: 2s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • cesbo/rcsa
    0 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • and-cesbo

rcsa

Pure Rust DVB Common Scrambling Algorithm (DVB-CSA) for MPEG transport streams.

  • Descrambler: descrambles 188-byte TS packets in place with an even/odd control word pair. Payloads after an adaptation field and trailing partial blocks are handled; descrambled packets get their scrambling bits cleared.
  • Scrambler: the reverse, scrambles the payload of every clear packet with the even or the odd control word and sets the scrambling bits. Which packets stay clear (PSI) and when the parity switches is up to the caller.
  • CsaBatch: bitsliced batch of full-payload packets, 64 lanes (u64), 128 lanes (SSE2, NEON) or 256 lanes (AVX2, detected at runtime). Decrypt and encrypt.
  • Csa: one packet at a time, any payload length.

No dependencies; unsafe only in the SIMD backends and their dispatch.

Usage

use rcsa::Descrambler;

let mut descrambler = Descrambler::new();
descrambler.set_even(&cw[.. 8].try_into()?);
descrambler.set_odd(&cw[8 ..].try_into()?);

// a whole number of 188-byte packets; larger buffers are faster
descrambler.descramble(&mut packets);
use rcsa::{Parity, Scrambler};

let mut scrambler = Scrambler::new();
scrambler.set_even(&cw_even);
scrambler.set_odd(&cw_odd);

// packets that must stay clear are not passed in
scrambler.scramble(&mut packets, Parity::Even);

When a new control word takes effect is up to the caller: set_even/set_odd replace the key immediately.

Performance

Descrambling real SD and HD channels, one core of a Xeon E5-2660 v3 (Haswell), buffers of 1024-4096 packets, payload Mbit/s. FFdecsa and libdvbcsa built with -O3 -msse2, rcsa with the default target (AVX2 picked at runtime):

Mbit/s
rcsa 1230-1280
FFdecsa 1070-1090
libdvbcsa 750-765

Without AVX2 (SSE2) rcsa does about 980 Mbit/s on the same CPU.