4037
- 收藏
- 点赞
- 分享
- 举报
YUV文件转换成VIDEO_FRAME_INFO_S格式的转换问题
本帖最后由 qn1573466792 于 2020-1-3 16:20 编辑
怎么把NV21 的YUV文件转换成VIDEO_FRAME_INFO_S格式啊
我自己写了一个转换的函数,但是转换出来YUV文件是中间变灰了,整个画面有着蓝绿点
源YUV文件用ffplay播放没有问题,格式也是NV21的,应该是转换过程出现问题
实在找不到解决办法了,有人能够帮我吗????:'( :'( :'(
转换后的图片:
代码如下:
[code]HI_S32 HISI_VB_FileToFrame(FILE* file, VIDEO_FRAME_INFO_S *frame_info, int w, int h)
{
HI_S32 i;
HI_S32 size, luma_size, chrm_size;
HI_U8 *file_image;
memset(frame_info, 0, sizeof(VIDEO_FRAME_INFO_S));
frame_info->enModId = HI_ID_VI;
frame_info->stVFrame.u32Width = w;
frame_info->stVFrame.u32Height = h;
frame_info->stVFrame.enField = VIDEO_FIELD_FRAME;
frame_info->stVFrame.enPixelFormat = PIXEL_FORMAT_YVU_SEMIPLANAR_420;
frame_info->stVFrame.enVideoFormat = VIDEO_FORMAT_LINEAR;
frame_info->stVFrame.enCompressMode = COMPRESS_MODE_NONE;
frame_info->stVFrame.enDynamicRange = DYNAMIC_RANGE_SDR8;
frame_info->stVFrame.enColorGamut = COLOR_GAMUT_BT601;
frame_info->stVFrame.u32Stride[0] = HISI_CalcStride(frame_info->stVFrame.u32Width, USER_HISI_MD_ALIGN);
frame_info->stVFrame.u32Stride[1] = HISI_CalcStride(frame_info->stVFrame.u32Width, USER_HISI_MD_ALIGN);
frame_info->stVFrame.u32Stride[2] = HISI_CalcStride(frame_info->stVFrame.u32Width, USER_HISI_MD_ALIGN);
frame_info->stVFrame.u64HeaderPhyAddr[0] = 0;
frame_info->stVFrame.u64HeaderPhyAddr[1] = 0;
frame_info->stVFrame.u64HeaderPhyAddr[2] = 0;
//frame_info->stVFrame.u32TimeRef = 0;
//frame_info->stVFrame.u64PTS = 0;
size = HISI_CalcStride(frame_info->stVFrame.u32Width, USER_HISI_MD_ALIGN) * frame_info->stVFrame.u32Height * 2;
luma_size = HISI_CalcStride(frame_info->stVFrame.u32Width, USER_HISI_MD_ALIGN) * frame_info->stVFrame.u32Height;
chrm_size = luma_size >> 2;
USER_HISI_VB_BLK_HANDLE = HI_MPI_VB_GetBlock(USER_HISI_VB_POOL, size, NULL);
if(VB_INVALID_HANDLE == USER_HISI_VB_BLK_HANDLE) {
HISI_PRT("HI_MPI_VB_GetBlock fail\n");
sleep(10);
return HI_FAILURE;
}
frame_info->u32PoolId = HI_MPI_VB_Handle2PoolId(USER_HISI_VB_BLK_HANDLE);
frame_info->stVFrame.u64PhyAddr[0] = HI_MPI_VB_Handle2PhysAddr(USER_HISI_VB_BLK_HANDLE);
frame_info->stVFrame.u64PhyAddr[1] = frame_info->stVFrame.u64PhyAddr[0] + luma_size;
frame_info->stVFrame.u64PhyAddr[2] = frame_info->stVFrame.u64PhyAddr[1] + chrm_size;
frame_info->stVFrame.u64VirAddr[0] = (HI_UL)HI_MPI_SYS_Mmap(frame_info->stVFrame.u64PhyAddr[0], size);
frame_info->stVFrame.u64VirAddr[1] = frame_info->stVFrame.u64VirAddr[0] + luma_size;
frame_info->stVFrame.u64VirAddr[2] = frame_info->stVFrame.u64VirAddr[1] + chrm_size;
// frame_info->stVFrame.u32TimeRef += 40000;
// frame_info->stVFrame.u64PTS += 40000;
file_image = (HI_U8 *)(HI_UL)frame_info->stVFrame.u64VirAddr[0];
for(i = 0; i < frame_info->stVFrame.u32Height; i++) {
fread(file_image, frame_info->stVFrame.u32Width, 1, file);
file_image += frame_info->stVFrame.u32Stride[0];
}
file_image = (HI_U8 *)(HI_UL)frame_info->stVFrame.u64VirAddr[1];
for(i = 0; i < frame_info->stVFrame.u32Height/2; i++) {
fread(file_image, frame_info->stVFrame.u32Width, 1, file);
file_image += frame_info->stVFrame.u32Stride[1];
}
return HI_SUCCESS;
}[/code]
怎么把NV21 的YUV文件转换成VIDEO_FRAME_INFO_S格式啊
我自己写了一个转换的函数,但是转换出来YUV文件是中间变灰了,整个画面有着蓝绿点
源YUV文件用ffplay播放没有问题,格式也是NV21的,应该是转换过程出现问题
实在找不到解决办法了,有人能够帮我吗????:'( :'( :'(
转换后的图片:
代码如下:
[code]HI_S32 HISI_VB_FileToFrame(FILE* file, VIDEO_FRAME_INFO_S *frame_info, int w, int h)
{
HI_S32 i;
HI_S32 size, luma_size, chrm_size;
HI_U8 *file_image;
memset(frame_info, 0, sizeof(VIDEO_FRAME_INFO_S));
frame_info->enModId = HI_ID_VI;
frame_info->stVFrame.u32Width = w;
frame_info->stVFrame.u32Height = h;
frame_info->stVFrame.enField = VIDEO_FIELD_FRAME;
frame_info->stVFrame.enPixelFormat = PIXEL_FORMAT_YVU_SEMIPLANAR_420;
frame_info->stVFrame.enVideoFormat = VIDEO_FORMAT_LINEAR;
frame_info->stVFrame.enCompressMode = COMPRESS_MODE_NONE;
frame_info->stVFrame.enDynamicRange = DYNAMIC_RANGE_SDR8;
frame_info->stVFrame.enColorGamut = COLOR_GAMUT_BT601;
frame_info->stVFrame.u32Stride[0] = HISI_CalcStride(frame_info->stVFrame.u32Width, USER_HISI_MD_ALIGN);
frame_info->stVFrame.u32Stride[1] = HISI_CalcStride(frame_info->stVFrame.u32Width, USER_HISI_MD_ALIGN);
frame_info->stVFrame.u32Stride[2] = HISI_CalcStride(frame_info->stVFrame.u32Width, USER_HISI_MD_ALIGN);
frame_info->stVFrame.u64HeaderPhyAddr[0] = 0;
frame_info->stVFrame.u64HeaderPhyAddr[1] = 0;
frame_info->stVFrame.u64HeaderPhyAddr[2] = 0;
//frame_info->stVFrame.u32TimeRef = 0;
//frame_info->stVFrame.u64PTS = 0;
size = HISI_CalcStride(frame_info->stVFrame.u32Width, USER_HISI_MD_ALIGN) * frame_info->stVFrame.u32Height * 2;
luma_size = HISI_CalcStride(frame_info->stVFrame.u32Width, USER_HISI_MD_ALIGN) * frame_info->stVFrame.u32Height;
chrm_size = luma_size >> 2;
USER_HISI_VB_BLK_HANDLE = HI_MPI_VB_GetBlock(USER_HISI_VB_POOL, size, NULL);
if(VB_INVALID_HANDLE == USER_HISI_VB_BLK_HANDLE) {
HISI_PRT("HI_MPI_VB_GetBlock fail\n");
sleep(10);
return HI_FAILURE;
}
frame_info->u32PoolId = HI_MPI_VB_Handle2PoolId(USER_HISI_VB_BLK_HANDLE);
frame_info->stVFrame.u64PhyAddr[0] = HI_MPI_VB_Handle2PhysAddr(USER_HISI_VB_BLK_HANDLE);
frame_info->stVFrame.u64PhyAddr[1] = frame_info->stVFrame.u64PhyAddr[0] + luma_size;
frame_info->stVFrame.u64PhyAddr[2] = frame_info->stVFrame.u64PhyAddr[1] + chrm_size;
frame_info->stVFrame.u64VirAddr[0] = (HI_UL)HI_MPI_SYS_Mmap(frame_info->stVFrame.u64PhyAddr[0], size);
frame_info->stVFrame.u64VirAddr[1] = frame_info->stVFrame.u64VirAddr[0] + luma_size;
frame_info->stVFrame.u64VirAddr[2] = frame_info->stVFrame.u64VirAddr[1] + chrm_size;
// frame_info->stVFrame.u32TimeRef += 40000;
// frame_info->stVFrame.u64PTS += 40000;
file_image = (HI_U8 *)(HI_UL)frame_info->stVFrame.u64VirAddr[0];
for(i = 0; i < frame_info->stVFrame.u32Height; i++) {
fread(file_image, frame_info->stVFrame.u32Width, 1, file);
file_image += frame_info->stVFrame.u32Stride[0];
}
file_image = (HI_U8 *)(HI_UL)frame_info->stVFrame.u64VirAddr[1];
for(i = 0; i < frame_info->stVFrame.u32Height/2; i++) {
fread(file_image, frame_info->stVFrame.u32Width, 1, file);
file_image += frame_info->stVFrame.u32Stride[1];
}
return HI_SUCCESS;
}[/code]
我来回答
回答10个
时间排序
认可量排序
认可0
认可0
认可0
认可0
认可0
认可0
认可1
认可0
认可0
认可0
或将文件直接拖到这里
悬赏:
E币
网盘
* 网盘链接:
* 提取码:
悬赏:
E币
Markdown 语法
- 加粗**内容**
- 斜体*内容*
- 删除线~~内容~~
- 引用> 引用内容
- 代码`代码`
- 代码块```编程语言↵代码```
- 链接[链接标题](url)
- 无序列表- 内容
- 有序列表1. 内容
- 缩进内容
- 图片![alt](url)
相关问答
-
2023-10-26 21:06:31
-
2023-10-24 16:00:16
-
2020-08-12 11:29:46
-
2020-07-31 15:42:13
-
2019-05-11 13:32:04
-
2014-08-20 14:07:10
-
02020-05-18 15:33:20
-
2018-12-05 15:20:25
-
2019-01-21 14:58:53
-
2015-12-09 20:36:11
-
22020-01-07 11:46:55
-
2020-05-15 10:58:48
-
2017-07-11 17:38:56
-
2016-11-01 23:09:33
-
2020-12-12 09:44:25
-
2020-12-25 15:19:54
-
2020-04-07 11:16:26
-
2018-12-24 09:39:12
-
2020-07-23 09:09:18
无更多相似问答 去提问
点击登录
-- 积分
-- 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币)
取消
确认