⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 frameextractor.c

📁 SAMSUNG S3C6410 CPU BSP for winmobile6
💻 C
📖 第 1 页 / 共 2 页
字号:
			}

			if (pCTX->delim_insert) {
				memcpy(outbuf, pCTX->delim_ptr, pCTX->delim_leng);
				outbuf += pCTX->delim_leng;
				nbytes_to_write -= pCTX->delim_leng;	// 啊瓷茄 农扁甫 delimiter 辨捞父怒 哗具窃
				*n_fill = pCTX->delim_leng;
			}
			else
				*n_fill = 0;
		}
		else {
			// continue肺 甸绢柯 版快绰 (pCTX->cont_offset != 0)
			offset = pCTX->cont_offset;
			outbuf += (pCTX->cont_offset - pCTX->delim_leng);

			for (l=0; l<pCTX->delim_leng; l++) {
				Q_PUSH(*outbuf, queue, qp_s, qp_e, q_size, QUEUE_CAPACITY)
				outbuf++;
			}

		}
	}

	for (l=0; l<pCTX->delim_leng; l++) {
		if (q_size == 0 || l == q_size) {

			if (outbuf != NULL && offset >= nbytes_to_write) {
				if (pCTX->cont_offset == 0)
					pCTX->cont_offset = (pCTX->delim_leng + offset);
				else
					pCTX->cont_offset = offset;
				return FRAMEX_CONTINUE;
			}

			if ((int) strm_ptr->p_cur > (int) strm_ptr->p_end)
				break;
			b = *(strm_ptr->p_cur); strm_ptr->p_cur++; r = 1;
			offset++;
			if (outbuf != NULL) {
				*outbuf = b; outbuf++; (*n_fill)++;
			}
		}
		else {
			r = -1;
			Q_PEEK(b, queue, qp_s, qp_e + l)
		}


		if (b == pCTX->delim_ptr[l]) {
			if (r == 1)	// 货肺 佬篮 版快俊父 PUSH茄促.
				Q_PUSH(b, queue, qp_s, qp_e, q_size, QUEUE_CAPACITY)
		}
		else {
			if (r != 1)
				// 货肺 佬篮 版快啊 酒聪扼搁, 窍唱 哗滚赴促.
				Q_POP(c, queue, qp_s, qp_e, q_size, QUEUE_CAPACITY)
			else if (l > 0) {
				// 货肺 佬篮 版快 吝俊辑, delimiter狼 霉 octet(l=0)阑 厚背窍绰 版快绰
				// QUEUE俊 持瘤 臼绊 官肺 逞绢埃促.
				// 2锅掳 octet捞惑(l>0)阑 厚背窍绰 版快绰,
				// 盖 菊俊 窍唱甫 哗绊 盖 第俊 货肺 窍唱甫 持绰促.

				Q_POP(c, queue, qp_s, qp_e, q_size, QUEUE_CAPACITY)
				Q_PUSH(b, queue, qp_s, qp_e, q_size, QUEUE_CAPACITY)
			}

			l = -1;
		}

	}

	if (r == 1) {
		if (outbuf != NULL) {
			*n_fill -= pCTX->delim_leng;
			pCTX->cont_offset = 0;
		}

		return FRAMEX_OK;
	}
	else if (r == 0)
		return FRAMEX_ERR_EOS;

	return FRAMEX_ERR_NOTFOUND;
}


