cosmetics and fixed a head overflow.

This commit is contained in:
Damiano Galassi committed 2018-11-22 15:28:32 +01:00
1 parent d7f2d6ebba
commit a32f84002e
1 file changed
+10 -4
+10 -4
View File
@@ -897,7 +897,7 @@ int analyze_EAC3(void **context, uint8_t *frame, uint32_t size)
while (cumul_size != size) { while (cumul_size != size) {
int i; int i;
CMemoryBitstream gbc; CMemoryBitstream gbc;
gbc.SetBytes(frame + cumul_size, (size - cumul_size) * 8); gbc.SetBytes(frame + cumul_size, (size - cumul_size));
if (ac3_parse_header(gbc, &hdr) < 0) { if (ac3_parse_header(gbc, &hdr) < 0) {
free(hdr); free(hdr);
return -1; return -1;
@@ -1283,7 +1283,9 @@ bool parse_ac3_emdf(CMemoryBitstream &b, AC3HeaderInfo *hdr)
//Could use CMemoryBitstream.PutBytes() to create a copy of CMBS //Could use CMemoryBitstream.PutBytes() to create a copy of CMBS
uint16_t emdf_sync = b.GetBits(16); //syncword 0x5838 uint16_t emdf_sync = b.GetBits(16); //syncword 0x5838
if (emdf_sync != 0x5838) { if (emdf_sync != 0x5838) {
#ifdef DEBUG_PARSER
printf("WTF"); printf("WTF");
#endif
} }
uint32_t emdf_container_length = b.GetBits(16) * 8; //emdf_container_length uint32_t emdf_container_length = b.GetBits(16) * 8; //emdf_container_length
//bool have_oamd = false, have_joc = false; //for the lack of better, lets expect only sequence OAMD-JOC-END //bool have_oamd = false, have_joc = false; //for the lack of better, lets expect only sequence OAMD-JOC-END
@@ -1385,11 +1387,14 @@ bool parse_ac3_emdf(CMemoryBitstream &b, AC3HeaderInfo *hdr)
//Atmos in E-AC-3 is detected by looking for OAMD payload (see ETSI TS 103 420) //Atmos in E-AC-3 is detected by looking for OAMD payload (see ETSI TS 103 420)
// in EMDF container in skipfld inside audblk() of E-AC-3 frame (see ETSI TS 102 366) // in EMDF container in skipfld inside audblk() of E-AC-3 frame (see ETSI TS 102 366)
void analyze_ac3_skipfld(CMemoryBitstream &b, AC3HeaderInfo *hdr) void analyze_ac3_skipfld(CMemoryBitstream &b, AC3HeaderInfo *hdr)
{ //Let's take a look at frame's auxdata() {
//Let's take a look at frame's auxdata()
uint16_t emdf_syncword; uint16_t emdf_syncword;
if(hdr->bitstream_id != 16) if (hdr->bitstream_id != 16) {
return; return;
}
while (b.GetRemainingBits() > 16) { while (b.GetRemainingBits() > 16) {
emdf_syncword = b.PeakBits(16); emdf_syncword = b.PeakBits(16);
if (emdf_syncword == 0x5838) { //NB! b.head still points to emdf syncword because we peeked and did not get the bits! if (emdf_syncword == 0x5838) { //NB! b.head still points to emdf syncword because we peeked and did not get the bits!
@@ -1397,8 +1402,9 @@ void analyze_ac3_skipfld(CMemoryBitstream &b, AC3HeaderInfo *hdr)
printf("parsing bitstream_id: 0x%X frame_type: 0x%0X substreamid: 0x%0X\n", hdr->bitstream_id, hdr->frame_type, hdr->substreamid); printf("parsing bitstream_id: 0x%X frame_type: 0x%0X substreamid: 0x%0X\n", hdr->bitstream_id, hdr->frame_type, hdr->substreamid);
printf("SKIPFLD: found EMDF syncword 0x%x at bit pos: 0x%0x (%d)\n", emdf_syncword, b.GetBitPosition(), b.GetBitPosition()); printf("SKIPFLD: found EMDF syncword 0x%x at bit pos: 0x%0x (%d)\n", emdf_syncword, b.GetBitPosition(), b.GetBitPosition());
#endif #endif
if(parse_ac3_emdf(b, hdr)) if (parse_ac3_emdf(b, hdr)) {
break; break;
}
// else //false positive // else //false positive
// b.SkipBits(1); // b.SkipBits(1);
} else { } else {