Commit 431dcc49 authored by Michael Niedermayer's avatar Michael Niedermayer

swr: make realloc_audio() available outside swresample.c

Signed-off-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parent 5a5d7074
...@@ -369,7 +369,7 @@ av_assert0(s->out.ch_count); ...@@ -369,7 +369,7 @@ av_assert0(s->out.ch_count);
return 0; return 0;
} }
static int realloc_audio(AudioData *a, int count){ int swri_realloc_audio(AudioData *a, int count){
int i, countb; int i, countb;
AudioData old; AudioData old;
...@@ -509,7 +509,7 @@ static int resample(SwrContext *s, AudioData *out_param, int out_count, ...@@ -509,7 +509,7 @@ static int resample(SwrContext *s, AudioData *out_param, int out_count,
copy(&s->in_buffer, &tmp, s->in_buffer_count); copy(&s->in_buffer, &tmp, s->in_buffer_count);
s->in_buffer_index=0; s->in_buffer_index=0;
}else }else
if((ret=realloc_audio(&s->in_buffer, size)) < 0) if((ret=swri_realloc_audio(&s->in_buffer, size)) < 0)
return ret; return ret;
if(in_count){ if(in_count){
...@@ -549,18 +549,18 @@ static int swr_convert_internal(struct SwrContext *s, AudioData *out, int out_co ...@@ -549,18 +549,18 @@ static int swr_convert_internal(struct SwrContext *s, AudioData *out, int out_co
// in_max= out_count*(int64_t)s->in_sample_rate / s->out_sample_rate + resample_filter_taps; // in_max= out_count*(int64_t)s->in_sample_rate / s->out_sample_rate + resample_filter_taps;
// in_count= FFMIN(in_count, in_in + 2 - s->hist_buffer_count); // in_count= FFMIN(in_count, in_in + 2 - s->hist_buffer_count);
if((ret=realloc_audio(&s->postin, in_count))<0) if((ret=swri_realloc_audio(&s->postin, in_count))<0)
return ret; return ret;
if(s->resample_first){ if(s->resample_first){
av_assert0(s->midbuf.ch_count == s->used_ch_count); av_assert0(s->midbuf.ch_count == s->used_ch_count);
if((ret=realloc_audio(&s->midbuf, out_count))<0) if((ret=swri_realloc_audio(&s->midbuf, out_count))<0)
return ret; return ret;
}else{ }else{
av_assert0(s->midbuf.ch_count == s->out.ch_count); av_assert0(s->midbuf.ch_count == s->out.ch_count);
if((ret=realloc_audio(&s->midbuf, in_count))<0) if((ret=swri_realloc_audio(&s->midbuf, in_count))<0)
return ret; return ret;
} }
if((ret=realloc_audio(&s->preout, out_count))<0) if((ret=swri_realloc_audio(&s->preout, out_count))<0)
return ret; return ret;
postin= &s->postin; postin= &s->postin;
...@@ -613,7 +613,7 @@ static int swr_convert_internal(struct SwrContext *s, AudioData *out, int out_co ...@@ -613,7 +613,7 @@ static int swr_convert_internal(struct SwrContext *s, AudioData *out, int out_co
int dither_count= FFMAX(out_count, 1<<16); int dither_count= FFMAX(out_count, 1<<16);
av_assert0(preout != in); av_assert0(preout != in);
if((ret=realloc_audio(&s->dither, dither_count))<0) if((ret=swri_realloc_audio(&s->dither, dither_count))<0)
return ret; return ret;
if(ret) if(ret)
for(ch=0; ch<s->dither.ch_count; ch++) for(ch=0; ch<s->dither.ch_count; ch++)
...@@ -645,7 +645,7 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun ...@@ -645,7 +645,7 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun
uint8_t *tmp_arg[SWR_CH_MAX]; uint8_t *tmp_arg[SWR_CH_MAX];
tmp.count = 0; tmp.count = 0;
tmp.data = NULL; tmp.data = NULL;
if((ret=realloc_audio(&tmp, s->drop_output))<0) if((ret=swri_realloc_audio(&tmp, s->drop_output))<0)
return ret; return ret;
reversefill_audiodata(&tmp, tmp_arg); reversefill_audiodata(&tmp, tmp_arg);
...@@ -666,7 +666,7 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun ...@@ -666,7 +666,7 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun
if (s->resample && !s->flushed) { if (s->resample && !s->flushed) {
AudioData *a= &s->in_buffer; AudioData *a= &s->in_buffer;
int i, j, ret; int i, j, ret;
if((ret=realloc_audio(a, s->in_buffer_index + 2*s->in_buffer_count)) < 0) if((ret=swri_realloc_audio(a, s->in_buffer_index + 2*s->in_buffer_count)) < 0)
return ret; return ret;
av_assert0(a->planar); av_assert0(a->planar);
for(i=0; i<a->ch_count; i++){ for(i=0; i<a->ch_count; i++){
...@@ -721,7 +721,7 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun ...@@ -721,7 +721,7 @@ int swr_convert(struct SwrContext *s, uint8_t *out_arg[SWR_CH_MAX], int out_coun
copy(&s->in_buffer, &tmp, s->in_buffer_count); copy(&s->in_buffer, &tmp, s->in_buffer_count);
s->in_buffer_index=0; s->in_buffer_index=0;
}else }else
if((ret=realloc_audio(&s->in_buffer, size)) < 0) if((ret=swri_realloc_audio(&s->in_buffer, size)) < 0)
return ret; return ret;
} }
...@@ -766,7 +766,7 @@ int swr_inject_silence(struct SwrContext *s, int count){ ...@@ -766,7 +766,7 @@ int swr_inject_silence(struct SwrContext *s, int count){
silence.count = 0; silence.count = 0;
silence.data = NULL; silence.data = NULL;
if((ret=realloc_audio(&silence, count))<0) if((ret=swri_realloc_audio(&silence, count))<0)
return ret; return ret;
if(silence.planar) for(i=0; i<silence.ch_count; i++) { if(silence.planar) for(i=0; i<silence.ch_count; i++) {
......
...@@ -141,6 +141,7 @@ struct Resampler { ...@@ -141,6 +141,7 @@ struct Resampler {
extern struct Resampler const swri_resampler; extern struct Resampler const swri_resampler;
int swri_realloc_audio(AudioData *a, int count);
int swri_resample_int16(struct ResampleContext *c, int16_t *dst, const int16_t *src, int *consumed, int src_size, int dst_size, int update_ctx); int swri_resample_int16(struct ResampleContext *c, int16_t *dst, const int16_t *src, int *consumed, int src_size, int dst_size, int update_ctx);
int swri_resample_int32(struct ResampleContext *c, int32_t *dst, const int32_t *src, int *consumed, int src_size, int dst_size, int update_ctx); int swri_resample_int32(struct ResampleContext *c, int32_t *dst, const int32_t *src, int *consumed, int src_size, int dst_size, int update_ctx);
int swri_resample_float(struct ResampleContext *c, float *dst, const float *src, int *consumed, int src_size, int dst_size, int update_ctx); int swri_resample_float(struct ResampleContext *c, float *dst, const float *src, int *consumed, int src_size, int dst_size, int update_ctx);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment