# HG changeset patch # User michael # Date 1067533129 0 # Node ID 3d1d0490e5a678a2ffdda58a9397224385865b8b # Parent 6b224ca2403340c6611848d1e018797bb6c03691 pts fix and related fixes diff -r 6b224ca24033 -r 3d1d0490e5a6 h263.c --- a/h263.c Thu Oct 30 05:40:58 2003 +0000 +++ b/h263.c Thu Oct 30 16:58:49 2003 +0000 @@ -1848,8 +1848,8 @@ void ff_set_mpeg4_time(MpegEncContext * s, int picture_number){ int time_div, time_mod; - if(s->current_picture.pts) - s->time= (s->current_picture.pts*s->time_increment_resolution + 500*1000)/(1000*1000); + if(s->current_picture_ptr->pts) + s->time= (s->current_picture_ptr->pts*s->time_increment_resolution + 500*1000)/(1000*1000); else s->time= av_rescale(picture_number*(int64_t)s->avctx->frame_rate_base, s->time_increment_resolution, s->avctx->frame_rate); time_div= s->time/s->time_increment_resolution; @@ -4994,9 +4994,9 @@ - ROUNDED_DIV(s->last_non_b_time - s->pp_time, s->t_frame))*2; } - s->current_picture.pts= s->time*1000LL*1000LL / s->time_increment_resolution; + s->current_picture_ptr->pts= s->time*1000LL*1000LL / s->time_increment_resolution; if(s->avctx->debug&FF_DEBUG_PTS) - printf("MPEG4 PTS: %f\n", s->current_picture.pts/(1000.0*1000.0)); + printf("MPEG4 PTS: %f\n", s->current_picture_ptr->pts/(1000.0*1000.0)); check_marker(gb, "before vop_coded"); diff -r 6b224ca24033 -r 3d1d0490e5a6 h263dec.c --- a/h263dec.c Thu Oct 30 05:40:58 2003 +0000 +++ b/h263dec.c Thu Oct 30 16:58:49 2003 +0000 @@ -28,17 +28,6 @@ //#define DEBUG //#define PRINT_FRAME_TIME -#ifdef PRINT_FRAME_TIME -static inline long long rdtsc() -{ - long long l; - asm volatile( "rdtsc\n\t" - : "=A" (l) - ); -// printf("%d\n", int(l/1000)); - return l; -} -#endif int ff_h263_decode_init(AVCodecContext *avctx) { @@ -446,6 +435,12 @@ if (MPV_common_init(s) < 0) //we need the idct permutaton for reading a custom matrix return -1; } + + //we need to set current_picture_ptr before reading the header, otherwise we cant store anyting im there + if(s->current_picture_ptr==NULL || s->current_picture_ptr->data[0]){ + int i= ff_find_unused_picture(s, 0); + s->current_picture_ptr= &s->picture[i]; + } /* let's go :-) */ if (s->msmpeg4_version==5) { diff -r 6b224ca24033 -r 3d1d0490e5a6 mpegvideo.c --- a/mpegvideo.c Thu Oct 30 05:40:58 2003 +0000 +++ b/mpegvideo.c Thu Oct 30 16:58:49 2003 +0000 @@ -1014,32 +1014,33 @@ } } -static int find_unused_picture(MpegEncContext *s, int shared){ +int ff_find_unused_picture(MpegEncContext *s, int shared){ int i; if(shared){ for(i=0; ipicture[i].data[0]==NULL && s->picture[i].type==0) break; + if(s->picture[i].data[0]==NULL && s->picture[i].type==0) return i; } }else{ for(i=0; ipicture[i].data[0]==NULL && s->picture[i].type!=0) break; //FIXME + if(s->picture[i].data[0]==NULL && s->picture[i].type!=0) return i; //FIXME } for(i=0; ipicture[i].data[0]==NULL) break; + if(s->picture[i].data[0]==NULL) return i; } } - assert(imb_skiped = 0; assert(s->last_picture_ptr==NULL || s->out_format != FMT_H264 || s->codec_id == CODEC_ID_SVQ3); @@ -1068,18 +1069,22 @@ } } - i= find_unused_picture(s, 0); - - pic= (AVFrame*)&s->picture[i]; + if(s->current_picture_ptr && s->current_picture_ptr->data[0]==NULL) + pic= (AVFrame*)s->current_picture_ptr; //we allready have a unused image (maybe it was set before reading the header) + else{ + i= ff_find_unused_picture(s, 0); + pic= (AVFrame*)&s->picture[i]; + } + pic->reference= s->pict_type != B_TYPE ? 3 : 0; - if(s->current_picture_ptr) + if(s->current_picture_ptr) //FIXME broken, we need a coded_picture_number in MpegEncContext pic->coded_picture_number= s->current_picture_ptr->coded_picture_number+1; if( alloc_picture(s, (Picture*)pic, 0) < 0) return -1; - s->current_picture_ptr= &s->picture[i]; + s->current_picture_ptr= (Picture*)pic; } s->current_picture_ptr->pict_type= s->pict_type; @@ -1425,7 +1430,7 @@ // printf("%d %d %d %d\n",pic_arg->linesize[0], pic_arg->linesize[1], s->linesize, s->uvlinesize); if(direct){ - i= find_unused_picture(s, 1); + i= ff_find_unused_picture(s, 1); pic= (AVFrame*)&s->picture[i]; pic->reference= 3; @@ -1437,7 +1442,7 @@ alloc_picture(s, (Picture*)pic, 1); }else{ int offset= 16; - i= find_unused_picture(s, 0); + i= ff_find_unused_picture(s, 0); pic= (AVFrame*)&s->picture[i]; pic->reference= 3; @@ -1587,7 +1592,7 @@ if(s->reordered_input_picture[0]->type == FF_BUFFER_TYPE_SHARED){ // input is a shared pix, so we cant modifiy it -> alloc a new one & ensure that the shared one is reuseable - int i= find_unused_picture(s, 0); + int i= ff_find_unused_picture(s, 0); Picture *pic= &s->picture[i]; /* mark us unused / free shared pic */ diff -r 6b224ca24033 -r 3d1d0490e5a6 mpegvideo.h --- a/mpegvideo.h Thu Oct 30 05:40:58 2003 +0000 +++ b/mpegvideo.h Thu Oct 30 16:58:49 2003 +0000 @@ -718,6 +718,7 @@ void ff_mpeg_flush(AVCodecContext *avctx); void ff_print_debug_info(MpegEncContext *s, Picture *pict); void ff_write_quant_matrix(PutBitContext *pb, int16_t *matrix); +int ff_find_unused_picture(MpegEncContext *s, int shared); void ff_er_frame_start(MpegEncContext *s); void ff_er_frame_end(MpegEncContext *s);