Commit 47b229db authored by Alexander Strange's avatar Alexander Strange

ffmpeg: Factor out redundant sync_ipts calculation

Originally committed as revision 22536 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent e536ccd6
...@@ -900,6 +900,7 @@ static void do_video_out(AVFormatContext *s, ...@@ -900,6 +900,7 @@ static void do_video_out(AVFormatContext *s,
AVFrame *final_picture, *formatted_picture, *resampling_dst, *padding_src; AVFrame *final_picture, *formatted_picture, *resampling_dst, *padding_src;
AVFrame picture_crop_temp, picture_pad_temp; AVFrame picture_crop_temp, picture_pad_temp;
AVCodecContext *enc, *dec; AVCodecContext *enc, *dec;
double sync_ipts;
avcodec_get_frame_defaults(&picture_crop_temp); avcodec_get_frame_defaults(&picture_crop_temp);
avcodec_get_frame_defaults(&picture_pad_temp); avcodec_get_frame_defaults(&picture_pad_temp);
...@@ -907,6 +908,8 @@ static void do_video_out(AVFormatContext *s, ...@@ -907,6 +908,8 @@ static void do_video_out(AVFormatContext *s,
enc = ost->st->codec; enc = ost->st->codec;
dec = ist->st->codec; dec = ist->st->codec;
sync_ipts = get_sync_ipts(ost) / av_q2d(enc->time_base);
/* by default, we output a single frame */ /* by default, we output a single frame */
nb_frames = 1; nb_frames = 1;
...@@ -914,7 +917,7 @@ static void do_video_out(AVFormatContext *s, ...@@ -914,7 +917,7 @@ static void do_video_out(AVFormatContext *s,
if(video_sync_method){ if(video_sync_method){
double vdelta; double vdelta;
vdelta = get_sync_ipts(ost) / av_q2d(enc->time_base) - ost->sync_opts; vdelta = sync_ipts - ost->sync_opts;
//FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c //FIXME set to 0.5 after we fix some dts/pts bugs like in avidec.c
if (vdelta < -1.1) if (vdelta < -1.1)
nb_frames = 0; nb_frames = 0;
...@@ -922,7 +925,7 @@ static void do_video_out(AVFormatContext *s, ...@@ -922,7 +925,7 @@ static void do_video_out(AVFormatContext *s,
if(vdelta<=-0.6){ if(vdelta<=-0.6){
nb_frames=0; nb_frames=0;
}else if(vdelta>0.6) }else if(vdelta>0.6)
ost->sync_opts= lrintf(get_sync_ipts(ost) / av_q2d(enc->time_base)); ost->sync_opts= lrintf(sync_ipts);
}else if (vdelta > 1.1) }else if (vdelta > 1.1)
nb_frames = lrintf(vdelta); nb_frames = lrintf(vdelta);
//fprintf(stderr, "vdelta:%f, ost->sync_opts:%"PRId64", ost->sync_ipts:%f nb_frames:%d\n", vdelta, ost->sync_opts, get_sync_ipts(ost), nb_frames); //fprintf(stderr, "vdelta:%f, ost->sync_opts:%"PRId64", ost->sync_ipts:%f nb_frames:%d\n", vdelta, ost->sync_opts, get_sync_ipts(ost), nb_frames);
...@@ -936,7 +939,7 @@ static void do_video_out(AVFormatContext *s, ...@@ -936,7 +939,7 @@ static void do_video_out(AVFormatContext *s,
fprintf(stderr, "*** %d dup!\n", nb_frames-1); fprintf(stderr, "*** %d dup!\n", nb_frames-1);
} }
}else }else
ost->sync_opts= lrintf(get_sync_ipts(ost) / av_q2d(enc->time_base)); ost->sync_opts= lrintf(sync_ipts);
nb_frames= FFMIN(nb_frames, max_frames[CODEC_TYPE_VIDEO] - ost->frame_number); nb_frames= FFMIN(nb_frames, max_frames[CODEC_TYPE_VIDEO] - ost->frame_number);
if (nb_frames <= 0) if (nb_frames <= 0)
......
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