Skip to content

Commit

Permalink
[demuxers/MpegTS] Try to recover from encountering a damaged LATM fra…
Browse files Browse the repository at this point in the history
…me instead of giving up immediately
  • Loading branch information
eumagga0x2a committed Dec 20, 2020
1 parent f1fca08 commit 7bdd837
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions avidemux_plugins/ADM_demuxers/MpegTS/ADM_tsAudio.cpp
Expand Up @@ -310,7 +310,7 @@ bool ADM_tsAccess::getPacket(uint8_t *buffer, uint32_t *size, uint32_t maxS
case ADM_TS_MUX_LATM:
{
// Try to get one...
int retries=20;
int retries=40; // arbitrary
bool gotPacket=false;
uint64_t time=ADM_NO_PTS;
while(latm.empty()) // fetch next LOAS frame, it will contain several frames
Expand All @@ -321,8 +321,14 @@ bool ADM_tsAccess::getPacket(uint8_t *buffer, uint32_t *size, uint32_t maxS
return false;
}
if(gotPacket) time=packet->pts;
if(ADM_latm2aac::LATM_MORE_DATA_NEEDED==latm.convert(time))
ADM_latm2aac::LATM_STATE outcome = latm.convert(time);
if(outcome != ADM_latm2aac::LATM_OK)
{
if(outcome == ADM_latm2aac::LATM_ERROR)
{
latm.flush();
ADM_warning("Error demuxing LATM frame, %d attempts remaining.\n",retries);
}
if(false==demuxer.getNextPES(packet)) return false;
int avail=packet->payloadSize-packet->offset;
if(avail>maxSize) ADM_assert(0);
Expand Down

0 comments on commit 7bdd837

Please sign in to comment.