amldemux: CB1 correct pts to if have elst [1/1]
PD#SWPL-81980
Problem:
correct-dts-if-have-elst-in-qtdemux.patch, will make dts negative,
which will make regression, so reverted by qtdemux Community
Solution:
refine 00011-correct-dts-if-have-elst-in-qtdemux.patch,
Correct pts instead of dts, do not make dts be negative
Verify:
AH212
Signed-off-by: zengliang.li <zengliang.li@amlogic.com>
Change-Id: Ia648ff8a7913e03897e1c40d1123ea0e1ea19477
diff --git a/aml-qtdemux/qtdemux.c b/aml-qtdemux/qtdemux.c
index a3556af..8bf4d0e 100644
--- a/aml-qtdemux/qtdemux.c
+++ b/aml-qtdemux/qtdemux.c
@@ -6120,7 +6120,7 @@
}
/* position reporting */
- if (qtdemux->segment.rate >= 0) {
+ if (qtdemux->segment.rate >= 0 && GST_CLOCK_TIME_IS_VALID(position)) {
qtdemux->segment.position = position;
gst_qtdemux_sync_streams (qtdemux);
}
@@ -7607,7 +7607,7 @@
keyframe = QTSAMPLE_KEYFRAME (stream, sample);
/* check for segment end */
- if (G_UNLIKELY (demux->segment.stop != -1
+ if (G_UNLIKELY (demux->segment.stop != -1 && GST_CLOCK_TIME_IS_VALID(dts)
&& demux->segment.stop <= pts && stream->on_keyframe)
&& !(demux->upstream_format_is_time && demux->segment.rate < 0)) {
GST_DEBUG_OBJECT (demux, "we reached the end of our segment.");
@@ -9972,7 +9972,13 @@
ctts_soffset = 0;
for (j = stream->ctts_sample_index; j < ctts_count; j++) {
- cur->pts_offset = ctts_soffset;
+ if (stream->elst_media_time != G_MAXUINT64 && FOURCC_vide == stream->subtype)
+ {
+ cur->pts_offset = ctts_soffset - stream->elst_media_time;
+ GST_DEBUG_OBJECT (qtdemux, "elst_media_time: %lld, new pts_offset: %lld", stream->elst_media_time, cur->pts_offset);
+ } else {
+ cur->pts_offset = ctts_soffset;
+ }
cur++;
if (G_UNLIKELY (cur > last)) {
@@ -10049,6 +10055,7 @@
GST_DEBUG_OBJECT (qtdemux, "looking for edit list container");
stream->n_segments = 0;
stream->segments = NULL;
+ stream->elst_media_time = G_MAXUINT64;
if ((edts = qtdemux_tree_get_child_by_type (trak, FOURCC_edts))) {
GNode *elst;
guint n_segments;
@@ -10109,7 +10116,10 @@
}
if (!empty_edit)
+ {
+ stream->elst_media_time = MIN(media_time, stream->elst_media_time);
media_start = QTSTREAMTIME_TO_GSTTIME (stream, media_time);
+ }
segment = &stream->segments[segment_number];
diff --git a/aml-qtdemux/qtdemux.h b/aml-qtdemux/qtdemux.h
index 7e9e7c6..02df262 100644
--- a/aml-qtdemux/qtdemux.h
+++ b/aml-qtdemux/qtdemux.h
@@ -521,6 +521,8 @@
/* KEY_UNITS trickmode with an interval */
GstClockTime last_keyframe_dts;
+ guint64 elst_media_time;
+
gint ref_count; /* atomic */
};