| 1 | /*************************************************************************** |
|---|
| 2 | * Copyright (c) 2003-2011, Broadcom Corporation |
|---|
| 3 | * All Rights Reserved |
|---|
| 4 | * Confidential Property of Broadcom Corporation |
|---|
| 5 | * |
|---|
| 6 | * THIS SOFTWARE MAY ONLY BE USED SUBJECT TO AN EXECUTED SOFTWARE LICENSE |
|---|
| 7 | * AGREEMENT BETWEEN THE USER AND BROADCOM. YOU HAVE NO RIGHT TO USE OR |
|---|
| 8 | * EXPLOIT THIS MATERIAL EXCEPT SUBJECT TO THE TERMS OF SUCH AN AGREEMENT. |
|---|
| 9 | * |
|---|
| 10 | * $brcm_Workfile: bxdm_pp_fix33.h $ |
|---|
| 11 | * $brcm_Revision: Hydra_Software_Devel/1 $ |
|---|
| 12 | * $brcm_Date: 4/28/11 1:50p $ |
|---|
| 13 | * |
|---|
| 14 | * [File Description:] |
|---|
| 15 | * |
|---|
| 16 | * Revision History: |
|---|
| 17 | * |
|---|
| 18 | * $brcm_Log: /magnum/commonutils/xdm/bxdm_pp_fix33.h $ |
|---|
| 19 | * |
|---|
| 20 | * Hydra_Software_Devel/1 4/28/11 1:50p nilesh |
|---|
| 21 | * SW7405-5057: New fixed point math library with proper support for -2^32 |
|---|
| 22 | * to 2^32 values. |
|---|
| 23 | * |
|---|
| 24 | ***************************************************************************/ |
|---|
| 25 | |
|---|
| 26 | /* BXDM_PP_FIX33 is an implementation of fixed point math in the format "Q33.31". |
|---|
| 27 | * The whole component is 33 bits to enable a full -2^32 to 2^32 range of |
|---|
| 28 | * possible values. This range makes BXDM_PP_FIX33 sufficient for applications |
|---|
| 29 | * such as PTS interpolation where the full 32-bit range is required. |
|---|
| 30 | */ |
|---|
| 31 | |
|---|
| 32 | #ifndef BXDM_PP_FIX33_H_ |
|---|
| 33 | #define BXDM_PP_FIX33_H_ |
|---|
| 34 | |
|---|
| 35 | #ifdef __cplusplus |
|---|
| 36 | extern "C" { |
|---|
| 37 | #if 0 |
|---|
| 38 | } |
|---|
| 39 | #endif |
|---|
| 40 | #endif |
|---|
| 41 | |
|---|
| 42 | typedef int64_t BXDM_PP_Fix33_t; |
|---|
| 43 | |
|---|
| 44 | /* Convert to BXDM_PP_Fix33_t */ |
|---|
| 45 | BXDM_PP_Fix33_t BXDM_PP_Fix33_from_mixedfraction(const uint32_t oiWhole, const uint32_t uiNumerator, const uint32_t uiDenominator); |
|---|
| 46 | BXDM_PP_Fix33_t BXDM_PP_Fix33_from_int32(const int32_t iValue); |
|---|
| 47 | BXDM_PP_Fix33_t BXDM_PP_Fix33_from_uint32(const uint32_t uiValue); |
|---|
| 48 | |
|---|
| 49 | /* BXDM_PP_Fix33_t math operations */ |
|---|
| 50 | BXDM_PP_Fix33_t BXDM_PP_Fix33_add(const BXDM_PP_Fix33_t fixOperand1, const BXDM_PP_Fix33_t fixOperand2); |
|---|
| 51 | BXDM_PP_Fix33_t BXDM_PP_Fix33_sub(const BXDM_PP_Fix33_t fixOperand1, const BXDM_PP_Fix33_t fixOperand2); |
|---|
| 52 | BXDM_PP_Fix33_t BXDM_PP_Fix33_mulu(const BXDM_PP_Fix33_t fixOperand1, const uint32_t uiOperand2); |
|---|
| 53 | BXDM_PP_Fix33_t BXDM_PP_Fix33_divu(const BXDM_PP_Fix33_t fixOperand1, const uint32_t uiOperand2); |
|---|
| 54 | BXDM_PP_Fix33_t BXDM_PP_Fix33_neg(const BXDM_PP_Fix33_t fixOperand); |
|---|
| 55 | |
|---|
| 56 | /* Convert from BXDM_PP_Fix33_t */ |
|---|
| 57 | int32_t BXDM_PP_Fix33_to_int32(const BXDM_PP_Fix33_t fixValue); |
|---|
| 58 | uint32_t BXDM_PP_Fix33_to_uint32(const BXDM_PP_Fix33_t fixValue); |
|---|
| 59 | |
|---|
| 60 | #ifdef __cplusplus |
|---|
| 61 | } |
|---|
| 62 | #endif |
|---|
| 63 | |
|---|
| 64 | #endif /* BXDM_PP_FIX33_H_ */ |
|---|