Drop egolay implementation (we have a new one).

git-svn-id: http://op25.osmocom.org/svn/trunk@171 65a5c917-d112-43f1-993d-58c26a4786be
This commit is contained in:
stevie 2009-09-09 12:04:00 +00:00
parent 09d298bde4
commit de3c49233c
12 changed files with 20 additions and 254 deletions

View File

@ -79,8 +79,7 @@ _op25_la_SOURCES = \
op25.cc \
op25_decoder_ff.cc \
vc55_imbe_decoder.cc \
value_string.cc \
egolay.cc
value_string.cc
# magic flags

View File

@ -32,7 +32,6 @@ dummy_imbe_decoder::~dummy_imbe_decoder()
}
void
dummy_imbe_decoder::decode(voice_codeword& in_out)
dummy_imbe_decoder::decode(const voice_codeword& cw)
{
}

View File

@ -46,9 +46,9 @@ public:
/**
* Ignores in_out and generates no audio.
*
* \param in_out IMBE codewords and parity.
* \param cw IMBE codewords and parity.
*/
virtual void decode(voice_codeword& in_out);
virtual void decode(const voice_codeword& cw);
};

View File

@ -1,141 +0,0 @@
/*!
* \file
* \brief Implementation of the Extended Golay Code (24, 12, 8)
* \author Tony Ottosson
*
* -------------------------------------------------------------------------
*
* IT++ - C++ library of mathematical, signal processing, speech processing,
* and communications classes and functions
*
* Copyright (C) 1995-2008 (see AUTHORS file for a list of contributors)
*
* 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; either version 2 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* -------------------------------------------------------------------------
*/
//#include <itpp/comm/egolay.h>
#include <egolay.h>
#include <itpp/comm/commfunc.h>
#include <itpp/base/specmat.h>
#include <itpp/base/converters.h>
namespace itpp {
My_Extended_Golay::My_Extended_Golay(void)
{
// B="0 1 1 1 1 1 1 1 1 1 1 1;1 1 1 0 1 1 1 0 0 0 1 0;1 1 0 1 1 1 0 0 0 1 0 1;1 0 1 1 1 0 0 0 1 0 1 1;1 1 1 1 0 0 0 1 0 1 1 0;1 1 1 0 0 0 1 0 1 1 0 1;1 1 0 0 0 1 0 1 1 0 1 1;1 0 0 0 1 0 1 1 0 1 1 1;1 0 0 1 0 1 1 0 1 1 1 0;1 0 1 0 1 1 0 1 1 1 0 0;1 1 0 1 1 0 1 1 1 0 0 0;1 0 1 1 0 1 1 1 0 0 0 1";
B="1 1 0 0 0 1 1 1 0 1 0 1;0 1 1 0 0 0 1 1 1 0 1 1;1 1 1 1 0 1 1 0 1 0 0 0;0 1 1 1 1 0 1 1 0 1 0 0;0 0 1 1 1 1 0 1 1 0 1 0;1 1 0 1 1 0 0 1 1 0 0 1;0 1 1 0 1 1 0 0 1 1 0 1;0 0 1 1 0 1 1 0 0 1 1 1;1 1 0 1 1 1 0 0 0 1 1 0;1 0 1 0 1 0 0 1 0 1 1 1;1 0 0 1 0 0 1 1 1 1 1 0;1 0 0 0 1 1 1 0 1 0 1 1";
G = concat_horizontal(eye_b(12), B);
}
void My_Extended_Golay::encode(const bvec &uncoded_bits, bvec &coded_bits)
{
int no_bits = uncoded_bits.length();
int no_blocks = floor_i(no_bits / 12.0);
coded_bits.set_size(24*no_blocks, false);
bmat Gt = G.T();
int i;
for (i=0; i<no_blocks; i++)
coded_bits.replace_mid(24*i, Gt * uncoded_bits.mid(i*12,12));
}
bvec My_Extended_Golay::encode(const bvec &uncoded_bits)
{
bvec coded_bits;
encode(uncoded_bits, coded_bits);
return coded_bits;
}
void My_Extended_Golay::decode(const bvec &coded_bits, bvec &decoded_bits)
{
int no_bits = coded_bits.length();
int no_blocks = floor_i(no_bits / 24.0);
decoded_bits.set_size(12*no_blocks, false);
int i, j;
bvec S(12),BS(12),r(12),temp(12),e(24),c(24);
bmat eyetemp = eye_b(12);
for (i=0; i<no_blocks; i++) {
r = coded_bits.mid(i*24,24);
// Step 1. Compute S=G*r.
S = G*r;
// Step 2. w(S)<=3. e=(S,0). Goto 8.
if( weight(S) <= 3 ) {
e = concat(S, zeros_b(12)); goto Step8;
}
// Step 3. w(S+Ii)<=2. e=(S+Ii,yi). Goto 8.
for (j=0; j<12; j++) {
temp = S + B.get_col(j);
if ( weight(temp) <=2 ) {
e = concat(temp, eyetemp.get_row(j)); goto Step8;
}
}
// STEP 4. Compute B*S
BS = B*S;
// Step 5. w(B*S)<=3. e=(0,BS). Goto8.
if ( weight(BS) <=3 ) {
e = concat(zeros_b(12), BS); goto Step8;
}
// Step 6. w(BS+Ri)<=2. e=(xi,BS+Ri). Goto 8.
for (j=0; j<12; j++) {
temp = BS + B.get_row(j);
if ( weight(temp) <=2 ) {
e = concat(eyetemp.get_row(j), temp); goto Step8;
}
}
// Step 7. Uncorrectable erreor pattern. Choose the first 12 bits.
e = zeros_b(24); goto Step8;
Step8: // Step 8. c=r+e. STOP
c = r + e;
decoded_bits.replace_mid(i*12, c.left(12));
}
}
bvec My_Extended_Golay::decode(const bvec &coded_bits)
{
bvec decoded_bits;
decode(coded_bits, decoded_bits);
return decoded_bits;
}
// -------------- Soft-decision decoding is not implemented ------------------
void My_Extended_Golay::decode(const vec &received_signal, bvec &output)
{
it_error("My_Extended_Golay::decode(vec, bvec); soft-decision decoding is not implemented");
}
bvec My_Extended_Golay::decode(const vec &received_signal)
{
it_error("My_Extended_Golay::decode(vec, bvec); soft-decision decoding is not implemented");
return bvec();
}
} // namespace itpp