// 促澜狼 frame俊辑 盔窍绰 荐狼 octets 蔼阑 犬牢父 茄促.
static int next_frame_peek_mem(FRAMEX_CTX *pCTX, MMAP_STRM_PTR *strm_ptr, unsigned char *peekbuf, const int peek_size, int *n_fill)
{
	int r;
	int l;
	int nbytes_to_peek;
	int qp_s, qp_e, q_size;
	unsigned char queue[QUEUE_CAPACITY], b, c;

	int offset;

	offset = 0;
	nbytes_to_peek = peek_size;
	Q_INIT(queue, qp_s, qp_e, q_size, QUEUE_CAPACITY)

	// 府畔且 outbuf 滚欺狼 盖 菊俊 delimiter甫 盲况持绰促.
	if (peekbuf != NULL) {
		if (pCTX->cont_offset == 0) {
			if (nbytes_to_peek <= pCTX->delim_leng) {
				return FRAMEX_ERR_BUFSIZE_TOO_SMALL;
			}

			if (pCTX->delim_insert) {
				memcpy(peekbuf, pCTX->delim_ptr, pCTX->delim_leng);
				peekbuf += pCTX->delim_leng;
				nbytes_to_peek -= pCTX->delim_leng;	// 啊瓷茄 农扁甫 delimiter 辨捞父怒 哗具窃
				*n_fill = pCTX->delim_leng;
			}
			else
				*n_fill = 0;
		}
		else {
			// continue肺 甸绢柯 版快绰 ERROR促.

		}
	}

	for (l=0; l<pCTX->delim_leng; l++) {
		if (q_size == 0 || l == q_size) {

			if ((int) strm_ptr->p_cur > (int) strm_ptr->p_end)
				break;
			b = *(strm_ptr->p_cur); strm_ptr->p_cur++; r = 1;
			offset++;
			if (peekbuf != NULL) {
				*peekbuf = b; peekbuf++; (*n_fill)++;
			}

			// fread 俺荐啊 peek_size啊 登搁, 呕免茄促.
			if (offset >= nbytes_to_peek)
				break;
		}
		else {
			r = -1;
			Q_PEEK(b, queue, qp_s, qp_e + l)
		}


		if (b == pCTX->delim_ptr[l]) {
			if (r == 1)	// 货肺 佬篮 版快俊父 PUSH茄促.
				Q_PUSH(b, queue, qp_s, qp_e, q_size, QUEUE_CAPACITY)
		}
		else {
			if (r != 1)
				// 货肺 佬篮 版快啊 酒聪扼搁, 窍唱 哗滚赴促.
				Q_POP(c, queue, qp_s, qp_e, q_size, QUEUE_CAPACITY)
			else if (l > 0) {
				// 货肺 佬篮 版快 吝俊辑, delimiter狼 霉 octet(l=0)阑 厚背窍绰 版快绰
				// QUEUE俊 持瘤 臼绊 官肺 逞绢埃促.
				// 2锅掳 octet捞惑(l>0)阑 厚背窍绰 版快绰,
				// 盖 菊俊 窍唱甫 哗绊 盖 第俊 货肺 窍唱甫 持绰促.

				Q_POP(c, queue, qp_s, qp_e, q_size, QUEUE_CAPACITY)
				Q_PUSH(b, queue, qp_s, qp_e, q_size, QUEUE_CAPACITY)
			}

			l = -1;
		}

	}

	if (r == 1) {
		if (peekbuf != NULL) {
			*n_fill -= pCTX->delim_leng;
			pCTX->cont_offset = 0;
		}

//		fseek(fpin, -(peek_size-pCTX->delim_leng), SEEK_CUR);
		strm_ptr->p_cur = (strm_ptr->p_cur  -  (peek_size-pCTX->delim_leng));

		return FRAMEX_OK;
	}
	else if (r == 0)
		return FRAMEX_ERR_EOS;

	return FRAMEX_ERR_NOTFOUND;
}


//
// int FrameExtractorFirst(FRAMEX_CTX *pCTX, FILE *fpin)
//
// Description
//		力老 贸澜狼 delimiter啊 唱坷绰 巴阑 茫绰促.
// Return
//
// Parameters
//
int FrameExtractorFirst(FRAMEX_CTX *pCTX, FRAMEX_IN in)
{
	if (pCTX == NULL)
		return -1;

	if (pCTX->in_type == FRAMEX_IN_TYPE_FILE)
		return next_delimiter(pCTX, (FILE *) in, NULL, 0, NULL);
	else
		return next_delimiter_mem(pCTX, (MMAP_STRM_PTR *) in, NULL, 0, NULL);
}

