diff mbox series

[FFmpeg-devel,11/24] ffmpeg: set want_sdp when initializing the muxer

Message ID 20211213152042.5900-11-anton@khirnov.net
State New
Headers show
Series [FFmpeg-devel,01/24] ffmpeg: pass the muxer context explicitly to some functions | expand

Checks

Context Check Description
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished
andriy/make_ppc success Make finished
andriy/make_fate_ppc success Make fate finished

Commit Message

Anton Khirnov Dec. 13, 2021, 3:20 p.m. UTC
Allows making the variable local to ffmpeg_mux.
---
 fftools/ffmpeg.c     | 9 +--------
 fftools/ffmpeg.h     | 1 -
 fftools/ffmpeg_mux.c | 5 +++++
 3 files changed, 6 insertions(+), 9 deletions(-)

Comments

Andreas Rheinhardt Dec. 16, 2021, 9:40 p.m. UTC | #1
Anton Khirnov:
> Allows making the variable local to ffmpeg_mux.
> ---
>  fftools/ffmpeg.c     | 9 +--------
>  fftools/ffmpeg.h     | 1 -
>  fftools/ffmpeg_mux.c | 5 +++++
>  3 files changed, 6 insertions(+), 9 deletions(-)
> 
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index 3ed1201fda..f76e5df8d2 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -138,8 +138,6 @@ static int nb_frames_drop = 0;
>  static int64_t decode_error_stat[2];
>  unsigned nb_output_dumped = 0;
>  
> -int want_sdp = 1;
> -
>  static BenchmarkTimeStamps current_time;
>  AVIOContext *progress_avio = NULL;
>  
> @@ -4557,7 +4555,7 @@ static void log_callback_null(void *ptr, int level, const char *fmt, va_list vl)
>  
>  int main(int argc, char **argv)
>  {
> -    int i, ret;
> +    int ret;
>      BenchmarkTimeStamps ti;
>  
>      init_dynload();
> @@ -4600,11 +4598,6 @@ int main(int argc, char **argv)
>          exit_program(1);
>      }
>  
> -    for (i = 0; i < nb_output_files; i++) {
> -        if (strcmp(output_files[i]->format->name, "rtp"))
> -            want_sdp = 0;
> -    }
> -
>      current_time = ti = get_benchmark_time_stamps();
>      if (transcode() < 0)
>          exit_program(1);
> diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
> index 67ff391334..4aed24c2a7 100644
> --- a/fftools/ffmpeg.h
> +++ b/fftools/ffmpeg.h
> @@ -646,7 +646,6 @@ extern char *qsv_device;
>  #endif
>  extern HWDevice *filter_hw_device;
>  
> -extern int want_sdp;
>  extern unsigned nb_output_dumped;
>  extern int main_return_code;
>  
> diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
> index aba4b563a4..e6417cdb8c 100644
> --- a/fftools/ffmpeg_mux.c
> +++ b/fftools/ffmpeg_mux.c
> @@ -38,6 +38,8 @@ struct Muxer {
>      int header_written;
>  };
>  
> +static int want_sdp = 1;
> +
>  static void close_all_output_streams(OutputStream *ost, OSTFinished this_stream, OSTFinished others)
>  {
>      int i;
> @@ -349,6 +351,9 @@ int of_muxer_init(OutputFile *of, uint64_t limit_filesize)
>  
>      mux->limit_filesize = limit_filesize;
>  
> +    if (strcmp(of->format->name, "rtp"))
> +        want_sdp = 0;
> +
>      return 0;
>  }
>  
> 

This variable could actually be completely local to
check_init_output_file()/of_check_init().

