Code Monkey home page Code Monkey logo

iobit's Introduction

iobit GoDoc Build Status

Package iobit provides primitives for reading & writing bits The main purpose of this library is to remove the need to write custom bit-masks when reading or writing bitstreams, and to ease maintenance.

Download:

go get github.com/bamiaux/iobit

Full documentation at http://godoc.org/github.com/bamiaux/iobit


Package iobit provides primitives for reading & writing bits

The main purpose of this library is to remove the need to write custom bit-masks when reading or writing bitstreams, and to ease maintenance. This is true especially when you need to read/write data which is not aligned on bytes.

Errors are sticky so you can check for errors after a chunk of meaningful work rather than after every operation.

For example, with iobit you can read an MPEG-TS PCR like this:

r := iobit.NewReader(buffer)
base := r.Uint64(33)     // PCR base is 33-bits
r.Skip(6)                // 6-bits are reserved
extension := r.Uint64(9) // PCR extension is 9-bits

instead of:

base  = uint64(buffer[0]) << 25
base |= uint64(buffer[1]) << 17
base |= uint64(buffer[2]) << 9
base |= uint64(buffer[3]) << 1
base |= buffer[4] >> 7
extension := uint16(buffer[4] & 0x1) << 8
extension |= buffer[5]

and write it like this:

w := iobit.NewWriter(buffer)
w.PutUint64(33, base)
w.PutUint32(6, 0)
w.PutUint32(9, extension)

iobit's People

Contributors

bamiaux avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.