Niotso  git revision 558726a9f13d7c3423a683dd2f4323589b66c310
The New Implementation of The Sims Online
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Macros | Functions | Variables
read_utk.c File Reference
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <stdio.h>
#include "read_utk.h"

Macros

#define read_uint32(x)   (unsigned)(((x)[0]<<(8*0)) | ((x)[1]<<(8*1)) | ((x)[2]<<(8*2)) | ((x)[3]<<(8*3)))
 
#define read_uint16(x)   (unsigned)(((x)[0]<<(8*0)) | ((x)[1]<<(8*1)))
 
#define write_uint16(dest, src)
 
#define round(x)   ((x) >= 0 ? (x)+0.5 : (x)-0.5)
 
#define clamp(x, low, high)   ((x) < low ? low : (x) > high ? high : (x))
 
#define min(x, y)   ((x) < (y) ? (x) : (y))
 

Functions

static uint8_t ReadBits (utkcontext_t *ctx, uint8_t bits)
 
static void InitUTKParameters (utkcontext_t *ctx)
 
static void DecodeFrame (utkcontext_t *ctx)
 
static void GenerateExcitation (utkcontext_t *ctx, int Voiced, float *Window, int Interval)
 
static void Synthesize (utkcontext_t *ctx, unsigned Sample, unsigned Blocks)
 
static void RCtoLPC (const float *__restrict RC, float *__restrict LPC)
 
int utk_read_header (utkheader_t *UTKHeader, const uint8_t *Buffer, size_t FileSize)
 
int utk_decode (const uint8_t *__restrict InBuffer, uint8_t *__restrict OutBuffer, size_t InSize, size_t Samples)
 
static void Synthesize (utkcontext_t *ctx, size_t Sample, size_t Samples)
 

Variables

static const float UTKCosine [64]
 
static const uint8_t UTKCodebook [512]
 
static const uint8_t UTKCodeSkips [29] = {8,7,8,7,2,2,2,3,3,4,4,3,3,5,5,4,4,6,6,5,5,7,7,6,6,8,8,7,7}
 

Macro Definition Documentation

#define clamp (   x,
  low,
  high 
)    ((x) < low ? low : (x) > high ? high : (x))
#define min (   x,
 
)    ((x) < (y) ? (x) : (y))
#define read_uint16 (   x)    (unsigned)(((x)[0]<<(8*0)) | ((x)[1]<<(8*1)))
#define read_uint32 (   x)    (unsigned)(((x)[0]<<(8*0)) | ((x)[1]<<(8*1)) | ((x)[2]<<(8*2)) | ((x)[3]<<(8*3)))
#define round (   x)    ((x) >= 0 ? (x)+0.5 : (x)-0.5)
#define write_uint16 (   dest,
  src 
)
Value:
do {\
(dest)[0] = ((src)&0x00FF)>>(8*0); \
(dest)[1] = ((src)&0xFF00)>>(8*1); \
} while(0)

Function Documentation

static void DecodeFrame ( utkcontext_t ctx)
static
static void GenerateExcitation ( utkcontext_t ctx,
int  Voiced,
float *  Window,
int  Interval 
)
static
static void InitUTKParameters ( utkcontext_t ctx)
static
static void RCtoLPC ( const float *__restrict  RC,
float *__restrict  LPC 
)
static
static uint8_t ReadBits ( utkcontext_t ctx,
uint8_t  bits 
)
static
static void Synthesize ( utkcontext_t ctx,
unsigned  Sample,
unsigned  Blocks 
)
static
static void Synthesize ( utkcontext_t ctx,
size_t  Sample,
size_t  Samples 
)
static
int utk_decode ( const uint8_t *__restrict  InBuffer,
uint8_t *__restrict  OutBuffer,
size_t  InSize,
size_t  Samples 
)
int utk_read_header ( utkheader_t UTKHeader,
const uint8_t *  Buffer,
size_t  FileSize 
)

Variable Documentation

const uint8_t UTKCodebook[512]
static
const uint8_t UTKCodeSkips[29] = {8,7,8,7,2,2,2,3,3,4,4,3,3,5,5,4,4,6,6,5,5,7,7,6,6,8,8,7,7}
static
const float UTKCosine[64]
static
Initial value:
= {
0,
-.99677598476409912109375, -.99032700061798095703125, -.983879029750823974609375, -.977430999279022216796875,
-.970982015132904052734375, -.964533984661102294921875, -.958085000514984130859375, -.9516370296478271484375,
-.930754005908966064453125, -.904959976673126220703125, -.879167020320892333984375, -.853372991085052490234375,
-.827579021453857421875, -.801786005496978759765625, -.775991976261138916015625, -.75019800662994384765625,
-.724404990673065185546875, -.6986110210418701171875, -.6706349849700927734375, -.61904799938201904296875,
-.567460000514984130859375, -.515873014926910400390625, -.4642859995365142822265625, -.4126980006694793701171875,
-.361110985279083251953125, -.309523999691009521484375, -.257937014102935791015625, -.20634900033473968505859375,
-.1547619998455047607421875, -.10317499935626983642578125, -.05158700048923492431640625,
0,
+.05158700048923492431640625, +.10317499935626983642578125, +.1547619998455047607421875, +.20634900033473968505859375,
+.257937014102935791015625, +.309523999691009521484375, +.361110985279083251953125, +.4126980006694793701171875,
+.4642859995365142822265625, +.515873014926910400390625, +.567460000514984130859375, +.61904799938201904296875,
+.6706349849700927734375, +.6986110210418701171875, +.724404990673065185546875, +.75019800662994384765625,
+.775991976261138916015625, +.801786005496978759765625, +.827579021453857421875, +.853372991085052490234375,
+.879167020320892333984375, +.904959976673126220703125, +.930754005908966064453125, +.9516370296478271484375,
+.958085000514984130859375, +.964533984661102294921875, +.970982015132904052734375, +.977430999279022216796875,
+.983879029750823974609375, +.99032700061798095703125, +.99677598476409912109375
}