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

📄 jpg2kmqdecoder.h

📁 JPEG里MQ算术编码测试程序 编解码器 C
💻 H
字号:
#pragma once

#include "common.h"

class CJPG2KMQEState;
class CJPG2KMQETransition;

#define MQD_A_MIN ((long)(1<<23)) // Lower bound for A register.

class CJPG2KMQDecoder
{
public: // Member functions
	CJPG2KMQDecoder()
	{ 
		m_bActive = false; 
		m_pBufStart = m_pBufNext = NULL; 
	}

	void Start(LPBYTE pStart, int segmentLength, int bMQSegment);

	int Finish(int bCheckErterm = 0);

public: // Functions to check out state information for use with fast macros
	void CheckOut(long &A, long &C, long &D,long &t, 
		long &temp, LPBYTE &pStore, int &S)

	{ // Use this form for MQ codeword segments.
		A = m_A; 
		C = m_C;
		D = A- MQD_A_MIN; 
		D = (C<D)?C:D; 
		A -= D; 
		C -= D;
		t = m_t; 
		temp = m_temp; 
		pStore = m_pBufNext; 
		S = m_nS;
	}

	void CheckOut(long &t, long &temp, LPBYTE &pStore)
	{ // Use this form for raw codeword segments.
		t = m_t; 
		temp = m_temp; 
		pStore = m_pBufNext;
	}

	void CheckIn(long A, long C, long D,
		long t, long temp, LPBYTE pStore, int S)
	{ // Use this form for MQ codeword segments.
		m_A = A+D; 
		m_C = C+D;
		m_t = t; 
		m_temp = temp; 
		m_pBufNext = pStore; 
		m_nS = S;
	}

	void CheckIn(long t, long temp, LPBYTE pStore)
	{ // Use this form for raw codeword segments.
		m_t = t; 
		m_temp = temp; 
		m_pBufNext = pStore;
	}
public: // Encoding functions. Note: use macros for the highest throughput
	void MQDecode(long &symbol, CJPG2KMQEState &state);

	//instead of macro
	void MQDecode(long &symbol,CJPG2KMQEState &state,long &A,long &C,
		long &D,long &t,long &temp,LPBYTE &store,long &S);

	void MQDecodeRun(long &run); // Decodes 2 bit run length, MSB first

	//instead of macro
	void MQDecodeRun(long &run,long &A,long &C,long &D,
				long &t,long &temp,LPBYTE &store,long &S);


	void RawDecode(long &symbol);

	//instead of macro
	void RawDecode(long &symbol,long &t,long &temp,LPBYTE &store);
private:
	void FillLsbs();
	/* Used by the `mq_decode' member function. */

	//instead of macro
	void	FillLsbs(long &C,long &t,long &temp,LPBYTE &store,long &S);

public: // Probability estimation state machine.
	static long m_pBarTable[47]; // Normalized LPS probabilities

	static CJPG2KMQETransition m_TransitionTable[94]; // See defn of `mqd_transition'

	static void InitializeTransitionTable();

private: // Data
	long m_A; // The 8 MSB's and 8 LSB's of this word are guaranteed to be 0
	long m_C; // The 8 MSB's of this word are guaranteed to be 0
	long m_t;   // This is "t_bar" in the book
	long m_temp; // This is "T_bar" in the book
	LPBYTE m_pBufStart;
	LPBYTE m_pBufNext;
	int m_nS; // Number of synthesized FF's
	int m_bCheckedOut;
	int m_bMQSegment;
	int m_bActive;
	int m_nSegmentLength;
	BYTE m_OverwrittenBytes[2];
};

⌨️ 快捷键说明

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