comparison mpegvideo.c @ 1422:efeed6e29f9b libavcodec

oooooops, having 2 Eterms open and doing cvs diff in one and cvs commit in the other sucks, especially if they are in different directories (MPlayer/main/libavcodec vs. ffmpeg/libavcodec)
author michaelni
date Mon, 25 Aug 2003 22:54:53 +0000
parents 340c90faa1dc
children 39ebefd82728
comparison
equal deleted inserted replaced
1421:340c90faa1dc 1422:efeed6e29f9b
32 32
33 #ifdef USE_FASTMEMCPY 33 #ifdef USE_FASTMEMCPY
34 #include "fastmemcpy.h" 34 #include "fastmemcpy.h"
35 #endif 35 #endif
36 36
37 #undef NDEBUG 37 //#undef NDEBUG
38 #include <assert.h> 38 //#include <assert.h>
39 39
40 #ifdef CONFIG_ENCODERS 40 #ifdef CONFIG_ENCODERS
41 static void encode_picture(MpegEncContext *s, int picture_number); 41 static void encode_picture(MpegEncContext *s, int picture_number);
42 #endif //CONFIG_ENCODERS 42 #endif //CONFIG_ENCODERS
43 static void dct_unquantize_mpeg1_c(MpegEncContext *s, 43 static void dct_unquantize_mpeg1_c(MpegEncContext *s,
189 #ifdef CONFIG_ENCODERS 189 #ifdef CONFIG_ENCODERS
190 s->dct_quantize= dct_quantize_c; 190 s->dct_quantize= dct_quantize_c;
191 #endif 191 #endif
192 192
193 #ifdef HAVE_MMX 193 #ifdef HAVE_MMX
194 MPV_common_init_mmx(s); //FIXME dont pass mpegenccontext to these, rather use dspcontext 194 MPV_common_init_mmx(s);
195 #endif 195 #endif
196 #ifdef ARCH_ALPHA 196 #ifdef ARCH_ALPHA
197 MPV_common_init_axp(s); 197 MPV_common_init_axp(s);
198 #endif 198 #endif
199 #ifdef HAVE_MLIB 199 #ifdef HAVE_MLIB
277 CHECKED_ALLOCZ(pic->mb_mean , mb_array_size * sizeof(int8_t)) 277 CHECKED_ALLOCZ(pic->mb_mean , mb_array_size * sizeof(int8_t))
278 CHECKED_ALLOCZ(pic->mb_cmp_score, mb_array_size * sizeof(int32_t)) 278 CHECKED_ALLOCZ(pic->mb_cmp_score, mb_array_size * sizeof(int32_t))
279 } 279 }
280 280
281 CHECKED_ALLOCZ(pic->mbskip_table , mb_array_size * sizeof(uint8_t)+2) //the +2 is for the slice end check 281 CHECKED_ALLOCZ(pic->mbskip_table , mb_array_size * sizeof(uint8_t)+2) //the +2 is for the slice end check
282 CHECKED_ALLOCZ(pic->qscale_table , mb_array_size * sizeof(uint8_t)+3) //+3 for mpeg2 SIMD >>1 282 CHECKED_ALLOCZ(pic->qscale_table , mb_array_size * sizeof(uint8_t))
283 CHECKED_ALLOCZ(pic->mb_type_base , big_mb_num * sizeof(int)) 283 CHECKED_ALLOCZ(pic->mb_type_base , big_mb_num * sizeof(int))
284 pic->mb_type= pic->mb_type_base + s->mb_stride+1; 284 pic->mb_type= pic->mb_type_base + s->mb_stride+1;
285 if(s->out_format == FMT_H264){ 285 if(s->out_format == FMT_H264){
286 for(i=0; i<2; i++){ 286 for(i=0; i<2; i++){
287 CHECKED_ALLOCZ(pic->motion_val[i], 2 * 16 * s->mb_num * sizeof(uint16_t)) 287 CHECKED_ALLOCZ(pic->motion_val[i], 2 * 16 * s->mb_num * sizeof(uint16_t))
422 CHECKED_ALLOCZ(s->mb_type , mb_array_size * sizeof(uint8_t)) //needed for encoding 422 CHECKED_ALLOCZ(s->mb_type , mb_array_size * sizeof(uint8_t)) //needed for encoding
423 } 423 }
424 424
425 CHECKED_ALLOCZ(s->error_status_table, mb_array_size*sizeof(uint8_t)) 425 CHECKED_ALLOCZ(s->error_status_table, mb_array_size*sizeof(uint8_t))
426 426
427 if (s->out_format == FMT_H263 || s->encoding || 1) { 427 if (s->out_format == FMT_H263 || s->encoding) {
428 int size; 428 int size;
429 429
430 /* MV prediction */ 430 /* MV prediction */
431 size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2); 431 size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2);
432 CHECKED_ALLOCZ(s->motion_val, size * 2 * sizeof(int16_t)); 432 CHECKED_ALLOCZ(s->motion_val, size * 2 * sizeof(int16_t));
579 s->chroma_elim_threshold= avctx->chroma_elim_threshold; 579 s->chroma_elim_threshold= avctx->chroma_elim_threshold;
580 s->strict_std_compliance= avctx->strict_std_compliance; 580 s->strict_std_compliance= avctx->strict_std_compliance;
581 s->data_partitioning= avctx->flags & CODEC_FLAG_PART; 581 s->data_partitioning= avctx->flags & CODEC_FLAG_PART;
582 s->quarter_sample= (avctx->flags & CODEC_FLAG_QPEL)!=0; 582 s->quarter_sample= (avctx->flags & CODEC_FLAG_QPEL)!=0;
583 s->mpeg_quant= avctx->mpeg_quant; 583 s->mpeg_quant= avctx->mpeg_quant;
584 584
585 if (s->gop_size <= 1) { 585 if (s->gop_size <= 1) {
586 s->intra_only = 1; 586 s->intra_only = 1;
587 s->gop_size = 12; 587 s->gop_size = 12;
588 } else { 588 } else {
589 s->intra_only = 0; 589 s->intra_only = 0;
620 620
621 if(s->max_b_frames && s->codec_id != CODEC_ID_MPEG4 && s->codec_id != CODEC_ID_MPEG1VIDEO && s->codec_id != CODEC_ID_MPEG2VIDEO){ 621 if(s->max_b_frames && s->codec_id != CODEC_ID_MPEG4 && s->codec_id != CODEC_ID_MPEG1VIDEO && s->codec_id != CODEC_ID_MPEG2VIDEO){
622 fprintf(stderr, "b frames not supporetd by codec\n"); 622 fprintf(stderr, "b frames not supporetd by codec\n");
623 return -1; 623 return -1;
624 } 624 }
625 /* 625
626 if(s->mpeg_quant && s->codec_id != CODEC_ID_MPEG4){ //FIXME mpeg2 uses that too 626 if(s->mpeg_quant && s->codec_id != CODEC_ID_MPEG4){ //FIXME mpeg2 uses that too
627 fprintf(stderr, "mpeg2 style quantization not supporetd by codec\n"); 627 fprintf(stderr, "mpeg2 style quantization not supporetd by codec\n");
628 return -1; 628 return -1;
629 } 629 }
630 */ 630
631 if(s->codec_id==CODEC_ID_MJPEG){ 631 if(s->codec_id==CODEC_ID_MJPEG){
632 s->intra_quant_bias= 1<<(QUANT_BIAS_SHIFT-1); //(a + x/2)/x 632 s->intra_quant_bias= 1<<(QUANT_BIAS_SHIFT-1); //(a + x/2)/x
633 s->inter_quant_bias= 0; 633 s->inter_quant_bias= 0;
634 }else if(s->mpeg_quant || s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO){ 634 }else if(s->mpeg_quant || s->codec_id==CODEC_ID_MPEG1VIDEO || s->codec_id==CODEC_ID_MPEG2VIDEO){
635 s->intra_quant_bias= 3<<(QUANT_BIAS_SHIFT-3); //(a + x*3/8)/x 635 s->intra_quant_bias= 3<<(QUANT_BIAS_SHIFT-3); //(a + x*3/8)/x
1007 if(s->current_picture_ptr) 1007 if(s->current_picture_ptr)
1008 pic->coded_picture_number= s->current_picture_ptr->coded_picture_number+1; 1008 pic->coded_picture_number= s->current_picture_ptr->coded_picture_number+1;
1009 1009
1010 if( alloc_picture(s, (Picture*)pic, 0) < 0) 1010 if( alloc_picture(s, (Picture*)pic, 0) < 0)
1011 return -1; 1011 return -1;
1012 assert(pic->data[0]);
1013 1012
1014 s->current_picture_ptr= &s->picture[i]; 1013 s->current_picture_ptr= &s->picture[i];
1015 } 1014 }
1016 1015
1017 s->current_picture_ptr->pict_type= s->pict_type; 1016 s->current_picture_ptr->pict_type= s->pict_type;
2350 0,dmv_pix_op, 2349 0,dmv_pix_op,
2351 s->mv[dir][2][0],s->mv[dir][2][1],16); 2350 s->mv[dir][2][0],s->mv[dir][2][1],16);
2352 } 2351 }
2353 } 2352 }
2354 break; 2353 break;
2355 default: 2354
2356 printf("X");
2357 } 2355 }
2358 } 2356 }
2359 2357
2360 2358
2361 /* put block[] to dest[] */ 2359 /* put block[] to dest[] */
3003 } 3001 }
3004 }else{ 3002 }else{
3005 for(i=0;i<6;i++) { 3003 for(i=0;i<6;i++) {
3006 if(!skip_dct[i]){ 3004 if(!skip_dct[i]){
3007 int overflow; 3005 int overflow;
3008 START_TIMER;
3009 s->block_last_index[i] = s->dct_quantize(s, s->block[i], i, s->qscale, &overflow); 3006 s->block_last_index[i] = s->dct_quantize(s, s->block[i], i, s->qscale, &overflow);
3010 STOP_TIMER("dct_quant");
3011 // FIXME we could decide to change to quantizer instead of clipping 3007 // FIXME we could decide to change to quantizer instead of clipping
3012 // JS: I don't think that would be a good idea it could lower quality instead 3008 // JS: I don't think that would be a good idea it could lower quality instead
3013 // of improve it. Just INTRADC clipping deserves changes in quantizer 3009 // of improve it. Just INTRADC clipping deserves changes in quantizer
3014 if (overflow) clip_coeffs(s, s->block[i], s->block_last_index[i]); 3010 if (overflow) clip_coeffs(s, s->block[i], s->block_last_index[i]);
3015 }else 3011 }else
4016 /* note: block[0] is assumed to be positive */ 4012 /* note: block[0] is assumed to be positive */
4017 block[0] = (block[0] + (q >> 1)) / q; 4013 block[0] = (block[0] + (q >> 1)) / q;
4018 start_i = 1; 4014 start_i = 1;
4019 last_non_zero = 0; 4015 last_non_zero = 0;
4020 qmat = s->q_intra_matrix[qscale]; 4016 qmat = s->q_intra_matrix[qscale];
4021 if(s->mpeg_quant) 4017 if(s->mpeg_quant || s->out_format == FMT_MPEG1)
4022 bias= 1<<(QMAT_SHIFT-1); 4018 bias= 1<<(QMAT_SHIFT-1);
4023 length = s->intra_ac_vlc_length; 4019 length = s->intra_ac_vlc_length;
4024 last_length= s->intra_ac_vlc_last_length; 4020 last_length= s->intra_ac_vlc_last_length;
4025 } else { 4021 } else {
4026 start_i = 0; 4022 start_i = 0;