0
轉換採樣率AV_SAMPLE_FMT_S16和播放的OpenAL,得到以下錯誤(http://joxi.ru/B_JkUdg5CbDrWhe9oNI)錯誤轉換採樣率從AV_SAMPLE_FMT_FLTP AV_SAMPLE_FMT_S16
CONV_FUNC (AV_SAMPLE_FMT_S16, int16_t, AV_SAMPLE_FMT_FLT, av_clip_int16 (lrintf (* (const float *) pi * (1 << 15))))
文件audioconvert.c
我的代碼
swrContext = swr_alloc();
av_opt_set_int(swrContext, "in_channel_layout", cc->channel_layout, 0);
av_opt_set_int(swrContext, "out_channel_layout", cc->channel_layout, 0);
av_opt_set_int(swrContext, "in_sample_rate", cc->sample_rate, 0);
av_opt_set_int(swrContext, "out_sample_rate", cc->sample_rate, 0);
av_opt_set_sample_fmt(swrContext, "in_sample_fmt", cc->sample_fmt, 0);
av_opt_set_sample_fmt(swrContext, "out_sample_fmt", AV_SAMPLE_FMT_S16P, 0);
swr_init(swrContext);
uint8_t *output;
int out_samples = (int)av_rescale_rnd(swr_get_delay(swrContext, 44100) + (int64_t)decoded_frame->nb_samples, 44100, 44100, AV_ROUND_UP);
swr_convert(swrContext, &output, out_samples, (const uint8_t **)decoded_frame->extended_data, decoded_frame->nb_samples); //error
alBufferData(BufID,AL_FORMAT_STEREO16,output, decsize,44100);
可能有其他解決方案嗎?
可能有其他解決方案嗎?我做的How to convert sample rate from AV_SAMPLE_FMT_FLTP to AV_SAMPLE_FMT_S16?
你怎麼解決?我試圖從S16轉換到S16P,代碼崩潰了'CONV_FUNC(AV_SAMPLE_FMT_S16,int16_t,AV_SAMPLE_FMT_S16,*(const int16_t *)pi)行' – frankish 2013-08-08 16:42:44