VENC功能及参数说明
不推荐使用旧版本中的VENC功能,后续版本会删除。旧版本中的VENC功能已迁移到VENC新接口,请参见VENC功能接口进行开发。
功能
实现YUV420/YVU420图片数据的编码。
- VENC支持以下格式输入:
YUV420 semi-planner NV12/NV21-8bit
- VENC输出格式为:
H264 BP/MP/HP
H265 MP
VENC性能指标
场景 |
总帧率 |
---|---|
1080p * 1路(不支持多路) |
30fps |
入参:venc_in_msg
成员变量 |
说明 |
取值范围 |
---|---|---|
Int width |
图像宽度。 |
128~1920,且为偶数。 |
Int height |
图像高度。 |
128~1920,且为偶数。 |
Int coding_type |
视频编码协议H265-main level(0)、H264-baseline level(1)、H264-main level(2)、H264-high level(3) |
0~3
|
Int YUV_store_type |
YUV图像存储格式。 |
0或者1
|
char* input_data |
输入图像数据地址。 |
不能为NULL。 |
Int input_data_size |
输入图像数据大小。 |
正数。 |
shared_ptr<AutoBuffer> output_data_queue |
输出编码码流数据地址。 |
需要配置此buffer,此buffer为调用方申请智能指针当做参数传入DVPP。用户可读取该buffer获取输出图片。 必填 |
出参
暂无。
调用示例
void TEST_3() //venc demo { int read_file_size; int unit_file_size; FILE *fp = fopen(in_file_name, "rb"); if (fp == NULL) { printf("open file: %s failed.\n", in_file_name); return; } printf("open yuv success \n"); fseek(fp, 0L, SEEK_END); int file_size = ftell(fp); fseek(fp, 0L, SEEK_SET); venc_in_msg venc_msg; venc_msg.width = gWidth; venc_msg.height = gHigh; venc_msg.coding_type = gFormat; venc_msg.YUV_store_type = gBitwidth; venc_msg.output_data_queue = make_shared<AutoBuffer>(); unit_file_size = gWidth * gHigh * 3 / 2 * MAX_FRAME_NUM_VENC; //单次文件大小为16帧 dvppapi_ctl_msg dvppApiCtlMsg; dvppApiCtlMsg.in = (void *)(&venc_msg); dvppApiCtlMsg.in_size = sizeof(venc_in_msg); IDVPPAPI *pidvppapi = NULL; CreateDvppApi(pidvppapi); char out_filename[] = "venc.bin"; FILE *outputBufferFile; outputBufferFile = fopen (out_filename, "wb+"); do{ read_file_size = file_size>unit_file_size? unit_file_size:file_size; //每次读取文件大小不能超过16帧 venc_msg.input_data = (char *)malloc(read_file_size); int read_len = fread(venc_msg.input_data, 1, read_file_size, fp); printf("file size is %d,read len is %d.\n", read_file_size, read_len); venc_msg.input_data_size = read_len; if (pidvppapi != NULL) { if (DvppCtl(pidvppapi, DVPP_CTL_VENC_PROC, &dvppApiCtlMsg) != 0) { printf("call dvppctl process faild!\n"); DestroyDvppApi(pidvppapi); fclose(fp); fclose(outputBufferFile); return; } if (venc_msg.output_data_queue->getBufferSize() > 100) { //防止编码结果只含有头部信息 char* out_buf = venc_msg.output_data_queue->getBuffer(); int out_buf_size = venc_msg.output_data_queue->getBufferSize(); int write_size = fwrite(out_buf, 1, out_buf_size, outputBufferFile); fflush(outputBufferFile); } else { printf("venc output data is too small : %d \n", venc_msg.output_data_queue->getBufferSize()); } } else { printf("pidvppapi is null!\n"); } if (venc_msg.input_data != NULL) { free(venc_msg.input_data); venc_msg.input_data = NULL; } file_size = file_size - unit_file_size; } while (file_size > 0); DestroyDvppApi(pidvppapi); fclose(outputBufferFile); fclose(fp); return; }