View File

@ -1,83 +0,0 @@
/*!
* \file
* \brief Definition of the Extended Golay Code (24, 12, 8)
* \author Tony Ottosson
*
* -------------------------------------------------------------------------
*
* IT++ - C++ library of mathematical, signal processing, speech processing,
* and communications classes and functions
*
* Copyright (C) 1995-2008 (see AUTHORS file for a list of contributors)
*
* 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; either version 2 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*
* -------------------------------------------------------------------------
*/
#ifndef EGOLAY_H
#define EGOLAY_H
#include <itpp/base/vec.h>
#include <itpp/base/mat.h>
#include <itpp/comm/channel_code.h>
namespace itpp {
/*!
\ingroup fec
\brief Extended Golay code (24,12,8).
\author Tony Ottosson
The code is given in systematic form with the information bits
first, followed by the parity check bits. The decoder uses the
arithmetic decoding algorithm that is for example described in
Wicker "Error Control Systems for Digital Communication and
Storage", Prentice Hall, 1995 (page 143).
*/
class My_Extended_Golay : public Channel_Code {
public:
//! Constructor
My_Extended_Golay();
//! Destructor
virtual ~My_Extended_Golay(){ }
//! Encoder. Will truncate some bits if not \a length = \c integer * 12
virtual void encode(const bvec &uncoded_bits, bvec &coded_bits);
//! Encoder. Will truncate some bits if not \a length = \c integer * 12
virtual bvec encode(const bvec &uncoded_bits);
//! Decoder. Will truncate some bits if not \a length = \c integer * 24
virtual void decode(const bvec &coded_bits, bvec &decoded_bits);
//! Decoder. Will truncate some bits if not \a length = \c integer * 24
virtual bvec decode(const bvec &coded_bits);
// Soft-decision decoding is not implemented
virtual void decode(const vec &received_signal, bvec &output);
virtual bvec decode(const vec &received_signal);
//! Get the code rate
virtual double get_rate() const { return 0.5; };
//! Gets the generator matrix for the code (also the parity check matrix)
bmat get_G() const { return G; }
private:
bmat B,G;
};
} // namespace itpp
#endif // #ifndef EGOLAY_H

View File

