In this logical branch, fq->queued and fq->allocated must be equal. Deleting this code will make it easier to understand the logic (copy the data before tail to the newly requested space)
Unified · Split
| @@ -79,9 +79,8 @@ int ff_framequeue_add(FFFrameQueue *fq, AVFrame *frame) · 78 unmodified lines | |||
| 79 | FFFrameBucket *nq = av_realloc_array(fq->queue, na, sizeof(*nq)); | 79 | FFFrameBucket *nq = av_realloc_array(fq->queue, na, sizeof(*nq)); |
| 80 | if (!nq) | 80 | if (!nq) |
| 81 | return AVERROR(ENOMEM); | 81 | return AVERROR(ENOMEM); |
| 82 | if (fq->tail + fq->queued > fq->allocated) | 82 | if (fq->tail) |
| 83 | memmove(nq + fq->allocated, nq, | 83 | memmove(nq + fq->allocated, nq, fq->tail * sizeof(*nq)); |
| 84 | (fq->tail + fq->queued - fq->allocated) * sizeof(*nq)); | ||
| 85 | fq->queue = nq; | 84 | fq->queue = nq; |
| 86 | fq->allocated = na; | 85 | fq->allocated = na; |
| 87 | } | 86 | } |