diff mbox series

[FFmpeg-devel,02/13] fftools/ffmpeg: fix computing video frame duration from repeat_pict

Message ID 20230507133255.20881-2-anton@khirnov.net
State Accepted
Commit 78e84c054a2a04edeea25e9ee54d0fb172cd7053
Headers show
Series [FFmpeg-devel,01/13] lavu/frame: extend AVFrame.repeat_pict documentation | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov May 7, 2023, 1:32 p.m. UTC
This field contains the number of _field_ durations by which the
standard frame duration should be extended.
---
 fftools/ffmpeg.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 8323c32ffd..4e45ab74b9 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -1008,10 +1008,10 @@  static int64_t video_duration_estimate(const InputStream *ist, const AVFrame *fr
         return frame->duration;
 
     if (ist->dec_ctx->framerate.den && ist->dec_ctx->framerate.num) {
-        int ticks = frame->repeat_pict >= 0 ?
-                    frame->repeat_pict + 1  :
-                    ist->dec_ctx->ticks_per_frame;
-        codec_duration = av_rescale_q(ticks, av_inv_q(ist->dec_ctx->framerate),
+        int fields = frame->repeat_pict + 2;
+        AVRational field_rate = av_mul_q(ist->dec_ctx->framerate,
+                                         (AVRational){ 2, 1 });
+        codec_duration = av_rescale_q(fields, av_inv_q(field_rate),
                                       ist->st->time_base);
     }