From 90f80f1a8d26f865f613be568806521aa3bb4138 Mon Sep 17 00:00:00 2001
From: Thulinma <jaron@vietors.com>
Date: Tue, 20 Sep 2016 13:25:43 +0200
Subject: [PATCH] Fixed negative offsets

---
 lib/dtscmeta.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/lib/dtscmeta.cpp b/lib/dtscmeta.cpp
index 6a4c5dd1..5f28ad1b 100644
--- a/lib/dtscmeta.cpp
+++ b/lib/dtscmeta.cpp
@@ -873,8 +873,14 @@ namespace DTSC {
   }
 
   ///\brief returns the offset of a part
+  ///Assumes the offset is actually negative if bit 0x800000 is set.
   uint32_t Part::getOffset() {
-    return Bit::btoh24(data + 6);
+    uint32_t ret = Bit::btoh24(data + 6);
+    if (ret & 0x800000){
+      return ret | 0xff000000ul;
+    }else{
+      return ret;
+    }
   }
 
   ///\brief Sets the offset of a part