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

📄 stagescodinggaggles.c

📁 CCSDS空间图像图像压缩标准c源代码
💻 C
📖 第 1 页 / 共 3 页
字号:
		counter = 0;
		if((PtrCoding->PtrHeader->Header.Part4).DWTType == INTEGER_WAVELET)
		{
			for(k = 0; k < 3; k ++) 
			{	
				if((((k == 0) && (PtrCoding->PtrHeader->Header.Part4.CustomWtHL1_2bits >= BitPlane)) // HL3 band. 
					|| ((k == 1) &&	(PtrCoding->PtrHeader->Header.Part4.CustomWtLH1_2bits >= BitPlane)) // HL3 band. 
					|| ((k == 2) && (PtrCoding->PtrHeader->Header.Part4.CustomWtHH1_2bits >= BitPlane)))) // HL3 band. 
					continue;
				flag = TRUE; 
					
				if(((BlockCodingInfo[BlockSeq].StrPlaneHitHistory.TranD & ( 1 << (2 - k))) > 0) &&
					((BlockCodingInfo[BlockSeq].StrPlaneHitHistory.TranGi & ( 1 << (2 - k))) == 0))
					counter ++;
			}
		}
		else
		{
			flag = TRUE; 
			for(k = 0; k < 3; k ++) 
			{	
				if(((BlockCodingInfo[BlockSeq].StrPlaneHitHistory.TranD & ( 1 << (2 - k))) > 0) &&
					((BlockCodingInfo[BlockSeq].StrPlaneHitHistory.TranGi & ( 1 << (2 - k))) == 0))
					counter ++;
			}
		}

		if (flag == FALSE)
			continue; 

		if(counter > 0)
		{
			DWORD32 TempWord;
			
			if(counter != 1)
			{
				if(FlagCodeOptionOutput[counter - 2] == FALSE)
				{
					FlagCodeOptionOutput[counter - 2] = TRUE;
					if(counter == 2)
					{
						BitsRead(PtrCoding, &TempWord, 1);				
					}
					else 						
					{
						BitsRead(PtrCoding, &TempWord, 2);				
					}
					CodeOptionsAllGaggles[counter - 2] = (UCHAR8) TempWord;
					
					if ((PtrCoding->DecodingStopLocations.BitPlaneStopDecoding != -1)
						&& PtrCoding->RateReached == TRUE && !PtrCoding->DecodingStopLocations.LocationFind)
					{
							PtrCoding->DecodingStopLocations.BlockNoStopDecoding = BlockSeq;
							if((BlockCodingInfo[BlockSeq].StrPlaneHitHistory.TranGi  & 0x4) == 0)
							{
								PtrCoding->DecodingStopLocations.X_LocationStopDecoding = 0;						
								PtrCoding->DecodingStopLocations.Y_LocationStopDecoding = 4;
							}
							else if((BlockCodingInfo[BlockSeq].StrPlaneHitHistory.TranGi & 0x2)== 0)
							{
								PtrCoding->DecodingStopLocations.X_LocationStopDecoding = 4;						
								PtrCoding->DecodingStopLocations.Y_LocationStopDecoding = 0;
							}
							else
							{
								PtrCoding->DecodingStopLocations.X_LocationStopDecoding = 4;						
								PtrCoding->DecodingStopLocations.Y_LocationStopDecoding = 4;
							}

							PtrCoding->DecodingStopLocations.LocationFind = TRUE;
							return;
					}
				} 
			}

			RiceDecoding(&TempWord, counter, CodeOptionsAllGaggles, PtrCoding);
			
			if ((PtrCoding->DecodingStopLocations.BitPlaneStopDecoding != -1)
						&& PtrCoding->RateReached == TRUE && !PtrCoding->DecodingStopLocations.LocationFind)
					{
							PtrCoding->DecodingStopLocations.BlockNoStopDecoding = BlockSeq;
							if((BlockCodingInfo[BlockSeq].StrPlaneHitHistory.TranGi  & 0x4) == 0)
							{
								PtrCoding->DecodingStopLocations.X_LocationStopDecoding = 0;						
								PtrCoding->DecodingStopLocations.Y_LocationStopDecoding = 4;
							}
							else if((BlockCodingInfo[BlockSeq].StrPlaneHitHistory.TranGi & 0x2) == 0)
							{
								PtrCoding->DecodingStopLocations.X_LocationStopDecoding = 4;						
								PtrCoding->DecodingStopLocations.Y_LocationStopDecoding = 0;
							}
							else
							{
								PtrCoding->DecodingStopLocations.X_LocationStopDecoding = 4;						
								PtrCoding->DecodingStopLocations.Y_LocationStopDecoding = 4;
							}

							PtrCoding->DecodingStopLocations.LocationFind = TRUE;
							return;
					}
			StrSymbol.sym_mapped_pattern = (UCHAR8)TempWord;			
			StrSymbol.sym_len = counter;
			StrSymbol.type = ENUM_TRAN_GI;
			DeMappingPattern(&StrSymbol);

			for( i = 0; i < 3; i++)
			{
				if((BlockCodingInfo[BlockSeq].StrPlaneHitHistory.TranD & ( 1 << (2 - i))) > 0)
				{

					if ((PtrCoding->PtrHeader->Header.Part4).DWTType == INTEGER_WAVELET)
					{
						if((((i == 0) && (PtrCoding->PtrHeader->Header.Part4.CustomWtHL1_2bits >= BitPlane)) // HL3 band. 
						|| ((i == 1) &&	(PtrCoding->PtrHeader->Header.Part4.CustomWtLH1_2bits >= BitPlane)) // HL3 band. 
						|| ((i == 2) && (PtrCoding->PtrHeader->Header.Part4.CustomWtHH1_2bits >= BitPlane)))) // HL3 band. 
							continue;
					}
					if((BlockCodingInfo[BlockSeq].StrPlaneHitHistory.TranGi & ( 1 << (2 - i))) == 0)
					{
						BlockCodingInfo[BlockSeq].StrPlaneHitHistory.TranGi += (((StrSymbol.sym_val >> (counter - 1)) & 0x01)  << (2 - i));
						counter --;
					}
				}
			} 
		}
	// TranHi
		for(k = 0; k < 3; k ++)
		{
			if((PtrCoding->PtrHeader->Header.Part4).DWTType == INTEGER_WAVELET)
			{
				if((((k == 0) && (PtrCoding->PtrHeader->Header.Part4.CustomWtHL1_2bits >= BitPlane)) // HL3 band. 
					|| ((k == 1) &&	(PtrCoding->PtrHeader->Header.Part4.CustomWtLH1_2bits >= BitPlane)) // HL3 band. 
					|| ((k == 2) && (PtrCoding->PtrHeader->Header.Part4.CustomWtHH1_2bits >= BitPlane)))) // HL3 band. 
					continue;
			} 

			if((BlockCodingInfo[BlockSeq].StrPlaneHitHistory.TranGi & ( 1 << (2 - k))) != 0)
			{
				DWORD32 TempWord;
				counter = 0;
				for (i = 0; i < 4; i ++)
				{
					if((BlockCodingInfo[BlockSeq].StrPlaneHitHistory.TranHi[k].TranH & ( 1 << (3 - i))) == 0)
						counter ++;
				}
				if (counter == 0)
					continue;			

				if(counter != 1)
				{
					if(FlagCodeOptionOutput[counter - 2] == FALSE)
					{
						FlagCodeOptionOutput[counter - 2] = TRUE;
						if(counter == 2)
						{
							BitsRead(PtrCoding, &TempWord, 1);
						}
						else 						
						{									
							BitsRead(PtrCoding, &TempWord, 2);
						}
						CodeOptionsAllGaggles[counter - 2] = (UCHAR8) TempWord;

						if ((PtrCoding->DecodingStopLocations.BitPlaneStopDecoding != -1)
							&& PtrCoding->RateReached == TRUE && !PtrCoding->DecodingStopLocations.LocationFind)
						{
							PtrCoding->DecodingStopLocations.BlockNoStopDecoding = BlockSeq;
							if((BlockCodingInfo[BlockSeq].StrPlaneHitHistory.TranGi  & 0x4) == 0)
							{
								PtrCoding->DecodingStopLocations.X_LocationStopDecoding = 0;						
								PtrCoding->DecodingStopLocations.Y_LocationStopDecoding = 4;
							}
							else if((BlockCodingInfo[BlockSeq].StrPlaneHitHistory.TranGi & 0x2) == 0)
							{
								PtrCoding->DecodingStopLocations.X_LocationStopDecoding = 4;						
								PtrCoding->DecodingStopLocations.Y_LocationStopDecoding = 0;
							}
							else
							{
								PtrCoding->DecodingStopLocations.X_LocationStopDecoding = 4;						
								PtrCoding->DecodingStopLocations.Y_LocationStopDecoding = 4;
							}

							PtrCoding->DecodingStopLocations.LocationFind = TRUE;
							return;
						}
					} 
				}

				RiceDecoding(&TempWord, counter, CodeOptionsAllGaggles, PtrCoding);

				
				if ((PtrCoding->DecodingStopLocations.BitPlaneStopDecoding != -1)
						&& PtrCoding->RateReached == TRUE && !PtrCoding->DecodingStopLocations.LocationFind)
					{
							PtrCoding->DecodingStopLocations.BlockNoStopDecoding = BlockSeq;
							if((BlockCodingInfo[BlockSeq].StrPlaneHitHistory.TranGi  & 0x4) == 0)
							{
								PtrCoding->DecodingStopLocations.X_LocationStopDecoding = 0;						
								PtrCoding->DecodingStopLocations.Y_LocationStopDecoding = 4;
							}
							else if((BlockCodingInfo[BlockSeq].StrPlaneHitHistory.TranGi & 0x2) == 0)
							{
								PtrCoding->DecodingStopLocations.X_LocationStopDecoding = 4;						
								PtrCoding->DecodingStopLocations.Y_LocationStopDecoding = 0;
							}
							else
							{
								PtrCoding->DecodingStopLocations.X_LocationStopDecoding = 4;						
								PtrCoding->DecodingStopLocations.Y_LocationStopDecoding = 4;
							}

							PtrCoding->DecodingStopLocations.LocationFind = TRUE;
							return;
					}

				StrSymbol.sym_mapped_pattern = (UCHAR8) TempWord;
				StrSymbol.sym_len = counter;
				StrSymbol.type = ENUM_TRAN_HI;
				DeMappingPattern(&StrSymbol);

				if (StrSymbol.sym_val > 0)
				{
					for (i = 0; i < 4; i ++)
					{
						if((BlockCodingInfo[BlockSeq].StrPlaneHitHistory.TranHi[k].TranH & ( 1 << (3 - i))) != 0)
							continue;						
						temp_DWORD = ((StrSymbol.sym_val >> (counter - 1)) & 0x01);
						BlockCodingInfo[BlockSeq].StrPlaneHitHistory.TranHi[k].TranH += (((short)temp_DWORD) <<  (3 - i));
						counter --;
					}
				}
			}
		}

		if ((PtrCoding->DecodingStopLocations.BitPlaneStopDecoding != -1)
			&& PtrCoding->RateReached == TRUE && (!PtrCoding->DecodingStopLocations.LocationFind))
		{
			PtrCoding->DecodingStopLocations.BlockNoStopDecoding = BlockSeq;
			PtrCoding->DecodingStopLocations.X_LocationStopDecoding = 4;						
			PtrCoding->DecodingStopLocations.Y_LocationStopDecoding = 0;
			PtrCoding->DecodingStopLocations.LocationFind = TRUE;
			return;
		}

		//TypeHij 
		for (i = 0; i < 3; i ++)
		{						
			if((PtrCoding->PtrHeader->Header.Part4).DWTType == INTEGER_WAVELET)
			{
				if((((i == 0) && (PtrCoding->PtrHeader->Header.Part4.CustomWtHL1_2bits >= BitPlane)) // HL3 band. 
					|| ((i == 1) &&	(PtrCoding->PtrHeader->Header.Part4.CustomWtLH1_2bits >= BitPlane)) // HL3 band. 
					|| ((i == 2) && (PtrCoding->PtrHeader->Header.Part4.CustomWtHH1_2bits >= BitPlane)))) // HL3 band. 
					continue;
			} 

			for ( k = 0;  k < 4;  k ++)
			{	
				temp_x = (i >= 1 ? 1 : 0) * 4 + (k >= 2 ? 1 : 0) * 2;
				temp_y = (i != 1 ? 1 : 0) * 4 + (k % 2) * 2;
				
				BlockCodingInfo[BlockSeq].RefineBits.RefineGrandChildren[i].GrandChildrenRefSymbol <<= 4;

				if((BlockCodingInfo[BlockSeq].StrPlaneHitHistory.TranHi[i].TranH & ( 1 << ( 3 - k))) > 0)
				{
					DWORD32 TempWord;
					counter = 0;
					for (p = 0; p < 4; p++)
					{
						if(((BlockCodingInfo[BlockSeq].StrPlaneHitHistory.TypeHij[i].TypeHij[k].TranH & (1 << ( 3 - p)))) == 0)
							counter ++;
					}
					if (counter != 0)
					{
						if(counter != 1)
						{
							if(FlagCodeOptionOutput[counter - 2] == FALSE)
							{
								FlagCodeOptionOutput[counter - 2] = TRUE;
								if(counter == 2)
									BitsRead(PtrCoding, &TempWord, 1);
								else 						
									BitsRead(PtrCoding, &TempWord, 2);
								CodeOptionsAllGaggles[counter - 2] = (UCHAR8) TempWord;

								if ((PtrCoding->DecodingStopLocations.BitPlaneStopDecoding != -1)
									&& PtrCoding->RateReached == TRUE && !PtrCoding->DecodingStopLocations.LocationFind)
								{
										PtrCoding->DecodingStopLocations.BlockNoStopDecoding = BlockSeq;
										PtrCoding->DecodingStopLocations.X_LocationStopDecoding = temp_x;						
										PtrCoding->DecodingStopLocations.Y_LocationStopDecoding = temp_y;
										PtrCoding->DecodingStopLocations.LocationFind = TRUE;
										return;
								}
							}
						}

						RiceDecoding(&TempWord, counter, CodeOptionsAllGaggles, PtrCoding);

						if ((PtrCoding->DecodingStopLocations.BitPlaneStopDecoding != -1)
							&& PtrCoding->RateReached == TRUE && !PtrCoding->DecodingStopLocations.LocationFind)
						{
							PtrCoding->DecodingStopLocations.BlockNoStopDecoding = BlockSeq;
							PtrCoding->DecodingStopLocations.X_LocationStopDecoding = temp_x;						
							PtrCoding->DecodingStopLocations.Y_LocationStopDecoding = temp_y;
							PtrCoding->DecodingStopLocations.LocationFind = TRUE;
							return;
						}
				
						StrSymbol.sym_mapped_pattern = (UCHAR8) TempWord;
						StrSymbol.sym_len = (UCHAR8) counter;
						StrSymbol.type = ENUM_TYPE_HIJ;
						DeMappingPattern(&StrSymbol);


						for (p = 0; p < 4; p ++)
						{
							if((BlockCodingInfo[BlockSeq].StrPlaneHitHistory.TypeHij[i].TypeHij[k].TranH & ( 1 << (3 - p))) != 0)
							{
								BlockCodingInfo[BlockSeq].RefineBits.RefineGrandChildren[i].GrandChildrenRefSymbol += ( 1 << (3 - p));
								BlockCodingInfo[BlockSeq].RefineBits.RefineGrandChildren[i].GrandChildrenSymbolLength ++;
								continue;
							}
							temp_DWORD = (StrSymbol.sym_val & (1 << (counter - 1)));
							counter --;		
							if(temp_DWORD > 0)
							{
								DWORD32 TempWord;
								BlockCodingInfo[BlockSeq].PtrBlockAddress[temp_x + p / 2][temp_y + p % 2] += (1 << (BitPlane - 1));
								BlockCodingInfo[BlockSeq].StrPlaneHitHistory.TypeHij[i].TypeHij[k].TranH += (1 << ( 3 - p));
								BitsRead(PtrCoding, &TempWord, 1); // sign bit
								if (TempWord == NEGATIVE_SIGN)
									BlockCodingInfo[BlockSeq].PtrBlockAddress[temp_x + p / 2][temp_y + p % 2] = - BlockCodingInfo[BlockSeq].PtrBlockAddress[temp_x + p / 2][temp_y + p % 2];
								
								if ((PtrCoding->DecodingStopLocations.BitPlaneStopDecoding != -1)
									&& PtrCoding->RateReached == TRUE && !PtrCoding->DecodingStopLocations.LocationFind)
								{
									PtrCoding->DecodingStopLocations.BlockNoStopDecoding = BlockSeq;
									PtrCoding->DecodingStopLocations.X_LocationStopDecoding = temp_x + p / 2;						
									PtrCoding->DecodingStopLocations.Y_LocationStopDecoding = temp_y + p % 2;
									PtrCoding->DecodingStopLocations.LocationFind = TRUE;
									return;
								}			
							}	
							if ((PtrCoding->DecodingStopLocations.BitPlaneStopDecoding != -1)
								&& PtrCoding->RateReached == TRUE 
								&& (!PtrCoding->DecodingStopLocations.LocationFind ))
							{
								PtrCoding->DecodingStopLocations.BlockNoStopDecoding = BlockSeq;
								PtrCoding->DecodingStopLocations.X_LocationStopDecoding = temp_x + p / 2;						
								PtrCoding->DecodingStopLocations.Y_LocationStopDecoding = temp_y + p % 2;
								PtrCoding->DecodingStopLocations.LocationFind = TRUE;
								return;
							}
						}
					}
					else
					{
						BlockCodingInfo[BlockSeq].RefineBits.RefineGrandChildren[i].GrandChildrenRefSymbol += 0xF;
						BlockCodingInfo[BlockSeq].RefineBits.RefineGrandChildren[i].GrandChildrenSymbolLength += 4;
					}
				}
			}
		}
	}
	return;
}

⌨️ 快捷键说明

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