2556
- 收藏
- 点赞
- 分享
- 举报
如何将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
-
2017-08-11 14:01:20
-
2018-12-30 11:36:18
-
2020-12-15 19:52:55
-
2019-07-22 14:54:11
-
2018-12-29 13:39:57
-
2016-03-28 16:20:59
-
2021-03-17 16:46:55
-
2020-06-15 18:50:57
-
2016-06-20 14:01:17
-
2016-06-06 13:51:09
-
22017-06-15 21:14:30
-
2017-04-25 18:11:15
无更多相似问答 去提问
点击登录
-- 积分
-- E币
提问
—
收益
—
被采纳
—
我要提问
切换马甲
上一页
下一页
悬赏问答
-
5Hi3516CV610 如何使用SD卡升级固件
-
5cat /dev/logmpp 报错 <3>[ vi] [func]:vi_send_frame_node [line]:99 [info]:vi pic queue is full!
-
50如何获取vpss chn的图像修改后发送至vo
-
5FPGA通过Bt1120传YUV422数据过来,vi接收不到数据——3516dv500
-
50SS928 运行PQtools 拼接 推到设备里有一半画面会异常
-
53536AV100的sample_vdec输出到CVBS显示
-
10海思板子mpp怎么在vi阶段改变视频数据尺寸
-
10HI3559AV100 多摄像头同步模式
-
9海思ss928单路摄像头vio中加入opencv处理并显示
-
10EB-RV1126-BC-191板子运行自己编码的程序
举报反馈
举报类型
- 内容涉黄/赌/毒
- 内容侵权/抄袭
- 政治相关
- 涉嫌广告
- 侮辱谩骂
- 其他
详细说明
提醒
你的问题还没有最佳答案,是否结题,结题后将扣除20%的悬赏金
取消
确认
提醒
你的问题还没有最佳答案,是否结题,结题后将根据回答情况扣除相应悬赏金(1回答=1E币)
取消
确认