https://kb.speeddemosarchive.com/index.php?title=Anri-chan/Source/aud.cpp&feed=atom&action=history
Anri-chan/Source/aud.cpp - Revision history
2024-03-29T05:33:14Z
Revision history for this page on the wiki
MediaWiki 1.23.9
https://kb.speeddemosarchive.com/index.php?title=Anri-chan/Source/aud.cpp&diff=2093&oldid=prev
Ballofsnow: New page: <pre><nowiki> /* Returns the audio type. author: ballofsnow date: 31 July 2007 license: none (public domain) target: win32 (MINGW), recommend using the free IDE from bloodshed....
2007-08-01T03:41:43Z
<p>New page: <pre><nowiki> /* Returns the audio type. author: ballofsnow date: 31 July 2007 license: none (public domain) target: win32 (MINGW), recommend using the free IDE from bloodshed....</p>
<p><b>New page</b></p><div><pre><nowiki><br />
/*<br />
<br />
Returns the audio type.<br />
<br />
author: ballofsnow<br />
date: 31 July 2007<br />
license: none (public domain)<br />
target: win32 (MINGW), recommend using the free IDE from bloodshed.net<br />
version: beta 0.2<br />
<br />
AC3 00000000 = 0x00<br />
Unknown1 00100000 = 0x20<br />
Mpeg-1 01000000 = 0x40<br />
Mpeg-2ext 01100000 = 0x60<br />
LPCM 10000000 = 0x80<br />
Unknown2 10100000 = 0xA0<br />
DTS 11000000 = 0xC0<br />
SDDS 11100000 = 0xE0<br />
<br />
Find the byte at offset 0x204 or decimal 516 of an IFO file.<br />
<br />
*/<br />
<br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <string.h><br />
#include <bitset><br />
using namespace std;<br />
<br />
void usage(char *argv0);<br />
unsigned char checkifo[12]= { 0x44, 0x56, 0x44, 0x56, 0x49, 0x44, 0x45, 0x4F, 0x2D, 0x56, 0x54, 0x53 }; /* DVDVIDEO-VTS */<br />
unsigned char buffer[1024*1024];<br />
<br />
int main (int argc, char **argv) {<br />
FILE *ifo;<br />
char *ifoname=NULL;<br />
int rval;<br />
printf ("Audio type analyzer\n");<br />
printf ("beta 0.2, ballofsnow\n");<br />
printf ("This software comes with no warranty.\n");<br />
printf ("For help, run program with no parameters\n\n"); <br />
<br />
if (argc!=2) {<br />
usage(argv[0]);<br />
return 0;<br />
}<br />
<br />
/* LOAD AND VALIDATE THE IFO */<br />
ifoname=argv[1];<br />
if ((ifo=fopen(ifoname,"rb"))==NULL) {<br />
printf ("[-] Failed to open IFO file \"%s\".\n", ifoname);<br />
return -1;<br />
} <br />
// Source res is at offset 0x0200, or 512 decimal, 2 bytes.<br />
// Audio type is at offset 0x0204, or 516 decimal, 1 byte. <br />
fread(buffer,1,517,ifo);<br />
if (memcmp(checkifo,buffer,12) != 0) {<br />
printf ("This isn't an IFO file.\n");<br />
free(buffer);<br />
fclose(ifo);<br />
usage(argv[0]);<br />
return -1;<br />
}<br />
/* FINISHED VALIDATING */<br />
<br />
/* MASK THE BYTE TO GET THE RELEVANT BITS */<br />
bitset<CHAR_BIT> atype (buffer[516]); <br />
atype &= 0xE0;<br />
<br />
if (atype == 0x00) {<br />
printf ("AC3\n");<br />
rval=1; <br />
}<br />
else if (atype == 0x20) {<br />
printf ("Unknown1\n");<br />
rval=2;<br />
}<br />
else if (atype == 0x40) {<br />
printf ("Mpeg-1\n");<br />
rval=3;<br />
}<br />
else if (atype == 0x60) {<br />
printf ("Mpeg-2ext\n");<br />
rval=4;<br />
}<br />
else if (atype == 0x80) {<br />
printf ("LPCM\n");<br />
rval=5;<br />
}<br />
else if (atype == 0xA0) {<br />
printf ("Unknown2\n");<br />
rval=6;<br />
}<br />
else if (atype == 0xC0) {<br />
printf ("DTS\n");<br />
rval=7;<br />
}<br />
else if (atype == 0xE0) {<br />
printf ("SDDS\n");<br />
rval=8;<br />
}<br />
<br />
free(buffer); // ifo buffer<br />
fclose(ifo);<br />
return rval; <br />
}<br />
<br />
void usage(char *argv0) {<br />
printf ("Usage: %s <VTS IFO file>\n\n", argv0);<br />
printf ("Returns value to %%ERRORLEVEL%%.\n");<br />
printf (" 1 - AC3\n");<br />
printf (" 2 - Unknown1\n");<br />
printf (" 3 - Mpeg-1\n");<br />
printf (" 4 - Mpeg-2ext\n");<br />
printf (" 5 - LPCM\n");<br />
printf (" 6 - Unknown2\n");<br />
printf (" 7 - DTS\n");<br />
printf (" 8 - SDDS\n");<br />
}<br />
</nowiki></pre></div>
Ballofsnow