MCPcopy Create free account
hub / github.com/HandBrake/HandBrake / hb_audio_resample_update

Function hb_audio_resample_update

libhb/audio_resample.c:145–226  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

143}
144
145int hb_audio_resample_update(hb_audio_resample_t *resample)
146{
147 if (resample == NULL)
148 {
149 hb_error("hb_audio_resample_update: resample is NULL");
150 return 1;
151 }
152
153 int ret, resample_changed;
154
155 resample->resample_needed =
156 (resample->out.sample_fmt != resample->in.sample_fmt ||
157 resample->out.sample_rate != resample->in.sample_rate ||
158 av_channel_layout_compare(&resample->out.ch_layout, &resample->in.ch_layout));
159
160 resample_changed =
161 (resample->resample_needed &&
162 (resample->resample.sample_fmt != resample->in.sample_fmt ||
163 resample->resample.sample_rate != resample->in.sample_rate ||
164 av_channel_layout_compare(&resample->resample.ch_layout, &resample->in.ch_layout) ||
165 resample->resample.lfe_mix_level != resample->in.lfe_mix_level ||
166 resample->resample.center_mix_level != resample->in.center_mix_level ||
167 resample->resample.surround_mix_level != resample->in.surround_mix_level));
168
169 if (resample_changed || (resample->resample_needed &&
170 resample->swresample == NULL))
171 {
172 if (resample->swresample == NULL)
173 {
174 resample->swresample = swr_alloc();
175 if (resample->swresample == NULL)
176 {
177 hb_error("hb_audio_resample_update: swr_alloc() failed");
178 return 1;
179 }
180
181 av_opt_set_int(resample->swresample, "out_sample_fmt",
182 resample->out.sample_fmt, 0);
183 av_opt_set_int(resample->swresample, "out_sample_rate",
184 resample->out.sample_rate, 0);
185 av_opt_set_chlayout(resample->swresample, "out_chlayout",
186 &resample->out.ch_layout, 0);
187 av_opt_set_int(resample->swresample, "matrix_encoding",
188 resample->out.matrix_encoding, 0);
189 av_opt_set_double(resample->swresample, "rematrix_maxval",
190 resample->out.maxval, 0);
191 }
192
193 av_opt_set_int(resample->swresample, "in_sample_fmt",
194 resample->in.sample_fmt, 0);
195 av_opt_set_int(resample->swresample, "in_sample_rate",
196 resample->in.sample_rate, 0);
197 av_opt_set_chlayout(resample->swresample, "in_chlayout",
198 &resample->in.ch_layout, 0);
199 av_opt_set_double(resample->swresample, "lfe_mix_level",
200 resample->in.lfe_mix_level, 0);
201 av_opt_set_double(resample->swresample, "center_mix_level",
202 resample->in.center_mix_level, 0);

Callers 3

InitAudioFunction · 0.85
DecodeFunction · 0.85
decodeAudioFunction · 0.85

Calls 1

hb_errorFunction · 0.85

Tested by

no test coverage detected