Selaa lähdekoodia

Z991239-1781 #comment other 解决采集到的图像颜色偏蓝问题

陈礼鹏80274480 4 vuotta sitten
vanhempi
sitoutus
e68f54523f

+ 23 - 31
Module/mod_sipphone/video_session.cpp

@@ -1951,28 +1951,17 @@ void* videorender_func(void* arg)
 				long unsec = ts.tv_nsec + (1000 * 1000 * 100);
 				ts.tv_sec += (unsec / 1000000000);
 				ts.tv_nsec = (unsec % 1000000000);
-				Dbg("%s:%d", __FUNCTION__, __LINE__);
 				if (0 != sem_timedwait(&session->ui_stop_sem, &ts) && (ETIMEDOUT == errno))
 				{
 					video_frame_fill_black(vfrm);
-					Dbg("%s:%d", __FUNCTION__, __LINE__);
 					video_frame* tmp_frame_preview = video_frame_new(REC_COMMON_VIDEO_PREVIEW_WIDTH, REC_COMMON_VIDEO_PREVIEW_HEIGHT, VIDEO_FORMAT_RGB24);
 					videoq_frame qfrm;
 					qfrm.data = tmp_frame_preview->data[0];
-					Dbg("%s:%d,and current video queue len is %d", __FUNCTION__, __LINE__, session->video_shm_q_preview->GetVideoLens());
-					BOOL result = session->video_shm_q_preview->GetVideo(&qfrm, VIDEOQUEUE_FLAG_HORIZONTAL_FLIP);
-					static int icount = 0;
-					if (icount == 0) {
-						video_frame_save_bmpfile("local_test.bmp", tmp_frame_preview);
-						//icount++;
-					}
+					//Dbg("%s:%d,and current video queue len is %d", __FUNCTION__, __LINE__, session->video_shm_q_preview->GetVideoLens());
+					bool result = session->video_shm_q_preview->GetVideo(&qfrm, VIDEOQUEUE_FLAG_HORIZONTAL_FLIP);
 					if (result) {
-						Dbg("%s:%d", __FUNCTION__, __LINE__);
 						session->plocal_render->RenderVideoFrame(tmp_frame_preview);
 					}
-					else {
-						Dbg("%s:%d", __FUNCTION__, __LINE__);
-					}
 				}
 				else {
 					Dbg("%s:%d videorender_func exit!", __FUNCTION__, __LINE__);
@@ -2279,10 +2268,10 @@ int video_session_create(const video_session_conf_t *conf, video_session_t **p_s
 	video_session_t *session = ZALLOC_T(video_session_t);
 	if (session) 
 	{
-		char str_local[128] = {0};
-		char str_remote[128] = {0};
-		translate_ipaddr_from_int(str_local, 128, conf->local_rtp_ip);
-		translate_ipaddr_from_int(str_remote, 128, conf->remote_rtp_ip);
+		char str_local[MAX_PATH_SIZE] = {0};
+		char str_remote[MAX_PATH_SIZE] = {0};
+		translate_ipaddr_from_int(str_local, MAX_PATH_SIZE, conf->local_rtp_ip);
+		translate_ipaddr_from_int(str_remote, MAX_PATH_SIZE, conf->remote_rtp_ip);
 
 		Dbg("video_session_create session addr = 0x%0x,local_rtp_ip = %s,local_rtp_port = %d, local_pt = %d, remote_rtp_ip = %s,remote_rtp_port=%d, remote_pt = %d, call type = %d.", 
 			session, str_local, conf->local_rtp_port,conf->local_pt, str_remote, conf->remote_rtp_port, conf->remote_pt, conf->nCallType);
@@ -2480,7 +2469,6 @@ void double_record_broadcast_video_session_stop()
 void video_session_destroy(video_session_t *session)
 {
 	LOG_FUNCTION();
-
 #ifdef RVC_OS_WIN
 	if (NULL != session) {
 		if (NULL != session->pic_record) {
@@ -2496,28 +2484,32 @@ void video_session_destroy(video_session_t *session)
 				session->pic_record->evt = NULL;
 			}
 		}
+
+		if (session->video_shm_q_env) {
+			delete session->video_shm_q_env;
+			session->video_shm_q_env = NULL;
+		}
+
+		if (session->video_shm_q_opt) {
+			delete session->video_shm_q_opt;
+			session->video_shm_q_opt = NULL;
+		}
+
+		if (session->video_shm_q_preview) {
+			delete session->video_shm_q_preview;
+			session->video_shm_q_preview = NULL;
+		}
 	}
 #else
 
 #endif // RVC_OS_WIN
 
-	if (session->video_shm_q_env) {
-		delete session->video_shm_q_env;
-		session->video_shm_q_env = NULL;
-	}
-	if (session->video_shm_q_opt) {
-		delete session->video_shm_q_opt;
-		session->video_shm_q_opt = NULL;
-	}
-	if (session->video_shm_q_preview) {
-		delete session->video_shm_q_preview;
-		session->video_shm_q_preview = NULL;
-	}
 	if (session->video_error){
 		delete session->video_error->data;
 		delete session->video_error;
 	}
-	if (session->video_shm_q_remote){
+
+	if (session->video_shm_q_remote) {
 		delete session->video_shm_q_remote;
 		session->video_shm_q_remote = NULL;
 	}

+ 2 - 2
Other/libvideocapture/libvideocapture.cpp

@@ -336,10 +336,10 @@ int32_t VideoCaptureImpl::IncomingFrame(uint8_t* videoFrame,
 
 	if (width == m_dest_cap_width){
 		if (height == m_dest_cap_height){
-			yvyu_to_yu12(i420, videoFrame, m_dest_cap_width, m_dest_cap_height);
+			yuyv_to_yu12(i420, videoFrame, m_dest_cap_width, m_dest_cap_height);
 		}
 		else if(height > m_dest_cap_height){
-			yvyu_to_yu12(i420, videoFrame + width * (height - m_dest_cap_height), m_dest_cap_width, m_dest_cap_height);
+			yuyv_to_yu12(i420, videoFrame + width * (height - m_dest_cap_height), m_dest_cap_width, m_dest_cap_height);
 		}
 	}
 	

+ 50 - 0
Other/libvideoframework/video_common/videoutil.c

@@ -503,6 +503,56 @@ void yvyu_to_yu12(uint8_t* outframe, uint8_t* inframe, int width, int height)
 }
 
 
+/*
+ *convert from packed 422 yuv (yuyv) to 420 planar (yu12)
+ * args:
+ *    out - pointer to output yu12 planar data buffer
+ *    in - pointer to input yuyv packed data buffer
+ *    width - frame width
+ *    height - frame height
+ *
+ * asserts:
+ *    in is not null
+ *    out is not null
+ *
+ * returns: none
+ */
+void yuyv_to_yu12(uint8_t* out, uint8_t* in, int width, int height)
+{
+	/*assertions*/
+	assert(in);
+	assert(out);
+
+	int w = 0, h = 0;
+
+	uint8_t* in1 = in; //first line
+	uint8_t* in2 = in1 + (width * 2); //second line in yuyv buffer
+
+	uint8_t* py1 = out; // first line
+	uint8_t* py2 = py1 + width; //second line
+	uint8_t* pu = py1 + (width * height);
+	uint8_t* pv = pu + ((width * height) / 4);
+
+	for (h = 0; h < height; h += 2)
+	{
+		in2 = in1 + (width * 2);
+		py2 = py1 + width;
+		for (w = 0; w < width; w += 2) //yuyv 2 bytes per sample
+		{
+			//printf("decoding: h:%i w:%i\n", h, w);
+			*py1++ = *in1++;
+			*py2++ = *in2++;
+			*pu++ = ((*in1++) + (*in2++)) / 2; //average u samples
+			*py1++ = *in1++;
+			*py2++ = *in2++;
+			*pv++ = ((*in1++) + (*in2++)) / 2; //average v samples
+		}
+		in1 = in2;
+		py1 = py2;
+	}
+
+}
+
 void yu12_to_rgb24(uint8_t* outframe, uint8_t* inframe, int width, int height)
 {
 	/*assertions*/

+ 16 - 0
Other/libvideoframework/videoutil.h

@@ -72,6 +72,22 @@ int video_frame_fill_black(video_frame *frame);
 void yvyu_to_yu12(uint8_t* outframe, uint8_t* inframe, int width, int height);
 void yu12_to_rgb24(uint8_t* outframe, uint8_t* inframe, int width, int height);
 
+/*
+ *convert from packed 422 yuv (yuyv) to 420 planar (yu12)
+ * args:
+ *    out - pointer to output yu12 planar data buffer
+ *    in - pointer to input yuyv packed data buffer
+ *    width - frame width
+ *    height - frame height
+ *
+ * asserts:
+ *    in is not null
+ *    out is not null
+ *
+ * returns: none
+ */
+void yuyv_to_yu12(uint8_t* out, uint8_t* in, int width, int height);
+
 /*
  * FIXME:  yu12 to bgr24 with lines upsidedown
  *   used for bitmap files (DIB24)