[FFmpeg-devel] [PATCH 7/8] avformat/matroskadec: Use already parsed cues if available
Andreas Rheinhardt
andreas.rheinhardt at gmail.com
Thu Sep 5 23:16:08 EEST 2019
The WebM Dash specification [1] contains a requirement that a SeekHead
that references the Cues is mandatory if the Cues are after the
Clusters. There is no such requirement in case the Cues appear before
the Clusters.
Yet webm_dash_manifest_cues contained such an implicit requirement:
If it couldn't find an entry for Cues in the SeekHead, it concluded that
there were no Cues at all and returned an error.
This has been fixed: Now the list of all level 1 elements is searched for
Cues and said list contains already encountered Cues regardless of whether
they are referenced by a SeekHead.
[1]: http://wiki.webmproject.org/adaptive-streaming/webm-dash-specification
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>
---
libavformat/matroskadec.c | 11 +++++------
1 file changed, 5 insertions(+), 6 deletions(-)
diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
index 075ed63f00..10df4cce45 100644
--- a/libavformat/matroskadec.c
+++ b/libavformat/matroskadec.c
@@ -4106,22 +4106,21 @@ static int64_t webm_dash_manifest_compute_bandwidth(AVFormatContext *s, int64_t
static int webm_dash_manifest_cues(AVFormatContext *s, int64_t init_range)
{
MatroskaDemuxContext *matroska = s->priv_data;
- EbmlList *seekhead_list = &matroska->seekhead;
- MatroskaSeekhead *seekhead = seekhead_list->elem;
+ MatroskaLevel1Element *elem = matroska->level1_elems;
char *buf;
int64_t cues_start = -1, cues_end = -1, before_pos, bandwidth;
int i;
int end = 0;
// determine cues start and end positions
- for (i = 0; i < seekhead_list->nb_elem; i++)
- if (seekhead[i].id == MATROSKA_ID_CUES)
+ for (i = 0; i < matroska->num_level1_elems; i++)
+ if (elem[i].id == MATROSKA_ID_CUES)
break;
- if (i >= seekhead_list->nb_elem) return -1;
+ if (i >= matroska->num_level1_elems) return -1;
before_pos = avio_tell(matroska->ctx->pb);
- cues_start = seekhead[i].pos + matroska->segment_start;
+ cues_start = elem[i].pos;
if (avio_seek(matroska->ctx->pb, cues_start, SEEK_SET) == cues_start) {
// cues_end is computed as cues_start + cues_length + length of the
// Cues element ID (i.e. 4) + EBML length of the Cues element.
--
2.21.0
More information about the ffmpeg-devel
mailing list