diff mbox series

[FFmpeg-devel,05/10] fftools: move opt_timelimit from cmdutils to ffmpeg

Message ID 20220315090532.27295-5-anton@khirnov.net
State Accepted
Commit 00da464658c85f498b0078073856f1ff3f34a468
Headers show
Series [FFmpeg-devel,01/10] fftools/cmdutils: drop prototypes for nonexistent functions | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov March 15, 2022, 9:05 a.m. UTC
This option is only supported by ffmpeg.
---
 fftools/cmdutils.c   | 17 -----------------
 fftools/ffmpeg_opt.c | 20 ++++++++++++++++++++
 2 files changed, 20 insertions(+), 17 deletions(-)

Comments

Andreas Rheinhardt March 17, 2022, 3:34 p.m. UTC | #1
Anton Khirnov:
> This option is only supported by ffmpeg.
> ---
>  fftools/cmdutils.c   | 17 -----------------
>  fftools/ffmpeg_opt.c | 20 ++++++++++++++++++++
>  2 files changed, 20 insertions(+), 17 deletions(-)
> 
> diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
> index 12ef07b62f..e5684fa840 100644
> --- a/fftools/cmdutils.c
> +++ b/fftools/cmdutils.c
> @@ -47,10 +47,6 @@
>  #include "libavutil/opt.h"
>  #include "cmdutils.h"
>  #include "opt_common.h"
> -#if HAVE_SYS_RESOURCE_H
> -#include <sys/time.h>
> -#include <sys/resource.h>
> -#endif
>  #ifdef _WIN32
>  #include <windows.h>
>  #endif
> @@ -797,19 +793,6 @@ do {                                                                           \
>      return 0;
>  }
>  
> -int opt_timelimit(void *optctx, const char *opt, const char *arg)
> -{
> -#if HAVE_SETRLIMIT
> -    int lim = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX);
> -    struct rlimit rl = { lim, lim + 1 };
> -    if (setrlimit(RLIMIT_CPU, &rl))
> -        perror("setrlimit");
> -#else
> -    av_log(NULL, AV_LOG_WARNING, "-%s not implemented on this OS\n", opt);
> -#endif
> -    return 0;
> -}
> -
>  void print_error(const char *filename, int err)
>  {
>      char errbuf[128];
> diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
> index b2746259d7..778e02c39e 100644
> --- a/fftools/ffmpeg_opt.c
> +++ b/fftools/ffmpeg_opt.c
> @@ -19,8 +19,15 @@
>   * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
>   */
>  
> +#include "config.h"
> +
>  #include <stdint.h>
>  
> +#if HAVE_SYS_RESOURCE_H
> +#include <sys/time.h>
> +#include <sys/resource.h>
> +#endif
> +
>  #include "ffmpeg.h"
>  #include "cmdutils.h"
>  #include "opt_common.h"
> @@ -3501,6 +3508,19 @@ static int opt_progress(void *optctx, const char *opt, const char *arg)
>      return 0;
>  }
>  
> +int opt_timelimit(void *optctx, const char *opt, const char *arg)
> +{
> +#if HAVE_SETRLIMIT
> +    int lim = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX);
> +    struct rlimit rl = { lim, lim + 1 };
> +    if (setrlimit(RLIMIT_CPU, &rl))
> +        perror("setrlimit");
> +#else
> +    av_log(NULL, AV_LOG_WARNING, "-%s not implemented on this OS\n", opt);
> +#endif
> +    return 0;
> +}
> +
>  #define OFFSET(x) offsetof(OptionsContext, x)
>  const OptionDef options[] = {
>      /* main options */

LGTM to moving. Didn't look at whether the headers removed from
cmdutils.c were only used by opt_timelimit() though.

- Andreas
diff mbox series

Patch

diff --git a/fftools/cmdutils.c b/fftools/cmdutils.c
index 12ef07b62f..e5684fa840 100644
--- a/fftools/cmdutils.c
+++ b/fftools/cmdutils.c
@@ -47,10 +47,6 @@ 
 #include "libavutil/opt.h"
 #include "cmdutils.h"
 #include "opt_common.h"
-#if HAVE_SYS_RESOURCE_H
-#include <sys/time.h>
-#include <sys/resource.h>
-#endif
 #ifdef _WIN32
 #include <windows.h>
 #endif
@@ -797,19 +793,6 @@  do {                                                                           \
     return 0;
 }
 
-int opt_timelimit(void *optctx, const char *opt, const char *arg)
-{
-#if HAVE_SETRLIMIT
-    int lim = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX);
-    struct rlimit rl = { lim, lim + 1 };
-    if (setrlimit(RLIMIT_CPU, &rl))
-        perror("setrlimit");
-#else
-    av_log(NULL, AV_LOG_WARNING, "-%s not implemented on this OS\n", opt);
-#endif
-    return 0;
-}
-
 void print_error(const char *filename, int err)
 {
     char errbuf[128];
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index b2746259d7..778e02c39e 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -19,8 +19,15 @@ 
  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  */
 
+#include "config.h"
+
 #include <stdint.h>
 
+#if HAVE_SYS_RESOURCE_H
+#include <sys/time.h>
+#include <sys/resource.h>
+#endif
+
 #include "ffmpeg.h"
 #include "cmdutils.h"
 #include "opt_common.h"
@@ -3501,6 +3508,19 @@  static int opt_progress(void *optctx, const char *opt, const char *arg)
     return 0;
 }
 
+int opt_timelimit(void *optctx, const char *opt, const char *arg)
+{
+#if HAVE_SETRLIMIT
+    int lim = parse_number_or_die(opt, arg, OPT_INT64, 0, INT_MAX);
+    struct rlimit rl = { lim, lim + 1 };
+    if (setrlimit(RLIMIT_CPU, &rl))
+        perror("setrlimit");
+#else
+    av_log(NULL, AV_LOG_WARNING, "-%s not implemented on this OS\n", opt);
+#endif
+    return 0;
+}
+
 #define OFFSET(x) offsetof(OptionsContext, x)
 const OptionDef options[] = {
     /* main options */