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

Function swr_init

libswresample/swresample.c:156–406  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154}
155
156av_cold int swr_init(struct SwrContext *s){
157 int ret;
158 char l1[1024], l2[1024];
159
160 clear_context(s);
161
162 if((unsigned) s-> in_sample_fmt >= AV_SAMPLE_FMT_NB){
163 av_log(s, AV_LOG_ERROR, "Requested input sample format %d is invalid\n", s->in_sample_fmt);
164 return AVERROR(EINVAL);
165 }
166 if((unsigned) s->out_sample_fmt >= AV_SAMPLE_FMT_NB){
167 av_log(s, AV_LOG_ERROR, "Requested output sample format %d is invalid\n", s->out_sample_fmt);
168 return AVERROR(EINVAL);
169 }
170
171 if(s-> in_sample_rate <= 0){
172 av_log(s, AV_LOG_ERROR, "Requested input sample rate %d is invalid\n", s->in_sample_rate);
173 return AVERROR(EINVAL);
174 }
175 if(s->out_sample_rate <= 0){
176 av_log(s, AV_LOG_ERROR, "Requested output sample rate %d is invalid\n", s->out_sample_rate);
177 return AVERROR(EINVAL);
178 }
179
180 s->out.ch_count = s-> user_out_chlayout.nb_channels;
181 s-> in.ch_count = s-> user_in_chlayout.nb_channels;
182
183 if (swri_check_chlayout(s, &s->user_in_chlayout , "input") ||
184 swri_check_chlayout(s, &s->user_out_chlayout, "output"))
185 return AVERROR(EINVAL);
186
187 ret = av_channel_layout_copy(&s->in_ch_layout, &s->user_in_chlayout);
188 ret |= av_channel_layout_copy(&s->out_ch_layout, &s->user_out_chlayout);
189 ret |= av_channel_layout_copy(&s->used_ch_layout, &s->user_used_chlayout);
190 if (ret < 0)
191 return ret;
192
193 s->int_sample_fmt= s->user_int_sample_fmt;
194
195 s->dither.method = s->user_dither_method;
196
197 switch(s->engine){
198#if CONFIG_LIBSOXR
199 case SWR_ENGINE_SOXR: s->resampler = &swri_soxr_resampler; break;
200#endif
201 case SWR_ENGINE_SWR : s->resampler = &swri_resampler; break;
202 default:
203 av_log(s, AV_LOG_ERROR, "Requested resampling engine is unavailable\n");
204 return AVERROR(EINVAL);
205 }
206
207 if (!av_channel_layout_check(&s->used_ch_layout))
208 av_channel_layout_default(&s->used_ch_layout, s->in.ch_count);
209
210 if (s->used_ch_layout.nb_channels != s->in_ch_layout.nb_channels)
211 av_channel_layout_uninit(&s->in_ch_layout);
212
213 if (s->used_ch_layout.order == AV_CHANNEL_ORDER_UNSPEC)

Callers 12

swr_convert_frameFunction · 0.85
swr_set_compensationFunction · 0.85
mainFunction · 0.85
LLVMFuzzerTestOneInputFunction · 0.85
audio_decode_frameFunction · 0.85
opus_init_resampleFunction · 0.85
config_outputFunction · 0.85
config_propsFunction · 0.85
config_audio_outputFunction · 0.85
open_audioFunction · 0.85
mainFunction · 0.85
init_resamplerFunction · 0.85

Calls 15

av_logFunction · 0.85
swri_check_chlayoutFunction · 0.85
av_channel_layout_copyFunction · 0.85
av_channel_layout_checkFunction · 0.85
av_channel_layout_uninitFunction · 0.85
av_get_bytes_per_sampleFunction · 0.85
av_get_planar_sample_fmtFunction · 0.85
av_get_sample_fmt_nameFunction · 0.85
set_audiodata_fmtFunction · 0.85

Tested by 1

mainFunction · 0.68