## schroarith

schroarith

## Synopsis

                        SchroArith;
                        SchroArithContext;
    SchroArith*         schro_arith_new                     (void);
    void                schro_arith_free                    (SchroArith *arith);
    void                schro_arith_decode_init             (SchroArith *arith,
                                                             SchroBuffer *buffer);
    void                schro_arith_encode_init             (SchroArith *arith,
                                                             SchroBuffer *buffer);
    void                schro_arith_flush                   (SchroArith *arith);
    int                 schro_arith_decode_bit              (SchroArith *arith,
                                                             int context);
    void                schro_arith_decode_flush            (SchroArith *arith);
    int                 schro_arith_decode_sint             (SchroArith *arith,
                                                             int cont_context,
                                                             int value_context,
                                                             int sign_context);
    int                 schro_arith_decode_uint             (SchroArith *arith,
                                                             int cont_context,
                                                             int value_context);
    void                schro_arith_encode_bit              (SchroArith *arith,
                                                             int context,
                                                             int value);
    void                schro_arith_encode_sint             (SchroArith *arith,
                                                             int cont_context,
                                                             int value_context,
                                                             int sign_context,
                                                             int value);
    void                schro_arith_encode_uint             (SchroArith *arith,
                                                             int cont_context,
                                                             int value_context,
                                                             int value);
    void                schro_arith_estimate_bit            (SchroArith *arith,
                                                             int i,
                                                             int value);
    void                schro_arith_estimate_init           (SchroArith *arith);
    void                schro_arith_estimate_sint           (SchroArith *arith,
                                                             int cont_context,
                                                             int value_context,
                                                             int sign_context,
                                                             int value);
    void                schro_arith_estimate_uint           (SchroArith *arith,
                                                             int cont_context,
                                                             int value_context,
                                                             int value);

## Description

## Details

### SchroArith

    typedef struct {
      uint32_t range[2];
      uint32_t code;
      uint32_t range_size;
      uint16_t probabilities[SCHRO_CTX_LAST];
      uint8_t shift;
      uint16_t lut[512];

      int cntr;

      uint8_t *dataptr;
      int offset;
      int carry;
      SchroArithContext contexts[SCHRO_CTX_LAST];

      SchroBuffer *buffer;
    } SchroArith;

### SchroArithContext

    typedef struct {
      int next;
      int stat_range;
      int n_bits;
      int n_symbols;
      int ones;
    } SchroArithContext;

### schro_arith_new ()

    SchroArith*         schro_arith_new                     (void);

Returns : |

### schro_arith_free ()

    void                schro_arith_free                    (SchroArith *arith);

`arith` : |

### schro_arith_decode_init ()

    void                schro_arith_decode_init             (SchroArith *arith,
                                                             SchroBuffer *buffer);

`arith` : |
`buffer` : |

### schro_arith_encode_init ()

    void                schro_arith_encode_init             (SchroArith *arith,
                                                             SchroBuffer *buffer);

`arith` : |
`buffer` : |

### schro_arith_flush ()

    void                schro_arith_flush                   (SchroArith *arith);

`arith` : |

### schro_arith_decode_bit ()

    int                 schro_arith_decode_bit              (SchroArith *arith,
                                                             int context);

`arith` : |
`context` : |
Returns : |

### schro_arith_decode_flush ()

    void                schro_arith_decode_flush            (SchroArith *arith);

`arith` : |

### schro_arith_decode_sint ()

    int                 schro_arith_decode_sint             (SchroArith *arith,
                                                             int cont_context,
                                                             int value_context,
                                                             int sign_context);

`arith` : |
`cont_context` : |
`value_context` : |
`sign_context` : |
Returns : |

### schro_arith_decode_uint ()

    int                 schro_arith_decode_uint             (SchroArith *arith,
                                                             int cont_context,
                                                             int value_context);

`arith` : |
`cont_context` : |
`value_context` : |
Returns : |

### schro_arith_encode_bit ()

    void                schro_arith_encode_bit              (SchroArith *arith,
                                                             int context,
                                                             int value);

`arith` : |
`context` : |
`value` : |

### schro_arith_encode_sint ()

    void                schro_arith_encode_sint             (SchroArith *arith,
                                                             int cont_context,
                                                             int value_context,
                                                             int sign_context,
                                                             int value);

`arith` : |
`cont_context` : |
`value_context` : |
`sign_context` : |
`value` : |

### schro_arith_encode_uint ()

    void                schro_arith_encode_uint             (SchroArith *arith,
                                                             int cont_context,
                                                             int value_context,
                                                             int value);

`arith` : |
`cont_context` : |
`value_context` : |
`value` : |

### schro_arith_estimate_bit ()

    void                schro_arith_estimate_bit            (SchroArith *arith,
                                                             int i,
                                                             int value);

`arith` : |
`i` : |
`value` : |

### schro_arith_estimate_init ()

    void                schro_arith_estimate_init           (SchroArith *arith);

`arith` : |

### schro_arith_estimate_sint ()

    void                schro_arith_estimate_sint           (SchroArith *arith,
                                                             int cont_context,
                                                             int value_context,
                                                             int sign_context,
                                                             int value);

`arith` : |
`cont_context` : |
`value_context` : |
`sign_context` : |
`value` : |

### schro_arith_estimate_uint ()

    void                schro_arith_estimate_uint           (SchroArith *arith,
                                                             int cont_context,
                                                             int value_context,
                                                             int value);

`arith` : |
`cont_context` : |
`value_context` : |
`value` : |