This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

TDA4VM: 使用decode node解码h264文件卡在scheduling node

Part Number: TDA4VM
硬件:
开发板:TDA4VM
SDK版本:Linux + RTOS SDK 6.02

我想要通过tiovx的decode node解码h264文件并通过display node显示解码后的图像。
我参考tiovx目录下的test_video_decoder.c配置了decode node,并用decode node的输出image作为display node的输入进行显示

我用的h264文件是test_video_decoder.c里用的

"%s/tivx/video_decoder/1280x720_allIframe_CBR_20mbps_HIGHSPEED_HP_CABAC.264"

这个文件

当前的状态是我可以读取解码前几帧的数据并显示出来,但是解码几帧后就会在处理decode 的graph时卡住不继续执行动作了

我的代码如下:

vx_status app_init_decode(vx_context context, DecodeObj *decodeObj)
{
vx_status status = VX_SUCCESS;

/* Create object for encode parameters */
tivx_video_decoder_params_init(&decodeObj->params); //初始化参数
decodeObj->params.bitstream_format = TIVX_BITSTREAM_FORMAT_H264; //设置解码格式为H264

decodeObj->configuration_obj = vxCreateUserDataObject(context,
"tivx_video_decoder_params_t",
sizeof(tivx_video_decoder_params_t),
NULL);

vxCopyUserDataObject(decodeObj->configuration_obj,
0,
sizeof(tivx_video_decoder_params_t),
&decodeObj->params,
VX_WRITE_ONLY,
VX_MEMORY_TYPE_HOST);

if (vxGetStatus((vx_reference)decodeObj->configuration_obj) != VX_SUCCESS)
{
APP_PRINTF("configuration_obj create failed\n");
return VX_FAILURE;
}

decodeObj->num_buf = MAX_NUM_BUF;
decodeObj->pipeline_depth = MAX_NUM_BUF;
int i = 0;
for (i = 0; i < decodeObj->num_buf; i++)
{
decodeObj->bitstream_obj[i] = vxCreateUserDataObject(context, "video_bitstream", decodeObj->width * decodeObj->height * 3 / 2, NULL);
decodeObj->output_image[i] = vxCreateImage(context, decodeObj->width, decodeObj->height, VX_DF_IMAGE_NV12);
}

return status;
}

