Skip to main content

Bit Slicer 9k

  • Super fast bitslicing.
  • bitshift speed without bitwise complexity.

Install

pip install bitslicer9k

Help(Slicer9k)

Help on class Slicer9k in module bitslicer9k:

class Slicer9k(builtins.object)
 |  Slicer9k(bites)
 |  
 |  Methods defined here:
 |  
 |  __init__(self, bites)
 |      From bytes to bits
 |  
 |  as90k(self, num_bits)
 |      return bitslice as 90k time
 |  
 |  asdecodedhex(self, num_bits)
 |      return decoded hex of a bitslice
 |  
 |  asflag(self, num_bits=1)
 |      returns one bit as True or False
 |  
 |  ashex(self, num_bits)
 |      return the hex value of a bitslice
 |  
 |  asint(self, num_bits)
 |      Starting at self.idx of self.bits, slice off num_bits of bits.
 |  
 |  ----------------------------------------------------------------------

I used to do this

   from struct import unpack

    sync,two_bytes,one_byte = unpack('>BHB', packet[:4])
    tei = two_bytes >> 15 
    pusi = two_bytes >> 14 & 0x1
    ts_priority = two_bytes >>13 & 0x1
    pid = two_bytes & 0x1fff
    scramble = one_byte >>6
    afc = (one_byte & 48) >> 4
    count = one_byte & 15

Now I use bitslicer9k and do this

    from bitslicer9k import Slicer9k

    header= Slicer9k(packet[:4])
    sync=header.asint(8)
    tei=header.asflag(1)
    pusi=header.asflag(1)
    ts_priority=header.asflag(1)
    pid=header.asint(13)
    scramble=header.asint(2)
    afc=header.asint(2)
    count=header.asint(4)

Example Usage

  • Parse a SCTE 35 splice information section from a hex encoded string
>>> from bitslicer9k import Slicer9k   


>>> bites= bytes.fromhex( 'FC302F000000000000FFFFF00506FEAEF17C4C0019021743554549480000077F9F0808000000002CA56C97110000C4876A2E')


>>> class Splice_Info_Section:    
        def __init__(self,bs):
            self.table_id =bs.ashex(8)
            self.section_syntax_indicator = bs.asflag(1)
            self.private = bs.asflag(1)
            self.reserved=bs.asint(2)
            self.section_length = bs.asint(12)
            self.protocol_version = bs.asint(8)
            self.encrypted_packet =  bs.asflag(1)
            self.encryption_algorithm =bs.asint(6)
            self.pts_adjustment = bs.as90k(33)
            self.cw_index = bs.ashex(8)
            self.tier = bs.ashex(12)
            self.splice_command_length = bs.asint(12)
            self.splice_command_type = bs.asint(8)


>>> bs=Slicer9k(bites)

>>> sps=Splice_Info_Section(bs)

>>> vars(sps)

{'table_id': '0xfc', 'section_syntax_indicator': False, 'private': False, 'reserved': 3, 'section_length': 47,
'protocol_version': 0, 'encrypted_packet': False, 'encryption_algorithm': 0, 'pts_adjustment': '0.000000', 
'cw_index': '0xff', 'tier': '0xfff', 'splice_command_length': 5, 'splice_command_type': 6, 'descriptor_loop_length': 25}

>>> 

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

bitslicer9k-1.0.23.tar.gz (2.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bitslicer9k-1.0.23-py3-none-any.whl (2.8 kB view details)

Uploaded Python 3

File details

Details for the file bitslicer9k-1.0.23.tar.gz.

File metadata

  • Download URL: bitslicer9k-1.0.23.tar.gz
  • Upload date:
  • Size: 2.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.4

File hashes

Hashes for bitslicer9k-1.0.23.tar.gz
Algorithm Hash digest
SHA256 4eb3d2708e0100f6e52ab83c966d57a6158c9b102ea0c6317183440bfe42121b
MD5 aeb6661daa1287ead0c5352a8f7ac23f
BLAKE2b-256 ee2d8e783b7cfb1f6d8de3b5ba64cd09404b2d07451608cc21a55184f2a2b84d

See more details on using hashes here.

File details

Details for the file bitslicer9k-1.0.23-py3-none-any.whl.

File metadata

  • Download URL: bitslicer9k-1.0.23-py3-none-any.whl
  • Upload date:
  • Size: 2.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.38.0 CPython/3.7.4

File hashes

Hashes for bitslicer9k-1.0.23-py3-none-any.whl
Algorithm Hash digest
SHA256 97ebed7251d12bf38387796b3cf1c50087df883e7fe8e28612e67e2a6232f727
MD5 26b256ee22d19bc9cfe1724fa6a7034e
BLAKE2b-256 97f8e814d14ac48d3958f5cb0001bc8fcf294f8a367a1bfea73b0fd83d76d0d0

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.0.23 This release

2 files

1.0.21

2 files

1.0.19

2 files

1.0.15

2 files

1.0.13

2 files

1.0.11

2 files

1.0.9

2 files

1.0.7

2 files

1.0.5

2 files

1.0.3

2 files

1.0.1

2 files

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page