AEBook.c++
1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
/*****************************************************************************
* File: AEBook.c++
*
* AEBook Class Implementations
*
****************************************************************************/
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include "Assets.h"
#include "Mgrs.h"
/*****************************************************************************
*
* Initialization Routines
*
****************************************************************************/
AEBook::AEBook()
{
classType = AL_BOOK_CLASS;
order = 0;
npredictors = 0;
bookData = 0;
assert(theU64Dev->AllocHdwr(this,AL_BOOK_CLASS) == 0);
}
AEBook::~AEBook()
{
if(bookData)
free(bookData);
theU64Dev->DeallocHdwr(this);
}
/*****************************************************************************
*
* Asset's Methods
*
****************************************************************************/
void AEBook::SetBook(int ord, int npds, short *data)
{
int c,bookSize;
if(bookData)
free(bookData);
bookSize = npds*ord*ADPCMVSIZE*sizeof(s16);
bookData = (short*)malloc(bookSize);
if(!bookData)
{
fprintf(stderr,"unable to allocate memory for book data\n");
return;
}
order = ord;
npredictors = npds;
bookSize /= 2; /* copy using 16bit words */
for(c = 0; c < bookSize; c++)
bookData[c] = data[c];
}
int AEBook::GetOrder(void)
{
return order;
}
int AEBook::GetNPredictors(void)
{
return npredictors;
}
int AEBook::GetBookData(short *data)
{
int c,bookItems;
if(!bookData)
return 0;
bookItems = npredictors*order*ADPCMVSIZE;
for(c = 0; c < bookItems; c++)
data[c] = bookData[c];
return bookItems; /* return the number of bookItems */
}
int AEBook::GetNumBookItems(void)
{
return npredictors*order*ADPCMVSIZE;
}