/* * Copyright (C) 2007-2011 Siemens AG * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published * by the Free Software Foundation, either version 3 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Lesser General Public License for more details. * GNU Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see . */ /******************************************************************* * * @author Daniel.Peintner.EXT@siemens.com * @version 2011-12-02 * @contact Joerg.Heuer@siemens.com * *

Code generated by EXIdizer

********************************************************************/ #ifndef METHODS_BAG_C #define METHODS_BAG_C #include "MethodsBag.h" #include "EXITypes.h" static const int smallLengths[] = { 0, 0, 1, 2, 2, 3, 3, 3, 3, 4, 4, 4, 4, 4, 4, 4, 4 }; int exiGetCodingLength(uint32_t characteristics, uint16_t* codingLength) { if (characteristics < 17) { *codingLength = smallLengths[characteristics]; return 0; } else if (characteristics < 33) { /* 17 .. 32 */ *codingLength = 5; return 0; } else if (characteristics < 65) { /* 33 .. 64 */ *codingLength = 6; return 0; } else if (characteristics < 129) { /* 65 .. 128 */ *codingLength = 7; return 0; } else if (characteristics < 257) { /* 129 .. 256 */ *codingLength = 8; return 0; } else if (characteristics < 513) { /* 257 .. 512 */ *codingLength = 9; return 0; } else if (characteristics < 1025) { /* 513 .. 1024 */ *codingLength = 10; return 0; } else { /* return (int) Math.ceil(Math.log((double) (characteristics)) / Math.log(2.0)); */ return EXI_UNSUPPORTED_EVENT_CODE_CHARACTERISTICS; } } uint8_t numberOf7BitBlocksToRepresent(uint32_t n) { /* assert (n >= 0); */ /* 7 bits */ if (n < 128) { return 1; } /* 14 bits */ else if (n < 16384) { return 2; } /* 21 bits */ else if (n < 2097152) { return 3; } /* 28 bits */ else if (n < 268435456) { return 4; } /* 35 bits */ else { /* int, 32 bits */ return 5; } } #endif