comparison mpegvideo.c @ 288:f82cce6cb182 libavcodec

10l (motion_val was uninitilized) 20l (first frame of a gop could be a p-frame sometimes) add hq flag to MpegEncContext
author michaelni
date Sun, 24 Mar 2002 04:16:51 +0000
parents 32a3dcce2e9b
children 73a9ce3d9715
comparison
equal deleted inserted replaced
287:32a3dcce2e9b 288:f82cce6cb182
172 perror("malloc"); 172 perror("malloc");
173 goto fail; 173 goto fail;
174 } 174 }
175 } 175 }
176 176
177 if (s->out_format == FMT_H263) { 177 if (s->out_format == FMT_H263 || s->encoding) {
178 int size; 178 int size;
179 /* MV prediction */ 179 /* MV prediction */
180 size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2); 180 size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2);
181 s->motion_val = malloc(size * 2 * sizeof(INT16)); 181 s->motion_val = malloc(size * 2 * sizeof(INT16));
182 if (s->motion_val == NULL) 182 if (s->motion_val == NULL)
293 s->max_qdiff= avctx->max_qdiff; 293 s->max_qdiff= avctx->max_qdiff;
294 s->qcompress= avctx->qcompress; 294 s->qcompress= avctx->qcompress;
295 s->qblur= avctx->qblur; 295 s->qblur= avctx->qblur;
296 s->avctx = avctx; 296 s->avctx = avctx;
297 s->aspect_ratio_info= avctx->aspect_ratio_info; 297 s->aspect_ratio_info= avctx->aspect_ratio_info;
298 s->hq= (avctx->flags & CODEC_FLAG_HQ);
298 299
299 if (s->gop_size <= 1) { 300 if (s->gop_size <= 1) {
300 s->intra_only = 1; 301 s->intra_only = 1;
301 s->gop_size = 12; 302 s->gop_size = 12;
302 } else { 303 } else {
504 505
505 init_put_bits(&s->pb, buf, buf_size, NULL, NULL); 506 init_put_bits(&s->pb, buf, buf_size, NULL, NULL);
506 507
507 if (!s->intra_only) { 508 if (!s->intra_only) {
508 /* first picture of GOP is intra */ 509 /* first picture of GOP is intra */
509 if (s->picture_in_gop_number >= s->gop_size){ 510 if (s->picture_in_gop_number % s->gop_size==0){
510 s->picture_in_gop_number=0; 511 s->picture_in_gop_number=0;
511 s->pict_type = I_TYPE; 512 s->pict_type = I_TYPE;
512 }else 513 }else
513 s->pict_type = P_TYPE; 514 s->pict_type = P_TYPE;
514 } else { 515 } else {
1095 s->mc_mb_var = 0; 1096 s->mc_mb_var = 0;
1096 /* Estimate motion for every MB */ 1097 /* Estimate motion for every MB */
1097 for(mb_y=0; mb_y < s->mb_height; mb_y++) { 1098 for(mb_y=0; mb_y < s->mb_height; mb_y++) {
1098 for(mb_x=0; mb_x < s->mb_width; mb_x++) { 1099 for(mb_x=0; mb_x < s->mb_width; mb_x++) {
1099 int xy= mb_y * s->mb_width + mb_x; 1100 int xy= mb_y * s->mb_width + mb_x;
1101 const int mot_stride = s->mb_width*2 + 2;
1102 int mot_xy = (mb_y*2 + 1)*mot_stride + mb_x*2 + 1;
1100 s->mb_x = mb_x; 1103 s->mb_x = mb_x;
1101 s->mb_y = mb_y; 1104 s->mb_y = mb_y;
1102 1105
1103 /* compute motion vector and macro block type (intra or non intra) */ 1106 /* compute motion vector and macro block type (intra or non intra) */
1104 motion_x = 0; 1107 motion_x = 0;
1112 } 1115 }
1113 /* Store MB type and MV */ 1116 /* Store MB type and MV */
1114 s->mb_type[xy] = s->mb_intra; 1117 s->mb_type[xy] = s->mb_intra;
1115 s->mv_table[0][xy] = motion_x; 1118 s->mv_table[0][xy] = motion_x;
1116 s->mv_table[1][xy] = motion_y; 1119 s->mv_table[1][xy] = motion_y;
1120
1121 s->motion_val[mot_xy ][0]= motion_x;
1122 s->motion_val[mot_xy ][1]= motion_y;
1123 s->motion_val[mot_xy+1][0]= motion_x;
1124 s->motion_val[mot_xy+1][1]= motion_y;
1125 mot_xy += mot_stride;
1126 s->motion_val[mot_xy ][0]= motion_x;
1127 s->motion_val[mot_xy ][1]= motion_y;
1128 s->motion_val[mot_xy+1][0]= motion_x;
1129 s->motion_val[mot_xy+1][1]= motion_y;
1117 } 1130 }
1118 } 1131 }
1119 emms_c(); 1132 emms_c();
1120 1133
1121 if(s->avg_mb_var < s->mc_mb_var && s->pict_type != B_TYPE){ //FIXME subtract MV bits 1134 if(s->avg_mb_var < s->mc_mb_var && s->pict_type != B_TYPE){ //FIXME subtract MV bits