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
Unified · Split
| @@ -531,21 +531,21 @@ static int yae_load_frag(ATempoContext *atempo, · 530 unmodified lines | ||
| 531 | 531 | dst = frag->data; |
| 532 | 532 | |
| 533 | 533 | start = atempo->position[0] - atempo->size; |
| 534 | − zeros = 0; | |
| 535 | 534 | |
| 536 | − if (frag->position[0] < start) { | |
| 537 | − // what we don't have we substitute with zeros: | |
| 538 | − zeros = FFMIN(start - frag->position[0], (int64_t)nsamples); | |
| 539 | − av_assert0(zeros != nsamples); | |
| 540 | − | |
| 541 | − memset(dst, 0, zeros * atempo->stride); | |
| 542 | − dst += zeros * atempo->stride; | |
| 543 | − } | |
| 535 | + // what we don't have we substitute with zeros: | |
| 536 | + zeros = | |
| 537 | + frag->position[0] < start ? | |
| 538 | + FFMIN(start - frag->position[0], (int64_t)nsamples) : 0; | |
| 544 | 539 | |
| 545 | 540 | if (zeros == nsamples) { |
| 546 | 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 | 549 | // get the remaining data from the ring buffer: |
| 550 | 550 | na = (atempo->head < atempo->tail ? |
| 551 | 551 | atempo->tail - atempo->head : |