int mpeg2enc(int argc, char *argv[]) { stdin_fd = stdin; verbose = 1; /* Read command line */ readcmdline(argc, argv); /* read quantization matrices */ readquantmat(); if(!strlen(out_path)) { fprintf(stderr, "No output file given.\n"); } /* open output file */ if(!(outfile = fopen(out_path, "wb"))) { sprintf(errortext,"Couldn't create output file %s", out_path); error(errortext); } init(); if(nframes < 0x7fffffff) printf("Frame Completion Current bitrate Predicted file size\n"); putseq(); stop_slice_engines(); stop_motion_engines(); stop_transform_engines(); stop_itransform_engines(); fclose(outfile); fclose(statfile); if(qt_file) quicktime_close(qt_file); if(qt_output) quicktime_close(qt_output); if(mpeg_file) mpeg3_close(mpeg_file); if(do_stdin) { fclose(stdin_fd); } pthread_mutex_destroy(&input_lock); pthread_mutex_destroy(&output_lock); return 0; }
void mpeg2enc(UINT16 h_size,UINT16 v_size,UINT8* y_addr,UINT8* c_addr,UINT8* f_y_addr,UINT8* f_c_addr,UINT8* out_stream_buf,UINT32* out_stream_size) { UINT32 dest_size = *out_stream_size; if(dest_size == 0) dest_size = 32768; #if (CAPTURE_MODE==FRAME_CAPTURE) prog_frame = 0; g_mquant = 18; #else //(CAPTURE_MODE==FIELD_CAPTURE) prog_frame = 1; g_mquant = 10; #endif do{ g_bs_ptr = out_stream_buf; g_bs_len = 0; initparam(); /* round picture dimensions to nearest multiple of 16 or 32 */ mb_width = (h_size+15)/16; #if (CAPTURE_MODE==FRAME_CAPTURE) mb_height = prog_seq ? (v_size+15)/16 : 2*((v_size+31)/32); #else//(CAPTURE_MODE==FIELD_CAPTURE) mb_height = prog_seq ? (v_size/2+15)/16 : 2*((v_size/2+31)/32); #endif mb_height2 = fieldpic ? mb_height>>1 : mb_height; /* for field pictures */ luma_width = 16*mb_width; luma_height = 16*mb_height; chrom_width = luma_width>>1; chrom_height = luma_height>>1; width2 = fieldpic ? luma_width<<1 : luma_width; chrom_width2 = fieldpic ? chrom_width<<1 : chrom_width; block_count = 6;//420 neworg[0] = f_c_addr; neworg[1] = neworg[0]+luma_width*luma_height; neworg[2] = neworg[1]+chrom_width*chrom_height; format_transform(y_addr,c_addr,neworg[0],neworg[1],neworg[2],luma_width,luma_height); initquantmat(); initbits(); putseq(); //soc_printf("mquant:%d,bs_len:%d\n",g_mquant,g_bs_len); if(g_mquant == 62 && g_bs_len>dest_size) { soc_printf("ERROR: compressed size exceed buffer size!\n"); break; } if(g_bs_len*10/dest_size < 12) g_mquant +=2; else if(g_bs_len*10/dest_size < 15) g_mquant +=4; else if(g_bs_len*10/dest_size < 18) g_mquant +=6; else if(g_bs_len*10/dest_size < 21) g_mquant +=8; else g_mquant +=10; if(g_mquant > 62) g_mquant = 62; }while(g_bs_len > dest_size); *out_stream_size = g_bs_len; return ; }
int32 translate_out(int32 c) { int32 temp; char outstr[32]; if (spec200 == 1) { /* Special terminal control seq */ spec200 = 0; switch (c) { case 'C': /* read model ID */ return SCPE_OK; case 'E': /* Reverse video off */ return SCPE_OK; case 'D': /* Reverse video on */ return SCPE_OK; default: return SCPE_OK; } } if (curpos == 1) { /* 2nd char of cursor position */ col = c & 0x7f; curpos++; return (SCPE_OK); } if (curpos == 2) { /* 3rd char of cursor position */ row = c & 0x7f; curpos = 0; sprintf(outstr, "\033[%d;%dH", row+1, col+1); if ((temp = putseq(outstr)) != SCPE_OK) return temp; return (SCPE_OK); } switch (c) { /* Single-char command or data */ case 003: /* Blink enable */ break; case 004: /* Blink disable */ break; case 005: /* Read cursor address */ break; case 010: /* Cursor home */ sprintf(outstr, "\033[1;1H"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; row = col = 0; return (SCPE_OK); case 012: /* Newline */ if ((temp = sim_putchar('\r')) != SCPE_OK) return temp; tto_unit.pos += 1; if ((temp = sim_putchar(c)) != SCPE_OK) return temp; tto_unit.pos += 1; col = 1; row++; if (row > 24) row = 1; return (SCPE_OK); case 013: /* Erase EOL */ sprintf(outstr, "\033[K"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; return (SCPE_OK); case 014: /* Erase screen */ sprintf(outstr, "\033[1;1H\033[2J"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; row = col = 0; return (SCPE_OK); case 015: /* CR */ if ((temp = sim_putchar(c)) != SCPE_OK) return temp; tto_unit.pos += 1; col = 1; return (SCPE_OK); case 016: /* Blink On */ sprintf(outstr, "\033[5m"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; return (SCPE_OK); case 017: /* Blink off */ sprintf(outstr, "\033[25m"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; return (SCPE_OK); case 020: /* Write cursor address */ curpos = 1; return SCPE_OK; case 024: /* underscore on */ sprintf(outstr, "\033[4m"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; return (SCPE_OK); case 025: /* underscore off */ sprintf(outstr, "\033[24m"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; return (SCPE_OK); break; case 027: /* cursor up */ sprintf(outstr, "\033[A"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; row--; if (row < 1) row = 24; return (SCPE_OK); case 030: /* cursor right */ sprintf(outstr, "\033[C"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; col++; if (col > 80) { col = 1; row++; if (row > 24) row = 1; } return (SCPE_OK); case 031: /* Cursor left */ sprintf(outstr, "\033[D"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; tto_unit.pos += 1; col--; if (col < 1) { col = 80; row--; if (row < 1) row = 24; } return (SCPE_OK); case 032: /* Cursor down */ sprintf(outstr, "\033[B"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; row++; if (row > 24) row = 1; return (SCPE_OK); case 034: /* Dim on */ sprintf(outstr, "\033[22m"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; return (SCPE_OK); case 035: /* Dim off */ sprintf(outstr, "\033[1m"); if ((temp = putseq(outstr)) != SCPE_OK) return temp; return (SCPE_OK); case 036: /* Special sequence */ spec200 = 1; return SCPE_OK; default: /* ..A character of data */ if ((temp = sim_putchar(c)) != SCPE_OK) return temp; tto_unit.pos += 1; col++; if (col > 80) { col = 1; row++; if (row > 24) row = 24; } return (SCPE_OK); } return SCPE_OK; }