You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-10 06:10:52 +02:00
fftools/sync_queue: make sure non-limiting streams are not used as queue head
A non-limiting stream could mistakenly end up being the queue head, which would then produce incorrect synchronization, seen e.g. in fate-matroska-flac-extradata-update for certain number of frame threads (e.g. 5). Found-By: James Almer
This commit is contained in:
@@ -217,17 +217,26 @@ static void finish_stream(SyncQueue *sq, unsigned int stream_idx)
|
|||||||
|
|
||||||
static void queue_head_update(SyncQueue *sq)
|
static void queue_head_update(SyncQueue *sq)
|
||||||
{
|
{
|
||||||
|
av_assert0(sq->have_limiting);
|
||||||
|
|
||||||
if (sq->head_stream < 0) {
|
if (sq->head_stream < 0) {
|
||||||
|
unsigned first_limiting = UINT_MAX;
|
||||||
|
|
||||||
/* wait for one timestamp in each stream before determining
|
/* wait for one timestamp in each stream before determining
|
||||||
* the queue head */
|
* the queue head */
|
||||||
for (unsigned int i = 0; i < sq->nb_streams; i++) {
|
for (unsigned int i = 0; i < sq->nb_streams; i++) {
|
||||||
SyncQueueStream *st = &sq->streams[i];
|
SyncQueueStream *st = &sq->streams[i];
|
||||||
if (st->limiting && st->head_ts == AV_NOPTS_VALUE)
|
if (!st->limiting)
|
||||||
|
continue;
|
||||||
|
if (st->head_ts == AV_NOPTS_VALUE)
|
||||||
return;
|
return;
|
||||||
|
if (first_limiting == UINT_MAX)
|
||||||
|
first_limiting = i;
|
||||||
}
|
}
|
||||||
|
|
||||||
// placeholder value, correct one will be found below
|
// placeholder value, correct one will be found below
|
||||||
sq->head_stream = 0;
|
av_assert0(first_limiting < UINT_MAX);
|
||||||
|
sq->head_stream = first_limiting;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned int i = 0; i < sq->nb_streams; i++) {
|
for (unsigned int i = 0; i < sq->nb_streams; i++) {
|
||||||
|
Reference in New Issue
Block a user