Check for zeros equal to the total samples early, because in that case we would already be leaving the first few frames out. Fixes trac ticket #10692
Showing the changes to libavfilter (1 of 1 file). Show all
Unified · Split
| @@ -531,21 +531,21 @@ static int yae_load_frag(ATempoContext *atempo, · 530 unmodified lines | |||
| 531 | dst = frag->data; | 531 | dst = frag->data; |
| 532 | 532 | ||
| 533 | start = atempo->position[0] - atempo->size; | 533 | start = atempo->position[0] - atempo->size; |
| 534 | zeros = 0; | ||
| 535 | 534 | ||
| 536 | if (frag->position[0] < start) { | 535 | // what we don't have we substitute with zeros: |
| 537 | // what we don't have we substitute with zeros: | 536 | zeros = |
| 538 | zeros = FFMIN(start - frag->position[0], (int64_t)nsamples); | 537 | frag->position[0] < start ? |
| 539 | av_assert0(zeros != nsamples); | 538 | FFMIN(start - frag->position[0], (int64_t)nsamples) : 0; |
| 540 | |||
| 541 | memset(dst, 0, zeros * atempo->stride); | ||
| 542 | dst += zeros * atempo->stride; | ||
| 543 | } | ||
| 544 | 539 | ||
| 545 | if (zeros == nsamples) { | 540 | if (zeros == nsamples) { |
| 546 | return 0; | 541 | return 0; |
| 547 | } | 542 | } |
| 548 | 543 | ||
| 544 | if (frag->position[0] < start) { | ||
| 545 | memset(dst, 0, zeros * atempo->stride); | ||
| 546 | dst += zeros * atempo->stride; | ||
| 547 | } | ||
| 548 | |||
| 549 | // get the remaining data from the ring buffer: | 549 | // get the remaining data from the ring buffer: |
| 550 | na = (atempo->head < atempo->tail ? | 550 | na = (atempo->head < atempo->tail ? |
| 551 | atempo->tail - atempo->head : | 551 | atempo->tail - atempo->head : |