@@ -63,29 +63,33 @@ int gZoomLevelUpdate;
63
63
void * test_thread (void * arg );
64
64
void * decode_video (void * arg );
65
65
66
- /*for testing: we dump the decoded frame to a file: here (_roiSh, _roiSw) and (_roiEh, _roiEw) are in pixel*/
67
- static void render_a_frame (int p_zoomLevelUpdate , int _width , int _height , float _roiSh , float _roiSw , float _roiEh , float _roiEw ) {
68
- int li ;
69
- int l_roiSh , l_roiSw , l_roiEh , l_roiEw ;
70
- LOGI (10 , "render_a_frame" );
71
- gVideoPicture .height = _height ;
72
- gVideoPicture .width = _width ;
73
- ++ gVideoPacketNum ;
74
- /*wait for the dump dependency thread to finish dumping dependency info first before start decoding a frame*/
66
+ static void wait_get_dependency () {
67
+ /*wait for the dump dependency thread to finish dumping dependency info first before start decoding a frame*/
75
68
if (gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> dump_dependency ) {
76
- while (gVideoPacketQueueList [ gCurrentDecodingVideoFileIndex ]. decode_gop_num >= gVideoPacketQueueList [gCurrentDecodingVideoFileIndex ].dep_gop_num ) {
69
+ while (g_decode_gop_num >= gVideoPacketQueueList [gCurrentDecodingVideoFileIndex ].dep_gop_num ) {
77
70
/*[TODO]it might be more appropriate to use some sort of signal*/
78
71
//pthread_mutex_lock(&gVideoPacketQueue.mutex);
79
72
//pthread_cond_wait(&gVideoPacketQueue.cond, &gVideoPacketQueue.mutex);
80
73
//pthread_mutex_unlock(&gVideoPacketQueue.mutex);
81
74
usleep (50 );
82
75
}
83
- LOGI (10 , "%d:%d:%d" , gNumOfGop , gVideoPacketQueueList [ gCurrentDecodingVideoFileIndex ]. decode_gop_num , gVideoPacketQueueList [gCurrentDecodingVideoFileIndex ].dep_gop_num );
76
+ LOGI (10 , "%d:%d:%d" , gNumOfGop , g_decode_gop_num , gVideoPacketQueueList [gCurrentDecodingVideoFileIndex ].dep_gop_num );
84
77
//update the gop start and end to memory data structure
85
78
if (gNumOfGop < gVideoPacketQueueList [gCurrentDecodingVideoFileIndex ].dep_gop_num ) {
86
79
load_gop_info (gCurrentDecodingVideoFileIndex , gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> g_gopF );
87
80
}
88
81
}
82
+ }
83
+
84
+ /*for testing: we dump the decoded frame to a file: here (_roiSh, _roiSw) and (_roiEh, _roiEw) are in pixel*/
85
+ static void render_a_frame (int p_zoomLevelUpdate , int _width , int _height , float _roiSh , float _roiSw , float _roiEh , float _roiEw ) {
86
+ int li ;
87
+ int l_roiSh , l_roiSw , l_roiEh , l_roiEw ;
88
+ LOGI (10 , "render_a_frame" );
89
+ gVideoPicture .height = _height ;
90
+ gVideoPicture .width = _width ;
91
+ ++ gVideoPacketNum ;
92
+ wait_get_dependency ();
89
93
/*see if it's a gop start, if so, load the gop info*/
90
94
LOGI (10 , "gVideoPacketNum = %d; gNumOfGop = %d;" , gVideoPacketNum , gNumOfGop );
91
95
for (li = 0 ; li < gNumOfGop ; ++ li ) {
@@ -99,22 +103,24 @@ static void render_a_frame(int p_zoomLevelUpdate, int _width, int _height, float
99
103
gCurrentDecodingVideoFileIndex = 0 ;
100
104
}
101
105
gZoomLevelUpdate = 0 ;
106
+ //after zoom level is updated, we'll need to check if we need to wait for dumping dependency
107
+ wait_get_dependency ();
102
108
}
103
109
//start of a gop
104
110
gStFrame = gGopStart [li ];
105
- //start of a gop indicates the previous gop is done decoding
106
- gVideoPacketQueueList [ gCurrentDecodingVideoFileIndex ]. decode_gop_num = li ;
107
- //3.0 based on roi pixel coordinates, calculate the mb-based roi coordinates
108
- l_roiSh = (_roiSh - 15 ) > 0 ? (_roiSh - 15 ):0 ;
109
- l_roiSw = (_roiSw - 15 ) > 0 ? (_roiSw - 15 ):0 ;
110
- l_roiEh = (_roiEh + 15 ) < gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> height ? (_roiEh + 15 ):gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> height ;
111
- l_roiEw = (_roiEw + 15 ) < gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> width ? (_roiEw + 15 ):gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> width ;
112
- l_roiSh = l_roiSh * (gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> height /16 ) / gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> height ;
113
- l_roiSw = l_roiSw * (gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> width /16 ) / gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> width ;
114
- l_roiEh = l_roiEh * (gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> height /16 ) / gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> height ;
115
- l_roiEw = l_roiEw * (gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> width /16 ) / gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> width ;
116
- //3.1 check if it's a beginning of a gop, if so, load the pre computation result and compute the inter frame dependency
117
- LOGI (10 , "decode video %d with roi (%d:%d) to (%d:%d)" , gCurrentDecodingVideoFileIndex , l_roiSh , l_roiSw , l_roiEh , l_roiEw );
111
+ //start of a gop indicates the previous gop is done decoding
112
+ g_decode_gop_num = li ;
113
+ //3.0 based on roi pixel coordinates, calculate the mb-based roi coordinates
114
+ l_roiSh = (_roiSh - 15 ) > 0 ? (_roiSh - 15 ):0 ;
115
+ l_roiSw = (_roiSw - 15 ) > 0 ? (_roiSw - 15 ):0 ;
116
+ l_roiEh = (_roiEh + 15 ) < gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> height ? (_roiEh + 15 ):gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> height ;
117
+ l_roiEw = (_roiEw + 15 ) < gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> width ? (_roiEw + 15 ):gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> width ;
118
+ l_roiSh = l_roiSh * (gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> height /16 ) / gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> height ;
119
+ l_roiSw = l_roiSw * (gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> width /16 ) / gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> width ;
120
+ l_roiEh = l_roiEh * (gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> height /16 ) / gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> height ;
121
+ l_roiEw = l_roiEw * (gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> width /16 ) / gVideoCodecCtxList [gCurrentDecodingVideoFileIndex ]-> width ;
122
+ //3.1 check if it's a beginning of a gop, if so, load the pre computation result and compute the inter frame dependency
123
+ LOGI (10 , "decode video %d with roi (%d:%d) to (%d:%d)" , gCurrentDecodingVideoFileIndex , l_roiSh , l_roiSw , l_roiEh , l_roiEw );
118
124
prepare_decode_of_gop (gCurrentDecodingVideoFileIndex , gGopStart [li ], gGopEnd [li ], l_roiSh , l_roiSw , l_roiEh , l_roiEw );
119
125
break ;
120
126
} else if (gVideoPacketNum < gGopEnd [li ]) {
0 commit comments