Download presentation
Presentation is loading. Please wait.
1
Chap 4. MPEG-2 부호기 전체 구조와 알고리즘
컴퓨터정보통신공학과 S&S LAB 최면욱
2
Content 4.1 전체구조 4.2 MPEG-부호기 전체구조 4.3 main() 처리루틴 4.4 파라미터 설정화일
4.5 양자화 매트릭스 파일설정
3
4.1 전체구조
4
4.2 MPEG-2 부호기 전체구조
5
4.3 main() 처리루틴 int main(argc,argv) /* mpeg2enc.c */ int argc;
char *argv[]; { if (argc!=3) { printf("\n%s, %s\n",version,author); printf("Usage: mpeg2encode in.par out.m2v\n"); exit(0); } readparmfile(argv[1]); /*1. read parameter file */ readquantmat(); /*2. read quantization matrices */ /* open output file */ if (!(outfile=fopen(argv[2],"wb"))) sprintf(errortext,"Couldn't create output file %s",argv[2]); error(errortext); init(); /* 3. 비트, fdct 및 idct의 초기화과정 putseq() ; /* 4. 총프레임에 따라 반복루틴을 수행하면서 하나의 픽처를 부호화 */ fclose(outfile); fclose(statfile); return 0; }
6
4.3 main() 처리루틴
7
4.4 파라미터 설정 파일 MPEG-2 Test Sequence, 25 frames/sec /* PAL.par */
test%d /* name of source files */ q%d /* name of reconstructed images ("-": don't store) */ - /* name of intra quant matrix file ("-": default matrix) */ - /* name of non intra quant matrix file ("-": default matrix) */ stat.out /* name of statistics file ("-": stdout ) */ 0 /* input picture file format: 0=*.Y,*.U,*.V, 1=*.yuv, 2=*.ppm */ 150 /* number of frames */ 0 /* number of first frame */ 00:00:00:00 /* timecode of first frame */ 12 /* N (# GOP안에 포함되는 프레임 수) */ 3 /* M (I/P frame 사이의 거리, 사이에 몇 개의 B프레임이 존재하는가 확인) */ 0 /* ISO/IEC stream 0이면 MPEG1처리 1이면 MPEG2처리*/ 0 /* 0:frame pictures, 1: field pictures */ 704 /* horizontal_size */ 576 /* vertical_size */ 2 /* aspect_ratio_information(종횡비 정보) 1=square pel, 2=4:3, 3=16:9, 4=2.11:1 */ 3 /* frame_rate_code 1=23.976, 2=24, 3=25, 4=29.97, 5=30 frames/sec. */ /* bit_rate (bits/s) 비트율의 최대값 */ 112 /* vbv_buffer_size (in multiples of 16 kbit) 가상버퍼사이즈*/ 0 /* low_delay 1로 설정하면 B픽처가 없음 */ 0 /* constrained_parameters_flag */ 4 /* Profile ID: Simple = 5, Main = 4, SNR = 3, Spatial = 2, High = 1 */ 8 /* Level ID: Low = 10, Main = 8, High 1440 = 6, High = 4 */ 0 /* progressive_sequence */ 1 /* chroma_format: 1=4:2:0, 2=4:2:2, 3=4:4:4 */ 1 /* video_format: 0=comp., 1=PAL, 2=NTSC, 3=SECAM, 4=MAC, 5=unspec. */ 5 /* color_primaries */
8
4.4 파라미터 설정 파일 5 /* transfer_characteristics */
5 /* matrix_coefficients */ 704 /* display_horizontal_size */ 576 /* display_vertical_size */ 0 /* intra_dc_precision (0: 8 bit, 1: 9 bit, 2: 10 bit, 3: 11 bit */ 1 /* top_field_first */ 0 0 0 /* frame_pred_frame_dct (I P B) */ 0 0 0 /* concealment_motion_vectors (I P B) */ 1 1 1 /* q_scale_type (I P B) */ 1 0 0 /* intra_vlc_format (I P B)*/ 0 0 0 /* alternate_scan (I P B) */ 0 /* repeat_first_field */ 0 /* progressive_frame */ 0 /* P distance between complete intra slice refresh */ 0 /* rate control: r (reaction parameter) */ 0 /* rate control: avg_act (initial average activity) */ 0 /* rate control: Xi (initial I frame global complexity measure) */ 0 /* rate control: Xp (initial P frame global complexity measure) */ 0 /* rate control: Xb (initial B frame global complexity measure) */ 0 /* rate control: d0i (initial I frame virtual buffer fullness) */ 0 /* rate control: d0p (initial P frame virtual buffer fullness) */ 0 /* rate control: d0b (initial B frame virtual buffer fullness) */ /* P: forw_hor_f_code forw_vert_f_code search_width/height */ 1 1 3 3 /* B1: forw_hor_f_code forw_vert_f_code search_width/height */ 1 1 7 7 /* B1: back_hor_f_code back_vert_f_code search_width/height */ 1 1 7 7 /* B2: forw_hor_f_code forw_vert_f_code search_width/height */ 1 1 3 3 /* B2: back_hor_f_code back_vert_f_code search_width/height */
9
4.5 양자화 메트릭스 파일설정 static void readquantmat() /* mpeg2enc.c */ {
int i,v; FILE *fd; if (iqname[0]=='-') { /* use default intra matrix */ load_iquant = 0; for (i=0; i<64; i++) intra_q[i] = default_intra_quantizer_matrix[i]; } else /* read customized intra matrix */ load_iquant = 1; if (!(fd = fopen(iqname,"r"))) { sprintf(errortext,"Couldn't open quant matrix file %s",iqname); error(errortext); } fscanf(fd,"%d",&v); if (v<1 || v>255) error("invalid value in quant matrix"); intra_q[i] = v; fclose(fd);
10
4.5 양자화 메트릭스 파일설정 if (niqname[0]=='-') {
{ /* use default non-intra matrix */ load_niquant = 0; for (i=0; i<64; i++) inter_q[i] = 16; } else /* read customized non-intra matrix */ load_niquant = 1; if (!(fd = fopen(niqname,"r"))) { sprintf(errortext,"Couldn't open quant matrix file %s",niqname); error(errortext); } fscanf(fd,"%d",&v); if (v<1 || v>255) error("invalid value in quant matrix"); inter_q[i] = v; fclose(fd); }
11
4.5 양자화 메트릭스 파일설정
12
4.5 양자화 메트릭스 파일설정 /* default intra quantization matrix */
/* intra.mat */
Similar presentations