Mercurial > libavcodec.hg
comparison mpegvideo.c @ 1705:954593137d37 libavcodec
picture number fixes
author | michael |
---|---|
date | Mon, 29 Dec 2003 22:25:08 +0000 |
parents | 6797179a0649 |
children | 3ba5c493db6f |
comparison
equal
deleted
inserted
replaced
1704:8bccf5eda14b | 1705:954593137d37 |
---|---|
425 s->c_dc_scale_table= ff_mpeg1_dc_scale_table; | 425 s->c_dc_scale_table= ff_mpeg1_dc_scale_table; |
426 s->chroma_qscale_table= ff_default_chroma_qscale_table; | 426 s->chroma_qscale_table= ff_default_chroma_qscale_table; |
427 if (!s->encoding) | 427 if (!s->encoding) |
428 s->progressive_sequence= 1; | 428 s->progressive_sequence= 1; |
429 s->progressive_frame= 1; | 429 s->progressive_frame= 1; |
430 s->coded_picture_number = 0; | |
430 | 431 |
431 y_size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2); | 432 y_size = (2 * s->mb_width + 2) * (2 * s->mb_height + 2); |
432 c_size = (s->mb_width + 2) * (s->mb_height + 2); | 433 c_size = (s->mb_width + 2) * (s->mb_height + 2); |
433 yc_size = y_size + 2 * c_size; | 434 yc_size = y_size + 2 * c_size; |
434 | 435 |
973 | 974 |
974 if(ff_rate_control_init(s) < 0) | 975 if(ff_rate_control_init(s) < 0) |
975 return -1; | 976 return -1; |
976 | 977 |
977 s->picture_number = 0; | 978 s->picture_number = 0; |
979 s->input_picture_number = 0; | |
978 s->picture_in_gop_number = 0; | 980 s->picture_in_gop_number = 0; |
979 s->fake_picture_number = 0; | 981 s->fake_picture_number = 0; |
980 /* motion detector init */ | 982 /* motion detector init */ |
981 s->f_code = 1; | 983 s->f_code = 1; |
982 s->b_code = 1; | 984 s->b_code = 1; |
1151 pic= (AVFrame*)&s->picture[i]; | 1153 pic= (AVFrame*)&s->picture[i]; |
1152 } | 1154 } |
1153 | 1155 |
1154 pic->reference= s->pict_type != B_TYPE ? 3 : 0; | 1156 pic->reference= s->pict_type != B_TYPE ? 3 : 0; |
1155 | 1157 |
1156 if(s->current_picture_ptr) //FIXME broken, we need a coded_picture_number in MpegEncContext | 1158 pic->coded_picture_number= s->coded_picture_number++; |
1157 pic->coded_picture_number= s->current_picture_ptr->coded_picture_number+1; | |
1158 | 1159 |
1159 if( alloc_picture(s, (Picture*)pic, 0) < 0) | 1160 if( alloc_picture(s, (Picture*)pic, 0) < 0) |
1160 return -1; | 1161 return -1; |
1161 | 1162 |
1162 s->current_picture_ptr= (Picture*)pic; | 1163 s->current_picture_ptr= (Picture*)pic; |
1642 } | 1643 } |
1643 } | 1644 } |
1644 } | 1645 } |
1645 copy_picture_attributes(pic, pic_arg); | 1646 copy_picture_attributes(pic, pic_arg); |
1646 | 1647 |
1647 if(s->input_picture[encoding_delay]) | 1648 pic->display_picture_number= s->input_picture_number++; |
1648 pic->display_picture_number= s->input_picture[encoding_delay]->display_picture_number + 1; | |
1649 | |
1650 } | 1649 } |
1651 | 1650 |
1652 /* shift buffer entries */ | 1651 /* shift buffer entries */ |
1653 for(i=1; i<MAX_PICTURE_COUNT /*s->encoding_delay+1*/; i++) | 1652 for(i=1; i<MAX_PICTURE_COUNT /*s->encoding_delay+1*/; i++) |
1654 s->input_picture[i-1]= s->input_picture[i]; | 1653 s->input_picture[i-1]= s->input_picture[i]; |
1658 return 0; | 1657 return 0; |
1659 } | 1658 } |
1660 | 1659 |
1661 static void select_input_picture(MpegEncContext *s){ | 1660 static void select_input_picture(MpegEncContext *s){ |
1662 int i; | 1661 int i; |
1663 int coded_pic_num=0; | |
1664 | |
1665 if(s->reordered_input_picture[0]) | |
1666 coded_pic_num= s->reordered_input_picture[0]->coded_picture_number + 1; | |
1667 | 1662 |
1668 for(i=1; i<MAX_PICTURE_COUNT; i++) | 1663 for(i=1; i<MAX_PICTURE_COUNT; i++) |
1669 s->reordered_input_picture[i-1]= s->reordered_input_picture[i]; | 1664 s->reordered_input_picture[i-1]= s->reordered_input_picture[i]; |
1670 s->reordered_input_picture[MAX_PICTURE_COUNT-1]= NULL; | 1665 s->reordered_input_picture[MAX_PICTURE_COUNT-1]= NULL; |
1671 | 1666 |
1672 /* set next picture types & ordering */ | 1667 /* set next picture types & ordering */ |
1673 if(s->reordered_input_picture[0]==NULL && s->input_picture[0]){ | 1668 if(s->reordered_input_picture[0]==NULL && s->input_picture[0]){ |
1674 if(/*s->picture_in_gop_number >= s->gop_size ||*/ s->next_picture_ptr==NULL || s->intra_only){ | 1669 if(/*s->picture_in_gop_number >= s->gop_size ||*/ s->next_picture_ptr==NULL || s->intra_only){ |
1675 s->reordered_input_picture[0]= s->input_picture[0]; | 1670 s->reordered_input_picture[0]= s->input_picture[0]; |
1676 s->reordered_input_picture[0]->pict_type= I_TYPE; | 1671 s->reordered_input_picture[0]->pict_type= I_TYPE; |
1677 s->reordered_input_picture[0]->coded_picture_number= coded_pic_num; | 1672 s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++; |
1678 }else{ | 1673 }else{ |
1679 int b_frames; | 1674 int b_frames; |
1680 | 1675 |
1681 if(s->flags&CODEC_FLAG_PASS2){ | 1676 if(s->flags&CODEC_FLAG_PASS2){ |
1682 for(i=0; i<s->max_b_frames+1; i++){ | 1677 for(i=0; i<s->max_b_frames+1; i++){ |
1733 if( s->picture_in_gop_number + b_frames >= s->gop_size | 1728 if( s->picture_in_gop_number + b_frames >= s->gop_size |
1734 || s->reordered_input_picture[0]->pict_type== I_TYPE) | 1729 || s->reordered_input_picture[0]->pict_type== I_TYPE) |
1735 s->reordered_input_picture[0]->pict_type= I_TYPE; | 1730 s->reordered_input_picture[0]->pict_type= I_TYPE; |
1736 else | 1731 else |
1737 s->reordered_input_picture[0]->pict_type= P_TYPE; | 1732 s->reordered_input_picture[0]->pict_type= P_TYPE; |
1738 s->reordered_input_picture[0]->coded_picture_number= coded_pic_num; | 1733 s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++; |
1739 for(i=0; i<b_frames; i++){ | 1734 for(i=0; i<b_frames; i++){ |
1740 coded_pic_num++; | |
1741 s->reordered_input_picture[i+1]= s->input_picture[i]; | 1735 s->reordered_input_picture[i+1]= s->input_picture[i]; |
1742 s->reordered_input_picture[i+1]->pict_type= B_TYPE; | 1736 s->reordered_input_picture[i+1]->pict_type= B_TYPE; |
1743 s->reordered_input_picture[i+1]->coded_picture_number= coded_pic_num; | 1737 s->reordered_input_picture[i+1]->coded_picture_number= s->coded_picture_number++; |
1744 } | 1738 } |
1745 } | 1739 } |
1746 } | 1740 } |
1747 | 1741 |
1748 if(s->reordered_input_picture[0]){ | 1742 if(s->reordered_input_picture[0]){ |
1836 | 1830 |
1837 for(i=0; i<4; i++){ | 1831 for(i=0; i<4; i++){ |
1838 avctx->error[i] += s->current_picture_ptr->error[i]; | 1832 avctx->error[i] += s->current_picture_ptr->error[i]; |
1839 } | 1833 } |
1840 } | 1834 } |
1841 | |
1842 s->input_picture_number++; | |
1843 | 1835 |
1844 flush_put_bits(&s->pb); | 1836 flush_put_bits(&s->pb); |
1845 s->frame_bits = (pbBufPtr(&s->pb) - s->pb.buf) * 8; | 1837 s->frame_bits = (pbBufPtr(&s->pb) - s->pb.buf) * 8; |
1846 | 1838 |
1847 stuffing_count= ff_vbv_update(s, s->frame_bits); | 1839 stuffing_count= ff_vbv_update(s, s->frame_bits); |