Hints about decoding of SV8 streams

Return to Basic Components of a SV8 stream.

Detect components:

Read two octets and then lookup in the following table:

Range Possible meaning
0000...1FFF Length Label
0000...0001     impossible
0002...1FFF     possible
2000...3FFF Cutted SV8 Audioframe
2000...31FE     possible
31FF...3FFF     impossible
3FFF...7FFF Tags, Sync Labels, Header
4150     APE Tag 2.0
4944     ID3 Version 2.x Tag
4D50     SV7 / SV8 Header
5441     ID3 Version 1.x Tag
664B     Transport Streaming Synchronization Label
8000...FFDF raw SV8 Audio frame
FFE0...FFFF MPEG Layer 1, 2 or 3 Frame
FFE0...FFE7     MPEG 2.5
FFF0...FFF7     MPEG 2
FFF7...FFFF     MPEG 1

This only showns what may be possible. There're additional restriction which can be used to check validy of the component.

Determine size of components:

Resynchronization of Interchange File Format:

    uint8_t*  p;                                        // Pointer to data stream
    uint16_t  len_pre;
    uint16_t  len_post;

    while ( (p[0] & 0xE0)  ||  (p[2] & 0xE0) )          // search for two length labels (p=1.5%)

    len_pre  = p[2]           * 256 + p[3];             // decode pre and post length label
    len_post = p[4 + len_pre] * 256 + p[5 + len_pre];

    if ( len_pre != len_post ) {                        // they should be the same, otherwise continue with next byte (p=2ppm)
        goto repeat;
    if ( p[6 + len_pre] & 0xE0 ) {                      // after the post length label the pre length label of the next frame (p=0.24ppm)
        p++;                                            // should be available
        goto repeat;
    if ( determine_len (p+4) != len_pre ) {             // test length of stream contents against length labels (p<1ppb)
        goto repeat;
    p += 4;
    // p points to the start of a raw audio frame

[eMail]      [Addr]