If you have an issue with any of our projects. feel free to register.

Commit 3cdebc84 authored by Christopher Snowhill's avatar Christopher Snowhill

Remove unused framework

parent 5f04d925
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>en</string>
<key>CFBundleExecutable</key>
<string>$(EXECUTABLE_NAME)</string>
<key>CFBundleIdentifier</key>
<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>$(PRODUCT_NAME)</string>
<key>CFBundlePackageType</key>
<string>FMWK</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2015 Christopher Snowhill. All rights reserved.</string>
<key>NSPrincipalClass</key>
<string></string>
</dict>
</plist>
//
// g7221.c
// g7221
//
// Created by Christopher Snowhill on 1/24/15.
// Copyright (c) 2015 Christopher Snowhill. All rights reserved.
//
#include "g7221.h"
#include "libsiren/siren7.h"
g7221_handle * g7221_init(int bytes_per_frame, int bandwidth)
{
g7221_handle * handle = 0;
int sample_rate = bytes_per_frame * 8 * 50;
if ( sample_rate >= 16000 && sample_rate <= 48000 )
{
if ( ( ( sample_rate / 800 ) * 800 ) == sample_rate )
{
if ( bandwidth == 7000 || bandwidth == 14000 )
{
handle = (g7221_handle *) Siren7_NewDecoder( sample_rate, ( bandwidth == 7000 ) ? 1 : 2 );
}
}
}
return handle;
}
void g7221_decode_frame(g7221_handle *handle, void *code_words, void *sample_buffer)
{
Siren7_DecodeFrame((SirenDecoder)handle, (unsigned char *)code_words, (unsigned char *)sample_buffer);
}
void g7221_reset(g7221_handle *handle)
{
Siren7_ResetDecoder ((SirenDecoder)handle);
}
void g7221_free(g7221_handle *handle)
{
Siren7_CloseDecoder((SirenDecoder) handle);
}
/*
Interface to reference G.722.1 decoder
*/
#ifndef G7221_H
#define G7221_H
/* forward definition for the opaque handle object */
typedef struct g7221_handle_s g7221_handle;
/* return a handle for decoding on successful init, NULL on failure */
g7221_handle * g7221_init(int bytes_per_frame, int bandwidth);
/* decode a frame, at code_words, into 16-bit PCM in sample_buffer */
void g7221_decode_frame(g7221_handle *handle, void *code_words, void *sample_buffer);
/* reset the decoder to its initial state */
void g7221_reset(g7221_handle *handle);
/* free resources */
void g7221_free(g7221_handle *handle);
#endif
This diff is collapsed.
/*
* Siren Encoder/Decoder library
*
* @author: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef _SIREN_COMMON_H
#define _SIREN_COMMON_H
typedef struct {
unsigned int RiffId;
unsigned int RiffSize;
} RiffHeader;
typedef struct {
unsigned short Format;
unsigned short Channels;
unsigned int SampleRate;
unsigned int ByteRate;
unsigned short BlockAlign;
unsigned short BitsPerSample;
} FmtChunk;
typedef struct {
FmtChunk fmt;
unsigned short ExtraSize;
unsigned short DctLength;
} SirenFmtChunk;
typedef struct {
RiffHeader riff;
unsigned int WaveId;
unsigned int FmtId;
unsigned int FmtSize;
SirenFmtChunk fmt;
unsigned int FactId;
unsigned int FactSize;
unsigned int Samples;
unsigned int DataId;
unsigned int DataSize;
} SirenWavHeader;
typedef struct {
RiffHeader riff;
unsigned int WaveId;
unsigned int FmtId;
unsigned int FmtSize;
FmtChunk fmt;
unsigned int FactId;
unsigned int FactSize;
unsigned int Samples;
unsigned int DataId;
unsigned int DataSize;
} PCMWavHeader;
#define RIFF_ID 0x46464952
#define WAVE_ID 0x45564157
#define FMT__ID 0x20746d66
#define DATA_ID 0x61746164
#define FACT_ID 0x74636166
extern int region_size;
extern float region_size_inverse;
extern float standard_deviation[64];
extern float deviation_inverse[64];
extern float region_power_table_boundary[63];
extern int expected_bits_table[8];
extern int vector_dimension[8];
extern int number_of_vectors[8];
extern float dead_zone[8];
extern int max_bin[8];
extern float step_size[8];
extern float step_size_inverse[8];
extern void siren_init(void);
extern int categorize_regions(int number_of_regions, int number_of_available_bits, int *absolute_region_power_index, int *power_categories, int *category_balance);
extern int GetSirenCodecInfo(int flag, int sample_rate, int *number_of_coefs, int *sample_rate_bits, int *rate_control_bits, int *rate_control_possibilities, int *checksum_bits, int *esf_adjustment, int *scale_factor, int *number_of_regions, int *sample_rate_code, int *bits_per_frame );
#ifdef __BIG_ENDIAN__
#define POW_2_8 256
#define POW_2_16 65536
#define POW_2_24 16777216
#define IDX(val, i) ((unsigned int) ((unsigned char *) &val)[i])
#define ME_FROM_LE16(val) ( (unsigned short) ( IDX(val, 0) + IDX(val, 1) * 256 ))
#define ME_FROM_LE32(val) ( (unsigned int) (IDX(val, 0) + IDX(val, 1) * 256 + \
IDX(val, 2) * 65536 + IDX(val, 3) * 16777216))
#define ME_TO_LE16(val) ( (unsigned short) ( \
(((unsigned short)val % 256) & 0xff) << 8 | \
((((unsigned short)val / POW_2_8) % 256) & 0xff) ))
#define ME_TO_LE32(val) ( (unsigned int) ( \
((((unsigned int) val ) % 256) & 0xff) << 24 | \
((((unsigned int) val / POW_2_8 ) % 256) & 0xff) << 16| \
((((unsigned int) val / POW_2_16) % 256) & 0xff) << 8 | \
((((unsigned int) val / POW_2_24) % 256) & 0xff) ))
#else
#define ME_TO_LE16(val) ( (unsigned short) (val))
#define ME_TO_LE32(val) ( (unsigned int) (val))
#define ME_FROM_LE16(val) ( (unsigned short) (val))
#define ME_FROM_LE32(val) ( (unsigned int) (val))
#endif
#endif /* _SIREN_COMMON_H */
/*
* Siren Encoder/Decoder library
*
* @author: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "siren7.h"
#define PI 3.1415926
typedef struct
{
float cos;
float msin;
} dct_table_type;
static float dct_core_320[100];
static float dct_core_640[100];
static dct_table_type dct_table_5[5];
static dct_table_type dct_table_10[10];
static dct_table_type dct_table_20[20];
static dct_table_type dct_table_40[40];
static dct_table_type dct_table_80[80];
static dct_table_type dct_table_160[160];
static dct_table_type dct_table_320[320];
static dct_table_type dct_table_640[640];
static dct_table_type *dct_tables[8] = { dct_table_5,
dct_table_10,
dct_table_20,
dct_table_40,
dct_table_80,
dct_table_160,
dct_table_320,
dct_table_640
};
static int dct4_initialized = 0;
void
siren_dct4_init (void)
{
int i, j = 0;
double scale_320 = (float) sqrt (2.0 / 320);
double scale_640 = (float) sqrt (2.0 / 640);
double angle;
double scale;
/* set up dct4 tables */
for (i = 0; i < 10; i++) {
angle = (float) ((i + 0.5) * PI);
for (j = 0; j < 10; j++) {
dct_core_320[(i * 10) + j] =
(float) (scale_320 * cos ((j + 0.5) * angle / 10));
dct_core_640[(i * 10) + j] =
(float) (scale_640 * cos ((j + 0.5) * angle / 10));
}
}
for (i = 0; i < 8; i++) {
scale = (float) (PI / ((5 << i) * 4));
for (j = 0; j < (5 << i); j++) {
angle = (float) (j + 0.5) * scale;
dct_tables[i][j].cos = (float) cos (angle);
dct_tables[i][j].msin = (float) -sin (angle);
}
}
dct4_initialized = 1;
}
void
siren_dct4 (float *Source, float *Destination, int dct_length)
{
int log_length = 0;
float *dct_core = NULL;
dct_table_type **dct_table_ptr_ptr = NULL;
dct_table_type *dct_table_ptr = NULL;
float OutBuffer1[640];
float OutBuffer2[640];
float *Out_ptr;
float *NextOut_ptr;
float *In_Ptr = NULL;
float *In_Ptr_low = NULL;
float *In_Ptr_high = NULL;
float In_val_low;
float In_val_high;
float *Out_ptr_low = NULL;
float *Out_ptr_high = NULL;
float mult1, mult2, mult3, mult4, mult5, mult6, mult7, mult8, mult9, mult10;
int i, j;
if (dct4_initialized == 0)
siren_dct4_init ();
if (dct_length == 640) {
log_length = 5;
dct_core = dct_core_640;
} else {
log_length = 4;
dct_core = dct_core_320;
}
Out_ptr = OutBuffer1;
NextOut_ptr = OutBuffer2;
In_Ptr = Source;
for (i = 0; i <= log_length; i++) {
for (j = 0; j < (1 << i); j++) {
Out_ptr_low = Out_ptr + (j * (dct_length >> i));
Out_ptr_high = Out_ptr + ((j + 1) * (dct_length >> i));
do {
In_val_low = *In_Ptr++;
In_val_high = *In_Ptr++;
*Out_ptr_low++ = In_val_low + In_val_high;
*--Out_ptr_high = In_val_low - In_val_high;
} while (Out_ptr_low < Out_ptr_high);
}
In_Ptr = Out_ptr;
Out_ptr = NextOut_ptr;
NextOut_ptr = In_Ptr;
}
for (i = 0; i < (2 << log_length); i++) {
for (j = 0; j < 10; j++) {
mult1 = In_Ptr[(i * 10)] * dct_core[j * 10];
mult2 = In_Ptr[(i * 10) + 1] * dct_core[(j * 10) + 1];
mult3 = In_Ptr[(i * 10) + 2] * dct_core[(j * 10) + 2];
mult4 = In_Ptr[(i * 10) + 3] * dct_core[(j * 10) + 3];
mult5 = In_Ptr[(i * 10) + 4] * dct_core[(j * 10) + 4];
mult6 = In_Ptr[(i * 10) + 5] * dct_core[(j * 10) + 5];
mult7 = In_Ptr[(i * 10) + 6] * dct_core[(j * 10) + 6];
mult8 = In_Ptr[(i * 10) + 7] * dct_core[(j * 10) + 7];
mult9 = In_Ptr[(i * 10) + 8] * dct_core[(j * 10) + 8];
mult10 = In_Ptr[(i * 10) + 9] * dct_core[(j * 10) + 9];
Out_ptr[(i * 10) + j] = mult1 + mult2 + mult3 + mult4 +
mult5 + mult6 + mult7 + mult8 + mult9 + mult10;
}
}
In_Ptr = Out_ptr;
Out_ptr = NextOut_ptr;
NextOut_ptr = In_Ptr;
dct_table_ptr_ptr = dct_tables;
for (i = log_length; i >= 0; i--) {
dct_table_ptr_ptr++;
for (j = 0; j < (1 << i); j++) {
dct_table_ptr = *dct_table_ptr_ptr;
if (i == 0)
Out_ptr_low = Destination + (j * (dct_length >> i));
else
Out_ptr_low = Out_ptr + (j * (dct_length >> i));
Out_ptr_high = Out_ptr_low + (dct_length >> i);
In_Ptr_low = In_Ptr + (j * (dct_length >> i));
In_Ptr_high = In_Ptr_low + (dct_length >> (i + 1));
do {
*Out_ptr_low++ =
(*In_Ptr_low * (*dct_table_ptr).cos) -
(*In_Ptr_high * (*dct_table_ptr).msin);
*--Out_ptr_high =
(*In_Ptr_high++ * (*dct_table_ptr).cos) +
(*In_Ptr_low++ * (*dct_table_ptr).msin);
dct_table_ptr++;
*Out_ptr_low++ =
(*In_Ptr_low * (*dct_table_ptr).cos) +
(*In_Ptr_high * (*dct_table_ptr).msin);
*--Out_ptr_high =
(*In_Ptr_low++ * (*dct_table_ptr).msin) -
(*In_Ptr_high++ * (*dct_table_ptr).cos);
dct_table_ptr++;
} while (Out_ptr_low < Out_ptr_high);
}
In_Ptr = Out_ptr;
Out_ptr = NextOut_ptr;
NextOut_ptr = In_Ptr;
}
}
/*
* Siren Encoder/Decoder library
*
* @author: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef _SIREN7_DCT4_H_
#define _SIREN7_DCT4_H_
extern void siren_dct4_init(void);
extern void siren_dct4(float *Source, float *Destination, int dct_length);
#endif /* _SIREN7_DCT4_H_ */
/*
* Siren Encoder/Decoder library
*
* @author: Youness Alaoui <kakaroto@kakaroto.homelinux.net>
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library 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
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#include "siren7.h"
SirenDecoder
Siren7_NewDecoder (int sample_rate, int flag)
{
SirenDecoder decoder = (SirenDecoder) malloc (sizeof (struct stSirenDecoder));
decoder->sample_rate = sample_rate;
decoder->flag = flag;
#ifdef __WAV_HEADER__
decoder->WavHeader.riff.RiffId = ME_TO_LE32 (RIFF_ID);
decoder->WavHeader.riff.RiffSize = sizeof (PCMWavHeader) - 2 * sizeof (int);
decoder->WavHeader.riff.RiffSize =
ME_TO_LE32 (decoder->WavHeader.riff.RiffSize);
decoder->WavHeader.WaveId = ME_TO_LE32 (WAVE_ID);
decoder->WavHeader.FmtId = ME_TO_LE32 (FMT__ID);
decoder->WavHeader.FmtSize = ME_TO_LE32 (sizeof (FmtChunk));
decoder->WavHeader.fmt.Format = ME_TO_LE16 (0x01);
decoder->WavHeader.fmt.Channels = ME_TO_LE16 (1);
decoder->WavHeader.fmt.SampleRate = ME_TO_LE32 (sample_rate);
decoder->WavHeader.fmt.ByteRate = ME_TO_LE32 (sample_rate * 2);
decoder->WavHeader.fmt.BlockAlign = ME_TO_LE16 (2);
decoder->WavHeader.fmt.BitsPerSample = ME_TO_LE16 (16);
decoder->WavHeader.FactId = ME_TO_LE32 (FACT_ID);
decoder->WavHeader.FactSize = ME_TO_LE32 (sizeof (int));
decoder->WavHeader.Samples = ME_TO_LE32 (0);
decoder->WavHeader.DataId = ME_TO_LE32 (DATA_ID);
decoder->WavHeader.DataSize = ME_TO_LE32 (0);
#endif
Siren7_ResetDecoder(decoder);
siren_init ();
return decoder;
}
void
Siren7_ResetDecoder(SirenDecoder decoder)
{
memset(decoder->context, 0, sizeof(decoder->context));
memset(decoder->backup_frame, 0, sizeof(decoder->backup_frame));
decoder->dw1 = 1;
decoder->dw2 = 1;
decoder->dw3 = 1;
decoder->dw4 = 1;
memset(decoder->absolute_region_power_index, 0, sizeof(decoder->absolute_region_power_index));
memset(decoder->decoder_standard_deviation, 0, sizeof(decoder->decoder_standard_deviation));
memset(decoder->power_categories, 0, sizeof(decoder->power_categories));
memset(decoder->category_balance, 0, sizeof(decoder->category_balance));
}
void
Siren7_CloseDecoder (SirenDecoder decoder)
{
free (decoder);
}
int
Siren7_DecodeFrame (SirenDecoder decoder, unsigned char *DataIn,
unsigned char *DataOut)
{
int number_of_coefs,
sample_rate_bits,
rate_control_bits,
rate_control_possibilities,
checksum_bits,
esf_adjustment,
scale_factor, number_of_regions, sample_rate_code, bits_per_frame;
int decoded_sample_rate_code;
int ChecksumTable[4] = { 0x7F80, 0x7878, 0x6666, 0x5555 };
int i, j;
int dwRes = 0;
int envelope_bits = 0;
int rate_control = 0;
int number_of_available_bits;
int number_of_valid_coefs;
int frame_error = 0;
int In[60];
float coefs[640];
float BufferOut[640];
int sum;
int checksum;
int calculated_checksum;
int idx;
int temp1;
int temp2;
bitstream bs = {0};
dwRes =
GetSirenCodecInfo (decoder->flag, decoder->sample_rate, &number_of_coefs,
&sample_rate_bits, &rate_control_bits, &rate_control_possibilities,
&checksum_bits, &esf_adjustment, &scale_factor, &number_of_regions,
&sample_rate_code, &bits_per_frame);
if (dwRes != 0)
return dwRes;
#ifdef __NO_CONTROL_OR_CHECK_FIELDS__
sample_rate_bits = 0;
checksum_bits = 0;
sample_rate_code = 0;
#endif
j = bits_per_frame / 16;
for (i = 0; i < j; i++)
#ifdef __BIG_ENDIAN_FRAMES__
In[i] = ((short *) DataIn)[i];
#else
In[i] =
((((short *) DataIn)[i] << 8) & 0xFF00) | ((((short *) DataIn)[i] >> 8)
& 0x00FF);
#endif
set_bitstream (&bs, In);
decoded_sample_rate_code = 0;
for (i = 0; i < sample_rate_bits; i++) {
decoded_sample_rate_code <<= 1;
decoded_sample_rate_code |= next_bit (&bs);
}