| 190 | } |
| 191 | |
| 192 | static int opus_init_resample(OpusStreamContext *s) |
| 193 | { |
| 194 | static const float delay[16] = { 0.0 }; |
| 195 | const uint8_t *delayptr[2] = { (uint8_t*)delay, (uint8_t*)delay }; |
| 196 | int ret; |
| 197 | |
| 198 | av_opt_set_int(s->swr, "in_sample_rate", s->silk_samplerate, 0); |
| 199 | ret = swr_init(s->swr); |
| 200 | if (ret < 0) { |
| 201 | av_log(s->avctx, AV_LOG_ERROR, "Error opening the resampler.\n"); |
| 202 | return ret; |
| 203 | } |
| 204 | |
| 205 | ret = swr_convert(s->swr, |
| 206 | NULL, 0, |
| 207 | delayptr, silk_resample_delay[s->packet.bandwidth]); |
| 208 | if (ret < 0) { |
| 209 | av_log(s->avctx, AV_LOG_ERROR, |
| 210 | "Error feeding initial silence to the resampler.\n"); |
| 211 | return ret; |
| 212 | } |
| 213 | |
| 214 | return 0; |
| 215 | } |
| 216 | |
| 217 | static int opus_decode_redundancy(OpusStreamContext *s, const uint8_t *data, int size) |
| 218 | { |
no test coverage detected