vx_status app_create_graph_decode(vx_graph graph, DecodeObj *decodeObj, vx_user_data_object *bitstream_obj)
{
vx_status status = VX_SUCCESS;

decodeObj->node = tivxVideoDecoderNode(graph,
decodeObj->configuration_obj,
bitstream_obj[0],
decodeObj->output_image[0]);

vxSetNodeTarget(decodeObj->node, VX_TARGET_STRING, TIVX_TARGET_VDEC1); //设置node Target目标核

vxSetReferenceName((vx_reference)decodeObj->node, "Decode_node");
status = vxGetStatus((vx_reference)decodeObj->node);
return status;
}
vx_status app_run_decodeGraph(vx_graph graph, DecodeObj *decodeObj)
{
vx_rectangle_t rect_y;
rect_y.start_x = 0;
rect_y.start_y = 0;
rect_y.end_x = 1280;
rect_y.end_y = 720;

vx_status status = VX_SUCCESS;
app_get_oneframe_decodeBitStream(&decodeObj->bitstream_obj[0], "/opt/test1.h264", current_frame);
current_frame ++;
if (current_frame >= 100) {
current_frame = 0;
}

status = vxProcessGraph(graph);
uint32_t checksum_actual = tivx_utils_simple_image_checksum( decodeObj->output_image[0], 0, rect_y);
printf("checksum_actual = 0x%x!!!\n", checksum_actual);
//}

return status;
}
void app_get_oneframe_decodeBitStream(vx_user_data_object *de_bitstream_obj, char *input_file, vx_uint32 current_frame)
{
vx_uint32 i;
uint8_t *bitstream;
vx_map_id map_id;
FILE* in_fp = NULL;
size_t num_read;
vx_size seek[300];
vx_status status, seek_status;

seek[0] = 0;
for(i = 1; i < 100; i++)
{
seek[i] = seek[i - 1] + bitstream_sizes[i - 1];
}

vxMapUserDataObject(*de_bitstream_obj, 0, bitstream_sizes[current_frame], &map_id, (void*) &bitstream, VX_WRITE_ONLY, VX_MEMORY_TYPE_HOST, 0);

in_fp = fopen(input_file, "rb+");
if (NULL != in_fp)
{
seek_status = fseek(in_fp, seek[current_frame], SEEK_SET);
printf("seek address = 0x%x!!!\n", seek[current_frame]);
if (0 == seek_status)
{
num_read = fread(bitstream, sizeof(uint8_t), bitstream_sizes[current_frame], in_fp);
fclose(in_fp);
in_fp = NULL;
if (bitstream_sizes[current_frame] != num_read)
{
printf("%s: Read less than expected!!!\n", input_file);
printf("Read %d, expected %d!!!\n", num_read, bitstream_sizes[current_frame]);
}
printf("%d byte for decode bitstream read \n", num_read);
}
else
{
fclose(in_fp);
in_fp = NULL;
printf("%s: Seek failed!!!\n", input_file);
}
}
else
{
printf("%s: Input file not found!!!\n", input_file);
}
vxUnmapUserDataObject(*de_bitstream_obj, map_id);
tivxSetUserDataObjectAttribute(*de_bitstream_obj, TIVX_USER_DATA_OBJECT_VALID_SIZE, (void*)&bitstream_sizes[current_frame], sizeof(vx_size));
}
static vx_status app_run_graph_for_one_frame(AppObj *obj, char *curFileName, vx_uint32 counter)
{
vx_status status = VX_SUCCESS;

//decode执行相关
if (status == VX_SUCCESS)
{
if (vx_true_e == tivxIsTargetEnabled(TIVX_TARGET_VDEC1))
{
uint64_t cur1_time = tivxPlatformGetTimeInUsecs();
APP_PRINTF("current time = %ld.\n", cur1_time);
status = app_run_decodeGraph(obj->decodeObj.graph, &obj->decodeObj);
cur1_time = tivxPlatformGetTimeInUsecs() - cur1_time;
/* convert to msecs */
cur1_time = cur1_time / 1000;
APP_PRINTF("\n\n解码信息:解码时间 = %ld ms\n", cur1_time);
}
} else {
APP_PRINTF("vx_status = %ld.\n", status);
}

if(status == VX_SUCCESS)
{
if ((vx_true_e == tivxIsTargetEnabled(TIVX_TARGET_DISPLAY1)) && (obj->displayObj.display_option == 1))
{
APP_PRINTF("app_tidl: Running display graph ... \n");
/* Execute the display graph */
if(status == VX_SUCCESS)
{
status = vxProcessGraph(obj->displayObj.disp_graph); //执行显示的graph
}
APP_PRINTF("app_tidl: Running display graph ... Done.\n");
}
} else {
APP_PRINTF("vx_status = %ld.\n", status);
}
return status;
}
执行后的log如下:
app_tidl: Init ...
app_init_display DONE!
app_templete: Init ... Done.
app_tidl: Creating graph ...
app_tidl: Creating graph ... Done.
app_tidl: Verifying display graph ...
0.015258 s: VX_ZONE_ERROR:[ownContextSendCmd:523] ownContextSendCmd: target_id: 106 cmd: 1 num_obj_desc: 1 obj_desc_id: 13
0.015989 s: VX_ZONE_INFO:[ownGraphNodeKernelInit:581] kernel init for node 0, kernel com.ti.hwa.display ...
0.015998 s: VX_ZONE_INFO:[ownGraphNodeKernelInit:592] kernel init for node 0, kernel com.ti.hwa.display ... done !!!
app_tidl: Verifying display graph ... Done.
app_tidl: Verifying decode graph ...
0.016183 s: VX_ZONE_ERROR:[ownContextSendCmd:523] ownContextSendCmd: target_id: 108 cmd: 1 num_obj_desc: 1 obj_desc_id: 12
0.083937 s: VX_ZONE_INFO:[ownGraphNodeKernelInit:581] kernel init for node 0, kernel com.ti.hwa.video_decoder ...
0.083946 s: VX_ZONE_INFO:[ownGraphNodeKernelInit:592] kernel init for node 0, kernel com.ti.hwa.video_decoder ... done !!!
app_tidl: Verifying decode graph ... Done.
app_tidl: Verifying graph ... Done.

Enter Choice: current time = 184243.
seek address = 0x0!!!
82993 byte for decode bitstream read
0.191066 s: VX_ZONE_INFO:[ownGraphScheduleGraph:763] Scheduling Graph (graph=19, pipe=0)
0.191074 s: VX_ZONE_INFO:[ownNodeKernelSchedule:584] Scheduling Node (node=12, pipe=0)
0.256662 s: VX_ZONE_INFO:[ownCheckGraphCompleted:676] Graph Completed (graph=19, pipe=0)
0.256694 s: VX_ZONE_INFO:[ownCheckGraphCompleted:701] All Graphs Completed
checksum_actual = 0x0!!!

