Skip to content

Commit

Permalink
[TS/Demux] Very simple brute force LATM /AAC prove
Browse files Browse the repository at this point in the history
  • Loading branch information
mean committed May 23, 2017
1 parent b4080ef commit 15cafef
Showing 1 changed file with 44 additions and 5 deletions.
49 changes: 44 additions & 5 deletions avidemux_plugins/ADM_demuxers/MpegTS/ADM_tsBruteForce.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#define MAX_PID (1<<17)
#define MAX_BUFFER_SIZE (10*1024)
static bool idAAC_ADTS(int pid,tsPacket *ts);
static bool idAAC_LATM(int pid,tsPacket *ts);
static bool idContent(int pid,tsPacket *ts,ADM_TS_TRACK_TYPE & trackType);
static bool idMP2(int pid,tsPacket *ts);
/**
Expand Down Expand Up @@ -305,6 +306,8 @@ TS_PESpacket pes2(pid);
}

}

// Mpeg audio ?
if(idMP2(pid,ts))
{
ADM_info("\t probably MP2\n");
Expand All @@ -318,7 +321,13 @@ TS_PESpacket pes2(pid);
trackType=ADM_TS_AAC_ADTS;
return true;
}

// AAC LATM ?
if( idAAC_LATM(pid,ts))
{
ADM_info("\t probably AAC/LATM\n");
trackType=ADM_TS_AAC_LATM;
return true;
}
ADM_info("Cannot identify track\n");
return false;
}
Expand Down Expand Up @@ -386,8 +395,40 @@ uint8_t mp2Buffer[MP2_PROBE_SIZE*2];
}
return false;
}
/**
\fn idMP2
/**
* \fn idAAC_LATM
\brief return true if the tracks is AAC/LATM
* @param pid
* @param ts
* @return
*/
bool idAAC_LATM(int pid, tsPacket *ts)
{
#define LATM_NB_PACKET 10
#define LATM_MIN_MATCH 7
int match=0;
TS_PESpacket pes(pid);
for(int i=0;i<LATM_NB_PACKET;i++)
{
if(!ts->getNextPES(&pes))
{
ADM_warning("ADTS:Cannot get PES for pid=%d\n",pid);
return false;
}
uint8_t *p=pes.payload+pes.offset;
int key=(p[0]<<8)+p[1];
if((key & 0xffe0)==0x56e0) // 0x2b7 shifted by one bit
match++;
}
ADM_info("\t LATM match : %d/%d\n",match,LATM_MIN_MATCH);
if(match>=LATM_MIN_MATCH)
{
return true;
}
return false;
}
/**
\fn idAAC_ADTS
\brief return true if the tracks is AAC/ADTS
*/
bool idAAC_ADTS(int pid,tsPacket *ts)
Expand Down Expand Up @@ -416,10 +457,8 @@ bool idAAC_ADTS(int pid,tsPacket *ts)
ADM_info("\t Adts match : %d/%d\n",match,ADTS_NB_PACKET);
if(match>=ADTS_MIN_MATCH)
{

return true;
}

return false;
}

Expand Down

0 comments on commit 15cafef

Please sign in to comment.