[Bf-blender-cvs] [a5c3f5b0bc3] master: Fix T103818: Freeze frames in movie strips when timecodes are used

Richard Antalik noreply at git.blender.org
Fri Jan 13 21:32:58 CET 2023


Commit: a5c3f5b0bc3339d94b53ed216f6e915b3968658a
Author: Richard Antalik
Date:   Fri Jan 13 21:25:41 2023 +0100
Branches: master
https://developer.blender.org/rBa5c3f5b0bc3339d94b53ed216f6e915b3968658a

Fix T103818: Freeze frames in movie strips when timecodes are used

Timecodes were generated from read packets, but applied to decoded
frames. This works as long as delay between packet read and decoded
frame is less than GOP size or if packet does not produce multiple
frames. In this case it did not work.

Use `pkt_pos`, `pkt_dts` and `pts` from `AVFrame` instead of `AVPacket`.
This way delay can be eliminated and timecode files are more reliable.

===================================================================

M	source/blender/imbuf/intern/indexer.c

===================================================================

diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c
index d824b87f493..6d849f54d4c 100644
--- a/source/blender/imbuf/intern/indexer.c
+++ b/source/blender/imbuf/intern/indexer.c
@@ -1040,16 +1040,6 @@ static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context,
     }
 
     if (next_packet->stream_index == context->videoStream) {
-      if (next_packet->flags & AV_PKT_FLAG_KEY) {
-        context->last_seek_pos = context->seek_pos;
-        context->last_seek_pos_pts = context->seek_pos_pts;
-        context->last_seek_pos_dts = context->seek_pos_dts;
-
-        context->seek_pos = next_packet->pos;
-        context->seek_pos_pts = next_packet->pts;
-        context->seek_pos_dts = next_packet->dts;
-      }
-
       int ret = avcodec_send_packet(context->iCodecCtx, next_packet);
       while (ret >= 0) {
         ret = avcodec_receive_frame(context->iCodecCtx, in_frame);
@@ -1062,6 +1052,17 @@ static int index_rebuild_ffmpeg(FFmpegIndexBuilderContext *context,
           fprintf(stderr, "Error decoding proxy frame: %s\n", av_err2str(ret));
           break;
         }
+
+        if (next_packet->flags & AV_PKT_FLAG_KEY) {
+          context->last_seek_pos = context->seek_pos;
+          context->last_seek_pos_pts = context->seek_pos_pts;
+          context->last_seek_pos_dts = context->seek_pos_dts;
+
+          context->seek_pos = in_frame->pkt_pos;
+          context->seek_pos_pts = in_frame->pts;
+          context->seek_pos_dts = in_frame->pkt_dts;
+        }
+
         index_rebuild_ffmpeg_proc_decoded_frame(context, next_packet, in_frame);
       }
     }



More information about the Bf-blender-cvs mailing list