解码信息:解码时间 = 72 ms
app_tidl: Running display graph ...
0.257182 s: VX_ZONE_INFO:[ownGraphScheduleGraph:763] Scheduling Graph (graph=16, pipe=0)
0.257190 s: VX_ZONE_INFO:[ownNodeKernelSchedule:584] Scheduling Node (node=13, pipe=0)
0.257447 s: VX_ZONE_INFO:[ownCheckGraphCompleted:676] Graph Completed (graph=16, pipe=0)
0.257453 s: VX_ZONE_INFO:[ownCheckGraphCompleted:701] All Graphs Completed
app_tidl: Running display graph ... Done.
current time = 257468.
seek address = 0x14431!!!
39524 byte for decode bitstream read
0.258004 s: VX_ZONE_INFO:[ownGraphScheduleGraph:763] Scheduling Graph (graph=19, pipe=0)
0.258010 s: VX_ZONE_INFO:[ownNodeKernelSchedule:584] Scheduling Node (node=12, pipe=0)
0.269753 s: VX_ZONE_INFO:[ownCheckGraphCompleted:676] Graph Completed (graph=19, pipe=0)
0.269759 s: VX_ZONE_INFO:[ownCheckGraphCompleted:701] All Graphs Completed
checksum_actual = 0x2bfbdee0!!!

