好文档 - 专业文书写作范文服务资料分享网站

z i g z a g 压 缩 算 法( 2 0 2 0) 

天下 分享 时间: 加入收藏 我要投稿 点赞

bits_in_next_word; ? } ? } }? return output_ptr;}

static UINT8 *encodeMCU (JPEG_ENCODER_STRUCTURE * jpeg_encoder_structure,UINT32

image_format,

UINT8

*

output_ptr) {? DCT (Y1);? quantization (Y1, ILqt);? output_ptr = huffman (jpeg_encoder_structure, 1, output_ptr);? if (image_format == FOUR_ZERO_ZERO)? return output_ptr;? DCT (Y2);? quantization (Y2, ILqt);? output_ptr = huffman (jpeg_encoder_structure, 1, output_ptr);? if (image_format == FOUR_TWO_TWO)? goto chroma;? DCT (Y3);? quantization (Y3, ILqt);? output_ptr = huffman (jpeg_encoder_structure, 1, output_ptr);? DCT (Y4);? quantization (Y4, ILqt);? output_ptr = huffman (jpeg_encoder_structure, 1, output_ptr);chroma:DCT (CB);? quantization (CB, ICqt);? output_ptr = huffman (jpeg_encoder_structure, 2, output_ptr);? DCT (CR);? quantization

(CR,

ICqt);?

output_ptr

=

huffman

(jpeg_encoder_structure, 3, output_ptr);? return output_ptr;} UINT32 encode_image (UINT8 * input_ptr, UINT8 * output_ptr,UINT32 quality_factor, UINT32 image_format,UINT32 image_width, UINT32 image_height) {? UINT16 i, j;? UINT8 * output;?

JPEG_ENCODER_STRUCTURE

JpegStruct;?

JPEG_ENCODER_STRUCTURE * jpeg_encoder_structure = JpegStruct;? output = output_ptr;?image_format = FOUR_TWO_TWO;?RGB_2_422

(input_ptr, output_ptr, image_width, image_height);?-* Initialization of JPEG control structure *- ?initialization (jpeg_encoder_structure, image_width,?image_height); ?-*

Quantization

Table

Initialization image_format,

*- ?initialize_quantization_tables (quality_factor); ?-* Writing Marker Data *- ?output_ptr =?write_markers (output_ptr, image_format, image_width, image_height);?for (i = 1; i = jpeg_encoder_structure-vertical_mcus; i++)?{?if (i jpeg_encoder_structure-vertical_mcus)?jpeg_encoder_structure-rows

=

jpeg_encoder_structure-mcu_height;?else?jpeg_encoder_structure-rows =?jpeg_encoder_structure-rows_in_bottom_mcus;?for (j = 1; j = jpeg_encoder_structure-horizontal_mcus; j++)?{?if (j

jpeg_encoder_structure-horizontal_mcus)?{?jpeg_encoder_structure-cols

=?jpeg_encoder_structure-mcu_width;?jpeg_encoder_structure-incr

=?jpeg_encoder_structure-length_minus_mcu_width;?}?else?{?jpeg_encoder_structure-cols

=?jpeg_encoder_structure-cols_in_right_mcus;?jpeg_encoder_s

tructure-incr

=?jpeg_encoder_structure-length_minus_width;?}?read_format (jpeg_encoder_structure, input_ptr);?-* Encode the data in MCU *-

?output_ptr

=encodeMCU

(jpeg_encoder_structure,

+= += Routine

image_format, output_ptr);?input_ptr

jpeg_encoder_structure-mcu_width_size;?}?input_ptr jpeg_encoder_structure-offset;?}?-*

Close

*- ?output_ptr = close_bitstream (output_ptr);?return (UINT32) (output_ptr - output);}void main(){ ?int

size=1280*720*3,sizeout=0,x,y;?unsigned

char

*outpict ;?outpict?= (unsigned char *) malloc (size);?unsigned char *inpict ; ?inpict = (unsigned char *) malloc (size);?for(x=0;x1280;x++)--inpict初始化成RGB模式?for (y=0;y720;y++)?{?*(inpict+x*3+y*1280*3)=y%2;?*(inpict+x*3+y*1280*3+1)=x%2;?*(inpict+x*3+y*1280*3+2)=y%2;?}?sizeout encode_image (inpict,outpict,1,0,1280,720); ?free(outpict);?free(inpict);?return 1;}

2、使用加权函数对DCT系数进行量化,这个加权函数对于人的视觉系统是最佳的。?

exitmessage(\enough memory to alloc the structure need for decompressing\

public static byte[] compress(byte srcBytes[]) throws

=

IOException {

57,45,0,0,0,0,23,0,-30,-8,0,0,1,000. [+8] = [00001000]原 = [0000 1000]补

strides = matrix.itemsize * np.array([width * 8, 8, width, 1])

?游程编码的原理:?用一个符号值或串长代替具有相同值的连续符号,使符号长度少于原始数据长度。 ?--

Quantization

table

marker?*output_ptr++

=

0xFF;?*output_ptr++ = 0xDB;

function e = ZigIDCT(oldbuf,dctfre,x,n,t); throw new RuntimeException(e);

z i g z a g 压 缩 算 法( 2 0 2 0) 

bits_in_next_word;?}?}}?returnoutput_ptr;}staticUINT8*encodeMCU(JPEG_ENCODER_STRUCTURE*jpeg_encoder_structure,UINT32image_format,UINT8*output_ptr
推荐度:
点击下载文档文档为doc格式
4qrhw3xvcy0a6ri16ozy38gut0xt46013rd
领取福利

微信扫码领取福利

微信扫码分享