comparison mpegvideo.c @ 6481:493dc59d469a libavcodec

add FF_ prefix to all (frame)_TYPE usage
author aurel
date Sun, 09 Mar 2008 23:31:02 +0000
parents 588d15844c80
children e44443c512b1
comparison
equal deleted inserted replaced
6480:6f01a499e785 6481:493dc59d469a
235 235
236 /* It might be nicer if the application would keep track of these 236 /* It might be nicer if the application would keep track of these
237 * but it would require an API change. */ 237 * but it would require an API change. */
238 memmove(s->prev_pict_types+1, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE-1); 238 memmove(s->prev_pict_types+1, s->prev_pict_types, PREV_PICT_TYPES_BUFFER_SIZE-1);
239 s->prev_pict_types[0]= s->pict_type; 239 s->prev_pict_types[0]= s->pict_type;
240 if(pic->age < PREV_PICT_TYPES_BUFFER_SIZE && s->prev_pict_types[pic->age] == B_TYPE) 240 if(pic->age < PREV_PICT_TYPES_BUFFER_SIZE && s->prev_pict_types[pic->age] == FF_B_TYPE)
241 pic->age= INT_MAX; // Skipped MBs in B-frames are quite rare in MPEG-1/2 and it is a bit tricky to skip them anyway. 241 pic->age= INT_MAX; // Skipped MBs in B-frames are quite rare in MPEG-1/2 and it is a bit tricky to skip them anyway.
242 242
243 return 0; 243 return 0;
244 fail: //for the CHECKED_ALLOCZ macro 244 fail: //for the CHECKED_ALLOCZ macro
245 if(r>=0) 245 if(r>=0)
834 s->mb_skipped = 0; 834 s->mb_skipped = 0;
835 835
836 assert(s->last_picture_ptr==NULL || s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3); 836 assert(s->last_picture_ptr==NULL || s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3);
837 837
838 /* mark&release old frames */ 838 /* mark&release old frames */
839 if (s->pict_type != B_TYPE && s->last_picture_ptr && s->last_picture_ptr != s->next_picture_ptr && s->last_picture_ptr->data[0]) { 839 if (s->pict_type != FF_B_TYPE && s->last_picture_ptr && s->last_picture_ptr != s->next_picture_ptr && s->last_picture_ptr->data[0]) {
840 if(s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3){ 840 if(s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3){
841 avctx->release_buffer(avctx, (AVFrame*)s->last_picture_ptr); 841 avctx->release_buffer(avctx, (AVFrame*)s->last_picture_ptr);
842 842
843 /* release forgotten pictures */ 843 /* release forgotten pictures */
844 /* if(mpeg124/h263) */ 844 /* if(mpeg124/h263) */
870 870
871 pic->reference= 0; 871 pic->reference= 0;
872 if (!s->dropable){ 872 if (!s->dropable){
873 if (s->codec_id == CODEC_ID_H264) 873 if (s->codec_id == CODEC_ID_H264)
874 pic->reference = s->picture_structure; 874 pic->reference = s->picture_structure;
875 else if (s->pict_type != B_TYPE) 875 else if (s->pict_type != FF_B_TYPE)
876 pic->reference = 3; 876 pic->reference = 3;
877 } 877 }
878 878
879 pic->coded_picture_number= s->coded_picture_number++; 879 pic->coded_picture_number= s->coded_picture_number++;
880 880
887 } 887 }
888 888
889 s->current_picture_ptr->pict_type= s->pict_type; 889 s->current_picture_ptr->pict_type= s->pict_type;
890 // if(s->flags && CODEC_FLAG_QSCALE) 890 // if(s->flags && CODEC_FLAG_QSCALE)
891 // s->current_picture_ptr->quality= s->new_picture_ptr->quality; 891 // s->current_picture_ptr->quality= s->new_picture_ptr->quality;
892 s->current_picture_ptr->key_frame= s->pict_type == I_TYPE; 892 s->current_picture_ptr->key_frame= s->pict_type == FF_I_TYPE;
893 893
894 copy_picture(&s->current_picture, s->current_picture_ptr); 894 copy_picture(&s->current_picture, s->current_picture_ptr);
895 895
896 if (s->pict_type != B_TYPE) { 896 if (s->pict_type != FF_B_TYPE) {
897 s->last_picture_ptr= s->next_picture_ptr; 897 s->last_picture_ptr= s->next_picture_ptr;
898 if(!s->dropable) 898 if(!s->dropable)
899 s->next_picture_ptr= s->current_picture_ptr; 899 s->next_picture_ptr= s->current_picture_ptr;
900 } 900 }
901 /* av_log(s->avctx, AV_LOG_DEBUG, "L%p N%p C%p L%p N%p C%p type:%d drop:%d\n", s->last_picture_ptr, s->next_picture_ptr,s->current_picture_ptr, 901 /* av_log(s->avctx, AV_LOG_DEBUG, "L%p N%p C%p L%p N%p C%p type:%d drop:%d\n", s->last_picture_ptr, s->next_picture_ptr,s->current_picture_ptr,
905 s->pict_type, s->dropable);*/ 905 s->pict_type, s->dropable);*/
906 906
907 if(s->last_picture_ptr) copy_picture(&s->last_picture, s->last_picture_ptr); 907 if(s->last_picture_ptr) copy_picture(&s->last_picture, s->last_picture_ptr);
908 if(s->next_picture_ptr) copy_picture(&s->next_picture, s->next_picture_ptr); 908 if(s->next_picture_ptr) copy_picture(&s->next_picture, s->next_picture_ptr);
909 909
910 if(s->pict_type != I_TYPE && (s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL) && !s->dropable){ 910 if(s->pict_type != FF_I_TYPE && (s->last_picture_ptr==NULL || s->last_picture_ptr->data[0]==NULL) && !s->dropable){
911 av_log(avctx, AV_LOG_ERROR, "warning: first frame is no keyframe\n"); 911 av_log(avctx, AV_LOG_ERROR, "warning: first frame is no keyframe\n");
912 assert(s->pict_type != B_TYPE); //these should have been dropped if we don't have a reference 912 assert(s->pict_type != FF_B_TYPE); //these should have been dropped if we don't have a reference
913 goto alloc; 913 goto alloc;
914 } 914 }
915 915
916 assert(s->pict_type == I_TYPE || (s->last_picture_ptr && s->last_picture_ptr->data[0])); 916 assert(s->pict_type == FF_I_TYPE || (s->last_picture_ptr && s->last_picture_ptr->data[0]));
917 917
918 if(s->picture_structure!=PICT_FRAME && s->out_format != FMT_H264){ 918 if(s->picture_structure!=PICT_FRAME && s->out_format != FMT_H264){
919 int i; 919 int i;
920 for(i=0; i<4; i++){ 920 for(i=0; i<4; i++){
921 if(s->picture_structure == PICT_BOTTOM_FIELD){ 921 if(s->picture_structure == PICT_BOTTOM_FIELD){
974 } 974 }
975 emms_c(); 975 emms_c();
976 976
977 s->last_pict_type = s->pict_type; 977 s->last_pict_type = s->pict_type;
978 s->last_lambda_for[s->pict_type]= s->current_picture_ptr->quality; 978 s->last_lambda_for[s->pict_type]= s->current_picture_ptr->quality;
979 if(s->pict_type!=B_TYPE){ 979 if(s->pict_type!=FF_B_TYPE){
980 s->last_non_b_pict_type= s->pict_type; 980 s->last_non_b_pict_type= s->pict_type;
981 } 981 }
982 #if 0 982 #if 0
983 /* copy back current_picture variables */ 983 /* copy back current_picture variables */
984 for(i=0; i<MAX_PICTURE_COUNT; i++){ 984 for(i=0; i<MAX_PICTURE_COUNT; i++){
1600 mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, 1600 mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
1601 1, 1, s->field_select[dir][1], 1601 1, 1, s->field_select[dir][1],
1602 ref_picture, pix_op, 1602 ref_picture, pix_op,
1603 s->mv[dir][1][0], s->mv[dir][1][1], block_s); 1603 s->mv[dir][1][0], s->mv[dir][1][1], block_s);
1604 } else { 1604 } else {
1605 if(s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != B_TYPE && !s->first_field){ 1605 if(s->picture_structure != s->field_select[dir][0] + 1 && s->pict_type != FF_B_TYPE && !s->first_field){
1606 ref_picture= s->current_picture_ptr->data; 1606 ref_picture= s->current_picture_ptr->data;
1607 } 1607 }
1608 1608
1609 mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr, 1609 mpeg_motion_lowres(s, dest_y, dest_cb, dest_cr,
1610 0, 0, s->field_select[dir][0], 1610 0, 0, s->field_select[dir][0],
1614 break; 1614 break;
1615 case MV_TYPE_16X8: 1615 case MV_TYPE_16X8:
1616 for(i=0; i<2; i++){ 1616 for(i=0; i<2; i++){
1617 uint8_t ** ref2picture; 1617 uint8_t ** ref2picture;
1618 1618
1619 if(s->picture_structure == s->field_select[dir][i] + 1 || s->pict_type == B_TYPE || s->first_field){ 1619 if(s->picture_structure == s->field_select[dir][i] + 1 || s->pict_type == FF_B_TYPE || s->first_field){
1620 ref2picture= ref_picture; 1620 ref2picture= ref_picture;
1621 }else{ 1621 }else{
1622 ref2picture= s->current_picture_ptr->data; 1622 ref2picture= s->current_picture_ptr->data;
1623 } 1623 }
1624 1624
1772 } 1772 }
1773 } 1773 }
1774 else if (s->h263_pred || s->h263_aic) 1774 else if (s->h263_pred || s->h263_aic)
1775 s->mbintra_table[mb_xy]=1; 1775 s->mbintra_table[mb_xy]=1;
1776 1776
1777 if ((s->flags&CODEC_FLAG_PSNR) || !(s->encoding && (s->intra_only || s->pict_type==B_TYPE) && s->avctx->mb_decision != FF_MB_DECISION_RD)) { //FIXME precalc 1777 if ((s->flags&CODEC_FLAG_PSNR) || !(s->encoding && (s->intra_only || s->pict_type==FF_B_TYPE) && s->avctx->mb_decision != FF_MB_DECISION_RD)) { //FIXME precalc
1778 uint8_t *dest_y, *dest_cb, *dest_cr; 1778 uint8_t *dest_y, *dest_cb, *dest_cr;
1779 int dct_linesize, dct_offset; 1779 int dct_linesize, dct_offset;
1780 op_pixels_func (*op_pix)[4]; 1780 op_pixels_func (*op_pix)[4];
1781 qpel_mc_func (*op_qpix)[16]; 1781 qpel_mc_func (*op_qpix)[16];
1782 const int linesize= s->current_picture.linesize[0]; //not s->linesize as this would be wrong for field pics 1782 const int linesize= s->current_picture.linesize[0]; //not s->linesize as this would be wrong for field pics
1783 const int uvlinesize= s->current_picture.linesize[1]; 1783 const int uvlinesize= s->current_picture.linesize[1];
1784 const int readable= s->pict_type != B_TYPE || s->encoding || s->avctx->draw_horiz_band || lowres_flag; 1784 const int readable= s->pict_type != FF_B_TYPE || s->encoding || s->avctx->draw_horiz_band || lowres_flag;
1785 const int block_size= lowres_flag ? 8>>s->avctx->lowres : 8; 1785 const int block_size= lowres_flag ? 8>>s->avctx->lowres : 8;
1786 1786
1787 /* avoid copy if macroblock skipped in last frame too */ 1787 /* avoid copy if macroblock skipped in last frame too */
1788 /* skip only during decoding as we might trash the buffers during encoding a bit */ 1788 /* skip only during decoding as we might trash the buffers during encoding a bit */
1789 if(!s->encoding){ 1789 if(!s->encoding){
1792 1792
1793 assert(age); 1793 assert(age);
1794 1794
1795 if (s->mb_skipped) { 1795 if (s->mb_skipped) {
1796 s->mb_skipped= 0; 1796 s->mb_skipped= 0;
1797 assert(s->pict_type!=I_TYPE); 1797 assert(s->pict_type!=FF_I_TYPE);
1798 1798
1799 (*mbskip_ptr) ++; /* indicate that this time we skipped it */ 1799 (*mbskip_ptr) ++; /* indicate that this time we skipped it */
1800 if(*mbskip_ptr >99) *mbskip_ptr= 99; 1800 if(*mbskip_ptr >99) *mbskip_ptr= 99;
1801 1801
1802 /* if previous was skipped too, then nothing to do ! */ 1802 /* if previous was skipped too, then nothing to do ! */
1838 if (s->mv_dir & MV_DIR_BACKWARD) { 1838 if (s->mv_dir & MV_DIR_BACKWARD) {
1839 MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.data, op_pix); 1839 MPV_motion_lowres(s, dest_y, dest_cb, dest_cr, 1, s->next_picture.data, op_pix);
1840 } 1840 }
1841 }else{ 1841 }else{
1842 op_qpix= s->me.qpel_put; 1842 op_qpix= s->me.qpel_put;
1843 if ((!s->no_rounding) || s->pict_type==B_TYPE){ 1843 if ((!s->no_rounding) || s->pict_type==FF_B_TYPE){
1844 op_pix = s->dsp.put_pixels_tab; 1844 op_pix = s->dsp.put_pixels_tab;
1845 }else{ 1845 }else{
1846 op_pix = s->dsp.put_no_rnd_pixels_tab; 1846 op_pix = s->dsp.put_no_rnd_pixels_tab;
1847 } 1847 }
1848 if (s->mv_dir & MV_DIR_FORWARD) { 1848 if (s->mv_dir & MV_DIR_FORWARD) {
1857 } 1857 }
1858 1858
1859 /* skip dequant / idct if we are really late ;) */ 1859 /* skip dequant / idct if we are really late ;) */
1860 if(s->hurry_up>1) goto skip_idct; 1860 if(s->hurry_up>1) goto skip_idct;
1861 if(s->avctx->skip_idct){ 1861 if(s->avctx->skip_idct){
1862 if( (s->avctx->skip_idct >= AVDISCARD_NONREF && s->pict_type == B_TYPE) 1862 if( (s->avctx->skip_idct >= AVDISCARD_NONREF && s->pict_type == FF_B_TYPE)
1863 ||(s->avctx->skip_idct >= AVDISCARD_NONKEY && s->pict_type != I_TYPE) 1863 ||(s->avctx->skip_idct >= AVDISCARD_NONKEY && s->pict_type != FF_I_TYPE)
1864 || s->avctx->skip_idct >= AVDISCARD_ALL) 1864 || s->avctx->skip_idct >= AVDISCARD_ALL)
1865 goto skip_idct; 1865 goto skip_idct;
1866 } 1866 }
1867 1867
1868 /* add dct residue */ 1868 /* add dct residue */
1996 if(s->first_field && !(s->avctx->slice_flags&SLICE_FLAG_ALLOW_FIELD)) return; 1996 if(s->first_field && !(s->avctx->slice_flags&SLICE_FLAG_ALLOW_FIELD)) return;
1997 } 1997 }
1998 1998
1999 h= FFMIN(h, s->avctx->height - y); 1999 h= FFMIN(h, s->avctx->height - y);
2000 2000
2001 if(s->pict_type==B_TYPE || s->low_delay || (s->avctx->slice_flags&SLICE_FLAG_CODED_ORDER)) 2001 if(s->pict_type==FF_B_TYPE || s->low_delay || (s->avctx->slice_flags&SLICE_FLAG_CODED_ORDER))
2002 src= (AVFrame*)s->current_picture_ptr; 2002 src= (AVFrame*)s->current_picture_ptr;
2003 else if(s->last_picture_ptr) 2003 else if(s->last_picture_ptr)
2004 src= (AVFrame*)s->last_picture_ptr; 2004 src= (AVFrame*)s->last_picture_ptr;
2005 else 2005 else
2006 return; 2006 return;
2007 2007
2008 if(s->pict_type==B_TYPE && s->picture_structure == PICT_FRAME && s->out_format != FMT_H264){ 2008 if(s->pict_type==FF_B_TYPE && s->picture_structure == PICT_FRAME && s->out_format != FMT_H264){
2009 offset[0]= 2009 offset[0]=
2010 offset[1]= 2010 offset[1]=
2011 offset[2]= 2011 offset[2]=
2012 offset[3]= 0; 2012 offset[3]= 0;
2013 }else{ 2013 }else{
2039 2039
2040 s->dest[0] = s->current_picture.data[0] + ((s->mb_x - 1) << mb_size); 2040 s->dest[0] = s->current_picture.data[0] + ((s->mb_x - 1) << mb_size);
2041 s->dest[1] = s->current_picture.data[1] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift)); 2041 s->dest[1] = s->current_picture.data[1] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift));
2042 s->dest[2] = s->current_picture.data[2] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift)); 2042 s->dest[2] = s->current_picture.data[2] + ((s->mb_x - 1) << (mb_size - s->chroma_x_shift));
2043 2043
2044 if(!(s->pict_type==B_TYPE && s->avctx->draw_horiz_band && s->picture_structure==PICT_FRAME)) 2044 if(!(s->pict_type==FF_B_TYPE && s->avctx->draw_horiz_band && s->picture_structure==PICT_FRAME))
2045 { 2045 {
2046 s->dest[0] += s->mb_y * linesize << mb_size; 2046 s->dest[0] += s->mb_y * linesize << mb_size;
2047 s->dest[1] += s->mb_y * uvlinesize << (mb_size - s->chroma_y_shift); 2047 s->dest[1] += s->mb_y * uvlinesize << (mb_size - s->chroma_y_shift);
2048 s->dest[2] += s->mb_y * uvlinesize << (mb_size - s->chroma_y_shift); 2048 s->dest[2] += s->mb_y * uvlinesize << (mb_size - s->chroma_y_shift);
2049 } 2049 }