mktable.c
来自「ESS3890+SL原代码(1*16内存)」· C语言 代码 · 共 1,775 行 · 第 1/4 页
C
1,775 行
#else "unsigned short *",#endif "unsigned char *", "unsigned char *", "unsigned short *",#ifdef FLASH_UPDATE "char *",#endif };/************************************************************************ Compression*************************************************************************/int compress_osd_font(){#ifdef TWO_FIELDS_OSD /* ENGLISH */ process_fix(32, /* Height */ 160, /* Bytes per Charactor */ 1, /* One Space Font */ osd_efont, /* Bitmap */ sizeof(osd_efont), /* Size of Bitmap */ &fonts[ENGLISH_FONTS]); /* Result of compression */#ifdef BILINGUAL_OSD /* Simplified CHINESE */ /* CHINESE */ process_fix(32, 160, 2, /* Two spaces font */ osd_cfont, sizeof(osd_cfont), &fonts[CHINESE_FONTS]);#endif /* BILINGUAL_OSD */#else /* Default font */#ifdef USE_CN_HEADER#ifdef USE_VWCOMP /* ENGLISH */ process_fix(16, /* Height */ 96, /* Bytes per Charactor */ 1, /* One Space Font */ osd_efont, /* Bitmap */ sizeof(osd_efont), /* Size of Bitmap */ &fonts[ENGLISH_FONTS]); /* Result of compression */#ifdef BILINGUAL_OSD /* Simplified CHINESE */ /* CHINESE */ process_fix(16, 96, 2, /* Two spaces font */ osd_cfont, sizeof(osd_cfont), &fonts[CHINESE_FONTS]);#endif /* BILINGUAL_OSD */#else /* ENGLISH */ process_osdx2(16, /* Height */ 96, /* Bytes per Charactor */ 1, /* One Space Font */ (unsigned int *)osd_font00, /* Bitmap..1st-half */ (unsigned short *)osd_font01, /* Bitmap..2nd-half */ &fonts[ENGLISH_FONTS]); /* Result of compression */#ifdef BILINGUAL_OSD /* CHINESE */ process_osdx2(16, /* Height */ 96, /* Bytes per Charactor */ 2, /* Two Space Font */ (unsigned int *)osd_cfont00, /* Bitmap..1st-half */ (unsigned short *)osd_cfont01,/* Bitmap..2nd-half */ &fonts[CHINESE_FONTS]); /* Result of compression */#endif#endif /* USE_VWCOMP */#else process_osd(16, 96, 192, (unsigned int *) osd_font00, (unsigned int *) osd_cfont00, (unsigned short *) osd_font01, (unsigned short *) osd_cfont01);#endif /* USE_CN_HEADER */#endif /* TWO_FIELDS_OSD */} int compress_newicon(){#ifdef TWO_FIELDS_OSD process_osdvw(icondata, sizeof(icondata),&newiconfonts);#endif /* TWO_FIELDS_OSD */}main(){ int i, j; unsigned long tablesz = 0; FILE *fp, *fph; if ((fp = fopen("const.dat","wb")) == NULL) { fprintf(stderr, "mpeg2.dat open error!\n"); exit(1); } if ((fph = fopen("const.h", "w")) == NULL) { fprintf(stderr, "mpeg2.dat open error!\n"); exit(1); } compress_osd_font(); compress_newicon(); for (i = 0; i < MAX_TBL_NUM ; i++) { tablesz = output_table(i,fp); }#ifdef COMPRESS_MKTBL_DATA for (i = 0; i < compress_group_num; i++) output_compress_group(i,fp);#endif fprintf(fph, "/* Automatically generated header file. DO NOT EDIT. */\n\n"); fprintf(fph, "#ifdef INIT_CONST\n"); fprintf(fph, "unsigned long vcx_romdatastart = 0x8000;\n"); fprintf(fph, "#else\n"); fprintf(fph, "extern unsigned long vcx_romdatastart ;\n"); fprintf(fph, "#endif\n");#ifdef P2O fprintf(fph, "\ntypedef short filter_set[20];\n\n");#endif fprintf(fph, "/*\n * Size of each ROM-based table\n */\n"); for (i = 0; i < MAX_TBL_NUM ; i++) { fprintf(fph, "#define T_%s_SZ %d\n", tables[i].name, tables[i].size); }#ifdef COMPRESS_MKTBL_DATA for (i = 0; i< compress_group_num; i++) fprintf(fph, "#define T_GROUP_%s_SZ %d\n", compress_group[i].name, compress_group[i].table_size); #endif fprintf(fph, "\n"); fprintf(fph, "/*\n * Starting location of each ROM-based table\n*/\n"); tablesz = 0; for (i = 0; i < MAX_TBL_NUM ; i++) {#ifdef COMPRESS_MKTBL_DATA if (tables[i].type < CTYPE_BASE) #endif { fprintf(fph, "#define T_%s ", tables[i].name, tablesz); fprintf(fph, "(%s (vcx_romdatastart + 0x%lx))\n", type_def[tables[i].type-1], tablesz); tablesz += SIZE(tables[i].size); } }#ifdef COMPRESS_MKTBL_DATA for (i = 0; i< compress_group_num; i++) { fprintf(fph, "#define T_GROUP_%s ", compress_group[i].name); fprintf(fph, "((char *) (vcx_romdatastart + 0x%lx))\n", tablesz); tablesz += SIZE(compress_group[i].compress_size);#if 0 for (j = 0; j < compress_group[i].item_num; j++) { fprintf(fph, "#define T_%s ", compress_group[i].item_table[j].name); fprintf(fph, "(%s (UCODE_DATA_cached_start + 0x%lx))\n", type_def[compress_group[i].item_table[j].type - 1], compress_group[i].item_table[j].offset); }#endif }#endif fprintf(fph, "\n\n#ifdef INIT_CONST\n"); for (i = 0; i < MAX_TBL_NUM ; i++) { if (tables[i].genvar) { int data_type; data_type = tables[i].type;#ifdef COMPRESS_MKTBL_DATA if (data_type > CTYPE_BASE) data_type -= CTYPE_BASE;#endif fprintf(fph, "%s %s;\n", stype_def[data_type-1], tables[i].name); } }#ifdef CXDSERVO /* ugly, but CXD3059 has different filtertbl size..for release */ fprintf(fph,"int filtertbl_SZ;\n");#endif fprintf(fph, "#else\n"); for (i = 0; i < MAX_TBL_NUM ; i++) { if (tables[i].genvar) { int data_type; data_type = tables[i].type;#ifdef COMPRESS_MKTBL_DATA if (data_type > CTYPE_BASE) data_type -= CTYPE_BASE;#endif fprintf(fph, "extern %s %s;\n", stype_def[data_type-1], tables[i].name); } }#ifdef CXDSERVO /* ugly, but CXD3059 has different filtertbl size..for release */ fprintf(fph,"extern int filtertbl_SZ;\n");#endif fprintf(fph, "#endif\n"); /* Output defines for messages */ fprintf(fph, "\n/* Offset of OSD messages */\n"); for (i = 0; i < MAX_TBL_NUM; i++) { if ((tables[i].type == OSDMESSAGE) || (tables[i].type == VFDMSG) || (tables[i].type == VFDICON)) write_message_defines(i, fph); } fclose(fp); fclose(fph); fp = fopen("init_t.c","w"); fprintf(fp, "/* Init Constant Table */\n"); fprintf(fp, "#define INIT_CONST\n"); fprintf(fp, "#include \"const.h\"\n"); fprintf(fp, "Init_const()\n{\n"); for (i = 0; i < MAX_TBL_NUM ; i++) { if (tables[i].genvar) { fprintf(fp," %s = T_%s;\n", tables[i].name, tables[i].name); } }#ifdef CXDSERVO /* ugly, but CXD3059 has different filtertbl size..for release */ fprintf(fp," filtertbl_SZ = T_filtertbl_SZ;\n");#endif fprintf(fp, "}\n"); fclose(fp); exit(0);}unsigned longoutput_table(int tb, FILE *fp){ int i; unsigned long ndata; COMPFONT *pfonts; switch (tables[tb].type) { case SHORT: case USHORT: case FILTER_SET: ndata = write_short((short *)tables[tb].table, SIZE(tables[tb].size)/sizeof(short), fp); break; case FONT: ndata = write_short((short *)(*(int *)(tables[tb].table)), SIZE(tables[tb].size)/sizeof(short), fp); break; case CHAR: case UCHAR: ndata = write_char(tables[tb].table, SIZE(tables[tb].size), fp); break; case COMPFONTDATA:#ifdef USE_CN_HEADER pfonts = (COMPFONT *) tables[tb].table; tables[tb].size = pfonts->szCompFont; ndata = write_char(pfonts->osd_comp_font, SIZE(tables[tb].size), fp); tables[tb].table = pfonts->osd_comp_font;#else tables[tb].size = szCompFont + szCompCFont; ndata = write_char((unsigned char *)(*(int *)(tables[tb].table)), SIZE(tables[tb].size), fp);#endif break; case COMPFONTCODE:#ifdef USE_CN_HEADER pfonts = (COMPFONT *) tables[tb].table; tables[tb].size = pfonts->szCodeBook; ndata = write_char(pfonts->code_book, SIZE(tables[tb].size), fp); tables[tb].table = pfonts->code_book;#else tables[tb].size = szCodeBook; ndata = write_char((unsigned char *)(*(int *)(tables[tb].table)), SIZE(tables[tb].size), fp);#endif break; case COMPFONTOFFSET:#ifdef USE_CN_HEADER pfonts = (COMPFONT *) tables[tb].table; tables[tb].size = pfonts->szOffsetTbl * sizeof(long);#ifdef USE_VWCOMP# ifdef TWO_FIELDS_OSD ndata = write_long((long *)pfonts->osd_offset_tbl, SIZE(tables[tb].size)/sizeof(long), fp);# else /* store as short to save ROM (LC).. * i.e. 16bits can hold our largest offset. */ tables[tb].size = pfonts->szOffsetTbl * sizeof(long) / 2; ndata = write_short_dw((long *)pfonts->osd_offset_tbl, tables[tb].size/sizeof(short), fp);# endif /* TWO_FIELDS_OSD */#else ndata = write_short((short *)pfonts->osd_offset_tbl, SIZE(tables[tb].size)/sizeof(short), fp);#endif /* USE_VWCOMP */ tables[tb].table = (uchar *)pfonts->osd_offset_tbl;#else tables[tb].size = szOffsetTbl * 2; ndata = write_short((short *)(*(int *)(tables[tb].table)), SIZE(tables[tb].size)/sizeof(short), fp);#endif /* USE_CN_HEADER */ break; case INT: case UINT: case LONG: case ULONG: ndata = write_long((long *) tables[tb].table, SIZE(tables[tb].size)/sizeof(long), fp); break; case OSDMESSAGE: ndata = write_osdmsg((OSDMSG *) tables[tb].table, tb, fp); break; case VFDMSG: ndata = write_vfdmsg((VFD_MSG *) tables[tb].table, tb, fp); break; case VFDICON: ndata = write_vfdicon((VFD_ICON *) tables[tb].table, tb, fp); break; case ICONTBL: ndata = write_icontbl((unsigned short *) tables[tb].table, tb, fp); break; #ifdef FLASH_UPDATE case LOGO_4_UPDATE: ndata = write_logo(tables[tb].table, SIZE(tables[tb].size), fp); break;#endif#ifdef COMPRESS_MKTBL_DATA#ifdef COMPRESS_MP3_UCODE case C1_INT:#else case C_SHORT: case C_USHORT: case C_CHAR: case C_UCHAR: case C_INT: case C_UINT: case C_LONG: case C_ULONG:#endif register_for_compress(tb); break;#endif /* COMPRESS_MKTBL_DATA */ } return ndata;}/* write a long to file */unsigned long write_long(unsigned long *dataptr, long count, FILE *fp){ long i; unsigned long data; for (i = 0; i < count; i++) { data = *dataptr++; fputc( (unsigned char) ( (data>>24) & 0xff), fp); fputc( (unsigned char) ( (data>>16) & 0xff), fp); fputc( (unsigned char) ( (data>> 8) & 0xff), fp); fputc( (unsigned char) ( data & 0xff), fp); } return (count * sizeof(long));}/* write a short to file */unsigned long write_short(unsigned short *dataptr, long count, FILE *fp){ long i; unsigned short data; for (i = 0; i < count; i++) { data = *dataptr++; fputc( (unsigned char) ( (data>> 8) & 0xff), fp); fputc( (unsigned char) ( data & 0xff), fp); } return (count * sizeof(short));}/* write long data to file as short */unsigned long write_short_dw(unsigned long *dataptr, long count, FILE *fp){ long i; unsigned int data; for (i = 0; i < count; i++) { data = *dataptr++; fputc( (unsigned char) ( (data>> 8) & 0xff), fp); fputc( (unsigned char) ( data & 0xff), fp); if (data>>16) { fprintf(stderr, "Error in write_short_dw()..\n"); fprintf(stderr, "data exceeded 16bits: 0x%x\n", data); exit(1); } } if (count & 0x1) { /* stuffing data..for DW alignment */ fputc(0x00, fp); fputc(0x00, fp); count++; } return (count * sizeof(short));} /* write a char to file */unsigned long write_char(unsigned char *dataptr, long count, FILE *fp){ long i; unsigned char data; for (i = 0; i < count; i++) { data = *dataptr++; fputc( (unsigned char) data, fp); } return (count * sizeof(char));}#ifdef FLASH_UPDATE/* write logo to file..also reserve space for logo update */unsigned long write_logo(unsigned char *dataptr, long count, FILE *fp){ long i; unsigned char data; if (count > sizeof(powerupScreen)) count = sizeof(powerupScreen); /* copy logo */ for (i = 0; i < count; i++) { data = *dataptr++; fputc( (unsigned char) data, fp); } /* fill the rest of logo space with zero */ for ( ; i < MAX_LOGO_SZ; i++) { fputc( 0x00, fp); }
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?