正在显示
1 个修改的文件
包含
4 行增加
和
0 行删除
@@ -141,14 +141,18 @@ void *FF_Resample_Send_And_Get_ResampleData(struct AudioDealInfo *AD_Info, unsig | @@ -141,14 +141,18 @@ void *FF_Resample_Send_And_Get_ResampleData(struct AudioDealInfo *AD_Info, unsig | ||
141 | 141 | ||
142 | struct pcm_Resample *ResampleInfo = (struct pcm_Resample *)AD_Info->ResampleInfo; | 142 | struct pcm_Resample *ResampleInfo = (struct pcm_Resample *)AD_Info->ResampleInfo; |
143 | 143 | ||
144 | + //按采样率缩放样本数量 | ||
144 | *out_nb_samples = av_rescale_rnd(nb_samples, ResampleInfo->Out_SampleRate, ResampleInfo->In_SampleRate, AV_ROUND_UP); | 145 | *out_nb_samples = av_rescale_rnd(nb_samples, ResampleInfo->Out_SampleRate, ResampleInfo->In_SampleRate, AV_ROUND_UP); |
145 | //printf("重采样得到的预计输出样本数量为%d\n",*out_nb_samples); | 146 | //printf("重采样得到的预计输出样本数量为%d\n",*out_nb_samples); |
147 | + | ||
148 | + //放置输出数据的数组 | ||
146 | ret = av_samples_alloc(&dst, NULL, 2, *out_nb_samples, AV_SAMPLE_FMT_S16, 0); | 149 | ret = av_samples_alloc(&dst, NULL, 2, *out_nb_samples, AV_SAMPLE_FMT_S16, 0); |
147 | if (ret < 0) { | 150 | if (ret < 0) { |
148 | printf("[ERROR][Resample]av_samples_alloc failed\n"); | 151 | printf("[ERROR][Resample]av_samples_alloc failed\n"); |
149 | return NULL; | 152 | return NULL; |
150 | } | 153 | } |
151 | 154 | ||
155 | + //重采样 | ||
152 | ret = swr_convert(ResampleInfo->m_swr, &dst, *out_nb_samples, (const uint8_t**)src, nb_samples); | 156 | ret = swr_convert(ResampleInfo->m_swr, &dst, *out_nb_samples, (const uint8_t**)src, nb_samples); |
153 | if (ret < 0) { | 157 | if (ret < 0) { |
154 | printf("[ERROR][Resample]swr_convert failed\n"); | 158 | printf("[ERROR][Resample]swr_convert failed\n"); |
-
请 注册 或 登录 后发表评论