c语言实现音频重采样8k->16k和 16k->8k

static int convert_16khz_to_8khz(void * dst_buf, const void *src_buf, int src_size)
{
	int i;
	short temp = 0,temp1 = 0;
	
	 for(i=0; i<src_size/4; i++)
	 {
	 	*((short *)dst_buf + i) = *((short *)src_buf + i * 2);
	 }

	 return src_size/2;
}
static int convert_8khz_to_16khz(void * dst_buf, void *src_buf, int src_size)
{
	int i;
	for(i=0; i<src_size/2; i++)
	{
		*((short *)dst_buf + i*2) = *((short *)src_buf + i);
		*((short *)dst_buf + i*2 + 1) = *((short *)src_buf + i);
	}

	return src_size * 2;
}

你可能感兴趣的:(c/c++,c语言,音视频)