Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
 help / color / mirror / Atom feed
* [FFmpeg-devel] [PATCH 5/6] avformat/mov: Notify new sequence at the start of editlist
@ 2025-03-18 12:58 Zhao Zhili
  0 siblings, 0 replies; only message in thread
From: Zhao Zhili @ 2025-03-18 12:58 UTC (permalink / raw)
  To: ffmpeg-devel; +Cc: Zhao Zhili

From: Zhao Zhili <zhilizhao@tencent.com>

---
 libavformat/avformat.h |  2 ++
 libavformat/mov.c      | 19 +++++++++++++------
 2 files changed, 15 insertions(+), 6 deletions(-)

diff --git a/libavformat/avformat.h b/libavformat/avformat.h
index 498c557a3c..f83151a73f 100644
--- a/libavformat/avformat.h
+++ b/libavformat/avformat.h
@@ -611,6 +611,8 @@ typedef struct AVIndexEntry {
 #define AVINDEX_DISCARD_FRAME  0x0002    /**
                                           * Flag is used to indicate which frame should be discarded after decoding.
                                           */
+#define AVINDEX_NEW_SEQUENCE   0x0004    /* Mark the start of a new sequence */
+
     int flags:2;
     int size:30; //Yeah, trying to keep the size of this small to reduce memory requirements (it is 24 vs. 32 bytes due to possible 8-byte alignment).
     int min_distance;         /**< Minimum distance between this and the previous keyframe, used to avoid unneeded searching. */
diff --git a/libavformat/mov.c b/libavformat/mov.c
index bf526db67a..787a2b87e6 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4394,20 +4394,23 @@ static void mov_fix_index(MOVContext *mov, AVStream *st)
                 }
             }
 
-            if (add_index_entry(st, current->pos, edit_list_dts_counter, current->size,
-                                current->min_distance, flags) == -1) {
-                av_log(mov->fc, AV_LOG_ERROR, "Cannot add index entry\n");
-                break;
-            }
 
             // Update the index ranges array
             if (!current_index_range || index != current_index_range->end) {
                 current_index_range = current_index_range ? current_index_range + 1
                                                           : msc->index_ranges;
                 current_index_range->start = index;
+                if ((flags & AVINDEX_KEYFRAME) && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO)
+                    flags |= AVINDEX_NEW_SEQUENCE;
             }
             current_index_range->end = index + 1;
 
+            if (add_index_entry(st, current->pos, edit_list_dts_counter, current->size,
+                                current->min_distance, flags) == -1) {
+                av_log(mov->fc, AV_LOG_ERROR, "Cannot add index entry\n");
+                break;
+            }
+
             // Only start incrementing DTS in frame_duration amounts, when we encounter a frame in edit list.
             if (edit_list_start_encountered > 0) {
                 edit_list_dts_counter = edit_list_dts_counter + frame_duration;
@@ -10889,7 +10892,11 @@ static int mov_finalize_packet(AVFormatContext *s, AVStream *st, AVIndexEntry *s
         uint8_t sample_is_depended_on = (sample_flags >> 2) & 0x3;
         pkt->flags |= sample_is_depended_on == MOV_SAMPLE_DEPENDENCY_NO ? AV_PKT_FLAG_DISPOSABLE : 0;
     }
-    pkt->flags |= sample->flags & AVINDEX_KEYFRAME ? AV_PKT_FLAG_KEY : 0;
+    if (sample->flags & AVINDEX_KEYFRAME) {
+        pkt->flags |= AV_PKT_FLAG_KEY;
+        if (sample->flags & AVINDEX_NEW_SEQUENCE)
+            pkt->flags |= AV_PKT_FLAG_NEW_SEQUENCE;
+    }
     pkt->pos = sample->pos;
 
     /* Multiple stsd handling. */
-- 
2.46.0

_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2025-03-18 12:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-18 12:58 [FFmpeg-devel] [PATCH 5/6] avformat/mov: Notify new sequence at the start of editlist Zhao Zhili

Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
		ffmpegdev@gitmailbox.com
	public-inbox-index ffmpegdev

Example config snippet for mirrors.


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git