You've already forked FFmpeg
							
							
				mirror of
				https://github.com/FFmpeg/FFmpeg.git
				synced 2025-10-30 23:18:11 +02:00 
			
		
		
		
	fftools/ffmpeg_enc: avoid breaking exactly integer timestamps in vsync code
The code will currently add a small offset to avoid exact midpoints, but this can cause inexact results when a float timestamp is exactly representable as an integer. Fixes off-by-one in the first frame duration in multiple FATE tests.
This commit is contained in:
		| @@ -888,9 +888,11 @@ static double adjust_frame_pts_to_encoder_tb(OutputFile *of, OutputStream *ost, | ||||
|     float_pts = av_rescale_q(frame->pts, filter_tb, tb) - | ||||
|                 av_rescale_q(start_time, AV_TIME_BASE_Q, tb); | ||||
|     float_pts /= 1 << extra_bits; | ||||
|     // avoid exact midoints to reduce the chance of rounding differences, this | ||||
|     // when float_pts is not exactly an integer, | ||||
|     // avoid exact midpoints to reduce the chance of rounding differences, this | ||||
|     // can be removed in case the fps code is changed to work with integers | ||||
|     float_pts += FFSIGN(float_pts) * 1.0 / (1<<17); | ||||
|     if (float_pts != llrint(float_pts)) | ||||
|         float_pts += FFSIGN(float_pts) * 1.0 / (1<<17); | ||||
|  | ||||
|     frame->pts = av_rescale_q(frame->pts, filter_tb, enc->time_base) - | ||||
|                  av_rescale_q(start_time, AV_TIME_BASE_Q, enc->time_base); | ||||
|   | ||||
| @@ -3,7 +3,7 @@ | ||||
| #codec_id 0: rawvideo | ||||
| #dimensions 0: 116x135 | ||||
| #sar 0: 0/1 | ||||
| 0,          0,          0,        2,    62640, 0x31eb581d | ||||
| 0,          0,          0,        3,    62640, 0x31eb581d | ||||
| 0,          3,          3,        3,    62640, 0x29e11b82 | ||||
| 0,          6,          6,        3,    62640, 0x207ed588 | ||||
| 0,          9,          9,        3,    62640, 0x3845c906 | ||||
|   | ||||
| @@ -3,7 +3,7 @@ | ||||
| #codec_id 0: rawvideo | ||||
| #dimensions 0: 320x224 | ||||
| #sar 0: 0/1 | ||||
| 0,          0,          0,        1,   215040, 0x067c5362 | ||||
| 0,          0,          0,        2,   215040, 0x067c5362 | ||||
| 0,          2,          2,        2,   215040, 0xd9eacb98 | ||||
| 0,          4,          4,        2,   215040, 0x3c8a4cbd | ||||
| 0,          6,          6,        2,   215040, 0xbdf996e1 | ||||
|   | ||||
| @@ -8,7 +8,7 @@ | ||||
| #codec_id 1: pcm_s16le | ||||
| #sample_rate 1: 44100 | ||||
| #channel_layout_name 1: mono | ||||
| 0,          0,          0,   199999,   230400, 0x88c4d19a | ||||
| 0,          0,          0,   200000,   230400, 0x88c4d19a | ||||
| 1,          0,          0,     1024,     2048, 0xb3f10192 | ||||
| 1,       1024,       1024,     1024,     2048, 0xb340fe4e | ||||
| 1,       2048,       2048,     1024,     2048, 0x0a5f0111 | ||||
|   | ||||
| @@ -3,7 +3,7 @@ | ||||
| #codec_id 0: rawvideo | ||||
| #dimensions 0: 480x360 | ||||
| #sar 0: 0/1 | ||||
| 0,          0,          0,        4,   691200, 0xef6c0f3d | ||||
| 0,          0,          0,        5,   691200, 0xef6c0f3d | ||||
| 0,          5,          5,        2,   691200, 0xc18b32de | ||||
| 0,          7,          7,        2,   691200, 0x2395a3d7 | ||||
| 0,          9,          9,        2,   691200, 0x81dc3cf2 | ||||
|   | ||||
		Reference in New Issue
	
	Block a user