Commit 9ebb8e11 authored by Michael Niedermayer's avatar Michael Niedermayer

check if the user specified timestamps are strictly monotone

timestamp guess code 10l fix

Originally committed as revision 3483 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 2c3cee34
...@@ -2112,11 +2112,13 @@ void ff_set_mpeg4_time(MpegEncContext * s, int picture_number){ ...@@ -2112,11 +2112,13 @@ void ff_set_mpeg4_time(MpegEncContext * s, int picture_number){
if(s->pict_type==B_TYPE){ if(s->pict_type==B_TYPE){
s->pb_time= s->pp_time - (s->last_non_b_time - s->time); s->pb_time= s->pp_time - (s->last_non_b_time - s->time);
assert(s->pb_time > 0 && s->pb_time < s->pp_time);
}else{ }else{
s->last_time_base= s->time_base; s->last_time_base= s->time_base;
s->time_base= time_div; s->time_base= time_div;
s->pp_time= s->time - s->last_non_b_time; s->pp_time= s->time - s->last_non_b_time;
s->last_non_b_time= s->time; s->last_non_b_time= s->time;
assert(s->pp_time > 0);
} }
} }
......
...@@ -902,6 +902,7 @@ int MPV_encode_init(AVCodecContext *avctx) ...@@ -902,6 +902,7 @@ int MPV_encode_init(AVCodecContext *avctx)
s->mpeg_quant= avctx->mpeg_quant; s->mpeg_quant= avctx->mpeg_quant;
s->rtp_mode= !!avctx->rtp_payload_size; s->rtp_mode= !!avctx->rtp_payload_size;
s->intra_dc_precision= avctx->intra_dc_precision; s->intra_dc_precision= avctx->intra_dc_precision;
s->user_specified_pts = AV_NOPTS_VALUE;
if (s->gop_size <= 1) { if (s->gop_size <= 1) {
s->intra_only = 1; s->intra_only = 1;
...@@ -1962,16 +1963,26 @@ static int load_input_picture(MpegEncContext *s, AVFrame *pic_arg){ ...@@ -1962,16 +1963,26 @@ static int load_input_picture(MpegEncContext *s, AVFrame *pic_arg){
copy_picture_attributes(s, pic, pic_arg); copy_picture_attributes(s, pic, pic_arg);
pic->display_picture_number= s->input_picture_number++; pic->display_picture_number= s->input_picture_number++;
if(pic->pts != AV_NOPTS_VALUE){ if(pic->pts != AV_NOPTS_VALUE){
s->user_specified_pts= pic->pts; if(s->user_specified_pts != AV_NOPTS_VALUE){
int64_t time= av_rescale(pic->pts, s->avctx->frame_rate, s->avctx->frame_rate_base*(int64_t)AV_TIME_BASE);
int64_t last= av_rescale(s->user_specified_pts, s->avctx->frame_rate, s->avctx->frame_rate_base*(int64_t)AV_TIME_BASE);
if(time <= last){
av_log(s->avctx, AV_LOG_ERROR, "Error, Invalid timestamp=%Ld, last=%Ld\n", pic->pts, s->user_specified_pts);
return -1;
}
}
}else{ }else{
if(s->user_specified_pts){ if(s->user_specified_pts != AV_NOPTS_VALUE){
pic->pts= s->user_specified_pts + AV_TIME_BASE*(int64_t)s->avctx->frame_rate_base / s->avctx->frame_rate; pic->pts= s->user_specified_pts + AV_TIME_BASE*(int64_t)s->avctx->frame_rate_base / s->avctx->frame_rate;
av_log(s->avctx, AV_LOG_INFO, "Warning: AVFrame.pts=? trying to guess (%Ld)\n", pic->pts); av_log(s->avctx, AV_LOG_INFO, "Warning: AVFrame.pts=? trying to guess (%Ld)\n", pic->pts);
}else{ }else{
pic->pts= av_rescale(pic->display_picture_number*(int64_t)s->avctx->frame_rate_base, AV_TIME_BASE, s->avctx->frame_rate); pic->pts= av_rescale(pic->display_picture_number*(int64_t)s->avctx->frame_rate_base, AV_TIME_BASE, s->avctx->frame_rate);
} }
} }
s->user_specified_pts= pic->pts;
} }
/* shift buffer entries */ /* shift buffer entries */
...@@ -2139,7 +2150,8 @@ int MPV_encode_picture(AVCodecContext *avctx, ...@@ -2139,7 +2150,8 @@ int MPV_encode_picture(AVCodecContext *avctx,
s->picture_in_gop_number++; s->picture_in_gop_number++;
load_input_picture(s, pic_arg); if(load_input_picture(s, pic_arg) < 0)
return -1;
select_input_picture(s); select_input_picture(s);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment