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 | 79 | FFFrameBucket *nq = av_realloc_array(fq->queue, na, sizeof(*nq)); |
| 80 | 80 | if (!nq) |
| 81 | 81 | return AVERROR(ENOMEM); |
| 82 | − if (fq->tail + fq->queued > fq->allocated) | |
| 83 | − memmove(nq + fq->allocated, nq, | |
| 84 | − (fq->tail + fq->queued - fq->allocated) * sizeof(*nq)); | |
| 82 | + if (fq->tail) | |
| 83 | + memmove(nq + fq->allocated, nq, fq->tail * sizeof(*nq)); | |
| 85 | 84 | fq->queue = nq; |
| 86 | 85 | fq->allocated = na; |
| 87 | 86 | } |