Mercurial > libavcodec.hg
comparison h263dec.c @ 903:22ee74da2cd3 libavcodec
cleanup
adding AVVideoFrame
moving quality, pict_type, key_frame, qscale_table, ... to AVVideoFrame
removing obsolete variables in AVCodecContext
skiping of MBs in b frames
correctly initalizing AVCodecContext
picture buffer cleanup
| author | michaelni |
|---|---|
| date | Wed, 04 Dec 2002 10:04:03 +0000 |
| parents | 4513713d664a |
| children | b3ae2aba4b24 |
comparison
equal
deleted
inserted
replaced
| 902:6acc8394960d | 903:22ee74da2cd3 |
|---|---|
| 197 /* DCT & quantize */ | 197 /* DCT & quantize */ |
| 198 s->dsp.clear_blocks(s->block[0]); | 198 s->dsp.clear_blocks(s->block[0]); |
| 199 | 199 |
| 200 s->mv_dir = MV_DIR_FORWARD; | 200 s->mv_dir = MV_DIR_FORWARD; |
| 201 s->mv_type = MV_TYPE_16X16; | 201 s->mv_type = MV_TYPE_16X16; |
| 202 // s->mb_skiped = 0; | |
| 202 //printf("%d %d %06X\n", ret, get_bits_count(&s->gb), show_bits(&s->gb, 24)); | 203 //printf("%d %d %06X\n", ret, get_bits_count(&s->gb), show_bits(&s->gb, 24)); |
| 203 ret= s->decode_mb(s, s->block); | 204 ret= s->decode_mb(s, s->block); |
| 204 | 205 |
| 205 PRINT_QP("%2d", s->qscale); | 206 PRINT_QP("%2d", s->qscale); |
| 206 MPV_decode_mb(s, s->block); | 207 MPV_decode_mb(s, s->block); |
| 345 void *data, int *data_size, | 346 void *data, int *data_size, |
| 346 UINT8 *buf, int buf_size) | 347 UINT8 *buf, int buf_size) |
| 347 { | 348 { |
| 348 MpegEncContext *s = avctx->priv_data; | 349 MpegEncContext *s = avctx->priv_data; |
| 349 int ret,i; | 350 int ret,i; |
| 350 AVPicture *pict = data; | 351 AVVideoFrame *pict = data; |
| 351 float new_aspect; | 352 float new_aspect; |
| 352 | 353 |
| 353 #ifdef PRINT_FRAME_TIME | 354 #ifdef PRINT_FRAME_TIME |
| 354 uint64_t time= rdtsc(); | 355 uint64_t time= rdtsc(); |
| 355 #endif | 356 #endif |
| 356 #ifdef DEBUG | 357 #ifdef DEBUG |
| 357 printf("*****frame %d size=%d\n", avctx->frame_number, buf_size); | 358 printf("*****frame %d size=%d\n", avctx->frame_number, buf_size); |
| 358 printf("bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]); | 359 printf("bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]); |
| 359 #endif | 360 #endif |
| 360 | |
| 361 s->flags= avctx->flags; | 361 s->flags= avctx->flags; |
| 362 | 362 |
| 363 *data_size = 0; | 363 *data_size = 0; |
| 364 | 364 |
| 365 /* no supplementary picture */ | 365 /* no supplementary picture */ |
| 521 if (ret < 0){ | 521 if (ret < 0){ |
| 522 fprintf(stderr, "header damaged\n"); | 522 fprintf(stderr, "header damaged\n"); |
| 523 return -1; | 523 return -1; |
| 524 } | 524 } |
| 525 | 525 |
| 526 s->avctx->key_frame = (s->pict_type == I_TYPE); | 526 // for hurry_up==5 |
| 527 s->avctx->pict_type = s->pict_type; | 527 s->current_picture.pict_type= s->pict_type; |
| 528 s->current_picture.key_frame= s->pict_type == I_TYPE; | |
| 528 | 529 |
| 529 /* skip b frames if we dont have reference frames */ | 530 /* skip b frames if we dont have reference frames */ |
| 530 if(s->num_available_buffers<2 && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size); | 531 if(s->num_available_buffers<2 && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size); |
| 531 /* skip b frames if we are in a hurry */ | 532 /* skip b frames if we are in a hurry */ |
| 532 if(avctx->hurry_up && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size); | 533 if(avctx->hurry_up && s->pict_type==B_TYPE) return get_consumed_bytes(s, buf_size); |
| 578 | 579 |
| 579 s->error_status_table[s->resync_mb_x + s->resync_mb_y*s->mb_width]|= VP_START; | 580 s->error_status_table[s->resync_mb_x + s->resync_mb_y*s->mb_width]|= VP_START; |
| 580 } | 581 } |
| 581 | 582 |
| 582 if (s->h263_msmpeg4 && s->msmpeg4_version<4 && s->pict_type==I_TYPE) | 583 if (s->h263_msmpeg4 && s->msmpeg4_version<4 && s->pict_type==I_TYPE) |
| 583 if(msmpeg4_decode_ext_header(s, buf_size) < 0) return -1; | 584 if(msmpeg4_decode_ext_header(s, buf_size) < 0){ |
| 585 s->error_status_table[s->mb_num-1]= AC_ERROR|DC_ERROR|MV_ERROR; | |
| 586 } | |
| 584 | 587 |
| 585 /* divx 5.01+ bistream reorder stuff */ | 588 /* divx 5.01+ bistream reorder stuff */ |
| 586 if(s->codec_id==CODEC_ID_MPEG4 && s->bitstream_buffer_size==0 && s->divx_version>=500){ | 589 if(s->codec_id==CODEC_ID_MPEG4 && s->bitstream_buffer_size==0 && s->divx_version>=500){ |
| 587 int current_pos= get_bits_count(&s->gb)>>3; | 590 int current_pos= get_bits_count(&s->gb)>>3; |
| 588 | 591 |
| 642 for(mb_y=0; mb_y<s->mb_height; mb_y++){ | 645 for(mb_y=0; mb_y<s->mb_height; mb_y++){ |
| 643 int mb_x; | 646 int mb_x; |
| 644 int y= mb_y*16 + 8; | 647 int y= mb_y*16 + 8; |
| 645 for(mb_x=0; mb_x<s->mb_width; mb_x++){ | 648 for(mb_x=0; mb_x<s->mb_width; mb_x++){ |
| 646 int x= mb_x*16 + 8; | 649 int x= mb_x*16 + 8; |
| 647 uint8_t *ptr= s->last_picture[0]; | 650 uint8_t *ptr= s->last_picture.data[0]; |
| 648 int xy= 1 + mb_x*2 + (mb_y*2 + 1)*(s->mb_width*2 + 2); | 651 int xy= 1 + mb_x*2 + (mb_y*2 + 1)*(s->mb_width*2 + 2); |
| 649 int mx= (s->motion_val[xy][0]>>1) + x; | 652 int mx= (s->motion_val[xy][0]>>1) + x; |
| 650 int my= (s->motion_val[xy][1]>>1) + y; | 653 int my= (s->motion_val[xy][1]>>1) + y; |
| 651 int i; | 654 int i; |
| 652 int max; | 655 int max; |
| 667 s->mbskip_table[mb_x + mb_y*s->mb_width]=0; | 670 s->mbskip_table[mb_x + mb_y*s->mb_width]=0; |
| 668 } | 671 } |
| 669 } | 672 } |
| 670 | 673 |
| 671 } | 674 } |
| 672 #endif | 675 #endif |
| 673 if(s->pict_type==B_TYPE || (!s->has_b_frames)){ | 676 if(s->pict_type==B_TYPE || (!s->has_b_frames)){ |
| 674 pict->data[0] = s->current_picture[0]; | 677 *pict= *(AVVideoFrame*)&s->current_picture; |
| 675 pict->data[1] = s->current_picture[1]; | |
| 676 pict->data[2] = s->current_picture[2]; | |
| 677 } else { | 678 } else { |
| 678 pict->data[0] = s->last_picture[0]; | 679 *pict= *(AVVideoFrame*)&s->last_picture; |
| 679 pict->data[1] = s->last_picture[1]; | 680 } |
| 680 pict->data[2] = s->last_picture[2]; | |
| 681 } | |
| 682 pict->linesize[0] = s->linesize; | |
| 683 pict->linesize[1] = s->uvlinesize; | |
| 684 pict->linesize[2] = s->uvlinesize; | |
| 685 | |
| 686 avctx->quality = s->qscale; | |
| 687 | 681 |
| 688 /* Return the Picture timestamp as the frame number */ | 682 /* Return the Picture timestamp as the frame number */ |
| 689 /* we substract 1 because it is added on utils.c */ | 683 /* we substract 1 because it is added on utils.c */ |
| 690 avctx->frame_number = s->picture_number - 1; | 684 avctx->frame_number = s->picture_number - 1; |
| 691 | 685 |
| 692 /* dont output the last pic after seeking | 686 /* dont output the last pic after seeking |
| 693 note we allready added +1 for the current pix in MPV_frame_end(s) */ | 687 note we allready added +1 for the current pix in MPV_frame_end(s) */ |
| 694 if(s->num_available_buffers>=2 || (!s->has_b_frames)) | 688 if(s->num_available_buffers>=2 || (!s->has_b_frames)) |
| 695 *data_size = sizeof(AVPicture); | 689 *data_size = sizeof(AVVideoFrame); |
| 696 #ifdef PRINT_FRAME_TIME | 690 #ifdef PRINT_FRAME_TIME |
| 697 printf("%Ld\n", rdtsc()-time); | 691 printf("%Ld\n", rdtsc()-time); |
| 698 #endif | 692 #endif |
| 699 return get_consumed_bytes(s, buf_size); | 693 return get_consumed_bytes(s, buf_size); |
| 700 } | 694 } |
