comparison mpegvideo.c @ 2979:bfabfdf9ce55 libavcodec

COSMETICS: tabs --> spaces, some prettyprinting
author diego
date Thu, 22 Dec 2005 01:10:11 +0000
parents e7189a8c22ed
children 529163f99474
comparison
equal deleted inserted replaced
2978:403183bbb505 2979:bfabfdf9ce55
352 assert(!pic->data[0]); 352 assert(!pic->data[0]);
353 353
354 r= s->avctx->get_buffer(s->avctx, (AVFrame*)pic); 354 r= s->avctx->get_buffer(s->avctx, (AVFrame*)pic);
355 355
356 if(r<0 || !pic->age || !pic->type || !pic->data[0]){ 356 if(r<0 || !pic->age || !pic->type || !pic->data[0]){
357 av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %d %p)\n", r, pic->age, pic->type, pic->data[0]); 357 av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (%d %d %d %p)\n", r, pic->age, pic->type, pic->data[0]);
358 return -1; 358 return -1;
359 } 359 }
360 360
361 if(s->linesize && (s->linesize != pic->linesize[0] || s->uvlinesize != pic->linesize[1])){ 361 if(s->linesize && (s->linesize != pic->linesize[0] || s->uvlinesize != pic->linesize[1])){
362 av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (stride changed)\n"); 362 av_log(s->avctx, AV_LOG_ERROR, "get_buffer() failed (stride changed)\n");
911 911
912 s->bit_rate = avctx->bit_rate; 912 s->bit_rate = avctx->bit_rate;
913 s->width = avctx->width; 913 s->width = avctx->width;
914 s->height = avctx->height; 914 s->height = avctx->height;
915 if(avctx->gop_size > 600){ 915 if(avctx->gop_size > 600){
916 av_log(avctx, AV_LOG_ERROR, "Warning keyframe interval too large! reducing it ...\n"); 916 av_log(avctx, AV_LOG_ERROR, "Warning keyframe interval too large! reducing it ...\n");
917 avctx->gop_size=600; 917 avctx->gop_size=600;
918 } 918 }
919 s->gop_size = avctx->gop_size; 919 s->gop_size = avctx->gop_size;
920 s->avctx = avctx; 920 s->avctx = avctx;
921 s->flags= avctx->flags; 921 s->flags= avctx->flags;
1118 case CODEC_ID_JPEGLS: 1118 case CODEC_ID_JPEGLS:
1119 case CODEC_ID_MJPEG: 1119 case CODEC_ID_MJPEG:
1120 s->out_format = FMT_MJPEG; 1120 s->out_format = FMT_MJPEG;
1121 s->intra_only = 1; /* force intra only for jpeg */ 1121 s->intra_only = 1; /* force intra only for jpeg */
1122 s->mjpeg_write_tables = avctx->codec->id != CODEC_ID_JPEGLS; 1122 s->mjpeg_write_tables = avctx->codec->id != CODEC_ID_JPEGLS;
1123 s->mjpeg_data_only_frames = 0; /* write all the needed headers */ 1123 s->mjpeg_data_only_frames = 0; /* write all the needed headers */
1124 s->mjpeg_vsample[0] = 1<<chroma_v_shift; 1124 s->mjpeg_vsample[0] = 1<<chroma_v_shift;
1125 s->mjpeg_vsample[1] = 1; 1125 s->mjpeg_vsample[1] = 1;
1126 s->mjpeg_vsample[2] = 1; 1126 s->mjpeg_vsample[2] = 1;
1127 s->mjpeg_hsample[0] = 1<<chroma_h_shift; 1127 s->mjpeg_hsample[0] = 1<<chroma_h_shift;
1128 s->mjpeg_hsample[1] = 1; 1128 s->mjpeg_hsample[1] = 1;
1141 if (h263_get_picture_format(s->width, s->height) == 7) { 1141 if (h263_get_picture_format(s->width, s->height) == 7) {
1142 av_log(avctx, AV_LOG_INFO, "Input picture size isn't suitable for h263 codec! try h263+\n"); 1142 av_log(avctx, AV_LOG_INFO, "Input picture size isn't suitable for h263 codec! try h263+\n");
1143 return -1; 1143 return -1;
1144 } 1144 }
1145 s->out_format = FMT_H263; 1145 s->out_format = FMT_H263;
1146 s->obmc= (avctx->flags & CODEC_FLAG_OBMC) ? 1:0; 1146 s->obmc= (avctx->flags & CODEC_FLAG_OBMC) ? 1:0;
1147 avctx->delay=0; 1147 avctx->delay=0;
1148 s->low_delay=1; 1148 s->low_delay=1;
1149 break; 1149 break;
1150 case CODEC_ID_H263P: 1150 case CODEC_ID_H263P:
1151 s->out_format = FMT_H263; 1151 s->out_format = FMT_H263;
1152 s->h263_plus = 1; 1152 s->h263_plus = 1;
1153 /* Fx */ 1153 /* Fx */
1154 s->umvplus = (avctx->flags & CODEC_FLAG_H263P_UMV) ? 1:0; 1154 s->umvplus = (avctx->flags & CODEC_FLAG_H263P_UMV) ? 1:0;
1155 s->h263_aic= (avctx->flags & CODEC_FLAG_H263P_AIC) ? 1:0; 1155 s->h263_aic= (avctx->flags & CODEC_FLAG_H263P_AIC) ? 1:0;
1156 s->modified_quant= s->h263_aic; 1156 s->modified_quant= s->h263_aic;
1157 s->alt_inter_vlc= (avctx->flags & CODEC_FLAG_H263P_AIV) ? 1:0; 1157 s->alt_inter_vlc= (avctx->flags & CODEC_FLAG_H263P_AIV) ? 1:0;
1158 s->obmc= (avctx->flags & CODEC_FLAG_OBMC) ? 1:0; 1158 s->obmc= (avctx->flags & CODEC_FLAG_OBMC) ? 1:0;
1159 s->loop_filter= (avctx->flags & CODEC_FLAG_LOOP_FILTER) ? 1:0; 1159 s->loop_filter= (avctx->flags & CODEC_FLAG_LOOP_FILTER) ? 1:0;
1160 s->unrestricted_mv= s->obmc || s->loop_filter || s->umvplus; 1160 s->unrestricted_mv= s->obmc || s->loop_filter || s->umvplus;
1161 s->h263_slice_structured= (s->flags & CODEC_FLAG_H263P_SLICE_STRUCT) ? 1:0; 1161 s->h263_slice_structured= (s->flags & CODEC_FLAG_H263P_SLICE_STRUCT) ? 1:0;
1162 1162
1163 /* /Fx */ 1163 /* /Fx */
1164 /* These are just to be sure */ 1164 /* These are just to be sure */
1165 avctx->delay=0; 1165 avctx->delay=0;
1166 s->low_delay=1; 1166 s->low_delay=1;
1167 break; 1167 break;
1168 case CODEC_ID_FLV1: 1168 case CODEC_ID_FLV1:
2471 }else{ 2471 }else{
2472 int dxy; 2472 int dxy;
2473 2473
2474 dxy= ((motion_x>>3)&1) | ((motion_y>>2)&2); 2474 dxy= ((motion_x>>3)&1) | ((motion_y>>2)&2);
2475 if (s->no_rounding){ 2475 if (s->no_rounding){
2476 s->dsp.put_no_rnd_pixels_tab[0][dxy](dest_y, ptr, linesize, 16); 2476 s->dsp.put_no_rnd_pixels_tab[0][dxy](dest_y, ptr, linesize, 16);
2477 }else{ 2477 }else{
2478 s->dsp.put_pixels_tab [0][dxy](dest_y, ptr, linesize, 16); 2478 s->dsp.put_pixels_tab [0][dxy](dest_y, ptr, linesize, 16);
2479 } 2479 }
2480 } 2480 }
2481 2481
4146 wrap_y<<=1; 4146 wrap_y<<=1;
4147 } 4147 }
4148 } 4148 }
4149 } 4149 }
4150 4150
4151 s->dsp.get_pixels(s->block[0], ptr_y , wrap_y); 4151 s->dsp.get_pixels(s->block[0], ptr_y , wrap_y);
4152 s->dsp.get_pixels(s->block[1], ptr_y + 8, wrap_y); 4152 s->dsp.get_pixels(s->block[1], ptr_y + 8, wrap_y);
4153 s->dsp.get_pixels(s->block[2], ptr_y + dct_offset , wrap_y); 4153 s->dsp.get_pixels(s->block[2], ptr_y + dct_offset , wrap_y);
4154 s->dsp.get_pixels(s->block[3], ptr_y + dct_offset + 8, wrap_y); 4154 s->dsp.get_pixels(s->block[3], ptr_y + dct_offset + 8, wrap_y);
4155 4155
4156 if(s->flags&CODEC_FLAG_GRAY){ 4156 if(s->flags&CODEC_FLAG_GRAY){
4157 skip_dct[4]= 1; 4157 skip_dct[4]= 1;
4158 skip_dct[5]= 1; 4158 skip_dct[5]= 1;
4159 }else{ 4159 }else{
4160 s->dsp.get_pixels(s->block[4], ptr_cb, wrap_c); 4160 s->dsp.get_pixels(s->block[4], ptr_cb, wrap_c);
4161 s->dsp.get_pixels(s->block[5], ptr_cr, wrap_c); 4161 s->dsp.get_pixels(s->block[5], ptr_cr, wrap_c);
4162 } 4162 }
4163 }else{ 4163 }else{
4164 op_pixels_func (*op_pix)[4]; 4164 op_pixels_func (*op_pix)[4];
4165 qpel_mc_func (*op_qpix)[16]; 4165 qpel_mc_func (*op_qpix)[16];
4168 dest_y = s->dest[0]; 4168 dest_y = s->dest[0];
4169 dest_cb = s->dest[1]; 4169 dest_cb = s->dest[1];
4170 dest_cr = s->dest[2]; 4170 dest_cr = s->dest[2];
4171 4171
4172 if ((!s->no_rounding) || s->pict_type==B_TYPE){ 4172 if ((!s->no_rounding) || s->pict_type==B_TYPE){
4173 op_pix = s->dsp.put_pixels_tab; 4173 op_pix = s->dsp.put_pixels_tab;
4174 op_qpix= s->dsp.put_qpel_pixels_tab; 4174 op_qpix= s->dsp.put_qpel_pixels_tab;
4175 }else{ 4175 }else{
4176 op_pix = s->dsp.put_no_rnd_pixels_tab; 4176 op_pix = s->dsp.put_no_rnd_pixels_tab;
4177 op_qpix= s->dsp.put_no_rnd_qpel_pixels_tab; 4177 op_qpix= s->dsp.put_no_rnd_qpel_pixels_tab;
4178 } 4178 }
4206 wrap_y<<=1; 4206 wrap_y<<=1;
4207 } 4207 }
4208 } 4208 }
4209 } 4209 }
4210 4210
4211 s->dsp.diff_pixels(s->block[0], ptr_y , dest_y , wrap_y); 4211 s->dsp.diff_pixels(s->block[0], ptr_y , dest_y , wrap_y);
4212 s->dsp.diff_pixels(s->block[1], ptr_y + 8, dest_y + 8, wrap_y); 4212 s->dsp.diff_pixels(s->block[1], ptr_y + 8, dest_y + 8, wrap_y);
4213 s->dsp.diff_pixels(s->block[2], ptr_y + dct_offset , dest_y + dct_offset , wrap_y); 4213 s->dsp.diff_pixels(s->block[2], ptr_y + dct_offset , dest_y + dct_offset , wrap_y);
4214 s->dsp.diff_pixels(s->block[3], ptr_y + dct_offset + 8, dest_y + dct_offset + 8, wrap_y); 4214 s->dsp.diff_pixels(s->block[3], ptr_y + dct_offset + 8, dest_y + dct_offset + 8, wrap_y);
4215 4215
4216 if(s->flags&CODEC_FLAG_GRAY){ 4216 if(s->flags&CODEC_FLAG_GRAY){
4221 s->dsp.diff_pixels(s->block[5], ptr_cr, dest_cr, wrap_c); 4221 s->dsp.diff_pixels(s->block[5], ptr_cr, dest_cr, wrap_c);
4222 } 4222 }
4223 /* pre quantization */ 4223 /* pre quantization */
4224 if(s->current_picture.mc_mb_var[s->mb_stride*mb_y+ mb_x]<2*s->qscale*s->qscale){ 4224 if(s->current_picture.mc_mb_var[s->mb_stride*mb_y+ mb_x]<2*s->qscale*s->qscale){
4225 //FIXME optimize 4225 //FIXME optimize
4226 if(s->dsp.sad[1](NULL, ptr_y , dest_y , wrap_y, 8) < 20*s->qscale) skip_dct[0]= 1; 4226 if(s->dsp.sad[1](NULL, ptr_y , dest_y , wrap_y, 8) < 20*s->qscale) skip_dct[0]= 1;
4227 if(s->dsp.sad[1](NULL, ptr_y + 8, dest_y + 8, wrap_y, 8) < 20*s->qscale) skip_dct[1]= 1; 4227 if(s->dsp.sad[1](NULL, ptr_y + 8, dest_y + 8, wrap_y, 8) < 20*s->qscale) skip_dct[1]= 1;
4228 if(s->dsp.sad[1](NULL, ptr_y +dct_offset , dest_y +dct_offset , wrap_y, 8) < 20*s->qscale) skip_dct[2]= 1; 4228 if(s->dsp.sad[1](NULL, ptr_y +dct_offset , dest_y +dct_offset , wrap_y, 8) < 20*s->qscale) skip_dct[2]= 1;
4229 if(s->dsp.sad[1](NULL, ptr_y +dct_offset+ 8, dest_y +dct_offset+ 8, wrap_y, 8) < 20*s->qscale) skip_dct[3]= 1; 4229 if(s->dsp.sad[1](NULL, ptr_y +dct_offset+ 8, dest_y +dct_offset+ 8, wrap_y, 8) < 20*s->qscale) skip_dct[3]= 1;
4230 if(s->dsp.sad[1](NULL, ptr_cb , dest_cb , wrap_c, 8) < 20*s->qscale) skip_dct[4]= 1; 4230 if(s->dsp.sad[1](NULL, ptr_cb , dest_cb , wrap_c, 8) < 20*s->qscale) skip_dct[4]= 1;
4231 if(s->dsp.sad[1](NULL, ptr_cr , dest_cr , wrap_c, 8) < 20*s->qscale) skip_dct[5]= 1; 4231 if(s->dsp.sad[1](NULL, ptr_cr , dest_cr , wrap_c, 8) < 20*s->qscale) skip_dct[5]= 1;
6263 } 6263 }
6264 *overflow= s->max_qcoeff < max; //overflow might have happened 6264 *overflow= s->max_qcoeff < max; //overflow might have happened
6265 6265
6266 /* we need this permutation so that we correct the IDCT, we only permute the !=0 elements */ 6266 /* we need this permutation so that we correct the IDCT, we only permute the !=0 elements */
6267 if (s->dsp.idct_permutation_type != FF_NO_IDCT_PERM) 6267 if (s->dsp.idct_permutation_type != FF_NO_IDCT_PERM)
6268 ff_block_permute(block, s->dsp.idct_permutation, scantable, last_non_zero); 6268 ff_block_permute(block, s->dsp.idct_permutation, scantable, last_non_zero);
6269 6269
6270 return last_non_zero; 6270 return last_non_zero;
6271 } 6271 }
6272 6272
6273 #endif //CONFIG_ENCODERS 6273 #endif //CONFIG_ENCODERS