From f3e584566773bb4a57250960768565965d5c189f Mon Sep 17 00:00:00 2001 From: max Date: Fri, 27 Nov 2009 20:27:23 +0000 Subject: [PATCH] add file op25_p25_frame.h git-svn-id: http://op25.osmocom.org/svn/trunk@185 65a5c917-d112-43f1-993d-58c26a4786be --- decoder/src/lib/op25_p25_frame.h | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 decoder/src/lib/op25_p25_frame.h diff --git a/decoder/src/lib/op25_p25_frame.h b/decoder/src/lib/op25_p25_frame.h new file mode 100644 index 0000000..f60b2c8 --- /dev/null +++ b/decoder/src/lib/op25_p25_frame.h @@ -0,0 +1,38 @@ +#ifndef INCLUDED_OP25_P25_FRAME_H +#define INCLUDED_OP25_P25_FRAME_H 1 + +static const size_t P25_VOICE_FRAME_SIZE = 1728; +static const size_t P25_HEADER_SYMBOLS = 24 + 32 + 1; +static const size_t P25_HEADER_BITS = P25_HEADER_SYMBOLS * 2; + +static const uint64_t P25_FRAME_SYNC_MAGIC = 0x5575F5FF77FFLL; +static const uint64_t P25_FRAME_SYNC_REV_P = 0x5575F5FF77FFLL ^ 0xAAAAAAAAAAAALL; +static const uint64_t P25_FRAME_SYNC_MASK = 0xFFFFFFFFFFFFLL; + +/* Given a 64-bit frame header word and a frame body which is to be initialized + * 1. Place flags at beginning of frame body + * 2. Store 64-bit frame header word + * 3. FIXME Place first status symbol + */ +static inline void +p25_setup_frame_header(bit_vector& frame_body, uint64_t hw) { + uint64_t acc = P25_FRAME_SYNC_MAGIC; + for (int i=47; i>=0; i--) { + frame_body[ i ] = acc & 1; + acc >>= 1; + } + acc = hw; + for (int i=113; i>=72; i--) { + frame_body[ i ] = acc & 1; + acc >>= 1; + } + // FIXME: insert proper status dibit bits at 70, 71 + frame_body[70] = 1; + frame_body[71] = 0; + for (int i=69; i>=48; i--) { + frame_body[ i ] = acc & 1; + acc >>= 1; + } +} + +#endif /* INCLUDED_OP25_P25_FRAME_H */