- Andreas
Anton Khirnov Dec. 17, 2021, 9:44 a.m. UTC | #2
Quoting Andreas Rheinhardt (2021-12-16 22:40:31)
> Anton Khirnov:
> > Allows making the variable local to ffmpeg_mux.
> > ---
> >  fftools/ffmpeg.c     | 9 +--------
> >  fftools/ffmpeg.h     | 1 -
> >  fftools/ffmpeg_mux.c | 5 +++++
> >  3 files changed, 6 insertions(+), 9 deletions(-)
> > 
> > diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> > index 3ed1201fda..f76e5df8d2 100644
> > --- a/fftools/ffmpeg.c
> > +++ b/fftools/ffmpeg.c
> > @@ -138,8 +138,6 @@ static int nb_frames_drop = 0;
> >  static int64_t decode_error_stat[2];
> >  unsigned nb_output_dumped = 0;
> >  
> > -int want_sdp = 1;
> > -
> >  static BenchmarkTimeStamps current_time;
> >  AVIOContext *progress_avio = NULL;
> >  
> > @@ -4557,7 +4555,7 @@ static void log_callback_null(void *ptr, int level, const char *fmt, va_list vl)
> >  
> >  int main(int argc, char **argv)
> >  {
> > -    int i, ret;
> > +    int ret;
> >      BenchmarkTimeStamps ti;
> >  
> >      init_dynload();
> > @@ -4600,11 +4598,6 @@ int main(int argc, char **argv)
> >          exit_program(1);
> >      }
> >  
> > -    for (i = 0; i < nb_output_files; i++) {
> > -        if (strcmp(output_files[i]->format->name, "rtp"))
> > -            want_sdp = 0;
> > -    }
> > -
> >      current_time = ti = get_benchmark_time_stamps();
> >      if (transcode() < 0)
> >          exit_program(1);
> > diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
> > index 67ff391334..4aed24c2a7 100644
> > --- a/fftools/ffmpeg.h
> > +++ b/fftools/ffmpeg.h
> > @@ -646,7 +646,6 @@ extern char *qsv_device;
> >  #endif
> >  extern HWDevice *filter_hw_device;
> >  
> > -extern int want_sdp;
> >  extern unsigned nb_output_dumped;
> >  extern int main_return_code;
> >  
> > diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
> > index aba4b563a4..e6417cdb8c 100644
> > --- a/fftools/ffmpeg_mux.c
> > +++ b/fftools/ffmpeg_mux.c
> > @@ -38,6 +38,8 @@ struct Muxer {
> >      int header_written;
> >  };
> >  
> > +static int want_sdp = 1;
> > +
> >  static void close_all_output_streams(OutputStream *ost, OSTFinished this_stream, OSTFinished others)
> >  {
> >      int i;
> > @@ -349,6 +351,9 @@ int of_muxer_init(OutputFile *of, uint64_t limit_filesize)
> >  
> >      mux->limit_filesize = limit_filesize;
> >  
> > +    if (strcmp(of->format->name, "rtp"))
> > +        want_sdp = 0;
> > +
> >      return 0;
> >  }
> >  
> > 
> 
> This variable could actually be completely local to
> check_init_output_file()/of_check_init().

If we are to have global variables at all (I'd prefer we didn't), I'd
rather have them visible, not hidden inside functions.
diff mbox series

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 3ed1201fda..f76e5df8d2 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -138,8 +138,6 @@  static int nb_frames_drop = 0;
 static int64_t decode_error_stat[2];
 unsigned nb_output_dumped = 0;
 
-int want_sdp = 1;
-
 static BenchmarkTimeStamps current_time;
 AVIOContext *progress_avio = NULL;
 
@@ -4557,7 +4555,7 @@  static void log_callback_null(void *ptr, int level, const char *fmt, va_list vl)
 
 int main(int argc, char **argv)
 {
-    int i, ret;
+    int ret;
     BenchmarkTimeStamps ti;
 
     init_dynload();
@@ -4600,11 +4598,6 @@  int main(int argc, char **argv)
         exit_program(1);
     }
 
-    for (i = 0; i < nb_output_files; i++) {
-        if (strcmp(output_files[i]->format->name, "rtp"))
-            want_sdp = 0;
-    }
-
     current_time = ti = get_benchmark_time_stamps();
     if (transcode() < 0)
         exit_program(1);
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 67ff391334..4aed24c2a7 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -646,7 +646,6 @@  extern char *qsv_device;
 #endif
 extern HWDevice *filter_hw_device;
 
-extern int want_sdp;
 extern unsigned nb_output_dumped;
 extern int main_return_code;
 
diff --git a/fftools/ffmpeg_mux.c b/fftools/ffmpeg_mux.c
index aba4b563a4..e6417cdb8c 100644
--- a/fftools/ffmpeg_mux.c
+++ b/fftools/ffmpeg_mux.c
@@ -38,6 +38,8 @@  struct Muxer {
     int header_written;
 };
 
+static int want_sdp = 1;
+
 static void close_all_output_streams(OutputStream *ost, OSTFinished this_stream, OSTFinished others)
 {
     int i;
@@ -349,6 +351,9 @@  int of_muxer_init(OutputFile *of, uint64_t limit_filesize)
 
     mux->limit_filesize = limit_filesize;
 
+    if (strcmp(of->format->name, "rtp"))
+        want_sdp = 0;
+
     return 0;
 }