/* cb_resolve_grp: configure group input select,format and frame rate in_fmt: input format from every vi in_frm: input frame rate vgrp: point to video group total: total channel grpcnt: group count */ static int cb_resolve_grp(int *in_chnl, int *in_fmt, int *in_frm, VGROUP_S *vgrp, int total, int grpcnt) { int i = 0, j = 0, k = 0, d1_cnt = 0, halfd1_cnt = 0, temp = 0, cif_cnt = 0; int inval = 0; int format[ISIL_MAX_VI], frm_rate[ISIL_MAX_VI]; int temp_ch[ISIL_MAX_VI] = {0}; int d1_ptr, cif_ptr, dir = 0; unsigned int grp_map = 0x0; if((total <= 0) || (grpcnt <= 0)) { return 0; } memset(format, 0, sizeof(int) * ISIL_MAX_VI); memset(frm_rate, 0, sizeof(int) * ISIL_MAX_VI); for(i = 0; i < grpcnt; i++) { for(j = 0; j < ISIL_CHN_NO; j++) { vgrp[i].in_select[j] = ISIL_INVAL_CHN; vgrp[i].in_fmt[j] = ISIL_VIDEO_SIZE_USER; vgrp[i].in_rate[j] = -1; } } /*count d1, and sort by d1*/ for(i = 0, j = 0, k = 0; i < total; i++) { if(in_chnl[i] == ISIL_INVAL_CHN) { inval++; continue; } if((in_fmt[i] == ISIL_VIDEO_SIZE_D1) || (in_fmt[i] == ISIL_VIDEO_SIZE_HALF_D1) || (in_fmt[i] == ISIL_VIDEO_SIZE_4CIF) || (in_fmt[i] == ISIL_VIDEO_SIZE_2CIF)) { temp_ch[j] = in_chnl[i]; format[j] = in_fmt[i]; frm_rate[j] = in_frm[i]; d1_cnt++; if((in_fmt[i] == ISIL_VIDEO_SIZE_HALF_D1) || (in_fmt[i] == ISIL_VIDEO_SIZE_2CIF)) { halfd1_cnt++; } j++; } else { temp_ch[total - k - 1] = in_chnl[i]; format[total - k - 1] = in_fmt[i]; frm_rate[total - k - 1] = in_frm[i]; k++; } } total -= inval; /*L->H sort d1 by frame*/ for(i = 0; i < (d1_cnt - 1); i++) { for(j = i; j < d1_cnt; j++) { if(frm_rate[i] > frm_rate[j]) { temp = temp_ch[i]; temp_ch[i] = temp_ch[j]; temp_ch[j] = temp; temp = format[i]; format[i] = format[j]; format[j] = temp; temp = frm_rate[i]; frm_rate[i] = frm_rate[j]; frm_rate[j] = temp; } } } /*L->H sort cif by frame*/ for(i = d1_cnt; i < total -1; i++) { for(j = i; j < total; j++) { if(frm_rate[i] > frm_rate[j]) { temp = temp_ch[i]; temp_ch[i] = temp_ch[j]; temp_ch[j] = temp; temp = format[i]; format[i] = format[j]; format[j] = temp; temp = frm_rate[i]; frm_rate[i] = frm_rate[j]; frm_rate[j] = temp; } } } cif_cnt = total - d1_cnt; /*channel limit*/ //memset(vgrp, 0x0, sizeof(VGROUP_S) * grpcnt); if(total <= grpcnt) { for(i = 0; i < total; i++) { vgrp[i].in_select[0] = temp_ch[i]; vgrp[i].in_fmt[0] = format[i]; vgrp[i].in_rate[0] = frm_rate[i]; vgrp[i].total = 1; } return 0; } if((d1_cnt <= grpcnt) || (d1_cnt == total) || (halfd1_cnt == total)) { /* for(i = 0, j = 0, k = 0; j < total ; i++, j++) { if(i == grpcnt) { i = 0; k++; } vgrp[i].total = k + 1; vgrp[i].in_select[k] = temp_ch[j]; vgrp[i].in_fmt[k] = format[j]; vgrp[i].in_rate[k] = frm_rate[j]; } return 0; */ grp_map = 0xffffffff; }else{ grp_map = GROUP_MAP[locate_map(d1_cnt, cif_cnt)]; } if(!grp_map) { /*don't exsit map*/ ISIL_DBG(ISIL_DBG_ERR, "don't exsit map, %dD1 + %dCIF\n", d1_cnt, cif_cnt); return -1; } d1_ptr = d1_cnt - 1; cif_ptr= d1_cnt; for(j = 0; j < grpcnt; j++){ dir = !dir; if(dir){ for(i = (grpcnt - 1); i >= 0; i--){ if(grp_map & (0x80000000 >> (i * ISIL_CHN_NO + j)))/*mask D1*/ { if(d1_ptr < 0){ continue; } vgrp[i].in_select[j] = temp_ch[d1_ptr]; vgrp[i].in_fmt[j] = format[d1_ptr]; vgrp[i].in_rate[j] = frm_rate[d1_ptr]; vgrp[i].total++; d1_ptr--; } } }else{ for(i = 0; i < grpcnt; i++){ if(grp_map & (0x80000000 >> (i * ISIL_CHN_NO + j)))/*mask D1*/ { if(d1_ptr < 0){ continue; } vgrp[i].in_select[j] = temp_ch[d1_ptr]; vgrp[i].in_fmt[j] = format[d1_ptr]; vgrp[i].in_rate[j] = frm_rate[d1_ptr]; vgrp[i].total++; d1_ptr--; } } } }
//�������������������������������������������������������������������������Ŀ // capture_mtlbitmap � // � // Attempts to locate and load the map bitmap file given. � //��������������������������������������������������������������������������� BXPColor *capture_mtlbitmap(char *fname, int locate, ushort *xs, ushort *ys, int forcesize) { int i; int desirex; int desirey; BXPColor *bm; BXPColor *tbm; BitmapInfo binfo; char fullname[256]; if (!locate) strcpy(fullname,fname); else if (!locate_map(fname,fullname)) return NULL; //��� Load image gfx_bitmap_info(fullname,&binfo, i); if (i != 1) return NULL; if ((bm=malloc(binfo.width * binfo.height * sizeof(BXPColor)))==0) return NULL; gfx_load_bitmap(fullname, binfo.width, binfo.height, bm, i); if (i < 1) { free(bm); return NULL; } //��� Check for resize if (forcesize) { desirex = *xs; desirey = *ys; } else if (mtl_sizemode == 3) { do_query(fname,binfo.width,binfo.height,1); desirex = query_xsize; desirey = query_ysize; } else if (mtl_sizemode == 2) { desirex = mtl_sizex; desirey = mtl_sizey; } else { // Must set size to 16, 32, 64, 128, or 256 desirex=16; desirey=16; if (binfo.width > desirex) desirex=32; if (binfo.height > desirey) desirey=32; if (binfo.width > desirex) desirex=64; if (binfo.height > desirey) desirey=64; if (binfo.width > desirex) desirex=128; if (binfo.height > desirey) desirey=128; if (binfo.width > desirex) desirex=256; if (binfo.height > desirey) desirey=256; } //��� Perform resize if (desirex != binfo.width || desirey != binfo.height) { tbm = bm; if ((bm = malloc(desirex * desirey * sizeof(BXPColor)))==0) { free(tbm); return 0; } gfx_resize_bitmap(tbm, binfo.width, binfo.height, bm, desirex, desirey, i); free(tbm); if (i < 1) { free(bm); return 0; } } //��� Return final image *xs = desirex; *ys = desirey; return bm; }