解码信息:解码时间 = 12 ms
app_tidl: Running display graph ...
0.270188 s: VX_ZONE_INFO:[ownGraphScheduleGraph:763] Scheduling Graph (graph=16, pipe=0)
0.270195 s: VX_ZONE_INFO:[ownNodeKernelSchedule:584] Scheduling Node (node=13, pipe=0)
0.293071 s: VX_ZONE_INFO:[ownCheckGraphCompleted:676] Graph Completed (graph=16, pipe=0)
0.293079 s: VX_ZONE_INFO:[ownCheckGraphCompleted:701] All Graphs Completed
app_tidl: Running display graph ... Done.
current time = 293096.
seek address = 0x1de95!!!
45091 byte for decode bitstream read
0.293738 s: VX_ZONE_INFO:[ownGraphScheduleGraph:763] Scheduling Graph (graph=19, pipe=0)
0.293744 s: VX_ZONE_INFO:[ownNodeKernelSchedule:584] Scheduling Node (node=12, pipe=0)
此时程序就卡住了,但是不一定每次都卡在这一帧,有时会多跑几帧数据,请确认这个问题是什么原因,多谢
[CMS]CMS功能安全问题关键技术点及模拟测试方案说明文档_V1.0.docx
1.6 MB
[CMS]CMS功能安全问题关键技术点及模拟测试方案说明文档_V1.0.docx
1.6 MB
3月25日
csdn.net
H.264裸流文件中获取每一帧数据_h264 如何获取一帧的长度_灏喾的博客-CSDN博客
H.264 入门知识
test.h264
1.6 MB
h264.txt
6.5 KB
1280x720_allIframe_CBR_20mbps_HIGHSPEED_HP_CABAC.264
22.9 MB
h264.txt
4.7 KB
20:50
20:50
app_tidl: Init ... app_init_display DONE! app_templete: Init ... Done. app_tidl: Creating graph ... app_tidl: Creating graph ... Done. app_tidl: Verifying display graph ... 0.015258 s: VX_ZONE_ERROR:[ownContextSendCmd:523] ownContextSendCmd: target_id: 106 cmd: 1 num_obj_desc: 1 obj_desc_id: 13 0.015989 s: VX_ZONE_INFO:[ownGraphNodeKernelInit:581] kernel init for node 0, kernel com.ti.hwa.display ... 0.015998 s: VX_ZONE_INFO:[ownGraphNodeKernelInit:592] kernel init for node 0, kernel com.ti.hwa.display ... done !!! app_tidl: Verifying display graph ... Done. app_tidl: Verifying decode graph ... 0.016183 s: VX_ZONE_ERROR:[ownContextSendCmd:523] ownContextSendCmd: target_id: 108 cmd: 1 num_obj_desc: 1 obj_desc_id: 12 0.083937 s: VX_ZONE_INFO:[ownGraphNodeKernelInit:581] kernel init for node 0, kernel com.ti.hwa.video_decoder ... 0.083946 s: VX_ZONE_INFO:[ownGraphNodeKernelInit:592] kernel init for node 0, kernel com.ti.hwa.video_decoder ... done !!! app_tidl: Verifying decode graph ... Done. app_tidl: Verifying graph ... Done. ================================= Demo : TIDL Object Classification ================================= p: Print performance statistics x: Exit Enter Choice: current time = 184243. seek address = 0x0!!! 82993 byte for decode bitstream read 0.191066 s: VX_ZONE_INFO:[ownGraphScheduleGraph:763] Scheduling Graph (graph=19, pipe=0) 0.191074 s: VX_ZONE_INFO:[ownNodeKernelSchedule:584] Scheduling Node (node=12, pipe=0) 0.256662 s: VX_ZONE_INFO:[ownCheckGraphCompleted:676] Graph Completed (graph=19, pipe=0) 0.256694 s: VX_ZONE_INFO:[ownCheckGraphCompleted:701] All Graphs Completed checksum_actual = 0x0!!! 解码信息:当前帧序号:第 0 帧 属性: 1080P 图像 720 x 1280 解码信息:解码时间 = 72 ms app_tidl: Running display graph ... 0.257182 s: VX_ZONE_INFO:[ownGraphScheduleGraph:763] Scheduling Graph (graph=16, pipe=0) 0.257190 s: VX_ZONE_INFO:[ownNodeKernelSchedule:584] Scheduling Node (node=13, pipe=0) 0.257447 s: VX_ZONE_INFO:[ownCheckGraphCompleted:676] Graph Completed (graph=16, pipe=0) 0.257453 s: VX_ZONE_INFO:[ownCheckGraphCompleted:701] All Graphs Completed app_tidl: Running display graph ... Done. current time = 257468. seek address = 0x14431!!! 39524 byte for decode bitstream read 0.258004 s: VX_ZONE_INFO:[ownGraphScheduleGraph:763] Scheduling Graph (graph=19, pipe=0) 0.258010 s: VX_ZONE_INFO:[ownNodeKernelSchedule:584] Scheduling Node (node=12, pipe=0) 0.269753 s: VX_ZONE_INFO:[ownCheckGraphCompleted:676] Graph Completed (graph=19, pipe=0) 0.269759 s: VX_ZONE_INFO:[ownCheckGraphCompleted:701] All Graphs Completed checksum_actual = 0x2bfbdee0!!! 解码信息:当前帧序号:第 0 帧 属性: 1080P 图像 720 x 1280 解码信息:解码时间 = 12 ms app_tidl: Running display graph ... 0.270188 s: VX_ZONE_INFO:[ownGraphScheduleGraph:763] Scheduling Graph (graph=16, pipe=0) 0.270195 s: VX_ZONE_INFO:[ownNodeKernelSchedule:584] Scheduling Node (node=13, pipe=0) 0.293071 s: VX_ZONE_INFO:[ownCheckGraphCompleted:676] Graph Completed (graph=16, pipe=0) 0.293079 s: VX_ZONE_INFO:[ownCheckGraphCompleted:701] All Graphs Completed app_tidl: Running display graph ... Done. current time = 293096. seek address = 0x1de95!!! 45091 byte for decode bitstream read 0.293738 s: VX_ZONE_INFO:[ownGraphScheduleGraph:763] Scheduling Graph (graph=19, pipe=0) 0.293744 s: VX_ZONE_INFO:[ownNodeKernelSchedule:584] Scheduling Node (node=12, pipe=0)
展开

