diff mbox

[FFmpeg-devel,2/2] avformat/hlsenc: fix missing first segment bug in fmp4 mode

Message ID 20171025235449.35684-1-lq@chinaffmpeg.org
State Superseded
Headers show

Commit Message

Steven Liu Oct. 25, 2017, 11:54 p.m. UTC
fix ticket id: #6776
fix code logic error, need not check first segment.

Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
---
 libavformat/hlsenc.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

Comments

Carl Eugen Hoyos Oct. 26, 2017, 2:38 p.m. UTC | #1
2017-10-26 1:54 GMT+02:00 Steven Liu <lq@chinaffmpeg.org>:
> fix ticket id: #6776
> fix code logic error, need not check first segment.
>
> Signed-off-by: Steven Liu <lq@chinaffmpeg.org>
> ---
>  libavformat/hlsenc.c | 26 +++++++++++++-------------
>  1 file changed, 13 insertions(+), 13 deletions(-)
>
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index 55ce800c5a..caced6a3dd 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -1080,15 +1080,16 @@ static int hls_window(AVFormatContext *s, int last)
>                  avio_printf(out, ",BYTERANGE=\"%"PRId64"@%"PRId64"\"", en->size, en->pos);
>              }
>              avio_printf(out, "\n");
> -        } else {
> -            if (hls->flags & HLS_ROUND_DURATIONS)
> -                avio_printf(out, "#EXTINF:%ld,\n",  lrint(en->duration));
> -            else
> -                avio_printf(out, "#EXTINF:%f,\n", en->duration);
> -            if (byterange_mode)
> -                avio_printf(out, "#EXT-X-BYTERANGE:%"PRId64"@%"PRId64"\n",
> -                            en->size, en->pos);
>          }
> +
> +        if (hls->flags & HLS_ROUND_DURATIONS)
> +            avio_printf(out, "#EXTINF:%ld,\n",  lrint(en->duration));
> +        else
> +            avio_printf(out, "#EXTINF:%f,\n", en->duration);
> +        if (byterange_mode)
> +            avio_printf(out, "#EXT-X-BYTERANGE:%"PRId64"@%"PRId64"\n",
> +                        en->size, en->pos);

If you reindent in this patch, please add braces.

An alternative is to only remove the three lines in the first patch
(makes reviewing simpler) and send another patch with the
reindentation (and the braces).

Thank you, Carl Eugen
diff mbox

Patch

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index 55ce800c5a..caced6a3dd 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -1080,15 +1080,16 @@  static int hls_window(AVFormatContext *s, int last)
                 avio_printf(out, ",BYTERANGE=\"%"PRId64"@%"PRId64"\"", en->size, en->pos);
             }
             avio_printf(out, "\n");
-        } else {
-            if (hls->flags & HLS_ROUND_DURATIONS)
-                avio_printf(out, "#EXTINF:%ld,\n",  lrint(en->duration));
-            else
-                avio_printf(out, "#EXTINF:%f,\n", en->duration);
-            if (byterange_mode)
-                avio_printf(out, "#EXT-X-BYTERANGE:%"PRId64"@%"PRId64"\n",
-                            en->size, en->pos);
         }
+
+        if (hls->flags & HLS_ROUND_DURATIONS)
+            avio_printf(out, "#EXTINF:%ld,\n",  lrint(en->duration));
+        else
+            avio_printf(out, "#EXTINF:%f,\n", en->duration);
+        if (byterange_mode)
+            avio_printf(out, "#EXT-X-BYTERANGE:%"PRId64"@%"PRId64"\n",
+                        en->size, en->pos);
+
         if (hls->flags & HLS_PROGRAM_DATE_TIME) {
             time_t tt, wrongsecs;
             int milli;
@@ -1113,11 +1114,10 @@  static int hls_window(AVFormatContext *s, int last)
             avio_printf(out, "#EXT-X-PROGRAM-DATE-TIME:%s.%03d%s\n", buf0, milli, buf1);
             prog_date_time += en->duration;
         }
-        if (!((hls->segment_type == SEGMENT_TYPE_FMP4) && (en == hls->segments))) {
-            if (hls->baseurl)
-                avio_printf(out, "%s", hls->baseurl);
-            avio_printf(out, "%s\n", en->filename);
-        }
+
+        if (hls->baseurl)
+            avio_printf(out, "%s", hls->baseurl);
+        avio_printf(out, "%s\n", en->filename);
     }
 
     if (last && (hls->flags & HLS_OMIT_ENDLIST)==0)