diff mbox

[FFmpeg-devel] fftools/ffmpeg: fix mixed code and declarations

Message ID 20180429022127.352-1-jamrial@gmail.com
State Superseded
Headers show

Commit Message

James Almer April 29, 2018, 2:21 a.m. UTC
Signed-off-by: James Almer <jamrial@gmail.com>
---
 fftools/ffmpeg.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

Comments

Derek Buitenhuis April 29, 2018, 11:08 a.m. UTC | #1
On 4/29/2018 3:21 AM, James Almer wrote:
> +    BenchmarkTimeStamps time_stamps = { .real_usec = av_gettime_relative() };

Does this build on supported versions of MSVC?

- Derek
James Almer April 29, 2018, 2 p.m. UTC | #2
On 4/29/2018 8:08 AM, Derek Buitenhuis wrote:
> On 4/29/2018 3:21 AM, James Almer wrote:
>> +    BenchmarkTimeStamps time_stamps = { .real_usec = av_gettime_relative() };
> 
> Does this build on supported versions of MSVC?

I don't know, i don't have MSVC to test. And afaik we support only 2013
or newer (or at least stopped caring about the older, non c99 compliant
ones).
wm4 April 29, 2018, 2:10 p.m. UTC | #3
On Sat, 28 Apr 2018 23:21:27 -0300
James Almer <jamrial@gmail.com> wrote:

> Signed-off-by: James Almer <jamrial@gmail.com>
> ---
>  fftools/ffmpeg.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
> 
> diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
> index d3054092ba..9b3e9d121e 100644
> --- a/fftools/ffmpeg.c
> +++ b/fftools/ffmpeg.c
> @@ -4727,8 +4727,7 @@ static int transcode(void)
>  
>  static BenchmarkTimeStamps get_benchmark_time_stamps(void)
>  {
> -    BenchmarkTimeStamps time_stamps;
> -    time_stamps.real_usec = av_gettime_relative();
> +    BenchmarkTimeStamps time_stamps = { .real_usec = av_gettime_relative() };
>  #if HAVE_GETRUSAGE
>      struct rusage rusage;
>  
> @@ -4833,10 +4832,11 @@ int main(int argc, char **argv)
>      if (transcode() < 0)
>          exit_program(1);
>      if (do_benchmark) {
> +        int64_t utime, stime, rtime;
>          current_time = get_benchmark_time_stamps();
> -        int64_t utime = current_time.user_usec - ti.user_usec;
> -        int64_t stime = current_time.sys_usec - ti.sys_usec;
> -        int64_t rtime = current_time.real_usec - ti.real_usec;
> +        utime = current_time.user_usec - ti.user_usec;
> +        stime = current_time.sys_usec - ti.sys_usec;
> +        rtime = current_time.real_usec - ti.real_usec;
>          av_log(NULL, AV_LOG_INFO,
>                 "bench: utime=%0.3fs stime=%0.3fs rtime=%0.3fs\n",
>                 utime / 1000000.0, stime / 1000000.0, rtime / 1000000.0);

It's pretty funny that we change something because it's not allowed in
C89 (but in C99), and add use of a C99 only feature in the same fix.
Hendrik Leppkes April 29, 2018, 2:25 p.m. UTC | #4
On Sun, Apr 29, 2018 at 4:00 PM, James Almer <jamrial@gmail.com> wrote:
> On 4/29/2018 8:08 AM, Derek Buitenhuis wrote:
>> On 4/29/2018 3:21 AM, James Almer wrote:
>>> +    BenchmarkTimeStamps time_stamps = { .real_usec = av_gettime_relative() };
>>
>> Does this build on supported versions of MSVC?
>
> I don't know, i don't have MSVC to test. And afaik we support only 2013
> or newer (or at least stopped caring about the older, non c99 compliant
> ones).

real_usec is the first field in the struct, just skip the designated
initializer entirely.

- Hendrik
diff mbox

Patch

diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index d3054092ba..9b3e9d121e 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -4727,8 +4727,7 @@  static int transcode(void)
 
 static BenchmarkTimeStamps get_benchmark_time_stamps(void)
 {
-    BenchmarkTimeStamps time_stamps;
-    time_stamps.real_usec = av_gettime_relative();
+    BenchmarkTimeStamps time_stamps = { .real_usec = av_gettime_relative() };
 #if HAVE_GETRUSAGE
     struct rusage rusage;
 
@@ -4833,10 +4832,11 @@  int main(int argc, char **argv)
     if (transcode() < 0)
         exit_program(1);
     if (do_benchmark) {
+        int64_t utime, stime, rtime;
         current_time = get_benchmark_time_stamps();
-        int64_t utime = current_time.user_usec - ti.user_usec;
-        int64_t stime = current_time.sys_usec - ti.sys_usec;
-        int64_t rtime = current_time.real_usec - ti.real_usec;
+        utime = current_time.user_usec - ti.user_usec;
+        stime = current_time.sys_usec - ti.sys_usec;
+        rtime = current_time.real_usec - ti.real_usec;
         av_log(NULL, AV_LOG_INFO,
                "bench: utime=%0.3fs stime=%0.3fs rtime=%0.3fs\n",
                utime / 1000000.0, stime / 1000000.0, rtime / 1000000.0);