📄 scan.java
字号:
{
return timeformat.format(new java.util.Date((len*8000)/Audio.Bitrate));
}
public void setBuffer(int buffersize)
{
this.buffersize=buffersize;
}
public int testFile(XInputFile aXInputFile, boolean more)
{
long len = aXInputFile.length();
int ret = testFile(aXInputFile, more, 0);
if (ret != 0)
return ret;
// if type is not yet detected, try it again on a later position (10% of length)
return testFile(aXInputFile, more, len / 10);
}
public int testFile(XInputFile aXInputFile, boolean more, long position)
{
video_streams.clear();
audio_streams.clear();
ttx_streams.clear();
pic_streams.clear();
video = msg_1;
audio = msg_2;
text = msg_3;
pics = msg_4; //DM28042004 081.7 int02 add
addInfo = "";
playtime = "";
hasVideo = false;
nullpacket = false;
long size = 0;
timeformat.setTimeZone(java.util.TimeZone.getTimeZone("GMT+0:00"));
int bs0 = buffersize / 100;
int bs1 = buffersize / 50;
int bs2 = buffersize / 10;
int bs3 = buffersize / 4;
int bs4 = buffersize - 65536; //DM10122003 081.6_int04 fix, //DM23022004 081.6_int18 fix
byte[] check= new byte[buffersize];
ByteArrayOutputStream bytecheck = new ByteArrayOutputStream();
try
{
size = aXInputFile.length();
// aXInputFile.randomAccessSingleRead(check, position);
aXInputFile.getNewInstance().randomAccessSingleRead(check, position);
riffcheck:
for (int a=0; a<bs0; a++) //DM30122003 081.6 int10 add, compressed as AC3,MPEG is currently better detected as ES-not RIFF
{
int ERRORCODE = Audio.WAV_parseHeader(check, a);
if (ERRORCODE > -1) //DM26032004 081.6 int18 changed
{
Audio.saveHeader();
if (more)
{
audio = Audio.WAV_displayHeader();
playtime = getAudioTime(size);
}
if (ERRORCODE > 0)
return Common.ES_RIFF_TYPE;
else if (Audio.lMode_extension > 1)
break riffcheck;
else
return Common.ES_cRIFF_TYPE;
}
}
supcheck:
for (int a=0; a < bs0; a++) //DM31012004 081.6 int13 add
{
if (check[a]!=0x53 || check[a+1]!=0x50)
continue supcheck;
int supframe_size = (0xFF & check[a+10])<<8 | (0xFF & check[a+11]);
int supframe_link = (0xFF & check[a+12])<<8 | (0xFF & check[a+13]);
int supframe_check = (0xFF & check[a+12+supframe_link])<<8 | (0xFF & check[a+13+supframe_link]);
int supframe_check2 = (0xFF & check[a+36+supframe_link])<<8 | (0xFF & check[a+37+supframe_link]);
if (supframe_link == supframe_check-24 && supframe_check == supframe_check2)
{
if (more)
{
int b=a+14+supframe_link, c=b+24, d, xa, xe, ya, ye;
for (d=b; d<c; d++)
{
switch(0xFF & check[d])
{
case 1:
d++;
continue;
case 2:
d+=24;
continue;
case 3:
case 4:
d+=2;
continue;
case 6:
d+=4;
continue;
case 5:
xa= (0xFF & check[++d])<<4 | (0xF0 & check[++d])>>>4;
xe= (0xF & check[d])<<8 | (0xFF & check[++d]);
ya= (0xFF & check[++d])<<4 | (0xF0 & check[++d])>>>4;
ye= (0xF & check[d])<<8 | (0xFF & check[++d]);
pics = "up.left x" + xa + ",y" + ya + " @ size " + (xe - xa + 1) + "*" + (ye - ya + 1); //DM05052004 081.7 int02 changed,fix
}
break;
}
//DM06032004 081.6 int18 add
byte packet[] = new byte[10+supframe_size];
System.arraycopy(check,a,packet,0,10+supframe_size);
X.subpicture.picture.decode_picture(packet,10,X.subpicture.isVisible());
}
return Common.ES_SUP_TYPE;
}
}
mpegtscheck:
for (int a=0; a < bs4; a++) //DM17012004 081.6 int11 changed
{
if ( check[a]!=0x47 || check[a+188]!=0x47 || check[a+376]!=0x47 || check[a+564]!=0x47 || check[a+752]!=0x47)
continue mpegtscheck;
PMTcheck(check, a);
return Common.TS_TYPE;
}
pvacheck:
for (int a=0; a < bs1; a++)
{
if ( check[a]!=(byte)0x41 || check[a+1]!=(byte)0x56 || check[a+4]!=(byte)0x55 )
continue pvacheck;
int next = a+8+( (255&check[a+6])<<8 | (255&check[a+7]) );
if ( check[next]!=(byte)0x41 || check[next+1]!=(byte)0x56 || check[next+4]!=(byte)0x55 )
continue pvacheck;
else
{
if (more)
loadPVA(check,a);
return Common.PVA_TYPE;
}
}
mpgcheck:
for (int a=0; a<bs2; a++)
{
if ( check[a]!=0 || check[a+1]!=0 || check[a+2]!=1 || check[a+3]!=(byte)0xba )
continue mpgcheck;
if ( (0xC0 & check[a+4])==0 )
{
if (more)
loadMPG2(check, a, false, true, bs1);
return Common.MPEG1PS_TYPE;
}
else if ( (0xC0 & check[a+4])==0x40 )
{
if (more)
// loadMPG2(check, a, false, false, bs1);
loadMPG2(check, a, X.cBox[14].isSelected(), false, bs1);
return Common.MPEG2PS_TYPE;
}
}
vdrcheck:
for (int a=0; a < bs4; a++)
{
if ( check[a]!=0 || check[a+1]!=0 || check[a+2]!=1 || (0xF0&check[a+3])!=0xe0 )
continue vdrcheck;
int next = a+6+( (255&check[a+4])<<8 | (255&check[a+5]) );
if (next==a+6 && (0xC0&check[a+6])==0x80 && (0xC0&check[a+8])==0)
{
addInfo += " !!(Vpacketsize=0)";
next=a;
nullpacket=true;
}
if ( check[next]!=0 || check[next+1]!=0 || check[next+2]!=1 )
continue vdrcheck;
else
{
if (more)
loadMPG2(check, a, true, false, bs3);
return Common.PES_AV_TYPE;
}
}
rawcheck:
for (int a=0; a < bs2; a++)
{
if ( check[a] != 0 || check[a+1] != 0 || check[a+2] != 1 )
continue rawcheck;
if ( (0xE0 & check[a+3]) == 0xC0 || (0xFF & check[a+3]) == 0xBD )
{
int next = a + 6 + ( (0xFF & check[a+4])<<8 | (0xFF & check[a+5]) );
if ( check[next] != 0 || check[next+1] != 0 || check[next+2] != 1 )
continue rawcheck;
if ( (0xE0 & check[a+3])==0xC0 && (0xE0 & check[a+3])==(0xE0 & check[next+3]) )
{
if (more)
loadMPG2(check, a, true, false, bs3);
return Common.PES_MPA_TYPE;
}
else if ( (0xFF & check[a+3]) == 0xBD && check[a+3] == check[next+3] )
{
if (more)
{
//DM10032004 081.6 int18 changed
if (check[a+8]==0x24 && (0xF0&check[a+9+0x24])>>>4 == 1)
{
addInfo=" (TTX)";
text = "SubID 0x"+Integer.toHexString((0xFF & check[a+9+0x24])).toUpperCase();
}
else
loadMPG2(check, a, true, false, bs3);
}
return Common.PES_PS1_TYPE;
}
}
}
//ES audio
audiocheck:
for (int a=0; a < bs0; a++)
{
/* DTS stuff taken from the VideoLAN project. */
/* Added by R One, 2003/12/18. */
//DM20122003 081.6 int07 add
if (Audio.DTS_parseHeader(check, a) > 0)
{
for (int b=0; b < 15; b++)
{
if (Audio.DTS_parseNextHeader(check,a + Audio.Size + b) == 1)
{
if ( (0xFF & check[a + Audio.Size]) > 0x7f || (0xFF & check[a+Audio.Size])==0 ) //smpte
continue audiocheck;
if (more)
{
audio = Audio.DTS_saveAnddisplayHeader();
playtime = getAudioTime(size);
}
if (b==0)
return Common.ES_DTS_TYPE;
else
return Common.ES_DTS_A_TYPE;
}
}
//DM30122003 081.6 int10 new
if (X.RButton[7].isSelected())
{
if (more)
audio = Audio.DTS_saveAnddisplayHeader();
playtime = getAudioTime(size);
return Common.ES_DTS_TYPE;
}
}
else if (Audio.AC3_parseHeader(check, a) > 0)
{
for (int b=0; b < 17; b++)
{
if (Audio.AC3_parseNextHeader(check,a + Audio.Size + b) == 1)
{
if ( (0xFF & check[a+Audio.Size]) > 0x3f || (0xFF & check[a + Audio.Size]) == 0 ) //smpte
continue audiocheck;
if (more)
{
audio = Audio.AC3_saveAnddisplayHeader();
playtime = getAudioTime(size);
}
if (b==0)
return Common.ES_AC3_TYPE;
else
return Common.ES_AC3_A_TYPE;
}
}
//DM30122003 081.6 int10 new
if (X.RButton[7].isSelected())
{
if (more)
audio = Audio.AC3_saveAnddisplayHeader();
playtime = getAudioTime(size);
return Common.ES_AC3_TYPE;
}
}
else if (Audio.MPA_parseHeader(check, a) > 0)
{
if (!X.RButton[7].isSelected() && Audio.MPA_parseNextHeader(check, a + Audio.Size) < 0) //DM30122003 081.6 int10 changed
continue audiocheck;
if (more)
{
audio = Audio.MPA_saveAnddisplayHeader();
playtime = getAudioTime(size);
}
return Common.ES_MPA_TYPE;
}
}
mpvcheck:
for (int a=0; a < bs3; a++)
{
if ( check[a] != 0 || check[a+1] != 0 || check[a+2] != 1 )
continue mpvcheck;
if ( check[a+3] == (byte)0xb3 )
{
for (int b=7; b < 600; b++)
{
if ( check[a+b]==0 && check[a+b+1]==0 && check[a+b+2]==1 && check[a+b+3]==(byte)0xb8 )
{
if (more)
{
hasVideo=true;
System.arraycopy(check,a,vbasic,0,12);
bytecheck.write(check,a,20);
video_streams.add(Video.videoformatByte(bytecheck.toByteArray()));
}
return Common.ES_MPV_TYPE;
}
}
}
else if ( check[a+3]==(byte)0xb8 )
{
for (int b=6; b < 20; b++)
{
if ( check[a+b]==0 && check[a+b+1]==0 && check[a+b+2]==1 && check[a+b+3]==0 )
{
if (more)
video = msg_9;
return Common.ES_MPV_TYPE;
}
}
}
}
}
catch ( IOException e )
{
playtime = msg_8;
}
check=null; //DM22122003 081.6 int09 new
System.gc();
return Common.Unsupported;
}
class ScanObject
{
private ByteArrayOutputStream buf = null;
private int id;
private int type;
private ScanObject()
{
buf = new ByteArrayOutputStream();
id = 0;
}
private ScanObject(int val1)
{
buf = new ByteArrayOutputStream();
id = val1;
}
private int getType()
{
return type;
}
private void write(byte data[]) throws IOException
{
buf.write(data);
}
private void write(byte data[], int offset, int length) throws IOException
{
buf.write(data, offset, length);
}
private byte[] getData() throws IOException
{
buf.flush();
return buf.toByteArray();
}
private void reset()
{
buf.reset();
}
}
} /** end class **/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -