| 42 | } |
| 43 | |
| 44 | int ff_af_queue_add(AudioFrameQueue *afq, const AVFrame *f) |
| 45 | { |
| 46 | AudioFrame *new = av_fast_realloc(afq->frames, &afq->frame_alloc, sizeof(*afq->frames)*(afq->frame_count+1)); |
| 47 | if(!new) |
| 48 | return AVERROR(ENOMEM); |
| 49 | afq->frames = new; |
| 50 | new += afq->frame_count; |
| 51 | |
| 52 | /* get frame parameters */ |
| 53 | new->duration = f->nb_samples; |
| 54 | new->duration += afq->remaining_delay; |
| 55 | if (f->pts != AV_NOPTS_VALUE) { |
| 56 | new->pts = av_rescale_q(f->pts, |
| 57 | afq->avctx->time_base, |
| 58 | (AVRational){ 1, afq->avctx->sample_rate }); |
| 59 | new->pts -= afq->remaining_delay; |
| 60 | if(afq->frame_count && new[-1].pts >= new->pts) |
| 61 | av_log(afq->avctx, AV_LOG_WARNING, "Queue input is backward in time\n"); |
| 62 | } else { |
| 63 | new->pts = AV_NOPTS_VALUE; |
| 64 | } |
| 65 | afq->remaining_delay = 0; |
| 66 | |
| 67 | /* add frame sample count */ |
| 68 | afq->remaining_samples += f->nb_samples; |
| 69 | |
| 70 | afq->frame_count++; |
| 71 | |
| 72 | return 0; |
| 73 | } |
| 74 | |
| 75 | void ff_af_queue_remove(AudioFrameQueue *afq, int nb_samples, int64_t *pts, |
| 76 | int64_t *duration) |
no test coverage detected