//
// int FrameExtractorNext(FRAMEX_CTX *pCTX, FILE *fpin, unsigned char outbuf[], int outbuf_size, int *n_fill)
//
// Description
//		FrameExtractorFirst() 窃荐甫 龋免窍咯 霉 frame狼 delimiter甫 茫篮 饶何磐 龋免茄促.
//		促澜 frame狼 delimiter啊 唱棵锭鳖瘤狼 frame阑 眠免窍咯, outbuf俊 汗荤茄促.
// Return
//
// Parameters
//		outbuf     [OUT]: pointer to the array that will be filled with the frame data
//		outbuf_size[IN] : length of the outbuf size
//		n_fill     [OUT]: number of octets filled in the out_buf
//
int FrameExtractorNext(FRAMEX_CTX *pCTX, FRAMEX_IN in, unsigned char outbuf[], int outbuf_size, int *n_fill)
{
	if (pCTX == NULL)
		return -1;

	if (pCTX->in_type == FRAMEX_IN_TYPE_FILE)
		return next_delimiter(pCTX, (FILE *) in, outbuf, outbuf_size, n_fill);
	else
		return next_delimiter_mem(pCTX, (MMAP_STRM_PTR *) in, outbuf, outbuf_size, n_fill);
}


//
// int FrameExtractorPeek(FRAMEX_CTX *pCTX, FILE *fpin, unsigned char peekbuf[], int peek_size, int *n_fill)
//
// Description
//		FrameExtractorFirst() 窃荐甫 龋免窍咯 霉 frame狼 delimiter甫 茫篮 饶何磐 龋免茄促.
//		促澜 frame狼 蔼阑 peek_size父怒 peekbuf俊 汗荤茄促.
//		捞 锭, Buffer甫 PEEK父 窍绰 巴捞骨肺, frame阑 眠免窍绰 巴篮 酒聪促.
// Return
//
// Parameters
//		peekbuf    [OUT]: pointer to the array that will be filled with the frame data
//		peek_size  [IN] : length of the outbuf size
//		n_fill     [OUT]: number of octets filled in the out_buf
//

int FrameExtractorPeek(FRAMEX_CTX *pCTX, FRAMEX_IN in, unsigned char peekbuf[], int peek_size, int *n_fill)
{
	if (pCTX == NULL)
		return -1;

	if (pCTX->in_type == FRAMEX_IN_TYPE_FILE)
		return next_frame_peek(pCTX, (FILE *) in, peekbuf, peek_size, n_fill);
	else
		return next_frame_peek_mem(pCTX, (MMAP_STRM_PTR *) in, peekbuf, peek_size, n_fill);
}
/*
int FrameExtractorPeek(FRAMEX_CTX *pCTX, FRAMEX_IN in, unsigned char peekbuf[], int peek_size, int *n_fill)
{
	FRAMEX_STRM_PTR    *strm_ptr;


	if (pCTX->in_type == FRAMEX_IN_TYPE_FILE) {
		*n_fill = fread(peekbuf, 1, peek_size, (FILE *) in);
		if (*n_fill > 0) {
			fseek((FILE *) in, -peek_size, SEEK_CUR);
			return FRAMEX_OK;
		}
		return FRAMEX_ERR_EOS;
	}
	else {
		strm_ptr = (FRAMEX_STRM_PTR *) in;

		if ((int) (strm_ptr->p_cur + peek_size) > (int) strm_ptr->p_end)
			peek_size = (int) strm_ptr->p_end - (int) strm_ptr->p_cur;

		memcpy(peekbuf, strm_ptr->p_cur, peek_size);
		*n_fill = peek_size;

		return FRAMEX_OK;
	}

}
*/

//
// int FrameExtractorFinal(FRAMEX_CTX *pCTX)
//
// Description
//		FRAMEX_CTX 备炼眉 单捞磐甫 秦力茄促.
// Return
//
// Parameters
//
int FrameExtractorFinal(FRAMEX_CTX *pCTX)
{
	if (pCTX == NULL)
		return 0;

	free(pCTX->delim_ptr);
	free(pCTX);

	return 0;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -