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

📄 jpc_cs.h

📁 用C语言实现的JPEG编码
💻 H
📖 第 1 页 / 共 2 页
字号:
typedef struct {	/* The component to which the marker applies. */	uint_fast16_t compno;	/* The ROI style. */	uint_fast8_t roisty;	/* The ROI shift value. */	uint_fast8_t roishift;} jpc_rgn_t;/**************************************\* QCD/QCC marker segment parameters.\**************************************//* * Quantization style constants. */#define	JPC_QCX_NOQNT	0 /* No quantization. */#define	JPC_QCX_SIQNT	1 /* Scalar quantization, implicit. */#define	JPC_QCX_SEQNT	2 /* Scalar quantization, explicit. *//* * Stepsize manipulation macros. */#define	JPC_QCX_GETEXPN(x)	((x) >> 11)#define	JPC_QCX_GETMANT(x)	((x) & 0x07ff)#define	JPC_QCX_EXPN(x)		(assert(!((x) & (~0x1f))), (((x) & 0x1f) << 11))#define	JPC_QCX_MANT(x)		(assert(!((x) & (~0x7ff))), ((x) & 0x7ff))/* Per component information. */typedef struct {	/* The quantization style. */	uint_fast8_t qntsty;	/* The number of step sizes. */	int numstepsizes;	/* The step sizes. */	uint_fast16_t *stepsizes;	/* The number of guard bits. */	uint_fast8_t numguard;} jpc_qcxcp_t;/* QCC marker segment parameters. */typedef struct {	/* The component associated with this marker segment. */	uint_fast16_t compno;	/* The parameters. */	jpc_qcxcp_t compparms;} jpc_qcc_t;/* QCD marker segment parameters. */typedef struct {	/* The parameters. */	jpc_qcxcp_t compparms;} jpc_qcd_t;/**************************************\* POD marker segment parameters.\**************************************/typedef struct {	/* The progression order. */	uint_fast8_t prgord;	/* The lower bound (inclusive) on the resolution level for the	  progression order volume. */	uint_fast8_t rlvlnostart;	/* The upper bound (exclusive) on the resolution level for the	  progression order volume. */	uint_fast8_t rlvlnoend;	/* The lower bound (inclusive) on the component for the progression	  order volume. */	uint_fast16_t compnostart;	/* The upper bound (exclusive) on the component for the progression	  order volume. */	uint_fast16_t compnoend;	/* The upper bound (exclusive) on the layer for the progression	  order volume. */	uint_fast16_t lyrnoend;} jpc_pocpchg_t;/* An alias for the above type. */typedef jpc_pocpchg_t jpc_pchg_t;/* POC marker segment parameters. */typedef struct {	/* The number of progression order changes. */	int numpchgs;	/* The per-progression-order-change information. */	jpc_pocpchg_t *pchgs;} jpc_poc_t;/**************************************\* PPM/PPT marker segment parameters.\**************************************//* PPM marker segment parameters. */typedef struct {	/* The index. */	uint_fast8_t ind;	/* The length. */	uint_fast16_t len;	/* The data. */	uchar *data;} jpc_ppm_t;/* PPT marker segment parameters. */typedef struct {	/* The index. */	uint_fast8_t ind;	/* The length. */	uint_fast32_t len;	/* The data. */	unsigned char *data;} jpc_ppt_t;/**************************************\* COM marker segment parameters.\**************************************//* * Registration IDs. */#define	JPC_COM_BIN		0x00#define	JPC_COM_LATIN	0x01typedef struct {	/* The registration ID. */	uint_fast16_t regid;	/* The length of the data in bytes. */	uint_fast16_t len;	/* The data. */	uchar *data;} jpc_com_t;/**************************************\* SOP marker segment parameters.\**************************************/typedef struct {	/* The sequence number. */	uint_fast16_t seqno;} jpc_sop_t;/**************************************\* CRG marker segment parameters.\**************************************//* Per component information. */typedef struct {	/* The horizontal offset. */	uint_fast16_t hoff;	/* The vertical offset. */	uint_fast16_t voff;} jpc_crgcomp_t;typedef struct {	/* The number of components. */	int numcomps;	/* Per component information. */	jpc_crgcomp_t *comps;} jpc_crg_t;/**************************************\* Marker segment parameters for unknown marker type.\**************************************/typedef struct {	/* The data. */	uchar *data;	/* The length. */	uint_fast16_t len;} jpc_unk_t;/**************************************\* Generic marker segment parameters.\**************************************/typedef union {	int soc;	/* unused */	jpc_sot_t sot;	int sod;	/* unused */	int eoc;	/* unused */	jpc_siz_t siz;	jpc_cod_t cod;	jpc_coc_t coc;	jpc_rgn_t rgn;	jpc_qcd_t qcd;	jpc_qcc_t qcc;	jpc_poc_t poc;	/* jpc_plm_t plm; */	/* jpc_plt_t plt; */	jpc_ppm_t ppm;	jpc_ppt_t ppt;	jpc_sop_t sop;	int eph;	/* unused */	jpc_com_t com;	jpc_crg_t crg;	jpc_unk_t unk;} jpc_msparms_t;/**************************************\* Marker segment.\**************************************//* Marker segment IDs. *//* The smallest valid marker value. */#define	JPC_MS_MIN	0xff00/* The largest valid marker value. */#define	JPC_MS_MAX	0xffff/* The minimum marker value that cannot occur within packet data. */#define	JPC_MS_INMIN	0xff80/* The maximum marker value that cannot occur within packet data. */#define	JPC_MS_INMAX	0xffff/* Delimiting marker segments. */#define	JPC_MS_SOC	0xff4f /* Start of code stream (SOC). */#define	JPC_MS_SOT	0xff90 /* Start of tile-part (SOT). */#define	JPC_MS_SOD	0xff93 /* Start of data (SOD). */#define	JPC_MS_EOC	0xffd9 /* End of code stream (EOC). *//* Fixed information marker segments. */#define	JPC_MS_SIZ	0xff51 /* Image and tile size (SIZ). *//* Functional marker segments. */#define	JPC_MS_COD	0xff52 /* Coding style default (COD). */#define JPC_MS_COC	0xff53 /* Coding style component (COC). */#define	JPC_MS_RGN	0xff5e /* Region of interest (RGN). */#define JPC_MS_QCD	0xff5c /* Quantization default (QCD). */#define JPC_MS_QCC	0xff5d /* Quantization component (QCC). */#define JPC_MS_POC	0xff5f /* Progression order default (POC). *//* Pointer marker segments. */#define	JPC_MS_TLM	0xff55 /* Tile-part lengths, main header (TLM). */#define	JPC_MS_PLM	0xff57 /* Packet length, main header (PLM). */#define	JPC_MS_PLT	0xff58 /* Packet length, tile-part header (PLT). */#define	JPC_MS_PPM	0xff60 /* Packed packet headers, main header (PPM). */#define	JPC_MS_PPT	0xff61 /* Packet packet headers, tile-part header (PPT). *//* In bit stream marker segments. */#define	JPC_MS_SOP	0xff91	/* Start of packet (SOP). */#define	JPC_MS_EPH	0xff92	/* End of packet header (EPH). *//* Informational marker segments. */#define	JPC_MS_CRG	0xff63 /* Component registration (CRG). */#define JPC_MS_COM	0xff64 /* Comment (COM). *//* Forward declaration. */struct jpc_msops_s;/* Generic marker segment class. */typedef struct {	/* The type of marker segment. */	uint_fast16_t id;	/* The length of the marker segment. */	uint_fast16_t len;	/* The starting offset within the stream. */	uint_fast32_t off;	/* The parameters of the marker segment. */	jpc_msparms_t parms;	/* The marker segment operations. */	struct jpc_msops_s *ops;} jpc_ms_t;/* Marker segment operations (which depend on the marker segment type). */typedef struct jpc_msops_s {	/* Destroy the marker segment parameters. */	void (*destroyparms)(jpc_ms_t *ms);	/* Get the marker segment parameters from a stream. */	int (*getparms)(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *in);	/* Put the marker segment parameters to a stream. */	int (*putparms)(jpc_ms_t *ms, jpc_cstate_t *cstate, jas_stream_t *out);	/* Dump the marker segment parameters (for debugging). */	int (*dumpparms)(jpc_ms_t *ms, FILE *out);} jpc_msops_t;/******************************************************************************\* Macros/Functions.\******************************************************************************//* Create a code-stream state object. */jpc_cstate_t *jpc_cstate_create(void);/* Destroy a code-stream state object. */void jpc_cstate_destroy(jpc_cstate_t *cstate);/* Create a marker segment. */jpc_ms_t *jpc_ms_create(int type);/* Destroy a marker segment. */void jpc_ms_destroy(jpc_ms_t *ms);/* Does a marker segment have parameters? */#define	JPC_MS_HASPARMS(x) \	(!((x) == JPC_MS_SOC || (x) == JPC_MS_SOD || (x) == JPC_MS_EOC || \	  (x) == JPC_MS_EPH || ((x) >= 0xff30 && (x) <= 0xff3f)))/* Get the marker segment type. */#define	jpc_ms_gettype(ms) \	((ms)->id)/* Read a marker segment from a stream. */jpc_ms_t *jpc_getms(jas_stream_t *in, jpc_cstate_t *cstate);/* Write a marker segment to a stream. */int jpc_putms(jas_stream_t *out, jpc_cstate_t *cstate, jpc_ms_t *ms);/* Copy code stream data from one stream to another. */int jpc_getdata(jas_stream_t *in, jas_stream_t *out, long n);/* Copy code stream data from one stream to another. */int jpc_putdata(jas_stream_t *out, jas_stream_t *in, long n);/* Dump a marker segment (for debugging). */void jpc_ms_dump(jpc_ms_t *ms, FILE *out);/* Read a 8-bit unsigned integer from a stream. */int jpc_getuint8(jas_stream_t *in, uint_fast8_t *val);/* Read a 16-bit unsigned integer from a stream. */int jpc_getuint16(jas_stream_t *in, uint_fast16_t *val);/* Read a 32-bit unsigned integer from a stream. */int jpc_getuint32(jas_stream_t *in, uint_fast32_t *val);/* Write a 8-bit unsigned integer to a stream. */int jpc_putuint8(jas_stream_t *out, uint_fast8_t val);/* Write a 16-bit unsigned integer to a stream. */int jpc_putuint16(jas_stream_t *out, uint_fast16_t val);/* Write a 32-bit unsigned integer to a stream. */int jpc_putuint32(jas_stream_t *out, uint_fast32_t val);#endif

⌨️ 快捷键说明

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