📄 debug.c
字号:
case 5: fprintf(fp, "V-sync. Field %d. Count %d. Frame %d. Next %d.", what->a0, what->a1, what->a2, what->a3); break;#endif#ifdef LOG_PIC case 6: fprintf(fp, "Found %c%d. 1st_seek %d. found_I %d.", typestr[what->a0], what->a1, what->a2, what->a3); break; case 7: fprintf(fp, "Finished %c%d. Next %c%d", typestr[what->a0],what->a1,typestr[what->a2],what->a3); break; case 8: fprintf(fp, "Finished %c%d. Next start-code %2x", typestr[what->a0], what->a1, what->a2); break; case 11: fprintf(fp, "Decoding can proceed. Ready to switch."); break; case 12: fprintf(fp, "Startcode %2x.", what->a0); break; case 13: fprintf(fp, "Startcode %2x. Seen_slice %d, huff_state %d", what->a0,what->a1,what->a2); break; case 14: fprintf(fp, "DISP_frame set to %d. Curr %d, Prev %d.", what->a0, what->a1, what->a2); break; case 15: fprintf(fp, "Reset vscale."); break;#endif#ifdef LOG_BUF case 20: fprintf(fp, "VBV grown by %d. wr %d. rd %d", what->a0, what->a1, what->a2); break; case 21: fprintf(fp, "ABV grown by %d. wr %d. rd %d", what->a0, what->a1, what->a2); break;#endif#ifdef LOG_CMDQ case 22: fprintf(fp, "before set_iquant: __LINE__: %d, cmdq_num: %d", what->a0, what->a1); break; case 23: fprintf(fp, "before intra_rla: __LINE__: %d, cmdq_num: %d", what->a0, what->a1); break; case 24: fprintf(fp, "before mpeg_intra_UV: __LINE__: %d, cmdq_num: %d", what->a0, what->a1); break;#endif#ifdef LOG_KARA case 25: fprintf(fp, "W_DPCM(%d): from_ptr=%d, dx=%d, dy=%d", what->a3, what->a0, what->a1, what->a2); break; case 26: fprintf(fp, "R_DPCM: to_ptr=%lx, dx*dy=%d", (what->a0<<2)+0x12000000, what->a1); break;#endif#ifdef LOG_BEAM case 30: fprintf(fp, "No beam race. early %d, count %d.", what->a0, what->a1); break; case 31: fprintf(fp, "Beam race succeed. row %d, beam %d.", what->a0, what->a1); break;#endif#ifdef LOG_TAKEOUT case 40: fprintf(fp, "Scale takeout UV. addr "); fprintf(fp, "%d, vadd %d, line_end %d, colY %d, width %d.", what->a0, what->a1, what->a2, what->a3, what->a4); break; case 41: fprintf(fp, "Scale takeout Y. "); fprintf(fp, "addr %d, line_end %d, colY %d, width %d.", what->a0, what->a1, what->a2, what->a3); break; case 42: fprintf(fp, "Video takeout UV. dram_mb_addr_UV "); fprintf(fp, "%d, Vadd %d, line_end %d.", what->a0, what->a1, what->a2); break; case 43: fprintf(fp, "Video takeout Y. "); fprintf(fp, "dram_mb_addr_Y %d, line_end %d.", what->a0, what->a1); break;#endif#ifdef LOG_TALK case 50: fprintf(fp, "Wait hirq timeout. "); break; case 51: fprintf(fp, "hirq. "); break; case 52: fprintf(fp, "Hellen said 0x%x. ", what->a0); break; case 53: fprintf(fp, "I said 0x%x. ", what->a0); break; case 54: fprintf(fp, "Disabled hirq. "); break; case 55: fprintf(fp, "Enabled hirq. "); break; case 56: fprintf(fp, "Wake hellen. "); break; case 57: fprintf(fp, "Write hellen 0x%x. ", what->a0); break; case 58: fprintf(fp, "Read hellen. "); break; case 59: fprintf(fp, "hirq exit. "); break;#endif#ifdef SCALING_TIMING case 70: fprintf(fp, "DC %d, DL %d, PType %d NPType %d.", what->a0, what->a1, what->a2, what->a3); break; case 71: fprintf(fp, "CF %d, PF %d, SF %d.", what->a0, what->a1, what->a2); break;#endif#ifdef LOG_ERR case 99: switch (what->a0) { case 1: fprintf(fp, "VBV overflow. Space %d. v_in_progress %d", what->a1, what->a2); break; case 2: fprintf(fp, "ABV overflow. Space %d. v_in_progress %d", what->a1, what->a2); break; case 3: fprintf(fp, "PCM underflow. Data %d. v_in_progress %d", what->a1, what->a2); break; case 4: fprintf(fp, "Audio foxhunt %d. Frame %d.", what->a1, what->a2); break; case 5: fprintf(fp, "Audio misc error %d. Frame %d.", what->a1, what->a2); break; case 6: fprintf(fp, "Video misc error."); break; case 8: fprintf(fp, "ABV disaster. Space %d, Alarm %d.", what->a1, what->a2); break; case 9: fprintf(fp, "VBV disaster. Space %d, Alarm %d.", what->a1, what->a2); break; case 10: fprintf(fp, "VBV skip a field."); break; case 11: fprintf(fp, "Too slow."); break; case 12: fprintf(fp, "Video is way ahead."); break; }#endif }#ifdef TRACE_PCM_TOO fprintf(fp, " abv=%d, vbv=%d, pcm_raw=%d, pcm=%d.", what->abv, what->vbv, what->pcm_raw, what->pcm);#else fprintf(fp, " abv=%d, vbv=%d.", what->abv, what->vbv);#endif if (event == what) fprintf(fp, " <--- earliest\n"); else fprintf(fp, "\n"); }}int DBG_show_event_history(){ DBG_print_event_history(stdout);}int DBG_dump_event_history(){ FILE *fp; fp = fopen("trace", "w"); DBG_print_event_history(fp); fclose(fp);}#endif/*************************************************************************** Dump data that continuously comes into the audio buffer to a file. ***************************************************************************/#ifdef DUMP_ABVvoid DBG_dump_abv_continuously_non_real_time(s, start, stop)char *s; /* File name */int start; /* Start dumping after being called that many times */int stop; /* Stop dumping after being called that many times */{ static int fp = 0; static int count = 0; int n; if (fp==0) { fp = open(s, O_BINARY | O_WRONLY | O_CREAT | O_TRUNC); if (fp==0) { printf("Can't open %s\n", s); DBG_console(); } } n = ABV_wrptr - ABV_rdptr; if (n < 0) { n = ABV_end - ABV_rdptr; } if (count >= start) { while (n >= 2048) { write(fp, dram(ABV_rdptr), 2048*4); ABV_rdptr += 2048; n -= 2048; } if (n) { write(fp, dram(ABV_rdptr), n*4); ABV_rdptr += n; } } else { ABV_rdptr += n; } if (ABV_rdptr >= ABV_end) ABV_rdptr = ABV_start; if (count == stop) { close(fp); DBG_console(); } count++;}#endif/*************************************************************************** Dump the PCM buffer to a file when it becomes full. ***************************************************************************/#ifdef DUMP_PCM_WHEN_FULL#ifdef DUMP_PCM_CONTINUOUSLYvoid DBG_dump_pcm_when_full(void){ static int fp = -1; if (PCM_raw_wrptr == PCM_start) { fp = DBG_dump_memory((char *)dram(PCM_start), PCM_size*4, fp, "audio.pcm")); }}#elsevoid DBG_dump_pcm_when_full(void){ if (PCM_raw_wrptr == PCM_start) { printf("Dumping the entire PCM buffer to audio.pcm..."); close(DBG_dump_memory(dram(PCM_start), PCM_size*4, -1, "audio.pcm")); printf("done\n"); DBG_console(); }}#endif#endif/*************************************************************************** Check elapsed time. ***************************************************************************/#ifdef MEASURE_TIMING#define N_TASK 7static int avg_time[N_TASK] = {0, 0, 0, 0, 0, 0, 0};static int total_time[N_TASK] = {0, 0, 0, 0, 0, 0, 0};static int count_n[N_TASK] = {0, 0, 0, 0, 0, 0, 0};static int start_time[N_TASK];static int check_mark = 512;static char what_material[N_TASK][8] = {"", "Audio", "Video", "Karaoke", "CDDA", "Scaling", "Echo"};int stop_timing = 0;void DBG_check_elapsed_every(int n){ check_mark = n;}void DBG_mark_current_time(int i){ start_time[i] = mvd[riface_timer2];}void DBG_check_elapsed(int i){ int j; static int m = 0; int elapsed = mvd[riface_timer2] - start_time[i]; if (!stop_timing) if (elapsed > 0) { total_time[i] += elapsed; count_n[i]++; m++; if (m == check_mark) { for (j=1; j<N_TASK; j++) { if (count_n[j]) { avg_time[j] = total_time[j]/count_n[j]; count_n[j] = 0; total_time[j] = 0; spoolkeyvar(avg_time+j); } } m = 0; } }}#endif/*************************************************************************** Poor man's viewgraphics. ***************************************************************************/#ifdef VIEWstatic DISP_Info view_info[25];static int view_dx, view_dy;int view_stop = 0;int view_speed = 1;int view_dir = 0;int view_mode = 1;int view_scratch = 0;static int round4(int x){ if (x%4) x = (x>>2)+1; return(x>>2);}static int proc_frame_define(){ int start, n; int i, cY, cUV, y_size, uv_size, y_size_compressed, uv_size_compressed ; int y_dx, y_dx_compressed; int uv_dx, uv_dx_compressed; vcx_osd_on = 0; mvd[buscon_dram_control] = 0x0200 + (5<<6) + 4; buscon_irq_disable(buscon_xportv_runbit); buscon_irq_disable(buscon_xporta_runbit); buscon_irq_disable(buscon_hufdecv_runbit); buscon_irq_disable(buscon_hufdeca_runbit); buscon_irq_disable(buscon_d2a_runbit); printf("Horizontal size(d), vertical size(d): "); scanf("%d, %d", &view_dx, &view_dy); DISP_change_resolution(view_dx, view_dy); printf("# of frames(d): "); scanf("%d", &n); /* In bytes */ y_size = view_dx * view_dy; uv_size = y_size>>2; y_size_compressed = (y_size * 3)>>2; uv_size_compressed = (uv_size * 3)>>2; /* Now in dwords */ y_size = round4(y_size); uv_size = round4(uv_size); y_size_compressed = round4(y_size_compressed); uv_size_compressed = round4(uv_size_compressed); start = view_scratch + y_size; y_dx = view_dx >> 2; /* no of dwords */ y_dx_compressed = (y_dx * 3)>>2; /* no of dwords */ uv_dx = view_dx >> 3; /* no of dwords */ uv_dx_compressed = (uv_dx * 3)>>2; /* no of dwords */ printf("Luma/chroma compression status for each frame(d): "); for (i=0; i<n; i++) { scanf("%d, %d", &cY, &cUV); view_info[i].startY = start; start += (cY) ? y_size_compressed : y_size; view_info[i].startU = start; view_info[i].startV = start + ((cUV) ? uv_dx_compressed : uv_dx); start += (cUV) ? 2*uv_size_compressed : 2*uv_size; view_info[i].zY = (cY) ? 0x8000 : 0; view_info[i].zUV = (cUV) ? 0x8000 : 0; view_info[i].wY = (cY) ? y_dx_compressed : y_dx; view_info[i].wUV = (cUV) ? uv_dx_compressed : uv_dx; view_info[i].height = view_dy; } DISP_info = view_info; mvd[vid_scn_y_wordsize] = y_dx - 1; mvd[vid_scn_uv_wordsize] = uv_dx; /* The following is only needed for full height screen dma of luma. Right now for full height we can't really mix compressed with non-compressed. */ mvd[buscon_dma_width2] = (cY)?y_dx_compressed:y_dx; return(0);}static void flip_msb(unsigned *x, int n){ int i; for (i=0; i<n>>2; i++) { *x = (*x) ^ 0x80808080; x++; }}static int load_component(int chroma, int start, int length, int offset, int fp, char *fname, int compressed){ char *address; int mode; if (chroma) mode = VPDMA_WIDTH2; else mode = VPDMA_WIDTH2 | VPDMA_INC2; address = (char *)dram(view_scratch); fp = DBG_load_memory(address, length, offset, fp, fname); flip_msb((unsigned *)address, length); { int scratch = view_scratch; int dx = view_dx>>2; int dx_compressed = dx; if (compressed) dx_compressed = (dx * 3)>>2; if (chroma) { dx /= 2; dx_compressed /= 2; } while (length > 0) { /* length is in bytes */ VP_xfer(NCMDQ_VP_xfer, VPCMD_W_DPCM, 0, 0, scratch, dx, 1); if (compressed) VP_xfer_bf(NCMDQ_VP_xfer, VPCMD_R_DPCM, 0, mode, start, dx, 1); else VP_xfer(NCMDQ_VP_xfer, VPCMD_R_DPCM, 0, mode, start, dx, 1); length -= dx<<2; scratch += dx; if (chroma) start += 2*dx_compressed; else start += dx_compressed; } } return(fp);}static int proc_frame_read(){ int i; int store, length, offset, nframes; int start, compressed; char fname[20]; int fp; printf("Filname: "); scanf("%s", fname); /* Everything in bytes */ printf("Store #(d), file offset(d), # of frames: "); scanf("%d,%d,%d", &store, &offset, &nframes); fp = -1; for (i=0; i<nframes; i++, store++) { DISP_frame = store; DISP_count = 0; compressed = DISP_info[store].zY; length = view_dx * view_dy; start = DISP_info[store].startY; fp = load_component(0, start, length, offset, fp, fname, compressed); compressed = DISP_info[store].zUV; length >>= 2; start = DISP_info[store].startU; fp = load_component(1, start, length, offset, fp, fname, compressed); start = DISP_info[store].startV; fp = load_component(2, start, length, offset, fp, fname, compressed); } return(0);}int proc_frame_run(){ int first, last, store; printf("First, last: "); scanf("%d,%d", &first, &last); view_stop = 0; store = first; while (1) { if (DISP_count > view_speed) { if (view_dir==0) { /* forward */ store++; if (store > last) { if (view_mode==1) { /* ping mode */ view_dir = 1; if (first==last) store = last; else store = last - 1; } else { store = first; } } } else { store--; if (store < first) { if (view_mode==1) { /* ping mode */ view_dir = 0; if (first==last) store = first; else store = first + 1; } else { store = last; } } } DISP_frame = store; DISP_count = 0; } dbg_console = 0; VCX_service(); if (view_stop) break; } return(0);}#endif#ifdef OH_MYuchar my_oh_my[512];int latest = 0;void oh_my(uchar x){ my_oh_my[latest++] = x; if (latest >= 512) latest = 0;}#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -