diff --git a/source/App/DecoderApp/DecApp.cpp b/source/App/DecoderApp/DecApp.cpp index 30cb33add21111311af62195a98f8a19f8e88093..ae1d37e5e661d65bf5f8ce846a4f2f2a01073cf8 100644 --- a/source/App/DecoderApp/DecApp.cpp +++ b/source/App/DecoderApp/DecApp.cpp @@ -1179,14 +1179,12 @@ void DecApp::xFlushOutput( PicList* pcListPic, const int layerId ) if (pcPic->fieldPic ) //Field Decoding { - PicList::iterator endPic = pcListPic->end(); - endPic--; - Picture *pcPicTop, *pcPicBottom = nullptr; + PicList::iterator endPic = pcListPic->end(); while (iterPic != endPic) { - pcPicTop = *(iterPic); + Picture *pcPicTop = *iterPic; iterPic++; - pcPicBottom = *(iterPic); + Picture *pcPicBottom = iterPic == endPic ? pcPicTop : *iterPic; if( pcPicTop->layerId != layerId && layerId != NOT_VALID ) { @@ -1227,19 +1225,24 @@ void DecApp::xFlushOutput( PicList* pcListPic, const int layerId ) pcPicTop->neededForOutput = false; pcPicBottom->neededForOutput = false; - if(pcPicTop) - { - pcPicTop->destroy(); - delete pcPicTop; - pcPicTop = nullptr; - } + pcPicTop->destroy(); + delete pcPicTop; + pcPicBottom->destroy(); + delete pcPicBottom; + iterPic--; + *iterPic = nullptr; + iterPic++; + *iterPic = nullptr; + iterPic++; + } + else + { + pcPicTop->destroy(); + delete pcPicTop; + iterPic--; + *iterPic = nullptr; + iterPic++; } - } - if(pcPicBottom) - { - pcPicBottom->destroy(); - delete pcPicBottom; - pcPicBottom = nullptr; } } else //Frame decoding @@ -1375,7 +1378,9 @@ void DecApp::xFlushOutput( PicList* pcListPic, const int layerId ) pcListPic->remove_if([](Picture* p) { return p == nullptr; }); } else - pcListPic->clear(); + { + pcListPic->clear(); + } m_iPOCLastDisplay = -MAX_INT; }