summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDamien Zammit <damien@zamaudio.com>2015-08-08 14:34:17 +1000
committerDamien Zammit <damien@zamaudio.com>2015-08-08 14:34:17 +1000
commitfca326f1368d44e0bc63aa2b79c7babf35509260 (patch)
tree436e1ec2d6c2585b15fd0efeee727fa12138aa6b
parentd3501789586fed3c072f8f9289470d49f28a6f39 (diff)
PT5 initial commit
Signed-off-by: Damien Zammit <damien@zamaudio.com>
-rw-r--r--Makefile6
-rw-r--r--ptfformat.cc36
-rw-r--r--ptfformat.h12
3 files changed, 43 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index 4f76078..c11adbd 100644
--- a/Makefile
+++ b/Makefile
@@ -1,5 +1,7 @@
+STRICT=-Wall -Wcast-align -Wextra -Wwrite-strings -Wunsafe-loop-optimizations -Wlogical-op
+
all:
- $(CXX) -o ptftool -g -Wall ptftool.cc ptfformat.cc
- $(CXX) -o ptunxor -g -Wall ptunxor.cc ptfformat.cc
+ $(CXX) -o ptftool -g ${STRICT} ptftool.cc ptfformat.cc
+ $(CXX) -o ptunxor -g ${STRICT} ptunxor.cc ptfformat.cc
clean:
rm ptftool ptunxor
diff --git a/ptfformat.cc b/ptfformat.cc
index 652024e..dbe0539 100644
--- a/ptfformat.cc
+++ b/ptfformat.cc
@@ -37,7 +37,7 @@ static const uint32_t xorlut[16] = {
0xbab0b0ba, 0xb0abaaba, 0xba0aabaa, 0xbaaaaaaa
};
-static const uint32_t swapbytes32 (const uint32_t v) {
+static uint32_t swapbytes32 (const uint32_t v) {
uint32_t rv = 0;
rv |= ((v >> 0) & 0xf) << 28;
rv |= ((v >> 4) & 0xf) << 24;
@@ -50,7 +50,7 @@ static const uint32_t swapbytes32 (const uint32_t v) {
return rv;
}
-static const uint64_t gen_secret (int i) {
+static uint64_t gen_secret (int i) {
assert (i > 0 && i < 256);
int iwrap = i & 0x7f; // wrap at 0x80;
uint32_t xor_lo = 0; // 0x40 flag
@@ -128,7 +128,7 @@ PTFFormat::load(std::string path, int64_t targetsr) {
fread(&c0, 1, 1, fp);
fread(&c1, 1, 1, fp);
- // For version 7 support:
+ // For version <= 7 support:
version = c0 & 0x0f;
c0 = c0 & 0xc0;
@@ -296,7 +296,12 @@ void
PTFFormat::parse(void) {
version = (version == 0) ? ptfunxored[61] : version;
- if (version == 7) {
+ if (version == 5) {
+ parse5header();
+ setrates();
+ parseaudio();
+ parserest89();
+ } else if (version == 7) {
parse7header();
setrates();
parseaudio();
@@ -331,6 +336,27 @@ PTFFormat::setrates(void) {
}
void
+PTFFormat::parse5header(void) {
+ int k;
+
+ // Find session sample rate
+ k = 0x100;
+ while (k < len) {
+ if ( (ptfunxored[k ] == 0x5a) &&
+ (ptfunxored[k+1] == 0x00) &&
+ (ptfunxored[k+2] == 0x02)) {
+ break;
+ }
+ k++;
+ }
+
+ sessionrate = 0;
+ sessionrate |= ptfunxored[k+12] << 16;
+ sessionrate |= ptfunxored[k+13] << 8;
+ sessionrate |= ptfunxored[k+14];
+}
+
+void
PTFFormat::parse7header(void) {
int k;
@@ -474,7 +500,7 @@ PTFFormat::parseaudio(void) {
std::string wave = string(wavname);
std::reverse(wave.begin(), wave.end());
- wav_t f = { wave, (uint16_t)(numberofwavs - 1), 0 };
+ wav_t f = { wave, (uint16_t)(numberofwavs - 1), 0, 0 };
if (foundin(wave, string(".grp"))) {
continue;
diff --git a/ptfformat.h b/ptfformat.h
index 2cd855f..156a5bf 100644
--- a/ptfformat.h
+++ b/ptfformat.h
@@ -75,8 +75,10 @@ public:
std::vector<track_t>::iterator begin = tr.begin();
std::vector<track_t>::iterator finish = tr.end();
std::vector<track_t>::iterator found;
-
- track_t f = { std::string(""), index };
+
+ wav_t w = { std::string(""), 0, 0, 0 };
+ region_t r = { std::string(""), 0, 0, 0, 0, w };
+ track_t f = { std::string(""), index, 0, r };
if ((found = std::find(begin, finish, f)) != finish) {
return true;
@@ -89,7 +91,8 @@ public:
std::vector<region_t>::iterator finish = reg.end();
std::vector<region_t>::iterator found;
- region_t r = { std::string(""), index };
+ wav_t w = { std::string(""), 0, 0, 0 };
+ region_t r = { std::string(""), index, 0, 0, 0, w };
if ((found = std::find(begin, finish, r)) != finish) {
return true;
@@ -102,7 +105,7 @@ public:
std::vector<wav_t>::iterator finish = wv.end();
std::vector<wav_t>::iterator found;
- wav_t w = { std::string(""), index };
+ wav_t w = { std::string(""), index, 0, 0 };
if ((found = std::find(begin, finish, w)) != finish) {
return true;
@@ -124,6 +127,7 @@ private:
void parse(void);
void unxor10(void);
void setrates(void);
+ void parse5header(void);
void parse7header(void);
void parse8header(void);
void parse9header(void);