diff mbox series

[FFmpeg-devel,4/7] lavc/mjpegdec: properly set pts and duration for smvjpeg

Message ID 20230414164244.15264-4-anton@khirnov.net
State Accepted
Commit b088d59347ed24c9346d8bc1c81ee09637fbd7ec
Headers show
Series [FFmpeg-devel,1/7] lavfi: ensure audio frame durations match the sample count | expand

Checks

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

Commit Message

Anton Khirnov April 14, 2023, 4:42 p.m. UTC
A single smvjpeg packet decodes into one large mjpeg frame, slices of
which are then returned as output frames. Packet duration covers all of
these slices.
---
 libavcodec/mjpegdec.c | 5 +++++
 1 file changed, 5 insertions(+)
diff mbox series

Patch

diff --git a/libavcodec/mjpegdec.c b/libavcodec/mjpegdec.c
index 0a69c42459..9b0137c91c 100644
--- a/libavcodec/mjpegdec.c
+++ b/libavcodec/mjpegdec.c
@@ -3010,6 +3010,8 @@  static void smv_process_frame(AVCodecContext *avctx, AVFrame *frame)
     frame->crop_top    = FFMIN(s->smv_next_frame * avctx->height, frame->height);
     frame->crop_bottom = frame->height - (s->smv_next_frame + 1) * avctx->height;
 
+    if (s->smv_frame->pts != AV_NOPTS_VALUE)
+        s->smv_frame->pts += s->smv_frame->duration;
     s->smv_next_frame = (s->smv_next_frame + 1) % s->smv_frames_per_jpeg;
 
     if (s->smv_next_frame == 0)
@@ -3041,6 +3043,9 @@  static int smvjpeg_receive_frame(AVCodecContext *avctx, AVFrame *frame)
     if (!got_frame)
         return AVERROR(EAGAIN);
 
+    // packet duration covers all the frames in the packet
+    s->smv_frame->duration /= s->smv_frames_per_jpeg;
+
 return_frame:
     av_assert0(s->smv_frame->buf[0]);
     ret = av_frame_ref(frame, s->smv_frame);