Skip to content

Commit

Permalink
Merge commit 'b9dea23766f52b8e059e72d34980bb7b456efe8f'
Browse files Browse the repository at this point in the history
* commit 'b9dea23766f52b8e059e72d34980bb7b456efe8f':
  resample: fix avresample_get_delay() return value

Merged-by: Michael Niedermayer <[email protected]>
  • Loading branch information
michaelni committed Apr 11, 2014
2 parents d241706 + b9dea23 commit c04961f
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion libavresample/resample.c
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ struct ResampleContext {
void (*resample_one)(struct ResampleContext *c, int no_filter, void *dst0,
int dst_index, const void *src0, int src_size,
int index, int frac);
int padding_size;
};


Expand Down Expand Up @@ -212,6 +213,7 @@ ResampleContext *ff_audio_resample_init(AVAudioResampleContext *avr)
goto error;
c->ideal_dst_incr = c->dst_incr;

c->padding_size = (c->filter_length - 1) / 2;
c->index = -phase_count * ((c->filter_length - 1) / 2);
c->frac = 0;

Expand Down Expand Up @@ -462,8 +464,10 @@ int ff_audio_resample(ResampleContext *c, AudioData *dst, AudioData *src)

int avresample_get_delay(AVAudioResampleContext *avr)
{
ResampleContext *c = avr->resample;

if (!avr->resample_needed || !avr->resample)
return 0;

return avr->resample->buffer->nb_samples;
return FFMAX(c->buffer->nb_samples - c->padding_size, 0);
}

0 comments on commit c04961f

Please sign in to comment.