comparison mpegvideo.c @ 2627:bf158d23bbcc libavcodec

Spelling errors patch by (Kevin Baragona | kevinmb500 gawab com)
author michael
date Sun, 24 Apr 2005 11:13:49 +0000
parents 08cce4785567
children 511e3afc43e1
comparison
equal deleted inserted replaced
2626:370f4b9ec7d8 2627:bf158d23bbcc
270 } 270 }
271 271
272 #endif //CONFIG_ENCODERS 272 #endif //CONFIG_ENCODERS
273 273
274 /* load & permutate scantables 274 /* load & permutate scantables
275 note: only wmv uses differnt ones 275 note: only wmv uses different ones
276 */ 276 */
277 if(s->alternate_scan){ 277 if(s->alternate_scan){
278 ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_alternate_vertical_scan); 278 ff_init_scantable(s->dsp.idct_permutation, &s->inter_scantable , ff_alternate_vertical_scan);
279 ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_alternate_vertical_scan); 279 ff_init_scantable(s->dsp.idct_permutation, &s->intra_scantable , ff_alternate_vertical_scan);
280 }else{ 280 }else{
310 if(!src->mb_type) 310 if(!src->mb_type)
311 av_log(s->avctx, AV_LOG_ERROR, "AVFrame.mb_type not set!\n"); 311 av_log(s->avctx, AV_LOG_ERROR, "AVFrame.mb_type not set!\n");
312 if(!src->ref_index[0]) 312 if(!src->ref_index[0])
313 av_log(s->avctx, AV_LOG_ERROR, "AVFrame.ref_index not set!\n"); 313 av_log(s->avctx, AV_LOG_ERROR, "AVFrame.ref_index not set!\n");
314 if(src->motion_subsample_log2 != dst->motion_subsample_log2) 314 if(src->motion_subsample_log2 != dst->motion_subsample_log2)
315 av_log(s->avctx, AV_LOG_ERROR, "AVFrame.motion_subsample_log2 doesnt match! (%d!=%d)\n", 315 av_log(s->avctx, AV_LOG_ERROR, "AVFrame.motion_subsample_log2 doesn't match! (%d!=%d)\n",
316 src->motion_subsample_log2, dst->motion_subsample_log2); 316 src->motion_subsample_log2, dst->motion_subsample_log2);
317 317
318 memcpy(dst->mb_type, src->mb_type, s->mb_stride * s->mb_height * sizeof(dst->mb_type[0])); 318 memcpy(dst->mb_type, src->mb_type, s->mb_stride * s->mb_height * sizeof(dst->mb_type[0]));
319 319
320 for(i=0; i<2; i++){ 320 for(i=0; i<2; i++){
961 av_log(avctx, AV_LOG_ERROR, "a vbv buffer size is needed, for encoding with a maximum bitrate\n"); 961 av_log(avctx, AV_LOG_ERROR, "a vbv buffer size is needed, for encoding with a maximum bitrate\n");
962 return -1; 962 return -1;
963 } 963 }
964 964
965 if(avctx->rc_min_rate && avctx->rc_max_rate != avctx->rc_min_rate){ 965 if(avctx->rc_min_rate && avctx->rc_max_rate != avctx->rc_min_rate){
966 av_log(avctx, AV_LOG_INFO, "Warning min_rate > 0 but min_rate != max_rate isnt recommanded!\n"); 966 av_log(avctx, AV_LOG_INFO, "Warning min_rate > 0 but min_rate != max_rate isn't recommended!\n");
967 } 967 }
968 968
969 if(avctx->rc_min_rate && avctx->rc_min_rate > avctx->bit_rate){ 969 if(avctx->rc_min_rate && avctx->rc_min_rate > avctx->bit_rate){
970 av_log(avctx, AV_LOG_INFO, "bitrate below min bitrate\n"); 970 av_log(avctx, AV_LOG_INFO, "bitrate below min bitrate\n");
971 return -1; 971 return -1;
988 av_log(avctx, AV_LOG_ERROR, "4MV not supported by codec\n"); 988 av_log(avctx, AV_LOG_ERROR, "4MV not supported by codec\n");
989 return -1; 989 return -1;
990 } 990 }
991 991
992 if(s->obmc && s->avctx->mb_decision != FF_MB_DECISION_SIMPLE){ 992 if(s->obmc && s->avctx->mb_decision != FF_MB_DECISION_SIMPLE){
993 av_log(avctx, AV_LOG_ERROR, "OBMC is only supported with simple mb decission\n"); 993 av_log(avctx, AV_LOG_ERROR, "OBMC is only supported with simple mb decision\n");
994 return -1; 994 return -1;
995 } 995 }
996 996
997 if(s->obmc && s->codec_id != CODEC_ID_H263 && s->codec_id != CODEC_ID_H263P){ 997 if(s->obmc && s->codec_id != CODEC_ID_H263 && s->codec_id != CODEC_ID_H263P){
998 av_log(avctx, AV_LOG_ERROR, "OBMC is only supported with H263(+)\n"); 998 av_log(avctx, AV_LOG_ERROR, "OBMC is only supported with H263(+)\n");
1019 av_log(avctx, AV_LOG_ERROR, "interlacing not supported by codec\n"); 1019 av_log(avctx, AV_LOG_ERROR, "interlacing not supported by codec\n");
1020 return -1; 1020 return -1;
1021 } 1021 }
1022 1022
1023 if(s->mpeg_quant && s->codec_id != CODEC_ID_MPEG4){ //FIXME mpeg2 uses that too 1023 if(s->mpeg_quant && s->codec_id != CODEC_ID_MPEG4){ //FIXME mpeg2 uses that too
1024 av_log(avctx, AV_LOG_ERROR, "mpeg2 style quantization not supporetd by codec\n"); 1024 av_log(avctx, AV_LOG_ERROR, "mpeg2 style quantization not supported by codec\n");
1025 return -1; 1025 return -1;
1026 } 1026 }
1027 1027
1028 if((s->flags & CODEC_FLAG_CBP_RD) && !(s->flags & CODEC_FLAG_TRELLIS_QUANT)){ 1028 if((s->flags & CODEC_FLAG_CBP_RD) && !(s->flags & CODEC_FLAG_TRELLIS_QUANT)){
1029 av_log(avctx, AV_LOG_ERROR, "CBP RD needs trellis quant\n"); 1029 av_log(avctx, AV_LOG_ERROR, "CBP RD needs trellis quant\n");
2215 int type= s->input_picture[i]->pict_type; 2215 int type= s->input_picture[i]->pict_type;
2216 if(type && type != B_TYPE) 2216 if(type && type != B_TYPE)
2217 b_frames= i; 2217 b_frames= i;
2218 } 2218 }
2219 if(s->input_picture[b_frames]->pict_type == B_TYPE && b_frames == s->max_b_frames){ 2219 if(s->input_picture[b_frames]->pict_type == B_TYPE && b_frames == s->max_b_frames){
2220 av_log(s->avctx, AV_LOG_ERROR, "warning, too many bframes in a row\n"); 2220 av_log(s->avctx, AV_LOG_ERROR, "warning, too many b frames in a row\n");
2221 } 2221 }
2222 2222
2223 if(s->picture_in_gop_number + b_frames >= s->gop_size){ 2223 if(s->picture_in_gop_number + b_frames >= s->gop_size){
2224 if((s->flags2 & CODEC_FLAG2_STRICT_GOP) && s->gop_size > s->picture_in_gop_number){ 2224 if((s->flags2 & CODEC_FLAG2_STRICT_GOP) && s->gop_size > s->picture_in_gop_number){
2225 b_frames= s->gop_size - s->picture_in_gop_number - 1; 2225 b_frames= s->gop_size - s->picture_in_gop_number - 1;
3684 if ((s->flags&CODEC_FLAG_PSNR) || !(s->encoding && (s->intra_only || s->pict_type==B_TYPE))) { //FIXME precalc 3684 if ((s->flags&CODEC_FLAG_PSNR) || !(s->encoding && (s->intra_only || s->pict_type==B_TYPE))) { //FIXME precalc
3685 uint8_t *dest_y, *dest_cb, *dest_cr; 3685 uint8_t *dest_y, *dest_cb, *dest_cr;
3686 int dct_linesize, dct_offset; 3686 int dct_linesize, dct_offset;
3687 op_pixels_func (*op_pix)[4]; 3687 op_pixels_func (*op_pix)[4];
3688 qpel_mc_func (*op_qpix)[16]; 3688 qpel_mc_func (*op_qpix)[16];
3689 const int linesize= s->current_picture.linesize[0]; //not s->linesize as this woulnd be wrong for field pics 3689 const int linesize= s->current_picture.linesize[0]; //not s->linesize as this would be wrong for field pics
3690 const int uvlinesize= s->current_picture.linesize[1]; 3690 const int uvlinesize= s->current_picture.linesize[1];
3691 const int readable= s->pict_type != B_TYPE || s->encoding || s->avctx->draw_horiz_band || lowres_flag; 3691 const int readable= s->pict_type != B_TYPE || s->encoding || s->avctx->draw_horiz_band || lowres_flag;
3692 const int block_size= lowres_flag ? 8>>s->avctx->lowres : 8; 3692 const int block_size= lowres_flag ? 8>>s->avctx->lowres : 8;
3693 3693
3694 /* avoid copy if macroblock skipped in last frame too */ 3694 /* avoid copy if macroblock skipped in last frame too */
3731 dest_cr= s->b_scratchpad+32*linesize; 3731 dest_cr= s->b_scratchpad+32*linesize;
3732 } 3732 }
3733 3733
3734 if (!s->mb_intra) { 3734 if (!s->mb_intra) {
3735 /* motion handling */ 3735 /* motion handling */
3736 /* decoding or more than one mb_type (MC was allready done otherwise) */ 3736 /* decoding or more than one mb_type (MC was already done otherwise) */
3737 if(!s->encoding){ 3737 if(!s->encoding){
3738 if(lowres_flag){ 3738 if(lowres_flag){
3739 h264_chroma_mc_func *op_pix = s->dsp.put_h264_chroma_pixels_tab; 3739 h264_chroma_mc_func *op_pix = s->dsp.put_h264_chroma_pixels_tab;
3740 3740
3741 if (s->mv_dir & MV_DIR_FORWARD) { 3741 if (s->mv_dir & MV_DIR_FORWARD) {
3941 3941
3942 block[j]= level; 3942 block[j]= level;
3943 } 3943 }
3944 3944
3945 if(overflow && s->avctx->mb_decision == FF_MB_DECISION_SIMPLE) 3945 if(overflow && s->avctx->mb_decision == FF_MB_DECISION_SIMPLE)
3946 av_log(s->avctx, AV_LOG_INFO, "warning, cliping %d dct coefficents to %d..%d\n", overflow, minlevel, maxlevel); 3946 av_log(s->avctx, AV_LOG_INFO, "warning, clipping %d dct coefficients to %d..%d\n", overflow, minlevel, maxlevel);
3947 } 3947 }
3948 3948
3949 #endif //CONFIG_ENCODERS 3949 #endif //CONFIG_ENCODERS
3950 3950
3951 /** 3951 /**
5116 av_log(s->avctx, AV_LOG_ERROR, "illegal MB type\n"); 5116 av_log(s->avctx, AV_LOG_ERROR, "illegal MB type\n");
5117 } 5117 }
5118 5118
5119 encode_mb(s, motion_x, motion_y); 5119 encode_mb(s, motion_x, motion_y);
5120 5120
5121 // RAL: Update last macrobloc type 5121 // RAL: Update last macroblock type
5122 s->last_mv_dir = s->mv_dir; 5122 s->last_mv_dir = s->mv_dir;
5123 5123
5124 if (s->out_format == FMT_H263 && s->pict_type!=B_TYPE) 5124 if (s->out_format == FMT_H263 && s->pict_type!=B_TYPE)
5125 ff_h263_update_motion_val(s); 5125 ff_h263_update_motion_val(s);
5126 5126
5156 } 5156 }
5157 //printf("MB %d %d bits\n", s->mb_x+s->mb_y*s->mb_stride, put_bits_count(&s->pb)); 5157 //printf("MB %d %d bits\n", s->mb_x+s->mb_y*s->mb_stride, put_bits_count(&s->pb));
5158 } 5158 }
5159 } 5159 }
5160 5160
5161 //not beautifull here but we must write it before flushing so it has to be here 5161 //not beautiful here but we must write it before flushing so it has to be here
5162 if (s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type == I_TYPE) 5162 if (s->msmpeg4_version && s->msmpeg4_version<4 && s->pict_type == I_TYPE)
5163 msmpeg4_encode_ext_header(s); 5163 msmpeg4_encode_ext_header(s);
5164 5164
5165 write_slice_end(s); 5165 write_slice_end(s);
5166 5166
5238 }else if(s->pict_type!=B_TYPE){ 5238 }else if(s->pict_type!=B_TYPE){
5239 if(s->flipflop_rounding || s->codec_id == CODEC_ID_H263P || s->codec_id == CODEC_ID_MPEG4) 5239 if(s->flipflop_rounding || s->codec_id == CODEC_ID_H263P || s->codec_id == CODEC_ID_MPEG4)
5240 s->no_rounding ^= 1; 5240 s->no_rounding ^= 1;
5241 } 5241 }
5242 5242
5243 s->mb_intra=0; //for the rate distoration & bit compare functions 5243 s->mb_intra=0; //for the rate distortion & bit compare functions
5244 for(i=1; i<s->avctx->thread_count; i++){ 5244 for(i=1; i<s->avctx->thread_count; i++){
5245 ff_update_duplicate_context(s->thread_context[i], s); 5245 ff_update_duplicate_context(s->thread_context[i], s);
5246 } 5246 }
5247 5247
5248 ff_init_me(s); 5248 ff_init_me(s);
5357 s->lambda= s->current_picture.quality; 5357 s->lambda= s->current_picture.quality;
5358 //printf("%d %d\n", s->avctx->global_quality, s->current_picture.quality); 5358 //printf("%d %d\n", s->avctx->global_quality, s->current_picture.quality);
5359 update_qscale(s); 5359 update_qscale(s);
5360 5360
5361 if(s->qscale < 3 && s->max_qcoeff<=128 && s->pict_type==I_TYPE && !(s->flags & CODEC_FLAG_QSCALE)) 5361 if(s->qscale < 3 && s->max_qcoeff<=128 && s->pict_type==I_TYPE && !(s->flags & CODEC_FLAG_QSCALE))
5362 s->qscale= 3; //reduce cliping problems 5362 s->qscale= 3; //reduce clipping problems
5363 5363
5364 if (s->out_format == FMT_MJPEG) { 5364 if (s->out_format == FMT_MJPEG) {
5365 /* for mjpeg, we do include qscale in the matrix */ 5365 /* for mjpeg, we do include qscale in the matrix */
5366 s->intra_matrix[0] = ff_mpeg1_default_intra_matrix[0]; 5366 s->intra_matrix[0] = ff_mpeg1_default_intra_matrix[0];
5367 for(i=1;i<64;i++){ 5367 for(i=1;i<64;i++){
5559 coeff[0][i]= (level>>31)|1; 5559 coeff[0][i]= (level>>31)|1;
5560 coeff_count[i]= 1; 5560 coeff_count[i]= 1;
5561 } 5561 }
5562 } 5562 }
5563 5563
5564 *overflow= s->max_qcoeff < max; //overflow might have happend 5564 *overflow= s->max_qcoeff < max; //overflow might have happened
5565 5565
5566 if(last_non_zero < start_i){ 5566 if(last_non_zero < start_i){
5567 memset(block + start_i, 0, (64-start_i)*sizeof(DCTELEM)); 5567 memset(block + start_i, 0, (64-start_i)*sizeof(DCTELEM));
5568 return last_non_zero; 5568 return last_non_zero;
5569 } 5569 }
5832 #ifdef REFINE_STATS 5832 #ifdef REFINE_STATS
5833 {START_TIMER 5833 {START_TIMER
5834 #endif 5834 #endif
5835 dc += (1<<(RECON_SHIFT-1)); 5835 dc += (1<<(RECON_SHIFT-1));
5836 for(i=0; i<64; i++){ 5836 for(i=0; i<64; i++){
5837 rem[i]= dc - (orig[i]<<RECON_SHIFT); //FIXME use orig dirrectly insteadof copying to rem[] 5837 rem[i]= dc - (orig[i]<<RECON_SHIFT); //FIXME use orig dirrectly instead of copying to rem[]
5838 } 5838 }
5839 #ifdef REFINE_STATS 5839 #ifdef REFINE_STATS
5840 STOP_TIMER("memset rem[]")} 5840 STOP_TIMER("memset rem[]")}
5841 #endif 5841 #endif
5842 sum=0; 5842 sum=0;
6211 max |=level; 6211 max |=level;
6212 }else{ 6212 }else{
6213 block[j]=0; 6213 block[j]=0;
6214 } 6214 }
6215 } 6215 }
6216 *overflow= s->max_qcoeff < max; //overflow might have happend 6216 *overflow= s->max_qcoeff < max; //overflow might have happened
6217 6217
6218 /* we need this permutation so that we correct the IDCT, we only permute the !=0 elements */ 6218 /* we need this permutation so that we correct the IDCT, we only permute the !=0 elements */
6219 if (s->dsp.idct_permutation_type != FF_NO_IDCT_PERM) 6219 if (s->dsp.idct_permutation_type != FF_NO_IDCT_PERM)
6220 ff_block_permute(block, s->dsp.idct_permutation, scantable, last_non_zero); 6220 ff_block_permute(block, s->dsp.idct_permutation, scantable, last_non_zero);
6221 6221