From ae85d6c9c0dcc71dd18c2afb5d15e8b033d67646 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Tue, 25 Dec 2012 09:14:59 +0100 Subject: [PATCH 1/2] hlsenc: use the segment filename in the playlist entry Avoid calling av_get_frame_filename twice, once to generate the segment filename and once to generate the playlist. --- libavformat/hlsenc.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index e039687d1e..7abb46d366 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -85,9 +85,7 @@ static int append_entry(HLSContext *hls, uint64_t duration) if (!en) return AVERROR(ENOMEM); - av_get_frame_filename(en->name, sizeof(en->name), - av_basename(hls->basename), - hls->number -1); + av_strlcpy(en->name, av_basename(hls->avf->filename), sizeof(en->name)); en->duration = duration; en->next = NULL; From 0448f26c97c5ab4858d31e456a4f1738ae783242 Mon Sep 17 00:00:00 2001 From: Luca Barbato Date: Tue, 25 Dec 2012 10:05:42 +0100 Subject: [PATCH 2/2] hlsenc: keep the playlist to the correct number of items Consider the corner case with a list size larger than the wrap number. --- libavformat/hlsenc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c index 7abb46d366..39e8df96ab 100644 --- a/libavformat/hlsenc.c +++ b/libavformat/hlsenc.c @@ -48,6 +48,7 @@ typedef struct HLSContext { int has_video; int64_t start_pts; int64_t end_pts; + int nb_entries; ListEntry *list; ListEntry *end_list; char *basename; @@ -97,11 +98,12 @@ static int append_entry(HLSContext *hls, uint64_t duration) hls->end_list = en; - if (hls->number >= hls->size) { + if (hls->nb_entries >= hls->size) { en = hls->list; hls->list = en->next; av_free(en); - } + } else + hls->nb_entries++; return 0; }