## schrounpack schrounpack |

## Synopsis

                        SchroUnpack;
    void                schro_unpack_byte_sync              (SchroUnpack *unpack);
    void                schro_unpack_copy                   (SchroUnpack *dest,
                                                             SchroUnpack *src);
    unsigned int        schro_unpack_decode_bit             (SchroUnpack *unpack);
    unsigned int        schro_unpack_decode_bits            (SchroUnpack *unpack,
                                                             int n);
    int                 schro_unpack_decode_sint            (SchroUnpack *unpack);
    void                schro_unpack_decode_sint_s16        (int16_t *dest,
                                                             SchroUnpack *unpack,
                                                             int n);
    int                 schro_unpack_decode_sint_slow       (SchroUnpack *unpack);
    unsigned int        schro_unpack_decode_uint            (SchroUnpack *unpack);
    int                 schro_unpack_get_bits_read          (SchroUnpack *unpack);
    int                 schro_unpack_get_bits_remaining     (SchroUnpack *unpack);
    void                schro_unpack_init_with_data         (SchroUnpack *unpack,
                                                             uint8_t *data,
                                                             int n_bytes,
                                                             unsigned int guard_bit);
    void                schro_unpack_limit_bits_remaining   (SchroUnpack *unpack,
                                                             int n_bits);
    void                schro_unpack_skip_bits              (SchroUnpack *unpack,
                                                             int n_bits);

## Description

## Details

### SchroUnpack

    typedef struct {
      /* pointer to data that haven't been shifted into the shift register */
      uint8_t *data;

      /* number of bits remaining that haven't been shifted into the shift
       * register */
      int n_bits_left;

      /* number of bits read by reader */
      int n_bits_read;

      /* chunk of bits we're currently frobbing, aligned to (1<<31) */
      uint32_t shift_register;
      int n_bits_in_shift_register;

      /* bit pattern used after an error */
      unsigned int guard_bit;

      /* unpacking has overrun the end of the buffer */
      int overrun;
    } SchroUnpack;

### schro_unpack_byte_sync ()

    void                schro_unpack_byte_sync              (SchroUnpack *unpack);

`unpack` : |

### schro_unpack_copy ()

    void                schro_unpack_copy                   (SchroUnpack *dest,
                                                             SchroUnpack *src);

`dest` : |
`src` : |

### schro_unpack_decode_bit ()

    unsigned int        schro_unpack_decode_bit             (SchroUnpack *unpack);

`unpack` : |
Returns : |

### schro_unpack_decode_bits ()

    unsigned int        schro_unpack_decode_bits            (SchroUnpack *unpack,
                                                             int n);

`unpack` : |
`n` : |
Returns : |

### schro_unpack_decode_sint ()

    int                 schro_unpack_decode_sint            (SchroUnpack *unpack);

`unpack` : |
Returns : |

### schro_unpack_decode_sint_s16 ()

    void                schro_unpack_decode_sint_s16        (int16_t *dest,
                                                             SchroUnpack *unpack,
                                                             int n);

`dest` : |
`unpack` : |
`n` : |

### schro_unpack_decode_sint_slow ()

    int                 schro_unpack_decode_sint_slow       (SchroUnpack *unpack);

`unpack` : |
Returns : |

### schro_unpack_decode_uint ()

    unsigned int        schro_unpack_decode_uint            (SchroUnpack *unpack);

`unpack` : |
Returns : |

### schro_unpack_get_bits_read ()

    int                 schro_unpack_get_bits_read          (SchroUnpack *unpack);

`unpack` : |
Returns : |

### schro_unpack_get_bits_remaining ()

    int                 schro_unpack_get_bits_remaining     (SchroUnpack *unpack);

`unpack` : |
Returns : |

### schro_unpack_init_with_data ()

    void                schro_unpack_init_with_data         (SchroUnpack *unpack,
                                                             uint8_t *data,
                                                             int n_bytes,
                                                             unsigned int guard_bit);

`unpack` : |
`data` : |
`n_bytes` : |
`guard_bit` : |

### schro_unpack_limit_bits_remaining ()

    void                schro_unpack_limit_bits_remaining   (SchroUnpack *unpack,
                                                             int n_bits);

`unpack` : |
`n_bits` : |

### schro_unpack_skip_bits ()

    void                schro_unpack_skip_bits              (SchroUnpack *unpack,
                                                             int n_bits);

`unpack` : |
`n_bits` : |