## schroutils

schroutils

## Synopsis

    typedef             schro_bool;
    #define             SCHRO_GET                           (ptr, offset, type)
    #define             OFFSET                              (ptr,offset)
    #define             SCHRO_INTERNAL
    #define             ARRAY_SIZE                          (x)
    #define             MIN                                 (a,b)
    #define             MAX                                 (a,b)
    #define             CLAMP                               (x,a,b)
    #define             DIVIDE_ROUND_UP                     (a,b)
    #define             ROUND_UP_SHIFT                      (x,y)
    #define             ROUND_UP_POW2                       (x,y)
    #define             ROUND_UP_2                          (x)
    #define             ROUND_UP_4                          (x)
    #define             ROUND_UP_8                          (x)
    #define             ROUND_UP_64                         (x)
    #define             ROUND_SHIFT                         (x,y)
    #define             NEED_CLAMP                          (x,y,a,b)
    #define             schro_divide                        (a,b)
    double              schro_utils_entropy                 (double a,
                                                             double total);
    int                 schro_utils_multiplier_to_quant_index
                                                            (double x);
    double              schro_utils_probability_to_entropy  (double x);
    void                schro_utils_reduce_fraction         (int *n,
                                                             int *d);
    int                 schro_dequantise                    (int q,
                                                             int quant_factor,
                                                             int quant_offset);
    int                 schro_quantise                      (int value,
                                                             int quant_factor,
                                                             int quant_offset);
    void                schro_dequantise_s16                (int16_t *dest,
                                                             int16_t *src,
                                                             int quant_factor,
                                                             int quant_offset,
                                                             int n);
    void                schro_quantise_s16                  (int16_t *dest,
                                                             int16_t *src,
                                                             int quant_factor,
                                                             int quant_offset,
                                                             int n);
    void *              schro_malloc                        (int size);
    void *              schro_malloc0                       (int size);
    void *              schro_realloc                       (void *ptr,
                                                             int size);
    void                schro_free                          (void *ptr);
    double              schro_utils_get_time                (void);
    int                 muldiv64                            (int a,
                                                             int b,
                                                             int c);

## Description

## Details

### schro_bool

    typedef unsigned int schro_bool;

### SCHRO_GET()

    #define SCHRO_GET(ptr, offset, type) (*(type *)((uint8_t *)(ptr) + (offset)) )

`ptr` : |
`offset` : |
`type` : |

### OFFSET()

    #define OFFSET(ptr,offset) ((void *)(((uint8_t *)(ptr)) + (offset)))

`ptr` : |
`offset` : |

### SCHRO_INTERNAL

    #define             SCHRO_INTERNAL

### ARRAY_SIZE()

    #define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))

`x` : |

### MIN()

    #define MIN(a,b) ((a)<(b) ? (a) : (b))

`a` : |
`b` : |

### MAX()

    #define MAX(a,b) ((a)>(b) ? (a) : (b))

`a` : |
`b` : |

### CLAMP()

    #define CLAMP(x,a,b) ((x)<(a) ? (a) : ((x)>(b) ? (b) : (x)))

`x` : |
`a` : |
`b` : |

### DIVIDE_ROUND_UP()

    #define DIVIDE_ROUND_UP(a,b) (((a) + (b) - 1)/(b))

`a` : |
`b` : |

### ROUND_UP_SHIFT()

    #define ROUND_UP_SHIFT(x,y) (((x) + (1<<(y)) - 1)>>(y))

`x` : |
`y` : |

### ROUND_UP_POW2()

    #define ROUND_UP_POW2(x,y) (((x) + (1<<(y)) - 1)&((~0)<<(y)))

`x` : |
`y` : |

### ROUND_UP_2()

    #define ROUND_UP_2(x) ROUND_UP_POW2(x,1)

`x` : |

### ROUND_UP_4()

    #define ROUND_UP_4(x) ROUND_UP_POW2(x,2)

`x` : |

### ROUND_UP_8()

    #define ROUND_UP_8(x) ROUND_UP_POW2(x,3)

`x` : |

### ROUND_UP_64()

    #define ROUND_UP_64(x) ROUND_UP_POW2(x,6)

`x` : |

### ROUND_SHIFT()

    #define ROUND_SHIFT(x,y) (((x) + (1<<((y)-1)))>>(y))

`x` : |
`y` : |

### NEED_CLAMP()

    #define NEED_CLAMP(x,y,a,b) ((x) < (a) || (y) > (b))

`x` : |
`y` : |
`a` : |
`b` : |

### schro_divide()

    #define schro_divide(a,b) (((a)<0)?(((a) - (b) + 1)/(b)):((a)/(b)))

`a` : |
`b` : |

### schro_utils_entropy ()

    double              schro_utils_entropy                 (double a,
                                                             double total);

`a` : |
`total` : |
Returns : |

### schro_utils_multiplier_to_quant_index ()

    int                 schro_utils_multiplier_to_quant_index
                                                            (double x);

`x` : |
Returns : |

### schro_utils_probability_to_entropy ()

    double              schro_utils_probability_to_entropy  (double x);

`x` : |
Returns : |

### schro_utils_reduce_fraction ()

    void                schro_utils_reduce_fraction         (int *n,
                                                             int *d);

`n` : |
`d` : |

### schro_dequantise ()

    int                 schro_dequantise                    (int q,
                                                             int quant_factor,
                                                             int quant_offset);

`q` : |
`quant_factor` : |
`quant_offset` : |
Returns : |

### schro_quantise ()

    int                 schro_quantise                      (int value,
                                                             int quant_factor,
                                                             int quant_offset);

`value` : |
`quant_factor` : |
`quant_offset` : |
Returns : |

### schro_dequantise_s16 ()

    void                schro_dequantise_s16                (int16_t *dest,
                                                             int16_t *src,
                                                             int quant_factor,
                                                             int quant_offset,
                                                             int n);

`dest` : |
`src` : |
`quant_factor` : |
`quant_offset` : |
`n` : |

### schro_quantise_s16 ()

    void                schro_quantise_s16                  (int16_t *dest,
                                                             int16_t *src,
                                                             int quant_factor,
                                                             int quant_offset,
                                                             int n);

`dest` : |
`src` : |
`quant_factor` : |
`quant_offset` : |
`n` : |

### schro_malloc ()

    void *              schro_malloc                        (int size);

`size` : |
Returns : |

### schro_malloc0 ()

    void *              schro_malloc0                       (int size);

`size` : |
Returns : |

### schro_realloc ()

    void *              schro_realloc                       (void *ptr,
                                                             int size);

`ptr` : |
`size` : |
Returns : |

### schro_free ()

    void                schro_free                          (void *ptr);

`ptr` : |

### schro_utils_get_time ()

    double              schro_utils_get_time                (void);

Returns : |

### muldiv64 ()

    int                 muldiv64                            (int a,
                                                             int b,
                                                             int c);

`a` : |
`b` : |
`c` : |
Returns : |