张小飞
[CMS]CMS功能安全问题关键技术点及模拟测试方案说明文档_V1.0.docx
1.6 MB
[CMS]CMS功能安全问题关键技术点及模拟测试方案说明文档_V1.0.docx
1.6 MB
3月25日
csdn.net
H.264裸流文件中获取每一帧数据_h264 如何获取一帧的长度_灏喾的博客-CSDN博客
H.264 入门知识
test.h264
1.6 MB
h264.txt
6.5 KB
1280x720_allIframe_CBR_20mbps_HIGHSPEED_HP_CABAC.264
22.9 MB
h264.txt
4.7 KB
20:50
20:50
app_tidl: Init ... app_init_display DONE! app_templete: Init ... Done. app_tidl: Creating graph ... app_tidl: Creating graph ... Done. app_tidl: Verifying display graph ... 0.015258 s: VX_ZONE_ERROR:[ownContextSendCmd:523] ownContextSendCmd: target_id: 106 cmd: 1 num_obj_desc: 1 obj_desc_id: 13 0.015989 s: VX_ZONE_INFO:[ownGraphNodeKernelInit:581] kernel init for node 0, kernel com.ti.hwa.display ... 0.015998 s: VX_ZONE_INFO:[ownGraphNodeKernelInit:592] kernel init for node 0, kernel com.ti.hwa.display ... done !!! app_tidl: Verifying display graph ... Done. app_tidl: Verifying decode graph ... 0.016183 s: VX_ZONE_ERROR:[ownContextSendCmd:523] ownContextSendCmd: target_id: 108 cmd: 1 num_obj_desc: 1 obj_desc_id: 12 0.083937 s: VX_ZONE_INFO:[ownGraphNodeKernelInit:581] kernel init for node 0, kernel com.ti.hwa.video_decoder ... 0.083946 s: VX_ZONE_INFO:[ownGraphNodeKernelInit:592] kernel init for node 0, kernel com.ti.hwa.video_decoder ... done !!! app_tidl: Verifying decode graph ... Done. app_tidl: Verifying graph ... Done. ================================= Demo : TIDL Object Classification ================================= p: Print performance statistics x: Exit Enter Choice: current time = 184243. seek address = 0x0!!! 82993 byte for decode bitstream read 0.191066 s: VX_ZONE_INFO:[ownGraphScheduleGraph:763] Scheduling Graph (graph=19, pipe=0) 0.191074 s: VX_ZONE_INFO:[ownNodeKernelSchedule:584] Scheduling Node (node=12, pipe=0) 0.256662 s: VX_ZONE_INFO:[ownCheckGraphCompleted:676] Graph Completed (graph=19, pipe=0) 0.256694 s: VX_ZONE_INFO:[ownCheckGraphCompleted:701] All Graphs Completed checksum_actual = 0x0!!! 解码信息:当前帧序号:第 0 帧 属性: 1080P 图像 720 x 1280 解码信息:解码时间 = 72 ms app_tidl: Running display graph ... 0.257182 s: VX_ZONE_INFO:[ownGraphScheduleGraph:763] Scheduling Graph (graph=16, pipe=0) 0.257190 s: VX_ZONE_INFO:[ownNodeKernelSchedule:584] Scheduling Node (node=13, pipe=0) 0.257447 s: VX_ZONE_INFO:[ownCheckGraphCompleted:676] Graph Completed (graph=16, pipe=0) 0.257453 s: VX_ZONE_INFO:[ownCheckGraphCompleted:701] All Graphs Completed app_tidl: Running display graph ... Done. current time = 257468. seek address = 0x14431!!! 39524 byte for decode bitstream read 0.258004 s: VX_ZONE_INFO:[ownGraphScheduleGraph:763] Scheduling Graph (graph=19, pipe=0) 0.258010 s: VX_ZONE_INFO:[ownNodeKernelSchedule:584] Scheduling Node (node=12, pipe=0) 0.269753 s: VX_ZONE_INFO:[ownCheckGraphCompleted:676] Graph Completed (graph=19, pipe=0) 0.269759 s: VX_ZONE_INFO:[ownCheckGraphCompleted:701] All Graphs Completed checksum_actual = 0x2bfbdee0!!! 解码信息:当前帧序号:第 0 帧 属性: 1080P 图像 720 x 1280 解码信息:解码时间 = 12 ms app_tidl: Running display graph ... 0.270188 s: VX_ZONE_INFO:[ownGraphScheduleGraph:763] Scheduling Graph (graph=16, pipe=0) 0.270195 s: VX_ZONE_INFO:[ownNodeKernelSchedule:584] Scheduling Node (node=13, pipe=0) 0.293071 s: VX_ZONE_INFO:[ownCheckGraphCompleted:676] Graph Completed (graph=16, pipe=0) 0.293079 s: VX_ZONE_INFO:[ownCheckGraphCompleted:701] All Graphs Completed app_tidl: Running display graph ... Done. current time = 293096. seek address = 0x1de95!!! 45091 byte for decode bitstream read 0.293738 s: VX_ZONE_INFO:[ownGraphScheduleGraph:763] Scheduling Graph (graph=19, pipe=0) 0.293744 s: VX_ZONE_INFO:[ownNodeKernelSchedule:584] Scheduling Node (node=12, pip