decoders.c

来自「mpeng Lib」· C语言 代码 · 共 936 行 · 第 1/3 页

C
936
字号
0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, 0x0011, };unsigned short int dct_coeff_first[256] = {0xffff, 0xffff, 0xffff, 0xffff, 0xf7d5, 0xf7d5, 0xf7d5, 0xf7d5, 0x0826, 0x0826, 0x2416, 0x2416, 0x0046, 0x0046, 0x2016, 0x2016, 0x1c15, 0x1c15, 0x1c15, 0x1c15, 0x1815, 0x1815, 0x1815, 0x1815, 0x0425, 0x0425, 0x0425, 0x0425, 0x1415, 0x1415, 0x1415, 0x1415, 0x3417, 0x0067, 0x3017, 0x2c17, 0x0c27, 0x0437, 0x0057, 0x2817, 0x0034, 0x0034, 0x0034, 0x0034, 0x0034, 0x0034, 0x0034, 0x0034, 0x1014, 0x1014, 0x1014, 0x1014, 0x1014, 0x1014, 0x1014, 0x1014, 0x0c14, 0x0c14, 0x0c14, 0x0c14, 0x0c14, 0x0c14, 0x0c14, 0x0c14, 0x0023, 0x0023, 0x0023, 0x0023, 0x0023, 0x0023, 0x0023, 0x0023, 0x0023, 0x0023, 0x0023, 0x0023, 0x0023, 0x0023, 0x0023, 0x0023, 0x0813, 0x0813, 0x0813, 0x0813, 0x0813, 0x0813, 0x0813, 0x0813, 0x0813, 0x0813, 0x0813, 0x0813, 0x0813, 0x0813, 0x0813, 0x0813, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0412, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, 0x0010, };/* Macro for filling up the decoding table for mb_addr_inc */#define ASSIGN1(start, end, step, val, num) \  for (i = start; i < end; i+= step) { \    for (j = 0; j < step; j++) { \      mb_addr_inc[i+j].value = val; \      mb_addr_inc[i+j].num_bits = num; \    } \    val--; \    }/* *-------------------------------------------------------------- * * init_mb_addr_inc -- * *	Initialize the VLC decoding table for macro_block_address_increment * * Results: *	The decoding table for macro_block_address_increment will *      be filled; illegal values will be filled as ERROR. * * Side effects: *	The global array mb_addr_inc will be filled. * *-------------------------------------------------------------- */static voidinit_mb_addr_inc(void){  int i, j, val;  for (i = 0; i < 8; i++) {    mb_addr_inc[i].value = ERROR;    mb_addr_inc[i].num_bits = 0;  }  mb_addr_inc[8].value = MACRO_BLOCK_ESCAPE;  mb_addr_inc[8].num_bits = 11;  for (i = 9; i < 15; i++) {    mb_addr_inc[i].value = ERROR;    mb_addr_inc[i].num_bits = 0;  }  mb_addr_inc[15].value = MACRO_BLOCK_STUFFING;  mb_addr_inc[15].num_bits = 11;  for (i = 16; i < 24; i++) {    mb_addr_inc[i].value = ERROR;    mb_addr_inc[i].num_bits = 0;  }  val = 33;  ASSIGN1(24, 36, 1, val, 11);  ASSIGN1(36, 48, 2, val, 10);  ASSIGN1(48, 96, 8, val, 8);  ASSIGN1(96, 128, 16, val, 7);  ASSIGN1(128, 256, 64, val, 5);  ASSIGN1(256, 512, 128, val, 4);  ASSIGN1(512, 1024, 256, val, 3);  ASSIGN1(1024, 2048, 1024, val, 1);}/* Macro for filling up the decoding table for mb_type */#define ASSIGN2(start, end, quant, motion_forward, motion_backward, pattern, intra, num, mb_type) \  for (i = start; i < end; i ++) { \    mb_type[i].mb_quant = quant; \    mb_type[i].mb_motion_forward = motion_forward; \    mb_type[i].mb_motion_backward = motion_backward; \    mb_type[i].mb_pattern = pattern; \    mb_type[i].mb_intra = intra; \    mb_type[i].num_bits = num; \  }	 /* *-------------------------------------------------------------- * * init_mb_type_P -- * *	Initialize the VLC decoding table for macro_block_type in *      predictive-coded pictures. * * Results: *	The decoding table for macro_block_type in predictive-coded *      pictures will be filled; illegal values will be filled as ERROR. * * Side effects: *	The global array mb_type_P will be filled. * *-------------------------------------------------------------- */static voidinit_mb_type_P(void){  int i;  mb_type_P[0].mb_quant = mb_type_P[0].mb_motion_forward     = mb_type_P[0].mb_motion_backward = mb_type_P[0].mb_pattern       = mb_type_P[0].mb_intra = ERROR;  mb_type_P[0].num_bits = 0;  ASSIGN2(1, 2, 1, 0, 0, 0, 1, 6, mb_type_P)  ASSIGN2(2, 4, 1, 0, 0, 1, 0, 5, mb_type_P)  ASSIGN2(4, 6, 1, 1, 0, 1, 0, 5, mb_type_P);  ASSIGN2(6, 8, 0, 0, 0, 0, 1, 5, mb_type_P);  ASSIGN2(8, 16, 0, 1, 0, 0, 0, 3, mb_type_P);  ASSIGN2(16, 32, 0, 0, 0, 1, 0, 2, mb_type_P);  ASSIGN2(32, 64, 0, 1, 0, 1, 0, 1, mb_type_P);}/* *-------------------------------------------------------------- * * init_mb_type_B -- * *	Initialize the VLC decoding table for macro_block_type in *      bidirectionally-coded pictures. * * Results: *	The decoding table for macro_block_type in bidirectionally-coded *      pictures will be filled; illegal values will be filled as ERROR. * * Side effects: *	The global array mb_type_B will be filled. * *-------------------------------------------------------------- */static voidinit_mb_type_B(void){  int i;  mb_type_B[0].mb_quant = mb_type_B[0].mb_motion_forward     = mb_type_B[0].mb_motion_backward = mb_type_B[0].mb_pattern       = mb_type_B[0].mb_intra = ERROR;  mb_type_B[0].num_bits = 0;  ASSIGN2(1, 2, 1, 0, 0, 0, 1, 6, mb_type_B);  ASSIGN2(2, 3, 1, 0, 1, 1, 0, 6, mb_type_B);  ASSIGN2(3, 4, 1, 1, 0, 1, 0, 6, mb_type_B);  ASSIGN2(4, 6, 1, 1, 1, 1, 0, 5, mb_type_B);  ASSIGN2(6, 8, 0, 0, 0, 0, 1, 5, mb_type_B);  ASSIGN2(8, 12, 0, 1, 0, 0, 0, 4, mb_type_B);  ASSIGN2(12, 16, 0, 1, 0, 1, 0, 4, mb_type_B);  ASSIGN2(16, 24, 0, 0, 1, 0, 0, 3, mb_type_B);  ASSIGN2(24, 32, 0, 0, 1, 1, 0, 3, mb_type_B);  ASSIGN2(32, 48, 0, 1, 1, 0, 0, 2, mb_type_B);  ASSIGN2(48, 64, 0, 1, 1, 1, 0, 2, mb_type_B);}/* Macro for filling up the decoding tables for motion_vectors */#define ASSIGN3(start, end, step, val, num) \  for (i = start; i < end; i+= step) { \    for (j = 0; j < step / 2; j++) { \      motion_vectors[i+j].code = val; \      motion_vectors[i+j].num_bits = num; \    } \    for (j = step / 2; j < step; j++) { \      motion_vectors[i+j].code = -val; \      motion_vectors[i+j].num_bits = num; \    } \    val--; \  }/* *-------------------------------------------------------------- * * init_motion_vectors -- * *	Initialize the VLC decoding table for the various motion *      vectors, including motion_horizontal_forward_code,  *      motion_vertical_forward_code, motion_horizontal_backward_code, *      and motion_vertical_backward_code. * * Results: *	The decoding table for the motion vectors will be filled; *      illegal values will be filled as ERROR. * * Side effects: *	The global array motion_vector will be filled. * *-------------------------------------------------------------- */static voidinit_motion_vectors(void){  int i, j, val = 16;  for (i = 0; i < 24; i++) {    motion_vectors[i].code = ERROR;    motion_vectors[i].num_bits = 0;  }  ASSIGN3(24, 36, 2, val, 11);  ASSIGN3(36, 48, 4, val, 10);  ASSIGN3(48, 96, 16, val, 8);  ASSIGN3(96, 128, 32, val, 7);  ASSIGN3(128, 256, 128, val, 5);  ASSIGN3(256, 512, 256, val, 4);  ASSIGN3(512, 1024, 512, val, 3);  ASSIGN3(1024, 2048, 1024, val, 1);}/* *-------------------------------------------------------------- * * init_tables -- * *	Initialize all the tables for VLC decoding; this must be *      called when the system is set up before any decoding can *      take place.

⌨️ 快捷键说明

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