@ -21,12 +21,10 @@
* 02110-1301, USA.
*/
#include <egolay.h>
#include <hdu.h>
#include <iomanip>
#include <iostream>
#include <itpp/base/vec.h>
// #include <itpp/comm/egolay.h>
#include <itpp/comm/reedsolomon.h>
#include <sstream>
#include <value_string.h>
@ -119,7 +117,6 @@ hdu::do_correct_errors(bit_vector& frame)
void
hdu::apply_golay_correction(bit_vector& frame)
{
static itpp::My_Extended_Golay golay;
static const size_t NOF_GOLAY_CODEWORDS = 36, GOLAY_CODEWORD_SZ = 18;
static const size_t GOLAY_CODEWORDS[NOF_GOLAY_CODEWORDS][GOLAY_CODEWORD_SZ] = {
{ 114, 115, 116, 117, 118, 119, 120, 121, 122, 123, 124, 125, 126, 127, 128, 129, 130, 131 },
@ -160,12 +157,9 @@ hdu::apply_golay_correction(bit_vector& frame)
{ 762, 763, 764, 765, 766, 767, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779 }
};
for(size_t i = 0; i < NOF_GOLAY_CODEWORDS; ++i) {
const size_t PAD_SZ = 6;
itpp::bvec b(PAD_SZ + GOLAY_CODEWORD_SZ);
b.zeros();
yank(frame, GOLAY_CODEWORDS[i], GOLAY_CODEWORD_SZ, b, PAD_SZ);
itpp::bvec d(golay.decode(b));
// yank_back(d, PAD_SZ, frame, GOLAY_CODEWORDS[i], GOLAY_DATA_SZ);
// yank(frame, GOLAY_CODEWORDS[i], GOLAY_CODEWORD_SZ, b, PAD_SZ);
// itpp::bvec d(golay.decode(b));
// yank_back(d, PAD_SZ, frame, GOLAY_CODEWORDS[i], GOLAY_DATA_SZ);
}
}

View File

@ -55,12 +55,11 @@ public:
virtual ~imbe_decoder();
/**
* Apply error correction to the voice_codeword in_out,
* decode the audio and write it to the audio_samples.
* Decode the compressed IMBE audio.
*
* \param in_out IMBE codeword (including parity check bits).
* \param cw IMBE codeword (including parity check bits).
*/
virtual void decode(voice_codeword& in_out) = 0;
virtual void decode(const voice_codeword& cw) = 0;
/**
* Returns the audio_samples samples. These are mono samples at

View File

@ -49,13 +49,13 @@ offline_imbe_decoder::~offline_imbe_decoder()
}
void
offline_imbe_decoder::decode(voice_codeword& in_out)
offline_imbe_decoder::decode(const voice_codeword& cw)
{
if(d_fp) {
uint8_t codewords[18];
extract(in_out, 0, 144, codewords);
extract(cw, 0, 144, codewords);
if(0 == fwrite(codewords, sizeof(codewords), 1, d_fp)) {
perror("fwrite(d_fp, 1, codewords, sizeof(codewords))");
perror("fwrite(codewords, sizeof(codewords), 1, d_fp)");
fclose(d_fp);
d_fp = NULL;
}

View File

@ -48,9 +48,9 @@ public:
/**
* Dump voice_codeword in_out to file.
*
* \param in_out IMBE codewords and parity.
* \param cw IMBE codewords and parity.
*/
virtual void decode(voice_codeword& in_out);
virtual void decode(const voice_codeword& cw);
private:

View File

@ -22,7 +22,6 @@
*/
#include <itpp/base/vec.h>
#include <itpp/comm/egolay.h>
#include <itpp/comm/reedsolomon.h>
#include <tdu.h>
#include <yank.h>
@ -57,7 +56,6 @@ tdu::do_correct_errors(bit_vector& frame)
void
tdu::apply_golay_correction(bit_vector& frame)
{
static itpp::Extended_Golay golay;
}
void

View File

@ -32,6 +32,7 @@
#include <sys/types.h>
#include <termios.h>
#include <vc55_imbe_decoder.h>
#include <yank.h>
using namespace std;
@ -69,13 +70,13 @@ vc55_imbe_decoder::~vc55_imbe_decoder()
}
void
vc55_imbe_decoder::decode(voice_codeword& in_out)
vc55_imbe_decoder::decode(const voice_codeword& cw)
{
if(-1 != d_fd) {
uint8_t packet[20];
packet[0] = 0x56;
packet[1] = 0xf0;
// ToDo extract(in_out, 0, 144, &packet[2]);
extract(cw, 0, 144, &packet[2]);
if(-1 == write(d_fd, packet, sizeof(packet))) {
perror("write(d_fd, packet, sizeof(packet))");
close(d_fd);

View File

@ -48,9 +48,9 @@ public:
/**
* Passess the voice_codeword in_out to the VC55PR device.
*
* \param in_out IMBE codewords and parity.
* \param cw IMBE codewords and parity.
*/
virtual void decode(voice_codeword& in_out);
virtual void decode(const voice_codeword& cw);
private: