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

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

?? mchannel.c

?? 《Visual C++小波變換技術與工程實踐》 作者:靳濟芳。書上的代碼。第6章:網絡圖像漸進傳輸實用案例。包括:圖像多分辨率表示
?? C
字號:
// --------------- MULTI-CHANNEL ROUTINES ---------------
// wavelet image compression
// channel balancing & quality enforcement
// (c) 2001-2002 Daniel Vollmer (maven@maven.de)

/* 	This program is free software; you can redistribute it and/or modify
	it under the terms of the GNU General Public License as published by
	the Free Software Foundation; either version 2 of the License, or
	(at your option) any later version.

	This program is distributed in the hope that it will be useful,
	but WITHOUT ANY WARRANTY; without even the implied warranty of
	MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.	See the
	GNU General Public License for more details.

	You should have received a copy of the GNU General Public License
	along with this program; if not, write to the Free Software
	Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA	02111-1307	USA
*/

#include "wavelet.h"
#include "mchannel.h"


// colour-space conversion (using 16.16 fixed point)
// this is the same transform as used in JPEG, and the results still need
// to be rounded and shifted / divided

#define RGB_Y(r, g, b) ((r) * 19595 + (g) * 38470 + (b) * 7471)
#define RGB_Cb(r, g, b) ((r) * -11059 + (g) * -21709 + (b) * 32768)
#define RGB_Cr(r, g, b) ((r) * 32768 + (g) * -27439 + (b) * -5329)

// the results of these need to be clamped to the range [0..255] after rounding
// and shifting
#define YCbCr_R(y, cb, cr) (/*(y) * 65536 + (cb) * 0 +*/ (cr) * 91881)
#define YCbCr_G(y, cb, cr) (/*(y) * 65536 +*/ (cb) * -22554 + (cr) * -46802)
#define YCbCr_B(y, cb, cr) (/*(y) * 65536 +*/ (cb) * 116130 /*+ (cr) * 0*/)

//----------------------------------------------------------------------------
// wv_rgb_to_ycbcr	converts an array of pixels
//				(given as seperate bitplanes) from RGB into YCbCr
//				returns the number of pixels converted
// Num			numbers of consecutive pixels to be converted
// R, G, B		pointers to the red, green and blue arrays, respectively (R->Y, G->Cb, B->Cr)
//----------------------------------------------------------------------------
WAVELET_DLL_API int WAVELET_DLL_CC wv_rgb_to_ycbcr(const int Num, wv_pel* R, wv_pel* G, wv_pel* B)
{
	if (Num > 0 && R && G && B)
	{
		int i;

		for (i = 0; i < Num; i++)
		{
			int rr = R[i], gg = G[i], bb = B[i];

			R[i] = (wv_pel)((RGB_Y(rr, gg, bb) + 32768) >> 16); // Y
			G[i] = (wv_pel)(((RGB_Cb(rr, gg, bb) + 32767) >> 16)); // Cb
			B[i] = (wv_pel)(((RGB_Cr(rr, gg, bb) + 32767) >> 16)); // Cr
		}
		return Num;
	}
	return 0;
}


//----------------------------------------------------------------------------
// wv_ycbcr_to_rgb	converts an array of pixels
//				(given as seperate bitplanes) from YCbCr into RGB
//				returns the number of pixels converted
// Num			numbers of consecutive pixels to be converted
// Y, Cb, Cr	pointers to the Y, Cb, and Cr arrays, respectively (Y->R, Cb->G, Cr->B)
//----------------------------------------------------------------------------
WAVELET_DLL_API int WAVELET_DLL_CC wv_ycbcr_to_rgb(const int Num, wv_pel* Y, wv_pel* Cb, wv_pel* Cr)
{
	if (Num > 0 && Y && Cb && Cr)
	{
		int i;

		for (i = 0; i < Num; i++)
		{
			int yy = Y[i], cb = Cb[i], cr = Cr[i];
			
			Y[i] = yy + ((YCbCr_R(yy, cb, cr) + 32768) >> 16); Y[i] = min(255, max(0, Y[i])); // R
			Cb[i] = yy + ((YCbCr_G(yy, cb, cr) + 32768) >> 16); Cb[i] = min(255, max(0, Cb[i])); // G
			Cr[i] = yy + ((YCbCr_B(yy, cb, cr) + 32768) >> 16); Cr[i] = min(255, max(0, Cr[i])); // B
		}
		return Num;
	}
	return 0;
}


//----------------------------------------------------------------------------
// wv_init_multi_channels	tries to find the matching settings for
//				a number of channels (i.e. satisfy all the constraints given)
//				returns the bits needed (never larger than MaxBits),
//				0 on failure to satisfy contraints
// MaxBits		number of bits to be used by all the channels,
//				or 0 for quality based encoding
// Threshold	how closely it tries to equalise quality (of the channels),
//				should be inbetween 0.0f..1.0f for good results, use 0.0f
//				if you don't mind waiting slightly longer...
// NumChannels	# of channels given in Channels to be compressed
// Channels		is the array of channel-parameters with NumChannels entries
//				(need a valid t_wv_cchannel and max_mse),
//				when encoding for quality each channel's max_mse gives the
//				maximum target error,
//				when encoding for size each channel's max_mse gives a
//				a target error relative to the other channels
// Sets			array with NumChannels entries where the best settings are
//				stored (on success). These have to be freed by the calling
//				application using wv_done_channel_settings.
//----------------------------------------------------------------------------
WAVELET_DLL_API int WAVELET_DLL_CC wv_init_multi_channels(const int MaxBits, const float Threshold, const int NumChannels, t_wv_mchannel_params* Channels, t_wv_csettings** Sets)
{
	int bits = 0;

	if (NumChannels > 0 && Channels && Sets)
	{
		int i;

		for (i = 0; i < NumChannels; i++)
			Sets[i] = NULL;
		if (MaxBits <= 0)
		{ // simply enforce mse constraints
			for (i = 0; i < NumChannels; i++)
			{
				bits = wv_init_channel_settings(Channels[i].cc, 0, Channels[i].max_mse, &Sets[i]);
				if (bits <= 0)
					break;
			}
		}
		else
		{ // balance the channels so that MSEs are about equal (including max_mse interpreted as delta_mse)
			int num_iter = 0, adjustment;
			int omin_idx = -1, omax_idx = -1;
			t_wv_csettings* lsets[wv_MAX_CHANNELS];
			float closest_match = NumChannels * 65536.0f;

			for (i = 0; i < NumChannels; i++)
			{
				Channels[i].bits_unused = Channels[i].old_bits = 0;
				Sets[i] = NULL;
				lsets[i] = NULL;
			}
		
			// distribute the bits equally as inital state
			adjustment = 0;
			for (i = 1; i < NumChannels; i++)
			{
				Channels[i].bits_alloced = MaxBits / NumChannels;
				adjustment += Channels[i].bits_alloced;
			}
			Channels[0].bits_alloced = MaxBits - adjustment; // gets all the bits left over
			adjustment = 1;
			
			do
			{
				float bmin_mse = 65536.0f, bmax_mse = -1.0f;
				float avg_mse = 0.0f;
				int bmin_idx = -1, bmax_idx = -1;
				int bits_available;

				for (i = 0; i < NumChannels; i++)
				{
					if (lsets[i] && Channels[i].bits_alloced != Channels[i].old_bits)
					{
						wv_done_channel_settings(lsets[i]);
						lsets[i] = NULL;
					}
					if (!lsets[i])
						bits = wv_init_channel_settings(Channels[i].cc, Channels[i].bits_alloced, 65536.0f, &lsets[i]);
					else
						bits = lsets[i]->num_bits;
					if (bits > 0 && lsets[i])
					{
//						fprintf(f, "%i bits_a: %i bits_u: %i error: %f\n", i, Channels[i].bits_alloced, lsets[i]->num_bits, lsets[i]->emse);
						Channels[i].old_bits = bits; // as we are going to redistribute the unused ones							
						Channels[i].bits_unused = Channels[i].bits_alloced - bits;
						// find the best and the worst channel (including relative error adjustments)
						if (lsets[i]->emse - Channels[i].max_mse <= bmin_mse)
						{
							bmin_mse = lsets[i]->emse - Channels[i].max_mse;
							bmin_idx = i;
						}
						if (lsets[i]->emse - Channels[i].max_mse >= bmax_mse)
						{
							bmax_mse = lsets[i]->emse - Channels[i].max_mse;
							bmax_idx = i;
						}
						avg_mse += lsets[i]->emse;
					}
					else
						break;
				}
						
				if (i != NumChannels || bmin_idx == -1 || bmax_idx == -1)
				{ // uh-oh, shouldn't happen
					bits = 0;
					break; // bits == 0 -> abort
				}
/*				// equalise difference between best & worst mse
				if (bmax_mse - bmin_mse <= closest_match)
				{ // this is better than our best-one so far, so keep it
					for (i = 0; i < NumChannels; i++)
					{
						Sets[i] = lsets[i]; // copy the set
						lsets[i] = NULL; // and don't let it be deleted
					}
					closest_match = bmax_mse - bmin_mse;
				}*/
				if (avg_mse <= closest_match)
				{ // this is better than our best-one so far, so keep it
					for (i = 0; i < NumChannels; i++)
					{
						Sets[i] = lsets[i]; // copy the set
						lsets[i] = NULL; // and don't let it be deleted
					}
					closest_match = avg_mse;
				}
				if ((bmin_idx == bmax_idx) || (bmax_mse - bmin_mse <= Threshold))
					break; // balanced or only one channel

				if (bmin_idx == omax_idx && bmax_idx == omin_idx)
				{
					adjustment++;
					if (adjustment > 16)
						break; // only flipping between two channels
				}

				// redistribute bits							
				bits_available = 0; // add up all the unused bits
				for (i = 0; i < NumChannels; i++)
					if (i != bmin_idx && i != bmax_idx)
					{
						bits_available += Channels[i].bits_unused;
						Channels[i].bits_alloced -= Channels[i].bits_unused;
					}
				
				// redistribute the unused bits, plus the one from the best & worst channel among them
				bits_available += Channels[bmin_idx].bits_alloced + Channels[bmax_idx].bits_alloced;

				Channels[bmin_idx].bits_alloced = (Channels[bmin_idx].bits_alloced * adjustment) / (adjustment + 1);
				Channels[bmax_idx].bits_alloced = bits_available - Channels[bmin_idx].bits_alloced; // gets the rest

				omin_idx = bmin_idx;
				omax_idx = bmax_idx;

				num_iter++;
			} while (num_iter < 256);

			// free the settings (we've copied the best ones to Sets)
			for (i = 0; i < NumChannels; i++)
				if (lsets[i] != NULL)
					wv_done_channel_settings(lsets[i]);
		}
		
		// recompute the final number of bits used
		bits = 0;
		for (i = 0; i < NumChannels; i++)
			if (Sets[i])
				bits += Sets[i]->num_bits;
	}
	return bits;
}

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
久久精品国产精品青草| 国产亚洲成av人在线观看导航 | 亚洲一区二区三区免费视频| 99精品在线免费| 亚洲精品日日夜夜| 欧美日韩一区成人| 麻豆精品久久久| 久久色成人在线| av资源站一区| 午夜天堂影视香蕉久久| 欧美大胆一级视频| 国产91对白在线观看九色| 中文字幕一区二| 欧美精品久久久久久久多人混战 | 国模娜娜一区二区三区| 国产人伦精品一区二区| 91污在线观看| 日本亚洲欧美天堂免费| 久久精品亚洲精品国产欧美| 91在线无精精品入口| 日日骚欧美日韩| 国产欧美日产一区| 欧美日韩国产首页| 国产一区二区电影| 亚洲综合清纯丝袜自拍| 久久综合999| 日本韩国精品一区二区在线观看| 免费看欧美美女黄的网站| 国产精品久久久久永久免费观看| 欧美三电影在线| 国产精品一二一区| 亚洲777理论| 国产精品免费av| 欧美精品成人一区二区三区四区| 国产福利精品导航| 五月天一区二区三区| 久久久国产精品麻豆 | 91精品在线麻豆| 国产成人av电影| 日韩精品亚洲专区| 国产精品毛片久久久久久| 91精品婷婷国产综合久久性色| 国产成人鲁色资源国产91色综 | 91免费观看在线| 激情综合网最新| 亚洲18色成人| 成人欧美一区二区三区黑人麻豆| 日韩视频一区二区在线观看| 欧美伊人久久大香线蕉综合69| 国产乱码一区二区三区| 视频精品一区二区| 亚洲视频图片小说| 久久久91精品国产一区二区三区| 欧美三级中文字幕在线观看| 99精品视频免费在线观看| 国产精品羞羞答答xxdd| 日韩精品欧美成人高清一区二区| 一区二区在线免费观看| 国产精品美女久久久久久久久 | 婷婷六月综合网| 一区二区三区在线影院| 国产精品毛片高清在线完整版 | 亚洲色图欧洲色图| 国产亚洲欧美激情| 精品久久久久久久一区二区蜜臀| 777色狠狠一区二区三区| 欧美视频一区二区三区四区| 91美女视频网站| a亚洲天堂av| 成人av在线资源网| 国产99久久久久久免费看农村| 久久激情五月激情| 日产精品久久久久久久性色| 午夜免费久久看| 天堂久久久久va久久久久| 日韩一区精品字幕| 免费在线观看成人| 精品一区免费av| 激情综合色丁香一区二区| 美女精品一区二区| 伦理电影国产精品| 国产麻豆欧美日韩一区| 国产福利视频一区二区三区| 成人app网站| 91啪亚洲精品| 欧美精品日日鲁夜夜添| 884aa四虎影成人精品一区| 欧美一区二区三区视频免费播放| 91精品国产aⅴ一区二区| 日韩三级电影网址| 欧美一级在线视频| 亚洲精品一区二区三区福利| 久久美女高清视频| 国产精品女同互慰在线看| 日韩毛片视频在线看| 亚洲电影中文字幕在线观看| 日本成人超碰在线观看| 国产综合久久久久影院| 风间由美一区二区三区在线观看| 91色综合久久久久婷婷| 欧美日韩国产首页| 久久一日本道色综合| 国产精品私房写真福利视频| 有坂深雪av一区二区精品| 日本中文字幕一区二区视频| 国产呦精品一区二区三区网站| 处破女av一区二区| 欧美在线小视频| 日韩无一区二区| 自拍偷自拍亚洲精品播放| 夜夜嗨av一区二区三区四季av | 亚洲国产婷婷综合在线精品| 麻豆精品蜜桃视频网站| av电影在线不卡| 91麻豆精品国产综合久久久久久| 久久免费精品国产久精品久久久久| 日韩一区中文字幕| 精品一区二区免费在线观看| 97se狠狠狠综合亚洲狠狠| 欧美一二三四区在线| 国产精品女同一区二区三区| 日韩成人精品在线| www.欧美日韩国产在线| 69久久夜色精品国产69蝌蚪网| 久久夜色精品国产欧美乱极品| 亚洲色图欧洲色图| 黑人巨大精品欧美一区| 欧美三级视频在线| 欧美国产一区二区在线观看| 亚州成人在线电影| 91麻豆免费观看| 国产亚洲精品7777| 免费看欧美美女黄的网站| 91麻豆免费看| 欧美极品aⅴ影院| 精品一区二区三区视频| 欧美性生活影院| 国产精品成人免费精品自在线观看| 久久精品二区亚洲w码| 欧美视频中文一区二区三区在线观看| 日本一区二区免费在线| 免费成人小视频| 欧美日韩在线播放三区| 亚洲欧美一区二区三区国产精品 | 国产精品乱人伦| 国产综合色在线| 91麻豆精品国产自产在线| 亚洲一区二区三区视频在线播放 | 99国产精品久| 国产日韩欧美精品在线| 美女www一区二区| 欧美一区二区黄| 首页亚洲欧美制服丝腿| 在线视频欧美区| 综合av第一页| 91视视频在线观看入口直接观看www | 欧美三级在线看| 亚洲一区二区三区自拍| 色呦呦国产精品| 亚洲人吸女人奶水| 99久久精品免费看国产免费软件| 久久精品夜色噜噜亚洲a∨| 麻豆精品一区二区| 欧美一级理论片| 毛片一区二区三区| 欧美一区二区三区四区视频| 五月天国产精品| 91精品国产91久久久久久最新毛片| 午夜精品久久久久久久蜜桃app| 欧洲一区二区av| 午夜国产不卡在线观看视频| 欧美日韩激情一区| 日韩精品乱码免费| 日韩精品资源二区在线| 久久精品国产精品亚洲精品| 欧美精品一区视频| 成人中文字幕合集| 国产精品护士白丝一区av| 色噜噜狠狠色综合欧洲selulu| 一区二区三区欧美在线观看| 欧美日韩中文一区| 日韩电影在线观看网站| 欧美第一区第二区| 国产激情一区二区三区四区| 国产免费观看久久| 色婷婷久久一区二区三区麻豆| 一区二区三区在线免费观看 | 欧美一二三在线| 国产麻豆成人精品| 亚洲色图在线看| 在线播放一区二区三区| 精品无人码麻豆乱码1区2区| 亚洲国产精品精华液2区45| 91免费视频大全| 免费人成网站在线观看欧美高清| 久久久不卡影院| 91福利视频在线| 蜜臀精品久久久久久蜜臀| 久久久久久久一区| 在线观看亚洲a|