[FFmpeg-cvslog] avformat/hlsenc: Don't unnecessarily duplicate baseurl string

Andreas Rheinhardt git at videolan.org
Thu May 28 12:58:55 EEST 2020


ffmpeg | branch: master | Andreas Rheinhardt <andreas.rheinhardt at gmail.com> | Mon May 25 18:52:57 2020 +0200| [c1638bfae1e704f7fd9541892b61258b4f45f91a] | committer: Andreas Rheinhardt

avformat/hlsenc: Don't unnecessarily duplicate baseurl string

Up until now, the HLS muxer duplicated a string for every VariantStream,
although neither the original nor the copies are ever modified. So use
the original directly and stop copying.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt at gmail.com>

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=c1638bfae1e704f7fd9541892b61258b4f45f91a
---

 libavformat/hlsenc.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 1bc3cb210b..77e49b44b1 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -177,7 +177,6 @@ typedef struct VariantStream {
     char *agroup; /* audio group name */
     char *sgroup; /* subtitle group name */
     char *ccgroup; /* closed caption group name */
-    char *baseurl;
     char *varname; // variant name
 } VariantStream;
 
@@ -1525,7 +1524,7 @@ static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
 
         ret = ff_hls_write_file_entry(byterange_mode ? hls->m3u8_out : vs->out, en->discont, byterange_mode,
                                       en->duration, hls->flags & HLS_ROUND_DURATIONS,
-                                      en->size, en->pos, vs->baseurl,
+                                      en->size, en->pos, hls->baseurl,
                                       en->filename, prog_date_time_p, en->keyframe_size, en->keyframe_pos, hls->flags & HLS_I_FRAMES_ONLY);
         if (ret < 0) {
             av_log(s, AV_LOG_WARNING, "ff_hls_write_file_entry get error\n");
@@ -1547,7 +1546,7 @@ static int hls_window(AVFormatContext *s, int last, VariantStream *vs)
         for (en = vs->segments; en; en = en->next) {
             ret = ff_hls_write_file_entry(hls->sub_m3u8_out, 0, byterange_mode,
                                           en->duration, 0, en->size, en->pos,
-                                          vs->baseurl, en->sub_filename, NULL, 0, 0, 0);
+                                          hls->baseurl, en->sub_filename, NULL, 0, 0, 0);
             if (ret < 0) {
                 av_log(s, AV_LOG_WARNING, "ff_hls_write_file_entry get error\n");
             }
@@ -2581,7 +2580,6 @@ static void hls_deinit(AVFormatContext *s)
         av_freep(&vs->sgroup);
         av_freep(&vs->language);
         av_freep(&vs->ccgroup);
-        av_freep(&vs->baseurl);
         av_freep(&vs->varname);
     }
 
@@ -2956,12 +2954,6 @@ static int hls_init(AVFormatContext *s)
                 *p = '.';
         }
 
-        if (hls->baseurl) {
-            vs->baseurl = av_strdup(hls->baseurl);
-            if (!vs->baseurl)
-                return AVERROR(ENOMEM);
-        }
-
         if ((ret = hls_mux_init(s, vs)) < 0)
             return ret;
 



More information about the ffmpeg-cvslog mailing list