putpic.c
上传用户:super_houu
上传日期:2008-09-21
资源大小:4099k
文件大小:5k
- #include "PlaycoreCaptureLogompeg_encdct.h"
- #include "PlaycoreCaptureLogompeg_encquantize.h"
- #include "PlaycoreCaptureLogompeg_encput_block.h"
- #include "PlaycoreCaptureLogompeg_encputbits.h"
- #include "PlaycoreCaptureLogompeg_encputvlc.h"
- #include "PlaycoreCaptureLogompeg_encmpeg_defs.h"
- #include "PlaycoreCaptureLogompeg_encenc_io.h"
- #include "PlaycoreCaptureLogompeg_encenc.h"
- #ifdef SUPPORT_CAPTURE_LOGO
- //static short MB[6][8][8];
- void PutSeqHdr(int hsize,int vsize,int aspectratio);
- void PutGopHdr(void);
- void PutPicHdr(int dc_prec,int prog_frame);
- void PutSeqEnd(void);
- void putseq(int hsize,int vsize,int aspectratio,int prog_frame,int quality)
- {
- short MB[6][8][8]; //jerry move it from bss to stack
- int i,j,k;
- int mb_height=vsize/16;
- int mb_width=hsize/16;
- int prev_mquant;
- int dc_prec=0; /* BUGBUG - uninitalized */
- MB_TYPE mb_type;
- int x, y;
- initbits();
- prev_mquant=quality;
- if( prev_mquant<2 )
- {
- prev_mquant=2;
- }
- else if (prev_mquant>62 )
- {
- prev_mquant=62;
- }
- putsyshdr();
- PutSeqHdr(hsize,vsize,aspectratio);
- PutGopHdr();
- PutPicHdr(dc_prec,prog_frame);
- for (j=0; j<mb_height; j++)
- {
- /* macroblock row loop */
- alignbits();
- putbits(0x00000101UL+j,32); /* slice SC */
- putbits(prev_mquant >> 1, 5);
- putbits(0,1); /* extra_bit_slice */
- for (k=0; k<3; k++)
- {
- pLogoCapture->dc_dct_pred[k] = 128;
- }
- for (i=0; i<mb_width; i++)
- {
- /* macroblock loop */
- get_mb(MB,i,j);
- for(k=0;k<6;k++)
- {
- dct(MB[k]);
- quant_intra(MB[k],dc_prec,prev_mquant);
- }
- mb_type=MB_INTRA; /* BUGBUG - what about quant ?? */
- putbits(1,1); /* macroblock_address_increment */
- putmbtype(mb_type);
- /* if (mb_type & MB_QUANT) BUGBUG - MB-quant
- {
- putbits(mbinfo[k].mquant>>1,5);
- prev_mquant = mbinfo[k].mquant;
- }*/
- for(k=0;k<4;k++)
- {
- put_blk(MB[k],0);
- }
- put_blk(MB[4],1);
- put_blk(MB[5],2);
- }
- }
- PutSeqEnd();
- alignsector();
- }
- void PutSeqHdr(int hsize,int vsize,int aspectratio)
- {
- alignbits();
- putbits(SEQ_START_CODE,32); /* sequence_header_code */
- putbits(hsize,12); /* horizontal_size_value */
- putbits(vsize,12); /* vertical_size_value */
- putbits(aspectratio,4); /* aspect_ratio_information */
- if( vsize==480 || vsize==240 )
- {
- putbits(4,4); /* NTSC */
- }
- else
- {
- putbits(3,4); /* PAL */
- }
- putbits(27000,18); /* bit_rate_value */
- putbits(1,1); /* marker_bit */
- putbits(112,10); /* vbv_buffer_size_value */
- putbits(0,1); /* constrained_parameters_flag */
- putbits(0,1); /* load_intra_quantizer_matrix */
- #if 0
- if (load_iquant)
- {
- for (i=0; i<64; i++) /* matrices are always downloaded in zig-zag order */
- {
- putbits(intra_q[zig_zag_scan[i]],8); /* intra_quantizer_matrix */
- }
- }
- #endif
- putbits(0,1); /* load_non_intra_quantizer_matrix */
- /* generate sequence extension (6.2.2.3, 6.3.5) header (MPEG-2 only) */
- alignbits();
- putbits(EXT_START_CODE,32); /* extension_start_code */
- putbits(SEQ_ID,4); /* extension_start_code_identifier */
- putbits(0x48 /*MP@ML*/,8); /* profile_and_level_indication */
- putbits(0,1); /* progressive sequence */
- putbits(CHROMA420,2); /* chroma_format */
- putbits(0,2); /* horizontal_size_extension */
- putbits(0,2); /* vertical_size_extension */
- putbits(0,12); /* bit_rate_extension */
- putbits(1,1); /* marker_bit */
- putbits(0,8); /* vbv_buffer_size_extension */
- putbits(0,1); /* low_delay -- currently not implemented */
- putbits(0,2); /* frame_rate_extension_n */
- putbits(0,5); /* frame_rate_extension_d */
- }
- void PutGopHdr(void)
- {
- alignbits();
- putbits(GOP_START_CODE,32); /* group_start_code */
- putbits(0,25); /* time_code */
- putbits(1,1); /* closed_gop */
- putbits(0,1); /* broken_link */
- }
- void PutPicHdr(int dc_prec,int prog_frame)
- {
- alignbits();
- putbits(PICTURE_START_CODE,32); /* picture_start_code */
- putbits(0,10); /* temporal_reference */
- putbits(1,3); /* picture_coding_type */
- putbits(0,16); /* vbv_delay */
- putbits(0,1); /* extra_bit_picture */
- /* generate picture coding extension (6.2.3.1, 6.3.11) */
- alignbits();
- putbits(EXT_START_CODE,32); /* extension_start_code */
- putbits(CODING_ID,4); /* extension_start_code_identifier */
- putbits(0xf,4); /* forward_horizontal_f_code */
- putbits(0xf,4); /* forward_vertical_f_code */
- putbits(0xf,4); /* backward_horizontal_f_code */
- putbits(0xf,4); /* backward_vertical_f_code */
- putbits(dc_prec,2); /* intra_dc_precision */
- putbits(FRAME_PICTURE,2); /* picture_structure */
- putbits(1,1); /* top_field_first */
- putbits(1,1); /* frame_pred_frame_dct */
- putbits(0,1); /* concealment_motion_vectors -- currently not implemented */
- putbits(0,1); /* q_scale_type */
- putbits(0,1); /* intra_vlc_format */
- putbits(0,1); /* alternate_scan */
- putbits(0,1); /* repeat_first_field */
- putbits(prog_frame,1); /* chroma_420_type */
- putbits(prog_frame,1); /* progressive_frame */
- putbits(0,1); /* composite_display_flag */
- }
- void PutSeqEnd(void)
- {
- alignbits();
- putbits(SEQ_END_CODE,32);
- putbits(0,32);
- putbits(ISO_END_CODE,32);
- putbits(0,32);
- }
- #endif