Skip to content

Commit

Permalink
Extra asserts to ensure samples are decoded properly
Browse files Browse the repository at this point in the history
  • Loading branch information
CookiePLMonster committed Feb 8, 2017
1 parent e49bbaa commit f5ee459
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
3 changes: 3 additions & 0 deletions vagdec.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,8 @@ static short quantize(double sample)
return short(a);
}

#include <cassert>

bool FetchStr( ASISTREAM *STR, int offset = -1 )
{
U8 in_buf[0x20];
Expand Down Expand Up @@ -159,6 +161,7 @@ bool FetchStr( ASISTREAM *STR, int offset = -1 )
int predict_nr = *(bufs[c]++);
int shift_factor = predict_nr & 0xf;
predict_nr >>= 4;
assert( predict_nr < 5 );
int flags = *(bufs[c]++);
if ( flags == 7 ) return false;
for ( int i = 0; i < 28; i += 2 )
Expand Down
4 changes: 4 additions & 0 deletions vbcalls.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
#include <vector>
#include <algorithm>

#include <cassert>

class VBStream
{
public:
Expand Down Expand Up @@ -97,6 +99,7 @@ class VBStream
}
}
virtualCursor += Bytes;
assert( (virtualCursor & ((VB_SAMPLE_SIZE*2)-1)) == 0 );
return Bytes;
}

Expand Down Expand Up @@ -136,6 +139,7 @@ class VBStream
ReadBlockAndInterleave();
currentBlockCursor = OffsetNoHeader & (VB_BLOCK_SIZE-1);
}
assert( (currentBlockCursor & ((VB_SAMPLE_SIZE*2)-1)) == 0 );
}
else
{
Expand Down
8 changes: 8 additions & 0 deletions vbdec.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -54,13 +54,17 @@
<SDLCheck>true</SDLCheck>
<AdditionalOptions>/Zc:threadSafeInit- %(AdditionalOptions)</AdditionalOptions>
<EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
<PreprocessorDefinitions>_DEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<AdditionalDependencies>mss/mss32.lib;mss/mss32_2.lib;%(AdditionalDependencies)</AdditionalDependencies>
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<SubSystem>Windows</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation>
</Link>
<PostBuildEvent>
<Command>copy /y "$(TargetPath)" "$(GTA_VC_ROOT)\mss\vbdec.asi"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
<ClCompile>
Expand All @@ -76,6 +80,7 @@
<EnableEnhancedInstructionSet>StreamingSIMDExtensions</EnableEnhancedInstructionSet>
<FloatingPointModel>Fast</FloatingPointModel>
<AdditionalOptions>/Zc:threadSafeInit- %(AdditionalOptions)</AdditionalOptions>
<PreprocessorDefinitions>NDEBUG;%(PreprocessorDefinitions)</PreprocessorDefinitions>
</ClCompile>
<Link>
<EnableCOMDATFolding>true</EnableCOMDATFolding>
Expand All @@ -84,6 +89,9 @@
<ImageHasSafeExceptionHandlers>false</ImageHasSafeExceptionHandlers>
<SubSystem>Windows</SubSystem>
</Link>
<PostBuildEvent>
<Command>copy /y "$(TargetPath)" "$(GTA_VC_ROOT)\mss\vbdec.asi"</Command>
</PostBuildEvent>
</ItemDefinitionGroup>
<ItemGroup>
<ClCompile Include="dllmain.cpp" />
Expand Down

0 comments on commit f5ee459

Please sign in to comment.