Instead of just updating statistics and leaving the work to the call site, have it actually do the work.
Showing the changes to libavfilter/framequeue.c (1 of 3 files). Show all
Unified · Split
| @@ -121,3 +121,30 @@ AVFrame *ff_framequeue_peek(FFFrameQueue *fq, size_t idx) · 120 unmodified lines | |||
| 121 | check_consistency(fq); | 121 | check_consistency(fq); |
| 122 | return b->frame; | 122 | return b->frame; |
| 123 | } | 123 | } |
| 124 | |||
| 125 | void ff_framequeue_skip_samples(FFFrameQueue *fq, size_t samples, AVRational time_base) | ||
| 126 | { | ||
| 127 | FFFrameBucket *b; | ||
| 128 | size_t bytes; | ||
| 129 | int planar, planes, i; | ||
| 130 | |||
| 131 | check_consistency(fq); | ||
| 132 | av_assert1(fq->queued); | ||
| 133 | b = bucket(fq, 0); | ||
| 134 | av_assert1(samples < b->frame->nb_samples); | ||
| 135 | planar = av_sample_fmt_is_planar(b->frame->format); | ||
| 136 | planes = planar ? b->frame->channels : 1; | ||
| 137 | bytes = samples * av_get_bytes_per_sample(b->frame->format); | ||
| 138 | if (!planar) | ||
| 139 | bytes *= b->frame->channels; | ||
| 140 | if (b->frame->pts != AV_NOPTS_VALUE) | ||
| 141 | b->frame->pts += av_rescale_q(samples, av_make_q(1, b->frame->sample_rate), time_base); | ||
| 142 | b->frame->nb_samples -= samples; | ||
| 143 | b->frame->linesize[0] -= bytes; | ||
| 144 | for (i = 0; i < planes; i++) | ||
| 145 | b->frame->extended_data[i] += bytes; | ||
| 146 | for (i = 0; i < planes && i < AV_NUM_DATA_POINTERS; i++) | ||
| 147 | b->frame->data[i] = b->frame->extended_data[i]; | ||
| 148 | fq->total_samples_tail += samples; | ||
| 149 | ff_framequeue_update_peeked(fq, 0); | ||
| 150 | } | ||