📄 sampjpeg.h
字号:
/********************************************************************************
// INTEL CORPORATION PROPRIETARY INFORMATION
// This software is supplied under the terms of a license agreement or
// nondisclosure agreement with Intel Corporation and may not be copied
// or disclosed except in accordance with the terms of that agreement.
// Copyright (c) 2003 Intel Corporation. All Rights Reserved.
//
// Description:
// Intel(R) Integrated Performance Primitives Sample Code
// JPEG Codec Definitions
//
********************************************************************************/
#ifndef _SAMPJPEG_H
#define _SAMPJPEG_H
#include "ippdefs.h"
#include "ippJP.h"
#include "sampdefs.h"
#ifdef __cplusplus
extern "C" {
#endif
/******************************************************
// Constant macro definitions
******************************************************/
#define JPEG_BI_RGB 0
#define JPEG_BI_BITFIELDS 3
#define JPEG_BGR888 2
#define JPEG_BGR555 4
#define JPEG_BGR565 8
#define JPEG_BLOCK_SIZE 64
#define JPEG_MCU_SIZE 384
#define JPEG_MCU_LINE 16
#define JPEG_MARKER_SOI 0xd8
#define JPEG_MARKER_SOS 0xda
#define JPEG_MARKER_EOI 0xd9
#define JPEG_MARKER_APP0 0xe0
#define JPEG_MARKER_DQT 0xdb
#define JPEG_MARKER_DHT 0xc4
#define JPEG_MARKER_SOF0 0xc0
/******************************************************
// Function macro definitions
******************************************************/
#define MAKE_MARKER_2B(ptr, marker)\
{\
*(ptr)++ = (Ipp8u)0xff;\
*(ptr)++ = (Ipp8u)(marker); \
}
#define MAKE_INT16_2B(ptr, value) \
{\
register int nTemp=(value);\
*(ptr)++ = (Ipp8u)((nTemp >> 8) & 0xff);\
*(ptr)++ = (Ipp8u)(nTemp & 0xff);\
}
#define MAKE_INT8_1B(ptr, value)\
{\
*(ptr)++ = (Ipp8u)(value); \
}
/******************************************************
// Data structure definitions
******************************************************/
typedef struct _IPPENCODEHUFFMANSPEC
{
Ipp32u huffSizeCode[256];
}jpeg_enc_huf_spec;
typedef struct _IPPDECODEHUFFMANSPEC
{
Ipp32u lookBitsVal[256];
Ipp16u huffVal[256];
Ipp32u mincodeptr[18];
Ipp16u maxcode[18];
}jpeg_dec_huf_spec;
typedef struct _jpeg_enc_state {
int width; /* Picture width in pixle number */
int height; /* Picture heigth in pixle number */
int step; /* Source picture line step */
int quality; /* Encoder quality indication: 1: high, 2: low */
int bits_per_pixel; /* bit number for every pixel */
int color_mode; /* Color mode: 2 - BGR 888, 4 - 555, 8 - 565 */
Ipp16s dc_pred[3]; /* DC prediction status */
Ipp16u lum_quant_table[64 + 7];/* Luminance quantization table */
Ipp16u chrom_quant_table[64 + 7]; /* Chrominance quantization table */
/* DC huffman table for Y */
jpeg_enc_huf_spec lum_dc_huffmansize_table;
/* AC huffman table for Y */
jpeg_enc_huf_spec lum_ac_huffmansize_table;
/* DC huffman table for Cb/Cr */
jpeg_enc_huf_spec chrom_dc_huffmansize_table;
/* AC huffman table for Cb/Cr */
jpeg_enc_huf_spec chrom_ac_huffmansize_table;
Ipp16s *work_buf; /* Temporary work buffer */
short *in_buf;
short *out_buf;
} jpeg_enc_state;
typedef struct _jpeg_dec_state {
int width; /* Picture width in pixle number */
int height; /* Picture heigth in pixle number */
int step; /* Source picture line step */
int color_mode; /* Color mode: 2 - BGR 888, 4 - 555, 8 - 565 */
Ipp16s dc_pred[3]; /* DC prediction status */
Ipp32s lum_quant_table[64 + 7]; /* Luminance quantization table */
Ipp32s chrom_quant_table[64 + 7]; /* Chrominance quantization table */
/* Raw quantization tables loaded from the bitstream */
/* Luminance quantization table of stream */
Ipp8u tmp_lum_quant_table[64 + 7];
/* Chrominance quantization table of stream */
Ipp8u tmp_chrom_quant_table[64 + 7];
/* DC huffman table for luminance */
jpeg_dec_huf_spec lum_dc_huffmansize_table;
/* AC huffman table for luminance */
jpeg_dec_huf_spec lum_ac_huffmansize_table;
/* DC huffman table for chrominance */
jpeg_dec_huf_spec chrom_dc_huffmansize_table;
/* AC huffman table for chrominance */
jpeg_dec_huf_spec chrom_ac_huffmansize_table;
/* Raw huffman tables loaded from the bitstream */
unsigned char lum_dc_huffbits[16]; /* Huffbits for luminance DC */
unsigned char lum_dc_huffvalues[16]; /* Huffvalue for luminance DC */
unsigned char chrom_dc_huffbits[16]; /* Huffbits for chrominance DC */
unsigned char chrom_dc_huffvalues[16]; /* Huffvalue for chrominance DC */
unsigned char lum_ac_huffbits[16]; /* Huffbits for luminance AC */
unsigned char lum_ac_huffvalues[162]; /* Huffvalue for luminance AC */
unsigned char chrom_ac_huffbits[16]; /* Huffbits for chrominance AC */
unsigned char chrom_ac_huffvalues[162];/* Huffvalue for chrominance DC */
Ipp16s *work_buf; /* Temporary work buffer */
} jpeg_dec_state;
/******************************************************
// Tables declaration
******************************************************/
extern unsigned char l_lum_quant_table[64];
extern unsigned char l_chrom_quant_table[64];
extern unsigned char h_lum_quant_table[64];
extern unsigned char h_chrom_quant_table[64];
extern unsigned char lum_dc_huffbits[];
extern unsigned char lum_dc_huffvalues[];
extern unsigned char chrom_dc_huffbits[];
extern unsigned char chrom_dc_huffvalues[];
extern unsigned char lum_ac_huffbits[];
extern unsigned char lum_ac_huffvalues[];
extern unsigned char chrom_ac_huffbits[];
extern unsigned char chrom_ac_huffvalues[];
extern const unsigned char zig_zag_tab_index[64];
/******************************************************
// Extern help functions declaration
******************************************************/
extern sample_status read_bmp_file(FILE *src, jpeg_enc_state *enc_state,
int *color_mode, int *data_size);
extern void write_sos_information(sample_bitstream *dst_bitstream);
extern void write_head_information(sample_bitstream *dst_bitsream,
jpeg_enc_state *enc_state);
extern sample_status read_jpeg_header(char **stream,
jpeg_dec_state *dec_state);
extern sample_status read_sos(char **stream);
/******************************************************
// High-level function declaration
******************************************************/
extern sample_status encoder_init_alloc_jpeg(FILE *src, int quality_ind,
jpeg_enc_state *enc_state,
sample_picture *picture,
sample_bitstream *bitstream);
extern sample_status encoder_free_jpeg(jpeg_enc_state *enc_state);
extern sample_status encode_jpeg(sample_picture *src_picture,
sample_bitstream *dst_stream,
jpeg_enc_state *enc_state);
extern sample_status decoder_init_alloc_jpeg(FILE *src,
jpeg_dec_state *dec_state,
sample_bitstream *bitstream,
sample_picture *picture);
extern sample_status decode_jpeg(sample_bitstream *bitstream,
sample_picture *picture,
jpeg_dec_state *dec_state);
extern sample_status decoder_free_jpeg(sample_bitstream *stream,
sample_picture *picture,
jpeg_dec_state *dec_state);
#ifdef __cplusplus
}
#endif
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -