MCPcopy Create free account
hub / github.com/FFmpeg/FFmpeg / ff_af_queue_remove

Function ff_af_queue_remove

libavcodec/audio_frame_queue.c:75–113  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

73}
74
75void ff_af_queue_remove(AudioFrameQueue *afq, int nb_samples, int64_t *pts,
76 int64_t *duration)
77{
78 int64_t out_pts = AV_NOPTS_VALUE;
79 int removed_samples = 0;
80 int i;
81
82 if (afq->frame_count || afq->frame_alloc) {
83 if (afq->frames->pts != AV_NOPTS_VALUE)
84 out_pts = afq->frames->pts;
85 }
86 if(!afq->frame_count)
87 av_log(afq->avctx, AV_LOG_WARNING, "Trying to remove %d samples, but the queue is empty\n", nb_samples);
88 if (pts)
89 *pts = ff_samples_to_time_base(afq->avctx, out_pts);
90
91 for(i=0; nb_samples && i<afq->frame_count; i++){
92 int n= FFMIN(afq->frames[i].duration, nb_samples);
93 afq->frames[i].duration -= n;
94 nb_samples -= n;
95 removed_samples += n;
96 if(afq->frames[i].pts != AV_NOPTS_VALUE)
97 afq->frames[i].pts += n;
98 }
99 afq->remaining_samples -= removed_samples;
100 i -= i && afq->frames[i-1].duration;
101 memmove(afq->frames, afq->frames + i, sizeof(*afq->frames) * (afq->frame_count - i));
102 afq->frame_count -= i;
103
104 if(nb_samples){
105 av_assert0(!afq->frame_count);
106 av_assert0(afq->remaining_samples == afq->remaining_delay);
107 if(afq->frames && afq->frames[0].pts != AV_NOPTS_VALUE)
108 afq->frames[0].pts += nb_samples;
109 av_log(afq->avctx, AV_LOG_DEBUG, "Trying to remove %d more samples than there are in the queue\n", nb_samples);
110 }
111 if (duration)
112 *duration = ff_samples_to_time_base(afq->avctx, removed_samples);
113}

Callers 15

libvorbis_encode_frameFunction · 0.85
ffat_encodeFunction · 0.85
encode_frameFunction · 0.85
ra144_encode_frameFunction · 0.85
aac_encode_frameFunction · 0.85
aptx_encode_frameFunction · 0.85
vorbis_encode_frameFunction · 0.85
libopus_encodeFunction · 0.85
libshine_encode_frameFunction · 0.85
encode_frameFunction · 0.85
mp3lame_encode_frameFunction · 0.85
aac_encode_flushFunction · 0.85

Calls 2

av_logFunction · 0.85
ff_samples_to_time_baseFunction · 0.85

Tested by

no test coverage detected