2587
- 收藏
- 点赞
- 分享
- 举报
如何将16位48000采样率立体声pcm文件通过hisi音频编码器编码成aac
打开一个16位采样率48000立体声的pcm文件,如何通过配置
typedef struct hiAUDIO_FRAME_S
{
AUDIO_BIT_WIDTH_E enBitwidth; /*audio frame bitwidth*/
AUDIO_SOUND_MODE_E enSoundmode; /*audio frame momo or stereo mode*/
HI_U8* u64VirAddr[2];
HI_U64 u64PhyAddr[2];
HI_U64 u64TimeStamp; /*audio frame timestamp*/
HI_U32 u32Seq; /*audio frame seq*/
HI_U32 u32Len; /*data lenth per channel in frame*/
HI_U32 u32PoolId[2];
} AUDIO_FRAME_S;
然后调用HI_S32 HI_MPI_AENC_SendFrame(AENC_CHN AeChn, const AUDIO_FRAME_S *pstFrm, const AEC_FRAME_S *pstAecFrm);进行编码成aac,下面代码应该怎样配置音频结构体数据
#if 1
AIO_ATTR_S stAioAttr;
HI_S32 s32AencChnCnt;
#ifdef HI_ACODEC_TYPE_TLV320AIC31
AUDIO_DEV AiDev = SAMPLE_AUDIO_EXTERN_AI_DEV;
AUDIO_DEV AoDev = SAMPLE_AUDIO_EXTERN_AO_DEV;
stAioAttr.enSamplerate = AUDIO_SAMPLE_RATE_48000;
stAioAttr.enBitwidth = AUDIO_BIT_WIDTH_16;
stAioAttr.enWorkmode = AIO_MODE_I2S_MASTER;
stAioAttr.enSoundmode = AUDIO_SOUND_MODE_STEREO;
stAioAttr.u32EXFlag = 0;
stAioAttr.u32FrmNum = 30;
stAioAttr.u32PtNumPerFrm = AACLC_SAMPLES_PER_FRAME;
stAioAttr.u32ChnCnt = 2;
stAioAttr.u32ClkSel = 1;
stAioAttr.enI2sType = AIO_I2STYPE_EXTERN;
#else
AUDIO_DEV AiDev = SAMPLE_AUDIO_INNER_AI_DEV;
AUDIO_DEV AoDev = SAMPLE_AUDIO_INNER_AO_DEV;
stAioAttr.enSamplerate = AUDIO_SAMPLE_RATE_48000;
stAioAttr.enBitwidth = AUDIO_BIT_WIDTH_16;
stAioAttr.enWorkmode = AIO_MODE_I2S_MASTER;
stAioAttr.enSoundmode = AUDIO_SOUND_MODE_STEREO;
stAioAttr.u32EXFlag = 0;
stAioAttr.u32FrmNum = 30;
stAioAttr.u32PtNumPerFrm = AACLC_SAMPLES_PER_FRAME;
stAioAttr.u32ChnCnt = 2;
stAioAttr.u32ClkSel = 0;
stAioAttr.enI2sType = AIO_I2STYPE_INNERCODEC;
#endif
gs_bAioReSample = HI_FALSE;
enInSampleRate = AUDIO_SAMPLE_RATE_BUTT;
enOutSampleRate = AUDIO_SAMPLE_RATE_BUTT;
s32AencChnCnt = stAioAttr.u32ChnCnt >> stAioAttr.enSoundmode; //1
s32Ret = SAMPLE_COMM_AUDIO_StartAenc(s32AencChnCnt, &stAioAttr, gs_enPayloadType);
if (s32Ret != HI_SUCCESS)
{
SAMPLE_DBG(s32Ret);
}
AUDIO_FRAME_S stFrame;
AEC_FRAME_S stAecFrm;
AUDIO_STREAM_S stStream;
FILE *fp = fopen("/mnt/playout_t.pcm", "rb+");
FILE *fp_down = fopen("/mnt/audio.aac", "wb+");
int nBytesRead = 0;
int s32GetRet = -1;
unsigned char *pbPCMBuffer = (unsigned char *)malloc(960);
stFrame.u64VirAddr[0] =(unsigned char *)malloc(960);
stFrame.enBitwidth = 1;
stFrame.enSoundmode = 1;
stFrame.u64TimeStamp = 0;
while(1)
{
nBytesRead = fread(pbPCMBuffer, 1, 960, fp);
printf("nBytesRead = %d\n",nBytesRead);
stFrame.u32Len = nBytesRead;
memcpy(stFrame.u64VirAddr[0],pbPCMBuffer,nBytesRead);
stFrame.u32Len = nBytesRead;
memset(&stAecFrm, 0, sizeof(AEC_FRAME_S));
s32Ret = HI_MPI_AENC_SendFrame(0, &stFrame, &stAecFrm);
if (HI_SUCCESS != s32Ret )
{
printf("%s: HI_MPI_AENC_SendFrame, failed with %#x!\n", \
__FUNCTION__, s32Ret);
break;
}
s32GetRet = HI_MPI_AENC_GetStream(0, &stStream, HI_FALSE);
if (HI_SUCCESS != s32GetRet )
{
printf("%s: HI_MPI_AENC_GetStream, failed with %#x!\n", \
__FUNCTION__, s32GetRet);
}
fwrite(stStream.pStream, 1, stStream.u32Len, fp_down);
if(nBytesRead <= 0)
{
break;
}
}
#endif
break;
}
typedef struct hiAUDIO_FRAME_S
{
AUDIO_BIT_WIDTH_E enBitwidth; /*audio frame bitwidth*/
AUDIO_SOUND_MODE_E enSoundmode; /*audio frame momo or stereo mode*/
HI_U8* u64VirAddr[2];
HI_U64 u64PhyAddr[2];
HI_U64 u64TimeStamp; /*audio frame timestamp*/
HI_U32 u32Seq; /*audio frame seq*/
HI_U32 u32Len; /*data lenth per channel in frame*/
HI_U32 u32PoolId[2];
} AUDIO_FRAME_S;
然后调用HI_S32 HI_MPI_AENC_SendFrame(AENC_CHN AeChn, const AUDIO_FRAME_S *pstFrm, const AEC_FRAME_S *pstAecFrm);进行编码成aac,下面代码应该怎样配置音频结构体数据
#if 1
AIO_ATTR_S stAioAttr;
HI_S32 s32AencChnCnt;
#ifdef HI_ACODEC_TYPE_TLV320AIC31
AUDIO_DEV AiDev = SAMPLE_AUDIO_EXTERN_AI_DEV;
AUDIO_DEV AoDev = SAMPLE_AUDIO_EXTERN_AO_DEV;
stAioAttr.enSamplerate = AUDIO_SAMPLE_RATE_48000;
stAioAttr.enBitwidth = AUDIO_BIT_WIDTH_16;
stAioAttr.enWorkmode = AIO_MODE_I2S_MASTER;
stAioAttr.enSoundmode = AUDIO_SOUND_MODE_STEREO;
stAioAttr.u32EXFlag = 0;
stAioAttr.u32FrmNum = 30;
stAioAttr.u32PtNumPerFrm = AACLC_SAMPLES_PER_FRAME;
stAioAttr.u32ChnCnt = 2;
stAioAttr.u32ClkSel = 1;
stAioAttr.enI2sType = AIO_I2STYPE_EXTERN;
#else
AUDIO_DEV AiDev = SAMPLE_AUDIO_INNER_AI_DEV;
AUDIO_DEV AoDev = SAMPLE_AUDIO_INNER_AO_DEV;
stAioAttr.enSamplerate = AUDIO_SAMPLE_RATE_48000;
stAioAttr.enBitwidth = AUDIO_BIT_WIDTH_16;
stAioAttr.enWorkmode = AIO_MODE_I2S_MASTER;
stAioAttr.enSoundmode = AUDIO_SOUND_MODE_STEREO;
stAioAttr.u32EXFlag = 0;
stAioAttr.u32FrmNum = 30;
stAioAttr.u32PtNumPerFrm = AACLC_SAMPLES_PER_FRAME;
stAioAttr.u32ChnCnt = 2;
stAioAttr.u32ClkSel = 0;
stAioAttr.enI2sType = AIO_I2STYPE_INNERCODEC;
#endif
gs_bAioReSample = HI_FALSE;
enInSampleRate = AUDIO_SAMPLE_RATE_BUTT;
enOutSampleRate = AUDIO_SAMPLE_RATE_BUTT;
s32AencChnCnt = stAioAttr.u32ChnCnt >> stAioAttr.enSoundmode; //1
s32Ret = SAMPLE_COMM_AUDIO_StartAenc(s32AencChnCnt, &stAioAttr, gs_enPayloadType);
if (s32Ret != HI_SUCCESS)
{
SAMPLE_DBG(s32Ret);
}
AUDIO_FRAME_S stFrame;
AEC_FRAME_S stAecFrm;
AUDIO_STREAM_S stStream;
FILE *fp = fopen("/mnt/playout_t.pcm", "rb+");
FILE *fp_down = fopen("/mnt/audio.aac", "wb+");
int nBytesRead = 0;
int s32GetRet = -1;
unsigned char *pbPCMBuffer = (unsigned char *)malloc(960);
stFrame.u64VirAddr[0] =(unsigned char *)malloc(960);
stFrame.enBitwidth = 1;
stFrame.enSoundmode = 1;
stFrame.u64TimeStamp = 0;
while(1)
{
nBytesRead = fread(pbPCMBuffer, 1, 960, fp);
printf("nBytesRead = %d\n",nBytesRead);
stFrame.u32Len = nBytesRead;
memcpy(stFrame.u64VirAddr[0],pbPCMBuffer,nBytesRead);
stFrame.u32Len = nBytesRead;
memset(&stAecFrm, 0, sizeof(AEC_FRAME_S));
s32Ret = HI_MPI_AENC_SendFrame(0, &stFrame, &stAecFrm);
if (HI_SUCCESS != s32Ret )
{
printf("%s: HI_MPI_AENC_SendFrame, failed with %#x!\n", \
__FUNCTION__, s32Ret);
break;
}
s32GetRet = HI_MPI_AENC_GetStream(0, &stStream, HI_FALSE);
if (HI_SUCCESS != s32GetRet )
{
printf("%s: HI_MPI_AENC_GetStream, failed with %#x!\n", \
__FUNCTION__, s32GetRet);
}
fwrite(stStream.pStream, 1, stStream.u32Len, fp_down);
if(nBytesRead <= 0)
{
break;
}
}
#endif
break;
}
我来回答
回答2个
时间排序
认可量排序
认可0
认可0
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
相关问答
-
2023-07-18 14:39:32
-
2020-08-29 10:55:01
-
2020-08-20 20:53:49
-
2023-07-19 16:46:20
-
2018-12-01 10:47:33
-
2018-08-02 10:16:58
-
2018-08-24 11:29:46
-
2018-12-30 11:36:18
-
2017-08-11 14:01:20
-
2016-03-28 16:20:59
-
2020-12-15 19:52:55
-
2018-12-29 13:39:57
-
2019-07-22 14:54:11
-
2020-06-15 18:50:57
-
2021-03-17 16:46:55
-
2016-06-20 14:01:17
-
2016-03-02 11:26:09
-
2017-04-25 18:11:15
-
22017-06-15 21:14:30
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
5SS928的emmc有32GB,bootargs设置使用16GB,但是为啥能用的只有rootfs的大小
-
33SS928怎样烧写ubuntu系统
-
10ToolPlatform下载rootfs提示网络失败
-
10谁有GK7205V500的SDK
-
5Hi3516CV610 烧录不进去
-
10Hi3559AV100 芯片硬解码h265编码格式的视频时出现视频播放错误,解码错误信息 s32PackErr:码流有错
-
5海思SS928 / SD3403的sample_venc.c摄像头编码Demo中,采集到的摄像头的YUV数据在哪个相关的函数中?
-
5海鸥派openEuler无法启动网卡,连接WIFI存在问题
-
66有没有ISP相关的巨佬帮忙看看SS928对接IMX347的图像问题
-
50求助hi3559与FPGA通过SLVS-EC接口对接问题
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认