ffmdec: limit the backward seek to the last resync position
If resyncing leads to the same position as previously, it will again
lead to a resync attempt, resulting in an infinite loop.
Thus don't seek back beyond the last syncpoint.
Signed-off-by: Andreas Cadhalpun <Andreas.Cadhalpun@googlemail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
(cherry picked from commit 6b8263b03a
)
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
This commit is contained in:

committed by
Michael Niedermayer

parent
9be586e166
commit
0f2401e3cb
@@ -77,6 +77,7 @@ static int ffm_read_data(AVFormatContext *s,
|
|||||||
FFMContext *ffm = s->priv_data;
|
FFMContext *ffm = s->priv_data;
|
||||||
AVIOContext *pb = s->pb;
|
AVIOContext *pb = s->pb;
|
||||||
int len, fill_size, size1, frame_offset, id;
|
int len, fill_size, size1, frame_offset, id;
|
||||||
|
int64_t last_pos = -1;
|
||||||
|
|
||||||
size1 = size;
|
size1 = size;
|
||||||
while (size > 0) {
|
while (size > 0) {
|
||||||
@@ -96,9 +97,11 @@ static int ffm_read_data(AVFormatContext *s,
|
|||||||
avio_seek(pb, tell, SEEK_SET);
|
avio_seek(pb, tell, SEEK_SET);
|
||||||
}
|
}
|
||||||
id = avio_rb16(pb); /* PACKET_ID */
|
id = avio_rb16(pb); /* PACKET_ID */
|
||||||
if (id != PACKET_ID)
|
if (id != PACKET_ID) {
|
||||||
if (ffm_resync(s, id) < 0)
|
if (ffm_resync(s, id) < 0)
|
||||||
return -1;
|
return -1;
|
||||||
|
last_pos = avio_tell(pb);
|
||||||
|
}
|
||||||
fill_size = avio_rb16(pb);
|
fill_size = avio_rb16(pb);
|
||||||
ffm->dts = avio_rb64(pb);
|
ffm->dts = avio_rb64(pb);
|
||||||
frame_offset = avio_rb16(pb);
|
frame_offset = avio_rb16(pb);
|
||||||
@@ -112,7 +115,9 @@ static int ffm_read_data(AVFormatContext *s,
|
|||||||
if (!frame_offset) {
|
if (!frame_offset) {
|
||||||
/* This packet has no frame headers in it */
|
/* This packet has no frame headers in it */
|
||||||
if (avio_tell(pb) >= ffm->packet_size * 3LL) {
|
if (avio_tell(pb) >= ffm->packet_size * 3LL) {
|
||||||
avio_seek(pb, -ffm->packet_size * 2LL, SEEK_CUR);
|
int64_t seekback = FFMIN(ffm->packet_size * 2LL, avio_tell(pb) - last_pos);
|
||||||
|
seekback = FFMAX(seekback, 0);
|
||||||
|
avio_seek(pb, -seekback, SEEK_CUR);
|
||||||
goto retry_read;
|
goto retry_read;
|
||||||
}
|
}
|
||||||
/* This is bad, we cannot find a valid frame header */
|
/* This is bad, we cannot find a valid frame header */
|
||||||
|
Reference in New Issue
Block a user