diff mbox series

[FFmpeg-devel,v2,1/7] avformat/hlsenc: Avoid setting unused variables

Message ID 20200228095321.7222-1-andreas.rheinhardt@gmail.com
State Accepted
Commit de20f6cb701bffc98062d825c339ce30a794ca01
Headers show
Series [FFmpeg-devel,v2,1/7] avformat/hlsenc: Avoid setting unused variables | expand

Checks

Context Check Description
andriy/ffmpeg-patchwork success Make fate finished

Commit Message

Andreas Rheinhardt Feb. 28, 2020, 9:53 a.m. UTC
Several variables which are only used when the HLS_SINGLE_FILE flag is
unset have been set even when this flag is set. This has been changed.

Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
---
Now not moving variables into a smaller scope.

 libavformat/hlsenc.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

Andreas Rheinhardt March 11, 2020, 12:52 p.m. UTC | #1
Andreas Rheinhardt:
> Several variables which are only used when the HLS_SINGLE_FILE flag is
> unset have been set even when this flag is set. This has been changed.
> 
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
> ---
> Now not moving variables into a smaller scope.
> 
>  libavformat/hlsenc.c | 16 ++++++++--------
>  1 file changed, 8 insertions(+), 8 deletions(-)
> 
> diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
> index f6dd894343..51cbfba151 100644
> --- a/libavformat/hlsenc.c
> +++ b/libavformat/hlsenc.c
> @@ -2332,11 +2332,6 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
>              }
>          }
>  
> -        if (oc->url[0]) {
> -            proto = avio_find_protocol_name(oc->url);
> -            use_temp_file = proto && !strcmp(proto, "file") && (hls->flags & HLS_TEMP_FILE);
> -        }
> -
>          if (hls->flags & HLS_SINGLE_FILE) {
>              ret = flush_dynbuf(vs, &range_length);
>              av_freep(&vs->temp_buffer);
> @@ -2345,6 +2340,12 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
>              }
>              vs->size = range_length;
>          } else {
> +            if (oc->url[0]) {
> +                proto = avio_find_protocol_name(oc->url);
> +                use_temp_file = proto && !strcmp(proto, "file")
> +                                      && (hls->flags & HLS_TEMP_FILE);
> +            }
> +
>              if ((hls->max_seg_size > 0 && (vs->size >= hls->max_seg_size)) || !byterange_mode) {
>                  AVDictionary *options = NULL;
>                  char *filename = NULL;
> @@ -2394,10 +2395,9 @@ static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
>                  av_freep(&vs->temp_buffer);
>                  av_freep(&filename);
>              }
> -        }
>  
> -        if (use_temp_file && !(hls->flags & HLS_SINGLE_FILE)) {
> -            hls_rename_temp_file(s, oc);
> +            if (use_temp_file)
> +                hls_rename_temp_file(s, oc);
>          }
>  
>          old_filename = av_strdup(oc->url);
> 
Ping.

- Andreas
diff mbox series

Patch

diff --git a/libavformat/hlsenc.c b/libavformat/hlsenc.c
index f6dd894343..51cbfba151 100644
--- a/libavformat/hlsenc.c
+++ b/libavformat/hlsenc.c
@@ -2332,11 +2332,6 @@  static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
             }
         }
 
-        if (oc->url[0]) {
-            proto = avio_find_protocol_name(oc->url);
-            use_temp_file = proto && !strcmp(proto, "file") && (hls->flags & HLS_TEMP_FILE);
-        }
-
         if (hls->flags & HLS_SINGLE_FILE) {
             ret = flush_dynbuf(vs, &range_length);
             av_freep(&vs->temp_buffer);
@@ -2345,6 +2340,12 @@  static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
             }
             vs->size = range_length;
         } else {
+            if (oc->url[0]) {
+                proto = avio_find_protocol_name(oc->url);
+                use_temp_file = proto && !strcmp(proto, "file")
+                                      && (hls->flags & HLS_TEMP_FILE);
+            }
+
             if ((hls->max_seg_size > 0 && (vs->size >= hls->max_seg_size)) || !byterange_mode) {
                 AVDictionary *options = NULL;
                 char *filename = NULL;
@@ -2394,10 +2395,9 @@  static int hls_write_packet(AVFormatContext *s, AVPacket *pkt)
                 av_freep(&vs->temp_buffer);
                 av_freep(&filename);
             }
-        }
 
-        if (use_temp_file && !(hls->flags & HLS_SINGLE_FILE)) {
-            hls_rename_temp_file(s, oc);
+            if (use_temp_file)
+                hls_rename_temp_file(s, oc);
         }
 
         old_filename = av_strdup(oc->url);