/** * Digital Voice Modem - Host Software * GPLv2 Open Source. Use is subject to license terms. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * @package DVM / Host Software * */ // // Based on code from the MMDVMHost project. (https://github.com/g4klx/MMDVMHost) // Licensed under the GPLv2 License (https://opensource.org/licenses/GPL-2.0) // /* * Copyright (C) 2016,2018 by Jonathan Naylor, G4KLX * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; version 2 of the License. * * 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 General Public License for more details. */ #if !defined(__P25_EDAC__TRELLIS_H__) #define __P25_EDAC__TRELLIS_H__ #include "Defines.h" namespace p25 { namespace edac { // --------------------------------------------------------------------------- // Class Declaration // Implements 1/2 rate and 3/4 rate Trellis for P25. // --------------------------------------------------------------------------- class HOST_SW_API Trellis { public: /// Initializes a new instance of the Trellis class. Trellis(); /// Finalizes a instance of the Trellis class. ~Trellis(); /// Decodes 3/4 rate Trellis. bool decode34(const uint8_t* data, uint8_t* payload); /// Encodes 3/4 rate Trellis. void encode34(const uint8_t* payload, uint8_t* data); /// Decodes 1/2 rate Trellis. bool decode12(const uint8_t* data, uint8_t* payload); /// Encodes 1/2 rate Trellis. void encode12(const uint8_t* payload, uint8_t* data); private: /// Helper to deinterleave the input symbols into dibits. void deinterleave(const uint8_t* in, int8_t* dibits) const; /// Helper to interleave the input dibits into symbols. void interleave(const int8_t* dibits, uint8_t* out) const; /// Helper to map dibits to C4FM constellation points. void dibitsToPoints(const int8_t* dibits, uint8_t* points) const; /// Helper to map C4FM constellation points to dibits. void pointsToDibits(const uint8_t* points, int8_t* dibits) const; /// Helper to convert a byte payload into tribits. void bitsToTribits(const uint8_t* payload, uint8_t* tribits) const; /// Helper to convert a byte payload into dibits. void bitsToDibits(const uint8_t* payload, uint8_t* dibits) const; /// Helper to convert tribits into a byte payload. void tribitsToBits(const uint8_t* tribits, uint8_t* payload) const; /// Helper to convert dibits into a byte payload. void dibitsToBits(const uint8_t* dibits, uint8_t* payload) const; /// Helper to fix errors in Trellis coding. bool fixCode34(uint8_t* points, uint32_t failPos, uint8_t* payload) const; /// Helper to detect errors in Trellis coding. uint32_t checkCode34(const uint8_t* points, uint8_t* tribits) const; /// Helper to fix errors in Trellis coding. bool fixCode12(uint8_t* points, uint32_t failPos, uint8_t* payload) const; /// Helper to detect errors in Trellis coding. uint32_t checkCode12(const uint8_t* points, uint8_t* dibits) const; }; } // namespace edac } // namespace p25 #endif // __P25_EDAC__TRELLIS_H__