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

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

?? encoder-h261.cpp

?? 完整的RTP RTSP代碼庫
?? CPP
?? 第 1 頁 / 共 2 頁
字號:
/* * encoder-h261.cc -- * *      H.261 video encoder * * Copyright (c) 1994-2002 The Regents of the University of California. * All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions are met: * * A. Redistributions of source code must retain the above copyright notice, *    this list of conditions and the following disclaimer. * B. Redistributions in binary form must reproduce the above copyright notice, *    this list of conditions and the following disclaimer in the documentation *    and/or other materials provided with the distribution. * C. Neither the names of the copyright holders nor the names of its *    contributors may be used to endorse or promote products derived from this *    software without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS ``AS * IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * POSSIBILITY OF SUCH DAMAGE. * * modifications done 3/2003, wmay@cisco.com */#include "mpeg4ip.h"#include "dct.h"#include "p64-huff.h"#include "crdef.h"#include "util.h"#include "encoder-h261.h"#include "mp4live_config.h"#include "video_util_resize.h"static config_index_t CFG_VIDEO_H261_QUALITY;static config_index_t CFG_VIDEO_H261_QUALITY_ADJ_FRAMES;static SConfigVariable H261ConfigVariables[] = {  CONFIG_INT(CFG_VIDEO_H261_QUALITY, "videoH261Quality", 10),  CONFIG_INT(CFG_VIDEO_H261_QUALITY_ADJ_FRAMES, "videoH261QualityAdjFrames", 8),};GUI_INT_RANGE(gui_q, CFG_VIDEO_H261_QUALITY, "H.261 Quality", 1, 32);GUI_INT_RANGE(gui_qf, CFG_VIDEO_H261_QUALITY_ADJ_FRAMES, "Frames before Adjusting Quality", 1, 100);DECLARE_TABLE(h261_gui_options) = {  TABLE_GUI(gui_q),  TABLE_GUI(gui_qf),};DECLARE_TABLE_FUNC(h261_gui_options);void AddH261ConfigVariables (CVideoProfile *pConfig){  pConfig->AddConfigVariables(H261ConfigVariables, 			      NUM_ELEMENTS_IN_ARRAY(H261ConfigVariables));}//#define DEBUG_QUALITY_ADJUSTMENT 1#define HLEN (4)#define	CIF_WIDTH	352#define	CIF_HEIGHT	288#define	QCIF_WIDTH	176#define	QCIF_HEIGHT	144#define	BMB		6	/* # blocks in a MB */#define MBPERGOB	33	/* # of Macroblocks per GOB */#if BYTE_ORDER == LITTLE_ENDIAN#if NBIT == 64#define STORE_BITS(bb, bc) \	bc[0] = bb >> 56; \	bc[1] = bb >> 48; \	bc[2] = bb >> 40; \	bc[3] = bb >> 32; \	bc[4] = bb >> 24; \	bc[5] = bb >> 16; \	bc[6] = bb >> 8; \	bc[7] = bb;#define LOAD_BITS(bc) \	((BB_INT)bc[0] << 56 | \	 (BB_INT)bc[1] << 48 | \	 (BB_INT)bc[2] << 40 | \	 (BB_INT)bc[3] << 32 | \	 (BB_INT)bc[4] << 24 | \	 (BB_INT)bc[5] << 16 | \	 (BB_INT)bc[6] << 8 | \	 (BB_INT)bc[7])#else#define STORE_BITS(bb, bc) \	bc[0] = bb >> 24; \	bc[1] = bb >> 16; \	bc[2] = bb >> 8; \	bc[3] = bb;#define LOAD_BITS(bc) (ntohl(*(BB_INT*)(bc)))#endif#else#define STORE_BITS(bb, bc) *(BB_INT*)bc = (bb);#define LOAD_BITS(bc) (*(BB_INT*)(bc))#endif#define PUT_BITS(bits, n, nbb, bb, bc) \{ \	nbb += (n); \	if (nbb > NBIT)  { \		u_int extra = (nbb) - NBIT; \		bb |= (BB_INT)(bits) >> extra; \		STORE_BITS(bb, bc) \		bc += sizeof(BB_INT); \		bb = (BB_INT)(bits) << (NBIT - extra); \		nbb = extra; \	} else \		bb |= (BB_INT)(bits) << (NBIT - (nbb)); \}CH261Encoder::CH261Encoder(CVideoProfile *vp,			   uint16_t mtu,			   CVideoEncoder *next, 			   bool realTime) :  CVideoEncoder(vp, mtu, next, realTime), m_encoded_frame_buffer(0), m_pBufferCurrent(0), ngob_(12){  m_head = NULL;  frame_data_ = NULL;  m_framesEncoded = 0;  m_localbuffer = NULL;	for (int q = 0; q < 32; ++q) {		llm_[q] = 0;		clm_[q] = 0;	}}void CH261Encoder::StopEncoder (void){	for (int q = 0; q < 32; ++q) {		if (llm_[q] != 0) delete[] llm_[q];		if (clm_[q] != 0) delete[] clm_[q];	}	CHECK_AND_FREE(m_localbuffer);}CH261PixelEncoder::CH261PixelEncoder(CVideoProfile *vp,				     uint16_t mtu,				     CVideoEncoder *next,				     bool realTime) :   CH261Encoder(vp, mtu, next, realTime),   ConditionalReplenisher(){	quant_required_ = 0;	setq(10);	m_started = false;}/* * Set up the forward DCT quantization table for * INTRA mode operation. */voidCH261Encoder::setquantizers(int lq, int mq, int hq){	int qt[64];	if (lq > 31)		lq = 31;	if (lq <= 0)		lq = 1;	lq_ = lq;	if (mq > 31)		mq = 31;	if (mq <= 0)		mq = 1;	mq_ = mq;	if (hq > 31)		hq = 31;	if (hq <= 0)		hq = 1;	hq_ = hq;	/*	 * quant_required_ indicates quantization is not folded	 * into fdct [because fdct is not performed]	 */	if (quant_required_ == 0) {		/*		 * Set the DC quantizer to 1, since we want to do this		 * coefficient differently (i.e., the DC is rounded while		 * the AC terms are truncated).		 */		qt[0] = 1;		int i;		for (i = 1; i < 64; ++i)			qt[i] = lq_ << 1;		dct_fdct_fold_q(qt, lqt_);		qt[0] = 1;		for (i = 1; i < 64; ++i)			qt[i] = mq_ << 1;		dct_fdct_fold_q(qt, mqt_);		qt[0] = 1;		for (i = 1; i < 64; ++i)			qt[i] = hq_ << 1;		dct_fdct_fold_q(qt, hqt_);	}}voidCH261Encoder::setq(int q){	setquantizers(q, q / 2, 1);}voidCH261PixelEncoder::size(int w, int h){  // next 3 lines is FrameModule::size(w, h);		width_ = w;		height_ = h;		framesize_ = w * h;	if (w == CIF_WIDTH && h == CIF_HEIGHT) {		/* CIF */		cif_ = 1;		ngob_ = 12;		bstride_ = 11;		lstride_ = 16 * CIF_WIDTH - CIF_WIDTH / 2;		cstride_ = 8 * 176 - 176 / 2;		loffsize_ = 16;		coffsize_ = 8;		bloffsize_ = 1;	} else if (w == QCIF_WIDTH && h == QCIF_HEIGHT) {		/* QCIF */		cif_ = 0;		ngob_ = 6; /* not really number of GOBs, just loop limit */		bstride_ = 0;		lstride_ = 16 * QCIF_WIDTH - QCIF_WIDTH;		cstride_ = 8 * 88 - 88;		loffsize_ = 16;		coffsize_ = 8;		bloffsize_ = 1;	} else {		/*FIXME*/		fprintf(stderr, "CH261PixelEncoder: H.261 bad geometry: %dx%d\n",			w, h);		exit(1);	}	u_int loff = 0;	u_int coff = 0;	u_int blkno = 0;	for (u_int gob = 0; gob < ngob_; gob += 2) {		loff_[gob] = loff;		coff_[gob] = coff;		blkno_[gob] = blkno;		/* width of a GOB (these aren't ref'd in QCIF case) */		loff_[gob + 1] = loff + 11 * 16;		coff_[gob + 1] = coff + 11 * 8;		blkno_[gob + 1] = blkno + 11;		/* advance to next GOB row */		loff += (16 * 16 * MBPERGOB) << cif_;		coff += (8 * 8 * MBPERGOB) << cif_;		blkno += MBPERGOB << cif_;	}}/* * Make a map to go from a 12 bit dct value to an 8 bit quantized * 'level' number.  The 'map' includes both the quantizer (for the * dct encoder) and the perceptual filter 'threshold' (for both * the pixel & dct encoders).  The first 4k of the map is for the * unfiltered coeff (the first 20 in zigzag order; roughly the * upper left quadrant) and the next 4k of the map are for the * filtered coef. */char*CH261Encoder::make_level_map(int q, u_int fthresh){	/* make the luminance map */	char* lm = new char[0x2000];	char* flm = lm + 0x1000;	int i;	lm[0] = 0;	flm[0] = 0;	q = quant_required_? q << 1 : 0;	for (i = 1; i < 0x800; ++i) {		int l = i;		if (q)			l /= q;		lm[i] = l;		lm[-i & 0xfff] = -l;		if ((u_int)l <= fthresh)			l = 0;		flm[i] = l;		flm[-i & 0xfff] = -l;	}	return (lm);}/* * encode_blk: *	encode a block of DCT coef's */voidCH261Encoder::encode_blk(const short* blk, const char* lm){	BB_INT bb = m_bitCache;	u_int nbb = m_bitsInCache;	uint8_t * bc = m_pBufferCurrent;	/*	 * Quantize DC.  Round instead of truncate.	 */	int dc = (blk[0] + 4) >> 3;	if (dc <= 0)		/* shouldn't happen with CCIR 601 black (level 16) */		dc = 1;	else if (dc > 254)		dc = 254;	else if (dc == 128)		/* per Table 6/H.261 */		dc = 255;	/* Code DC */	PUT_BITS(dc, 8, nbb, bb, bc);	int run = 0;	const u_char* colzag = &DCT_COLZAG[0];	for (int zag; (zag = *++colzag) != 0; ) {		if (colzag == &DCT_COLZAG[20])			lm += 0x1000;		int level = lm[((const u_short*)blk)[zag] & 0xfff];		if (level != 0) {			int val, nb;			huffent* he;			if (u_int(level + 15) <= 30 &&			    (nb = (he = &hte_tc[((level&0x1f) << 6)|run])->nb))				/* we can use a VLC. */				val = he->val;			else {				 /* Can't use a VLC.  Escape it. */				val = (1 << 14) | (run << 8) | (level & 0xff);				nb = 20;			}			PUT_BITS(val, nb, nbb, bb, bc);			run = 0;		} else			++run;	}	/* EOB */	PUT_BITS(2, 2, nbb, bb, bc);	m_bitCache = bb;	m_bitsInCache = nbb;	m_pBufferCurrent = bc;}/* * CH261PixelEncoder::encode_mb *	encode a macroblock given a set of input YUV pixels */voidCH261PixelEncoder::encode_mb(u_int mba, const u_char* frm,			    u_int loff, u_int coff, int how){	register int q;	float* qt;	if (how == CR_LQ) {		q = lq_;		qt = lqt_;	} else if (how == CR_HQ) {		q = hq_;		qt = hqt_;	} else {		/* must be medium quality */		q = mq_;		qt = mqt_;	}	/*	 * encode all 6 blocks of the macro block to find the largest	 * coef (so we can pick a new quantizer if gquant doesn't have	 * enough range).	 */	/*FIXME this can be u_char instead of short but need smarts in fdct */	short blk[64 * 6];	register int stride = width_;	/* luminance */	const u_char* p = &frm[loff];	dct_fdct(p, stride, blk + 0, qt);	dct_fdct(p + 8, stride, blk + 64, qt);	dct_fdct(p + 8 * stride, stride, blk + 128, qt);	dct_fdct(p + (8 * stride + 8), stride, blk + 192, qt);	/* chominance */	int fs = framesize_;	p = &frm[fs + coff];	stride >>= 1;	dct_fdct(p, stride, blk + 256, qt);	dct_fdct(p + (fs >> 2), stride, blk + 320, qt);	/*	 * if the default quantizer is too small to handle the coef.	 * dynamic range, spin through the blocks and see if any	 * coef. would significantly overflow.	 */	if (q < 8) {		register int cmin = 0, cmax = 0;		register short* bp = blk;		for (register int i = 6; --i >= 0; ) {			++bp;	// ignore dc coef			for (register int j = 63; --j >= 0; ) {				register int v = *bp++;				if (v < cmin)					cmin = v;				else if (v > cmax)					cmax = v;			}		}		if (cmax < -cmin)			cmax = -cmin;		if (cmax >= 128) {			/* need to re-quantize */			register int s;			for (s = 1; cmax >= (128 << s); ++s) {			}			q <<= s;			if (q > 31) q = 31;			if (q < 1) q = 1;			register short* bp = blk;			for (register int i = 6; --i >= 0; ) {				++bp;	// ignore dc coef				for (register int j = 63; --j >= 0; ) {					register int v = *bp;					*bp++ = v >> s;				}			}		}	}	u_int m = mba - mba_;	mba_ = mba;	huffent* he = &hte_mba[m - 1];	/* MBA */	PUT_BITS(he->val, he->nb, m_bitsInCache, m_bitCache, m_pBufferCurrent);	if (q != mquant_) {		/* MTYPE = INTRA + TC + MQUANT */		PUT_BITS(1, 7, m_bitsInCache, m_bitCache, m_pBufferCurrent);		PUT_BITS(q, 5, m_bitsInCache, m_bitCache, m_pBufferCurrent);		mquant_ = q;	} else {		/* MTYPE = INTRA + TC (no quantizer) */		PUT_BITS(1, 4, m_bitsInCache, m_bitCache, m_pBufferCurrent);	}	/* luminance */	/*const*/ char* lm = llm_[q];	if (lm == 0) {		lm = make_level_map(q, 1);		llm_[q] = lm;		clm_[q] = make_level_map(q, 2);	}	encode_blk(blk + 0, lm);	encode_blk(blk + 64, lm);	encode_blk(blk + 128, lm);	encode_blk(blk + 192, lm);	/* chominance */	lm = clm_[q];	encode_blk(blk + 256, lm);	encode_blk(blk + 320, lm);}intCH261Encoder::flush(pktbuf_t* pb, int last_mb_start_bits, pktbuf_t* pNewBuffer){	/* flush bit buffer */	STORE_BITS(m_bitCache, m_pBufferCurrent);	int cc = (last_mb_start_bits + 7) >> 3;	int ebit = (cc << 3) - last_mb_start_bits;	/*FIXME*/	if (cc == 0 && pNewBuffer != 0)		abort();	pb->len = cc;#if 0	rtphdr* rh = (rtphdr*)pb->data;	if (pNewBuffer == 0)		rh->rh_flags |= htons(RTP_M);#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
欧美日韩第一区日日骚| 亚洲一卡二卡三卡四卡| 美女视频黄免费的久久| 911精品国产一区二区在线| 久久麻豆一区二区| 秋霞电影网一区二区| 日韩片之四级片| 国产福利一区二区| 国产精品久久久久久久久快鸭 | 亚洲va在线va天堂| 欧美精品自拍偷拍| 激情综合色综合久久综合| 国产欧美日韩在线观看| 91亚洲精品久久久蜜桃网站| 亚洲国产欧美另类丝袜| 欧美成人精品二区三区99精品| 国产高清在线观看免费不卡| 综合久久综合久久| 欧美喷水一区二区| 国产精品18久久久久久vr| 中文字幕在线观看不卡| 欧美精品欧美精品系列| 国产精品1024| 婷婷亚洲久悠悠色悠在线播放| 精品国产污污免费网站入口| 一本久久精品一区二区| 日本 国产 欧美色综合| 中文字幕日韩一区| 日韩久久精品一区| 99久久精品免费| 蜜臀av在线播放一区二区三区| 国产精品妹子av| 日韩一级片网站| 色综合网站在线| 国产剧情在线观看一区二区| 亚洲一区二区av在线| 国产色产综合产在线视频| 欧美图片一区二区三区| 国产原创一区二区| 性做久久久久久| 国产精品伦理一区二区| 日韩一区二区三区免费看| 91视视频在线观看入口直接观看www| 欧美aⅴ一区二区三区视频| 亚洲国产岛国毛片在线| 欧美一二区视频| 欧美性xxxxx极品少妇| 国产69精品久久777的优势| 日韩电影在线免费观看| 亚洲色图欧洲色图| 日本一区二区三区四区| 日韩欧美精品在线| 欧美精品日韩综合在线| 色综合久久99| 成+人+亚洲+综合天堂| 久久不见久久见免费视频7| 亚洲成人免费在线观看| 亚洲视频一二三| 国产精品入口麻豆原神| 久久久激情视频| 久久亚洲捆绑美女| 日韩一区二区三区免费看 | 97精品电影院| 国产麻豆视频一区二区| 免费成人深夜小野草| 亚洲国产精品久久人人爱蜜臀| 亚洲色图欧洲色图| 亚洲三级在线观看| 亚洲视频香蕉人妖| 亚洲免费av高清| 最新日韩av在线| 天天色综合成人网| 亚洲色图自拍偷拍美腿丝袜制服诱惑麻豆| 久久久国产精华| 久久久久久久久久久黄色| 亚洲精品一区二区三区福利| 精品三级av在线| 日韩精品一区二区三区视频| 精品国产一区二区三区不卡| 欧美电影免费提供在线观看| 日韩精品一区二区三区蜜臀| 精品国产一区二区三区久久影院 | 国产美女一区二区| 国产一区激情在线| 国产精品夜夜爽| 成人中文字幕电影| 99r精品视频| 欧美中文字幕久久 | 这里只有精品免费| 日韩精品一区二区三区四区视频| 欧美一级黄色录像| 国产欧美综合色| 中文字幕综合网| 亚洲aⅴ怡春院| 久久精品二区亚洲w码| 国产一区在线精品| 99在线热播精品免费| 色哟哟国产精品免费观看| 欧美日韩亚洲另类| 欧美tickling挠脚心丨vk| 久久久精品黄色| 亚洲人成7777| 日韩成人免费在线| 国产精华液一区二区三区| 色综合av在线| 欧美成人猛片aaaaaaa| 国产精品天天摸av网| 亚洲午夜久久久久中文字幕久| 奇米一区二区三区| 成人毛片在线观看| 欧美军同video69gay| 国产亚洲人成网站| 亚洲午夜一区二区| 国产一区二区导航在线播放| 日本高清不卡在线观看| 欧美一级高清片| 亚洲欧美日韩电影| 精久久久久久久久久久| 色哦色哦哦色天天综合| 日韩免费福利电影在线观看| 国产精品福利影院| 久久精品久久精品| 色噜噜狠狠一区二区三区果冻| 精品裸体舞一区二区三区| 亚洲欧美另类小说视频| 国内不卡的二区三区中文字幕| 欧美亚洲图片小说| 中文字幕av一区二区三区| 天天综合网天天综合色| 波多野结衣中文字幕一区二区三区| 欧美日韩国产精品自在自线| 国产精品久线观看视频| 久久精品久久99精品久久| 在线视频综合导航| 欧美国产亚洲另类动漫| 日韩av在线发布| 日本韩国欧美在线| 国产精品―色哟哟| 国产另类ts人妖一区二区| 欧美精品粉嫩高潮一区二区| 亚洲男人的天堂在线观看| 国产福利91精品一区二区三区| 欧美一区二区视频在线观看| 一区二区三区欧美| youjizz国产精品| 久久久久久9999| 麻豆国产欧美一区二区三区| 欧美日韩日日摸| 怡红院av一区二区三区| www.爱久久.com| 亚洲国产精品99久久久久久久久| 久久精品av麻豆的观看方式| 欧美一区二区三区人| 亚洲1区2区3区4区| 欧美色欧美亚洲另类二区| 亚洲美女视频在线| 白白色亚洲国产精品| 亚洲国产精品成人综合| 国产原创一区二区| 久久久欧美精品sm网站| 韩国v欧美v日本v亚洲v| 精品免费国产二区三区 | 国产亚洲婷婷免费| 国产综合一区二区| 久久人人97超碰com| 国产在线不卡一卡二卡三卡四卡| 欧美电影免费观看高清完整版| 日本欧美肥老太交大片| 欧美精品久久天天躁| 日日夜夜免费精品| 日韩欧美中文字幕精品| 麻豆成人免费电影| 精品成人一区二区三区四区| 国内成+人亚洲+欧美+综合在线| 精品国产伦一区二区三区观看方式| 麻豆91在线观看| 久久久99免费| 成人性生交大片免费| 亚洲人成网站精品片在线观看| 91在线国产福利| 亚洲国产精品一区二区久久| 欧美日韩精品综合在线| 秋霞影院一区二区| 国产毛片精品一区| 欧美日韩午夜在线| 欧美一区三区二区| 蓝色福利精品导航| 日韩女优制服丝袜电影| 国产精品正在播放| 中日韩av电影| 色综合久久九月婷婷色综合| 婷婷丁香激情综合| 欧美精品一区二区不卡| eeuss鲁片一区二区三区| 一区二区三区中文在线| 日韩一区二区三区免费观看| 国产成人小视频| 一个色综合网站| 精品国产欧美一区二区| 99精品热视频|