comparison mpegvideo.c @ 2628:511e3afc43e1 libavcodec

Ministry of English Composition, reporting for duty (and the word is "skipped", not "skiped"; "skiped" would rhyme with "hyped")
author melanson
date Sun, 24 Apr 2005 17:21:11 +0000
parents bf158d23bbcc
children ef44d24680d1
comparison
equal deleted inserted replaced
2627:bf158d23bbcc 2628:511e3afc43e1
407 407
408 //it might be nicer if the application would keep track of these but it would require a API change 408 //it might be nicer if the application would keep track of these but it would require a API change
409 memmove(s->prev_pict_types+1, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE-1); 409 memmove(s->prev_pict_types+1, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE-1);
410 s->prev_pict_types[0]= s->pict_type; 410 s->prev_pict_types[0]= s->pict_type;
411 if(pic->age < PREV_PICT_TYPES_BUFFER_SIZE && s->prev_pict_types[pic->age] == B_TYPE) 411 if(pic->age < PREV_PICT_TYPES_BUFFER_SIZE && s->prev_pict_types[pic->age] == B_TYPE)
412 pic->age= INT_MAX; // skiped MBs in b frames are quite rare in mpeg1/2 and its a bit tricky to skip them anyway 412 pic->age= INT_MAX; // skipped MBs in b frames are quite rare in mpeg1/2 and its a bit tricky to skip them anyway
413 413
414 return 0; 414 return 0;
415 fail: //for the CHECKED_ALLOCZ macro 415 fail: //for the CHECKED_ALLOCZ macro
416 return -1; 416 return -1;
417 } 417 }
1442 */ 1442 */
1443 int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx) 1443 int MPV_frame_start(MpegEncContext *s, AVCodecContext *avctx)
1444 { 1444 {
1445 int i; 1445 int i;
1446 AVFrame *pic; 1446 AVFrame *pic;
1447 s->mb_skiped = 0; 1447 s->mb_skipped = 0;
1448 1448
1449 assert(s->last_picture_ptr==NULL || s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3); 1449 assert(s->last_picture_ptr==NULL || s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3);
1450 1450
1451 /* mark&release old frames */ 1451 /* mark&release old frames */
1452 if (s->pict_type != B_TYPE && s->last_picture_ptr && s->last_picture_ptr != s->next_picture_ptr && s->last_picture_ptr->data[0]) { 1452 if (s->pict_type != B_TYPE && s->last_picture_ptr && s->last_picture_ptr != s->next_picture_ptr && s->last_picture_ptr->data[0]) {
3225 int16_t mv_cache[4][4][2]; 3225 int16_t mv_cache[4][4][2];
3226 const int xy= s->mb_x + s->mb_y*s->mb_stride; 3226 const int xy= s->mb_x + s->mb_y*s->mb_stride;
3227 const int mot_stride= s->b8_stride; 3227 const int mot_stride= s->b8_stride;
3228 const int mot_xy= mb_x*2 + mb_y*2*mot_stride; 3228 const int mot_xy= mb_x*2 + mb_y*2*mot_stride;
3229 3229
3230 assert(!s->mb_skiped); 3230 assert(!s->mb_skipped);
3231 3231
3232 memcpy(mv_cache[1][1], s->current_picture.motion_val[0][mot_xy ], sizeof(int16_t)*4); 3232 memcpy(mv_cache[1][1], s->current_picture.motion_val[0][mot_xy ], sizeof(int16_t)*4);
3233 memcpy(mv_cache[2][1], s->current_picture.motion_val[0][mot_xy+mot_stride], sizeof(int16_t)*4); 3233 memcpy(mv_cache[2][1], s->current_picture.motion_val[0][mot_xy+mot_stride], sizeof(int16_t)*4);
3234 memcpy(mv_cache[3][1], s->current_picture.motion_val[0][mot_xy+mot_stride], sizeof(int16_t)*4); 3234 memcpy(mv_cache[3][1], s->current_picture.motion_val[0][mot_xy+mot_stride], sizeof(int16_t)*4);
3235 3235
3697 uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy]; 3697 uint8_t *mbskip_ptr = &s->mbskip_table[mb_xy];
3698 const int age= s->current_picture.age; 3698 const int age= s->current_picture.age;
3699 3699
3700 assert(age); 3700 assert(age);
3701 3701
3702 if (s->mb_skiped) { 3702 if (s->mb_skipped) {
3703 s->mb_skiped= 0; 3703 s->mb_skipped= 0;
3704 assert(s->pict_type!=I_TYPE); 3704 assert(s->pict_type!=I_TYPE);
3705 3705
3706 (*mbskip_ptr) ++; /* indicate that this time we skiped it */ 3706 (*mbskip_ptr) ++; /* indicate that this time we skipped it */
3707 if(*mbskip_ptr >99) *mbskip_ptr= 99; 3707 if(*mbskip_ptr >99) *mbskip_ptr= 99;
3708 3708
3709 /* if previous was skipped too, then nothing to do ! */ 3709 /* if previous was skipped too, then nothing to do ! */
3710 if (*mbskip_ptr >= age && s->current_picture.reference){ 3710 if (*mbskip_ptr >= age && s->current_picture.reference){
3711 return; 3711 return;
4372 d->b_count= s->b_count; 4372 d->b_count= s->b_count;
4373 d->skip_count= s->skip_count; 4373 d->skip_count= s->skip_count;
4374 d->misc_bits= s->misc_bits; 4374 d->misc_bits= s->misc_bits;
4375 d->last_bits= 0; 4375 d->last_bits= 0;
4376 4376
4377 d->mb_skiped= 0; 4377 d->mb_skipped= 0;
4378 d->qscale= s->qscale; 4378 d->qscale= s->qscale;
4379 d->dquant= s->dquant; 4379 d->dquant= s->dquant;
4380 } 4380 }
4381 4381
4382 static inline void copy_context_after_encode(MpegEncContext *d, MpegEncContext *s, int type){ 4382 static inline void copy_context_after_encode(MpegEncContext *d, MpegEncContext *s, int type){
4399 d->b_count= s->b_count; 4399 d->b_count= s->b_count;
4400 d->skip_count= s->skip_count; 4400 d->skip_count= s->skip_count;
4401 d->misc_bits= s->misc_bits; 4401 d->misc_bits= s->misc_bits;
4402 4402
4403 d->mb_intra= s->mb_intra; 4403 d->mb_intra= s->mb_intra;
4404 d->mb_skiped= s->mb_skiped; 4404 d->mb_skipped= s->mb_skipped;
4405 d->mv_type= s->mv_type; 4405 d->mv_type= s->mv_type;
4406 d->mv_dir= s->mv_dir; 4406 d->mv_dir= s->mv_dir;
4407 d->pb= s->pb; 4407 d->pb= s->pb;
4408 if(s->data_partitioning){ 4408 if(s->data_partitioning){
4409 d->pb2= s->pb2; 4409 d->pb2= s->pb2;
4771 if( (s->resync_mb_x == s->mb_x) 4771 if( (s->resync_mb_x == s->mb_x)
4772 && s->resync_mb_y+1 == s->mb_y){ 4772 && s->resync_mb_y+1 == s->mb_y){
4773 s->first_slice_line=0; 4773 s->first_slice_line=0;
4774 } 4774 }
4775 4775
4776 s->mb_skiped=0; 4776 s->mb_skipped=0;
4777 s->dquant=0; //only for QP_RD 4777 s->dquant=0; //only for QP_RD
4778 4778
4779 if(mb_type & (mb_type-1) || (s->flags & CODEC_FLAG_QP_RD)){ // more than 1 MB type possible or CODEC_FLAG_QP_RD 4779 if(mb_type & (mb_type-1) || (s->flags & CODEC_FLAG_QP_RD)){ // more than 1 MB type possible or CODEC_FLAG_QP_RD
4780 int next_block=0; 4780 int next_block=0;
4781 int pb_bits_count, pb2_bits_count, tex_pb_bits_count; 4781 int pb_bits_count, pb2_bits_count, tex_pb_bits_count;
4808 s->mv[0][i][1] = s->p_field_mv_table[i][j][xy][1]; 4808 s->mv[0][i][1] = s->p_field_mv_table[i][j][xy][1];
4809 } 4809 }
4810 encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER_I, pb, pb2, tex_pb, 4810 encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_INTER_I, pb, pb2, tex_pb,
4811 &dmin, &next_block, 0, 0); 4811 &dmin, &next_block, 0, 0);
4812 } 4812 }
4813 if(mb_type&CANDIDATE_MB_TYPE_SKIPED){ 4813 if(mb_type&CANDIDATE_MB_TYPE_SKIPPED){
4814 s->mv_dir = MV_DIR_FORWARD; 4814 s->mv_dir = MV_DIR_FORWARD;
4815 s->mv_type = MV_TYPE_16X16; 4815 s->mv_type = MV_TYPE_16X16;
4816 s->mb_intra= 0; 4816 s->mb_intra= 0;
4817 s->mv[0][0][0] = 0; 4817 s->mv[0][0][0] = 0;
4818 s->mv[0][0][1] = 0; 4818 s->mv[0][0][1] = 0;
4819 encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_SKIPED, pb, pb2, tex_pb, 4819 encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_SKIPPED, pb, pb2, tex_pb,
4820 &dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]); 4820 &dmin, &next_block, s->mv[0][0][0], s->mv[0][0][1]);
4821 } 4821 }
4822 if(mb_type&CANDIDATE_MB_TYPE_INTER4V){ 4822 if(mb_type&CANDIDATE_MB_TYPE_INTER4V){
4823 s->mv_dir = MV_DIR_FORWARD; 4823 s->mv_dir = MV_DIR_FORWARD;
4824 s->mv_type = MV_TYPE_8X8; 4824 s->mv_type = MV_TYPE_8X8;