亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? netcam_jpeg.c

?? video motion detection of linux base
?? C
字號:
/* *	netcam_jpeg.c * *	Module for handling JPEG decompression for network cameras. * *	This code was inspired by the original module written by *	Jeroen Vreeken and enhanced by several Motion project *	contributors, particularly Angel Carpintero and *	Christopher Price. * *	Copyright 2005, William M. Brack *	This program is published under the GNU Public license */#include "motion.h"#include <stdlib.h>#include <stdio.h>#include <string.h>#include <jpeglib.h>#include <jerror.h>#include "rotate.h"/* * netcam_source_mgr is a locally-defined structure to contain elements * which are not present in the standard libjpeg (the element 'pub' is a * pointer to the standard information) */typedef struct {	struct jpeg_source_mgr pub;	char           *data;	int             length;	JOCTET         *buffer;	boolean         start_of_file;} netcam_source_mgr;typedef netcam_source_mgr *netcam_src_ptr;/* * Here we declare function prototypes for all the routines involved with * overriding libjpeg functions.  The reason these are required is that, * although the standard library handles input and output with stdio, * we are working with "remote" data (from the camera or from a file). */static void     netcam_init_source(j_decompress_ptr);static boolean  netcam_fill_input_buffer(j_decompress_ptr);static void     netcam_skip_input_data(j_decompress_ptr, long);static void     netcam_term_source(j_decompress_ptr);static void     netcam_memory_src(j_decompress_ptr, char *, int);static void     netcam_error_exit(j_common_ptr);static void netcam_init_source(j_decompress_ptr cinfo){	/*	 * Get our "private" structure from the libjpeg structure	 */	netcam_src_ptr  src = (netcam_src_ptr) cinfo->src;	/*	 * Set the 'start_of_file' flag in our private structure	 * (used by my_fill_input_buffer)	 */	src->start_of_file = TRUE;}static boolean netcam_fill_input_buffer(j_decompress_ptr cinfo){	netcam_src_ptr  src = (netcam_src_ptr) cinfo->src;	size_t nbytes;	/*	 * start_of_file is set any time netcam_init_source has been called	 * since the last entry to this routine.  This would be the normal	 * path when a new image is to be processed.  It is assumed that	 * this routine will only be called once for the entire image.	 * If an unexpected call (with start_of_file FALSE) occurs, the	 * routine will insert a "fake" "end of image" marker and return	 * to the library to process whatever data remains from the original	 * image (the one with errors).	 *	 * I'm not yet clear on what the result (from the application's	 * point of view) will be from this logic.  If the application	 * expects that a completely new image will be started, this will	 * give trouble.	 */	if (src->start_of_file) {		nbytes = src->length;		src->buffer = (JOCTET *) src->data;	} else {		/* Insert a fake EOI marker - as per jpeglib recommendation */		if (debug_level)			motion_log(LOG_INFO, 0, "**fake EOI inserted**");		src->buffer[0] = (JOCTET) 0xFF;		src->buffer[1] = (JOCTET) JPEG_EOI;    /* 0xD9 */		nbytes = 2;	}	src->pub.next_input_byte = src->buffer;	src->pub.bytes_in_buffer = nbytes;	src->start_of_file = FALSE;	return TRUE;}static void netcam_skip_input_data(j_decompress_ptr cinfo, long num_bytes){	netcam_src_ptr  src = (netcam_src_ptr) cinfo->src;	if (num_bytes > 0) {		while (num_bytes > (long) src->pub.bytes_in_buffer) {			num_bytes -= (long) src->pub.bytes_in_buffer;			(void) netcam_fill_input_buffer (cinfo);		}		src->pub.next_input_byte += (size_t) num_bytes;		src->pub.bytes_in_buffer -= (size_t) num_bytes;	}}static void netcam_term_source(j_decompress_ptr cinfo ATTRIBUTE_UNUSED){}/** * netcam_memory_src * *	Routine to setup for fetching data from a netcam buffer, used by the *	JPEG library decompression routine. * * Parameters: *	cinfo           pointer to the jpeg decompression object *	data            pointer to the image data received from a netcam *	length          total size of the image * * Returns:             Nothing *  */static void netcam_memory_src(j_decompress_ptr cinfo, char *data, int length){	netcam_src_ptr src;	if (cinfo->src == NULL) {		cinfo->src = (struct jpeg_source_mgr *)		             (*cinfo->mem->alloc_small)		             ((j_common_ptr) cinfo, JPOOL_PERMANENT,		              sizeof (netcam_source_mgr));	}	src = (netcam_src_ptr)cinfo->src;	src->data = data;	src->length = length;	src->pub.init_source = netcam_init_source;	src->pub.fill_input_buffer = netcam_fill_input_buffer;	src->pub.skip_input_data = netcam_skip_input_data;	src->pub.resync_to_restart = jpeg_resync_to_restart;	src->pub.term_source = netcam_term_source;	src->pub.bytes_in_buffer = 0;	src->pub.next_input_byte = NULL;}/** * netcam_error_exit * * 	Routine to override the libjpeg error exit routine so * 	that we can just throw away the bad frame and continue * 	with more data from the netcam. * * Parameters * * 	cinfo           pointer to the decompression control structure * * Returns:             does an (ugly) longjmp to get back to netcam_jpeg *                      code * */static void netcam_error_exit(j_common_ptr cinfo){	/* fetch our pre-stored pointer to the netcam context */	netcam_context_ptr netcam = cinfo->client_data;	/* output the message associated with the error */	(*cinfo->err->output_message)(cinfo);	/* set flag to show the decompression had errors */	netcam->jpeg_error |= 1;	/* need to "cleanup" the aborted decompression */	jpeg_destroy (cinfo);	/* jump back to wherever we started */	longjmp(netcam->setjmp_buffer, 1);}/** * netcam_output_message * * 	Routine to override the libjpeg error message output routine. * 	We do this so that we can output our module and thread i.d., * 	as well as put the message to the motion log. * * Parameters * * 	cinfo           pointer to the decompression control structure * * Returns              Nothing * */static void netcam_output_message(j_common_ptr cinfo){	char buffer[JMSG_LENGTH_MAX];		/* fetch our pre-stored pointer to the netcam context */	netcam_context_ptr netcam = cinfo->client_data;	/*	 * While experimenting with a "appro" netcam it was discovered	 * that the jpeg data produced by the camera caused warning	 * messages from libjpeg (JWRN_EXTRANEOUS_DATA).  The following	 * code is to assure that specific warning is ignored.	 * 	 * NOTE: It's likely that we will discover other error message	 * codes which we want to ignore.  In that case, we should have	 * some sort of table-lookup to decide which messages we really	 * care about.	 */	if (cinfo->err->msg_code != JWRN_EXTRANEOUS_DATA)		netcam->jpeg_error |= 2;    /* Set flag to show problem */	/*	 * We only display and log errors when debug_level	 * is non-zero.  The reasoning here is that these kinds	 * of errors are only produced when the input data is	 * wrong, and that indicates a network problem rather	 * than a problem with the content.	 */	if (debug_level) {		/*		 * Format the message according to library standards.		 * Write it out to the motion log.		 */		(*cinfo->err->format_message)(cinfo, buffer);		motion_log(LOG_ERR, 0, buffer);	}}/** * netcam_init_jpeg * * 	Initialises the JPEG library prior to doing a * 	decompression. * * Parameters: * 	netcam          pointer to netcam_context * 	cinfo           pointer to JPEG decompression context * * Returns:           Error code */static int netcam_init_jpeg(netcam_context_ptr netcam, j_decompress_ptr cinfo){	netcam_buff_ptr buff;	/*	 * First we check whether a new image has arrived.  If not, we	 * setup to wait for 1/2 a frame time.  This will (hopefully)	 * help in synchronizing the camera frames with the motion main	 * loop.	 */	pthread_mutex_lock(&netcam->mutex);	if (netcam->imgcnt_last == netcam->imgcnt) {    /* need to wait */		struct timespec waittime;		struct timeval curtime;		int retcode;			/*		 * We calculate the delay time (representing the desired frame		 * rate).  This delay time is in *nanoseconds*.		 * We will wait 0.5 seconds which gives a practical minimum		 * framerate of 2 which is desired for the motion_loop to		 * function.		 */		gettimeofday(&curtime, NULL);		curtime.tv_usec += 500000;		if (curtime.tv_usec > 1000000) {			curtime.tv_usec -= 1000000;			curtime.tv_sec++;		}				waittime.tv_sec = curtime.tv_sec;		waittime.tv_nsec = 1000L * curtime.tv_usec;				do {			retcode = pthread_cond_timedwait(&netcam->pic_ready,		                  &netcam->mutex, &waittime);		} while (retcode == EINTR);				if (retcode) {    /* we assume a non-zero reply is ETIMEOUT */			pthread_mutex_unlock(&netcam->mutex);						if (debug_level > 3)				motion_log(-1,0,"no new pic, no signal rcvd");							return NETCAM_GENERAL_ERROR | NETCAM_NOTHING_NEW_ERROR;		}				if (debug_level > 3)			motion_log(-1, 0, "***new pic delay successful***");	}		netcam->imgcnt_last = netcam->imgcnt;	/* set latest buffer as "current" */	buff = netcam->latest;	netcam->latest = netcam->jpegbuf;	netcam->jpegbuf = buff;	pthread_mutex_unlock(&netcam->mutex);	/* clear any error flag from previous work */	netcam->jpeg_error = 0;		buff = netcam->jpegbuf;	/* prepare for the decompression */	/* Initialize the JPEG decompression object */	jpeg_create_decompress(cinfo);	/* Set up own error exit routine */	cinfo->err = jpeg_std_error(&netcam->jerr);	cinfo->client_data = netcam;	netcam->jerr.error_exit = netcam_error_exit;	netcam->jerr.output_message = netcam_output_message;	/* Specify the data source as our own routine */	netcam_memory_src(cinfo, buff->ptr, buff->used);	/* Read file parameters (rejecting tables-only) */	jpeg_read_header(cinfo, TRUE);	/* Override the desired colour space */	cinfo->out_color_space = JCS_YCbCr;	/* Start the decompressor */	jpeg_start_decompress(cinfo);	return netcam->jpeg_error;}static int netcam_image_conv(netcam_context_ptr netcam,                               struct jpeg_decompress_struct *cinfo,                               unsigned char *image){	JSAMPARRAY      line;           /* array of decomp data lines */	unsigned char  *wline;          /* will point to line[0] *//* Working variables */	int             linesize, i;	unsigned char  *upic, *vpic;	unsigned char  *pic = image;	unsigned char   y;              /* switch for decoding YUV data */	unsigned int    width, height;	width = cinfo->output_width;	height = cinfo->output_height;	if (width && ((width != netcam->width) || (height != netcam->height))) {		motion_log(LOG_ERR, 0, 		           "JPEG image size %dx%d, JPEG was %dx%d",		           netcam->width, netcam->height, width, height);		jpeg_destroy_decompress (cinfo);		netcam->jpeg_error |= 4;		return netcam->jpeg_error;	}	/* Set the output pointers (these come from YUV411P definition */	upic = pic + width * height;	vpic = upic + (width * height) / 4;	/* YCbCr format will give us one byte each for YUV */	linesize = cinfo->output_width * 3;	/* Allocate space for one line */	line = (cinfo->mem->alloc_sarray)((j_common_ptr) cinfo, JPOOL_IMAGE,	                                   cinfo->output_width * cinfo->output_components, 1);	wline = line[0];	y = 0;	while (cinfo->output_scanline < height) {		jpeg_read_scanlines (cinfo, line, 1);		for (i = 0; i < linesize; i += 3) {			pic[i / 3] = wline[i];			if (i & 1) {				upic[(i / 3) / 2] = wline[i + 1];				vpic[(i / 3) / 2] = wline[i + 2];			}		}		pic += linesize / 3;		if (y++ & 1) {			upic += width / 2;			vpic += width / 2;		}	}	jpeg_finish_decompress (cinfo);	jpeg_destroy_decompress (cinfo);	if (netcam->cnt->rotate_data.degrees > 0) {		/* rotate as specified */		rotate_map(netcam->cnt, image);	}	return netcam->jpeg_error;}/** * netcam_proc_jpeg * *	Routine to decode an image received from a netcam into a YUV420P buffer *	suitable for processing by motion. * * Parameters: *	netcam    pointer to the netcam_context structure *      image     Pointer to a buffer for the returned image * * Returns:  * *      0         Success *      non-zero  error code from other routines *                (e.g. netcam_init_jpeg or netcam_image_conv) *                or just NETCAM_GENERAL_ERROR */int netcam_proc_jpeg(netcam_context_ptr netcam, unsigned char *image){	struct jpeg_decompress_struct cinfo;    /* decompression control struct */	int retval = 0;                         /* value returned to caller */	int ret;                                /* working var */	/*	 * This routine is only called from the main thread.	 * We need to "protect" the "latest" image while we	 * decompress it.  netcam_init_jpeg uses	 * netcam->mutex to do this;	 */	if (debug_level > 5) {		motion_log(LOG_INFO, 0, "processing jpeg image - content length "				"%d", netcam->latest->content_length);	}		ret = netcam_init_jpeg(netcam, &cinfo);		if (ret != 0)		return ret;	/* Do a sanity check on dimensions	 * If dimensions have changed we throw an	 * error message that will cause	 * restart of Motion	 */	if (netcam->width) {    /* 0 means not yet init'ed */		if ((cinfo.output_width != netcam->width) ||			(cinfo.output_height != netcam->height)) {			motion_log(LOG_ERR, 0,		        	   "Camera width/height mismatch "			           "with JPEG image - expected %dx%d, JPEG %dx%d",			           netcam->width, netcam->height,			           cinfo.output_width, cinfo.output_height);			retval = NETCAM_RESTART_ERROR;		       	return retval;				}	}	/* do the conversion */	ret = netcam_image_conv(netcam, &cinfo, image);		if (ret != 0)		retval |= NETCAM_JPEG_CONV_ERROR;	jpeg_destroy_decompress (&cinfo);	return retval;}/** * netcam_get_dimensions * *	This function gets the height and width of the JPEG image *	located in the supplied netcam_image_buffer * * Parameters * *	netcam     pointer to the netcam context * * Returns:   Nothing, but fills in width and height into context * */void netcam_get_dimensions(netcam_context_ptr netcam){	struct jpeg_decompress_struct cinfo; /* decompression control struct */	netcam_init_jpeg(netcam, &cinfo);	netcam->width = cinfo.output_width;	netcam->height = cinfo.output_height;	jpeg_destroy_decompress(&cinfo);}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
一区二区国产视频| 成人综合激情网| 国产盗摄精品一区二区三区在线 | av不卡一区二区三区| 欧美三日本三级三级在线播放| 久久亚洲二区三区| 五月激情六月综合| 91视视频在线观看入口直接观看www | 日韩高清一级片| 91网站在线观看视频| 久久久综合视频| 美国十次综合导航| 欧美视频中文字幕| 亚洲人快播电影网| 成人免费视频国产在线观看| 日韩欧美视频一区| 亚洲18女电影在线观看| 色婷婷久久久综合中文字幕| 中文字幕精品综合| 国内精品自线一区二区三区视频| 欧美日韩成人在线一区| 亚洲制服丝袜在线| 99久久国产综合精品色伊| 国产欧美日韩中文久久| 国产精品资源网| 久久久噜噜噜久噜久久综合| 免费观看在线综合色| 欧美另类久久久品| 午夜不卡av在线| 欧美日韩国产高清一区二区三区| 亚洲午夜一二三区视频| 在线看国产一区二区| 免费高清视频精品| 日韩欧美一区二区三区在线| 视频一区二区三区入口| 宅男噜噜噜66一区二区66| 视频一区免费在线观看| 欧美一卡2卡3卡4卡| 免费观看91视频大全| 精品久久99ma| 国产一区 二区 三区一级| 亚洲精品一区二区在线观看| 激情五月播播久久久精品| 久久天天做天天爱综合色| 国产成人在线视频免费播放| 国产精品少妇自拍| 色婷婷综合久久久中文字幕| 亚洲超碰97人人做人人爱| 欧美美女网站色| 久久99久久精品| 欧美国产综合色视频| 99国产精品国产精品久久| 亚洲激情图片小说视频| 911精品产国品一二三产区| 韩国女主播成人在线观看| 国产精品妹子av| 欧美精品黑人性xxxx| 久久爱www久久做| 中文字幕亚洲不卡| 欧美一区二视频| 国产suv精品一区二区三区| 成人免费一区二区三区视频 | 一区二区三区欧美| 5566中文字幕一区二区电影| 久久se精品一区二区| 国产精品理伦片| 在线电影院国产精品| 狠狠色丁香久久婷婷综合_中| 亚洲国产成人午夜在线一区| 精品视频免费在线| 国产精品主播直播| 亚洲第四色夜色| 国产欧美va欧美不卡在线| 欧美日韩国产a| 成人妖精视频yjsp地址| 亚洲电影一级片| 国产精品日韩精品欧美在线| 欧美日韩电影一区| 波多野结衣亚洲| 精品一区二区三区在线视频| 亚洲免费av网站| 国产午夜精品美女毛片视频| 欧美视频中文一区二区三区在线观看| 国产真实乱对白精彩久久| 亚洲一区二区av电影| 国产日韩欧美一区二区三区乱码| 欧美日韩免费观看一区三区| 成人激情开心网| 国内精品国产成人国产三级粉色| 亚洲一二三级电影| 中文字幕日韩精品一区| 久久久久国产精品麻豆ai换脸| 91超碰这里只有精品国产| 91麻豆免费视频| 在线播放欧美女士性生活| 成人综合婷婷国产精品久久蜜臀 | 国产一区二区三区免费看| 婷婷开心激情综合| 亚洲精品国产一区二区精华液 | 制服丝袜在线91| 在线观看区一区二| 不卡av在线网| 成人亚洲一区二区一| 国产精品一线二线三线| 韩国中文字幕2020精品| 日本视频在线一区| 日韩二区在线观看| 亚洲成人久久影院| 亚洲一区二区三区视频在线| 一区二区在线免费观看| 亚洲免费观看高清在线观看| 亚洲素人一区二区| 中文字幕在线播放不卡一区| 国产精品久久久久久久久久免费看 | 91福利小视频| 色综合久久久久| 色综合久久天天| 91在线porny国产在线看| 不卡区在线中文字幕| av电影在线不卡| 91在线观看视频| 在线影视一区二区三区| 欧美在线视频全部完| 欧美体内she精高潮| 欧美日韩的一区二区| 欧美一区二区三区四区久久| 日韩精品综合一本久道在线视频| 精品久久久影院| 久久久不卡网国产精品一区| 国产日产欧美一区| 亚洲欧美日韩国产综合在线| 亚洲成av人片在线观看无码| 日韩激情视频在线观看| 麻豆精品蜜桃视频网站| 国产一区日韩二区欧美三区| 成人国产精品视频| 欧美日韩在线播放| 日韩免费看的电影| 国产嫩草影院久久久久| 怡红院av一区二区三区| 日韩二区三区四区| 国产精品一区不卡| 在线一区二区三区四区| 日韩欧美专区在线| 国产精品大尺度| 日韩成人午夜精品| 国产成人高清在线| 欧美色欧美亚洲另类二区| 日韩免费看的电影| 国产精品久99| 久久精品72免费观看| av激情成人网| 91精品国产欧美日韩| 欧美国产欧美亚州国产日韩mv天天看完整| 成人欧美一区二区三区视频网页 | 蜜桃视频在线观看一区| 成人午夜视频免费看| 51精品久久久久久久蜜臀| 国产精品美女视频| 日韩精品久久久久久| 成人看片黄a免费看在线| 欧美剧情片在线观看| 中文字幕五月欧美| 九九**精品视频免费播放| 91黄色小视频| 欧美激情一区二区三区在线| 婷婷久久综合九色综合绿巨人 | 久久国产尿小便嘘嘘| 91啦中文在线观看| 久久久综合视频| 奇米影视在线99精品| 在线观看亚洲精品视频| 国产欧美精品一区二区色综合| 日韩国产欧美在线视频| 色综合中文字幕国产 | 在线观看成人小视频| 国产日韩精品久久久| 狂野欧美性猛交blacked| 欧美在线三级电影| 国产精品国产三级国产普通话99| 老司机精品视频一区二区三区| 色婷婷国产精品久久包臀| 国产日韩欧美激情| 激情综合亚洲精品| 欧美高清视频不卡网| 亚洲欧洲中文日韩久久av乱码| 国产乱码精品一区二区三 | 91久久人澡人人添人人爽欧美| 久久精品夜夜夜夜久久| 美腿丝袜亚洲色图| 欧美老年两性高潮| 亚洲午夜精品网| 欧美婷婷六月丁香综合色| 一区二区三区在线视频免费观看| 99久久婷婷国产综合精品电影 | 日韩一区二区在线免费观看| 亚洲国产欧美在线| 欧美最猛黑人xxxxx猛交| 艳妇臀荡乳欲伦亚洲一区| 91麻豆免费看片|