@@ -50,6 +50,7 @@ void get_video_info(char **p_videoFilenameList, int p_debug) {
50
50
gVideoCodecCtxDepList = (AVCodecContext * )malloc (gNumOfVideoFiles * sizeof (AVCodecContext ));
51
51
gVideoPacketDepList = (AVPacket * )malloc (gNumOfVideoFiles * sizeof (AVPacket ));
52
52
for (l_i = 0 ; l_i < gNumOfVideoFiles ; ++ l_i ) {
53
+ packet_queue_init (& gVideoPacketQueueList [l_i ]); //initialize the packet queue
53
54
gVideoPacketQueueList [l_i ].dep_gop_num = 0 ;
54
55
g_decode_gop_num = 0 ;
55
56
gVideoPacketQueueList [l_i ].nb_packets = 0 ;
@@ -601,13 +602,13 @@ void dep_decode_a_video_packet(int p_videoFileIndex) {
601
602
char l_depGopRecFileName [100 ], l_depIntraFileName [100 ], l_depInterFileName [100 ], l_depMbPosFileName [100 ], l_depDcpFileName [100 ];
602
603
AVFrame * l_videoFrame = avcodec_alloc_frame ();
603
604
int l_numOfDecodedFrames , l_frameType ;
604
- // LOGI(10, "dep_decode_a_video_packet for video: %d", p_videoFileIndex);
605
+ LOGI (10 , "dep_decode_a_video_packet for video: %d" , p_videoFileIndex );
605
606
while (av_read_frame (gFormatCtxDepList [p_videoFileIndex ], & gVideoPacketDepList [p_videoFileIndex ]) >= 0 ) {
606
607
if (gVideoPacketDepList [p_videoFileIndex ].stream_index == gVideoStreamIndexList [p_videoFileIndex ]) {
607
- // LOGI(10, "got a video packet, dump dependency: %d", p_videoFileIndex);
608
+ LOGI (10 , "got a video packet, dump dependency: %d" , p_videoFileIndex );
608
609
++ gVideoCodecCtxDepList [p_videoFileIndex ]-> dep_video_packet_num ;
609
610
/*put the video packet into the packet queue, for the decoding thread to access*/
610
- // LOGI(10, "put a video packet into queue: %d", p_videoFileIndex);
611
+ LOGI (10 , "put a video packet into queue: %d" , p_videoFileIndex );
611
612
packet_queue_put (& gVideoPacketQueueList [p_videoFileIndex ], & gVideoPacketDepList [p_videoFileIndex ]);
612
613
/*update the gop information if it's an I-frame
613
614
update: for every GOP, we generate a set of dependency files. It has the following advantages:
@@ -617,31 +618,36 @@ void dep_decode_a_video_packet(int p_videoFileIndex) {
617
618
*/
618
619
l_frameType = (gVideoPacketDepList [p_videoFileIndex ].data [4 ] & 0xC0 );
619
620
if (l_frameType == 0x00 ) { //an I frame packet
621
+ LOGI (10 , "dump dependency: got I frame" );
620
622
if (gVideoCodecCtxDepList [p_videoFileIndex ]-> dep_video_packet_num == 1 ) {
621
623
//if it's first frame, no action is needed
622
624
} else {
623
625
//print the end frame number of previoius gop
624
- fprintf (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_gopF , "%d:\n" , gVideoCodecCtxDepList [p_videoFileIndex ]-> dep_video_packet_num - 1 );
626
+ if (gVideoCodecCtxDepList [p_videoFileIndex ]-> dump_dependency ) {
627
+ fprintf (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_gopF , "%d:\n" , gVideoCodecCtxDepList [p_videoFileIndex ]-> dep_video_packet_num - 1 );
628
+ //TODO: fflush all the dependency files for previous gop, may not be necessary since we're closing these files
629
+ fflush (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_gopF );
630
+ fflush (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_mbPosF );
631
+ fflush (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_dcPredF );
632
+ fflush (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_intraDepF );
633
+ fflush (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_interDepF );
634
+ //close all dependency files for this GOP
635
+ fclose (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_gopF );
636
+ fclose (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_mbPosF );
637
+ fclose (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_dcPredF );
638
+ fclose (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_intraDepF );
639
+ fclose (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_interDepF );
640
+ }
625
641
++ gVideoPacketQueueList [p_videoFileIndex ].dep_gop_num ;
626
- //TODO: fflush all the dependency files for previous gop, may not be necessary since we're closing these files
627
- fflush (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_gopF );
628
- fflush (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_mbPosF );
629
- fflush (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_dcPredF );
630
- fflush (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_intraDepF );
631
- fflush (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_interDepF );
632
- //close all dependency files for this GOP
633
- fclose (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_gopF );
634
- fclose (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_mbPosF );
635
- fclose (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_dcPredF );
636
- fclose (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_intraDepF );
637
- fclose (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_interDepF );
638
642
}
639
643
/*check if the dependency files exist, if not, we'll need to dump the dependencies*/
644
+ LOGI (10 , "dependency files for video %d gop %d" , p_videoFileIndex , gVideoPacketQueueList [p_videoFileIndex ].dep_gop_num );
640
645
sprintf (l_depGopRecFileName , "./%s_goprec_gop%d.txt" , gVideoFileNameList [p_videoFileIndex ], gVideoPacketQueueList [p_videoFileIndex ].dep_gop_num );
641
646
sprintf (l_depIntraFileName , "./%s_intra_gop%d.txt" , gVideoFileNameList [p_videoFileIndex ], gVideoPacketQueueList [p_videoFileIndex ].dep_gop_num );
642
647
sprintf (l_depInterFileName , "./%s_inter_gop%d.txt" , gVideoFileNameList [p_videoFileIndex ], gVideoPacketQueueList [p_videoFileIndex ].dep_gop_num );
643
648
sprintf (l_depMbPosFileName , "./%s_mbpos_gop%d.txt" , gVideoFileNameList [p_videoFileIndex ], gVideoPacketQueueList [p_videoFileIndex ].dep_gop_num );
644
- sprintf (l_depDcpFileName , "./%s_dcp_gop%d.txt" , gVideoFileNameList [p_videoFileIndex ], gVideoPacketQueueList [p_videoFileIndex ].dep_gop_num );
649
+ sprintf (l_depDcpFileName , "./%s_dcp_gop%d.txt" , gVideoFileNameList [p_videoFileIndex ], gVideoPacketQueueList [p_videoFileIndex ].dep_gop_num );
650
+ LOGI (10 , "dependency files for video %d gop %d" , p_videoFileIndex , gVideoPacketQueueList [p_videoFileIndex ].dep_gop_num );
645
651
#ifdef CLEAR_DEP_BEFORE_START
646
652
remove (l_depGopRecFileName );
647
653
remove (l_depIntraFileName );
@@ -655,12 +661,13 @@ void dep_decode_a_video_packet(int p_videoFileIndex) {
655
661
gVideoCodecCtxDepList [p_videoFileIndex ]-> g_gopF = fopen (l_depGopRecFileName , "r" );
656
662
if (load_gop_info (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_gopF ) != 0 ) {
657
663
//the file content is complete, don't dump dependency
664
+ LOGI (10 , "dependency info is complete for video %d, gop %d" , p_videoFileIndex , gVideoPacketQueueList [p_videoFileIndex ].dep_gop_num );
658
665
gVideoCodecCtxDepList [p_videoFileIndex ]-> dump_dependency = 0 ;
659
666
}
660
667
fclose (gVideoCodecCtxDepList [p_videoFileIndex ]-> g_gopF );
661
668
}
662
669
if (gVideoCodecCtxDepList [p_videoFileIndex ]-> dump_dependency ) {
663
- packet_queue_init ( & gVideoPacketQueueList [p_videoFileIndex ]); //initialize the packet queue
670
+ LOGI ( 10 , "dumping dependency starts from video %d, gop %d" , p_videoFileIndex , gVideoPacketQueueList [p_videoFileIndex ]. dep_gop_num );
664
671
gVideoCodecCtxDepList [p_videoFileIndex ]-> g_gopF = fopen (l_depGopRecFileName , "w" );
665
672
gVideoCodecCtxDepList [p_videoFileIndex ]-> g_mbPosF = fopen (l_depMbPosFileName , "w" );
666
673
gVideoCodecCtxDepList [p_videoFileIndex ]-> g_dcPredF = fopen (l_depDcpFileName , "w" );
0 commit comments