Files
vpx/aom_dsp/divide.h
Alex Converse 1ac1ae73dc Move ANS to aom_dsp.
That's where it lives in aom/master.

Change-Id: I38f405827d9c2d0b06ef5f3bfd7cadc35d5991ef
2016-09-19 09:51:27 -07:00

41 lines
1.1 KiB
C

/*
* Copyright (c) 2015 The WebM project authors. All Rights Reserved.
*
* Use of this source code is governed by a BSD-style license
* that can be found in the LICENSE file in the root of the source
* tree. An additional intellectual property rights grant can be found
* in the file PATENTS. All contributing project authors may
* be found in the AUTHORS file in the root of the source tree.
*/
#ifndef AOM_DSP_DIVIDE_H_
#define AOM_DSP_DIVIDE_H_
// An implemntation of the divide by multiply alogrithm
// https://gmplib.org/~tege/divcnst-pldi94.pdf
#include <limits.h>
#include "./aom_config.h"
#include "aom/aom_integer.h"
#ifdef __cplusplus
extern "C" {
#endif // __cplusplus
struct fastdiv_elem {
unsigned mult;
unsigned shift;
};
extern const struct fastdiv_elem av1_fastdiv_tab[256];
static INLINE unsigned fastdiv(unsigned x, int y) {
unsigned t =
((uint64_t)x * av1_fastdiv_tab[y].mult) >> (sizeof(x) * CHAR_BIT);
return (t + x) >> av1_fastdiv_tab[y].shift;
}
#ifdef __cplusplus
} // extern "C"
#endif // __cplusplus
#endif // AOM_DSP_DIVIDE_H_