[FFmpeg-cvslog] checkasm: aacpsdsp: Tolerate extra intermediate precision in stereo_interpolate

2019-12-18 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö  | Wed Dec  4 
13:04:41 2019 +0200| [aad0e26f9312d380e613e312a3b307609296fe58] | committer: 
Martin Storsjö

checkasm: aacpsdsp: Tolerate extra intermediate precision in stereo_interpolate

The stereo_interpolate functions add h_step to the values h
BUF_SIZE times. Within the stereo_interpolate C functions, the
values h (h0-h3, h00-h13) are declared as local float variables,
but the compiler is free to keep them in a register with extra
precision.

If the accumulation is rounded to 32 bit float precision after
each step, the less significant bits of h_step end up ignored
and the sum can deviate, affecting the end result more than
the currently set EPS.

By clearing the log2(BUF_SIZE) lower bits of h_step, we make sure
that the accumulation shouldn't differ significantly, regardless
of any extra precision in the accmulating register/variable.

This fixes the aacpsdsp checkasm test when built with clang for
mingw/x86_32.

Signed-off-by: Martin Storsjö 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=aad0e26f9312d380e613e312a3b307609296fe58
---

 tests/checkasm/aacpsdsp.c | 18 ++
 1 file changed, 18 insertions(+)

diff --git a/tests/checkasm/aacpsdsp.c b/tests/checkasm/aacpsdsp.c
index ea68b39fa9..2ceef4341f 100644
--- a/tests/checkasm/aacpsdsp.c
+++ b/tests/checkasm/aacpsdsp.c
@@ -17,6 +17,7 @@
  */
 
 #include "libavcodec/aacpsdsp.h"
+#include "libavutil/intfloat.h"
 
 #include "checkasm.h"
 
@@ -34,6 +35,16 @@
 
 #define EPS 0.005
 
+static void clear_less_significant_bits(INTFLOAT *buf, int len, int bits)
+{
+int i;
+for (i = 0; i < len; i++) {
+union av_intfloat32 u = { .f = buf[i] };
+u.i &= (0x << bits);
+buf[i] = u.f;
+}
+}
+
 static void test_add_squares(void)
 {
 LOCAL_ALIGNED_16(INTFLOAT, dst0, [BUF_SIZE]);
@@ -198,6 +209,13 @@ static void test_stereo_interpolate(PSDSPContext *psdsp)
 
 randomize((INTFLOAT *)h, 2 * 4);
 randomize((INTFLOAT *)h_step, 2 * 4);
+// Clear the least significant 14 bits of h_step, to avoid
+// divergence when accumulating h_step BUF_SIZE times into
+// a float variable which may or may not have extra intermediate
+// precision. Therefore clear roughly log2(BUF_SIZE) less
+// significant bits, to get the same result regardless of any
+// extra precision in the accumulator.
+clear_less_significant_bits((INTFLOAT *)h_step, 2 * 4, 14);
 
 call_ref(l0, r0, h, h_step, BUF_SIZE);
 call_new(l1, r1, h, h_step, BUF_SIZE);

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".

[FFmpeg-cvslog] ffprobe: Fix fate tests for ffprobe in cases where TARGET_PATH differs from the current path

2019-12-18 Thread Martin Storsjö
ffmpeg | branch: master | Martin Storsjö  | Mon Dec  2 
11:16:25 2019 +0200| [e10654de2b0db0f3b4828a3cc066d6fa21d02516] | committer: 
Martin Storsjö

ffprobe: Fix fate tests for ffprobe in cases where TARGET_PATH differs from the 
current path

In these cases, we must pass the full path of the file to ffprobe
(as the current working dir on the remote system, e.g. when invoked
with "ssh remote ffprobe ..." isn't the wanted one).

The input filename passed to ffprobe is also included in the output,
which is part of the reference test data. Add a new option to
ffprobe to allow overriding what path is printed, to keep the
original relative path in the tests.

An alternative approach could be an option to allow requesting omitting
the file name from the dumped data, and updating the test references
accordingly.

Signed-off-by: Martin Storsjö 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e10654de2b0db0f3b4828a3cc066d6fa21d02516
---

 fftools/ffprobe.c  | 22 ++
 tests/fate/ffprobe.mak |  2 +-
 2 files changed, 19 insertions(+), 5 deletions(-)

diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index a95d74346d..b619c1f34e 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -254,6 +254,7 @@ static const OptionDef *options;
 
 /* FFprobe context */
 static const char *input_filename;
+static const char *print_input_filename;
 static AVInputFormat *iformat = NULL;
 
 static struct AVHashContext *hash;
@@ -2836,7 +2837,8 @@ static void show_error(WriterContext *w, int err)
 writer_print_section_footer(w);
 }
 
-static int open_input_file(InputFile *ifile, const char *filename)
+static int open_input_file(InputFile *ifile, const char *filename,
+   const char *print_filename)
 {
 int err, i;
 AVFormatContext *fmt_ctx = NULL;
@@ -2858,6 +2860,10 @@ static int open_input_file(InputFile *ifile, const char 
*filename)
 print_error(filename, err);
 return err;
 }
+if (print_filename) {
+av_freep(&fmt_ctx->url);
+fmt_ctx->url = av_strdup(print_filename);
+}
 ifile->fmt_ctx = fmt_ctx;
 if (scan_all_pmts_set)
 av_dict_set(&format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
@@ -2971,7 +2977,8 @@ static void close_input_file(InputFile *ifile)
 avformat_close_input(&ifile->fmt_ctx);
 }
 
-static int probe_file(WriterContext *wctx, const char *filename)
+static int probe_file(WriterContext *wctx, const char *filename,
+  const char *print_filename)
 {
 InputFile ifile = { 0 };
 int ret, i;
@@ -2980,7 +2987,7 @@ static int probe_file(WriterContext *wctx, const char 
*filename)
 do_read_frames = do_show_frames || do_count_frames;
 do_read_packets = do_show_packets || do_count_packets;
 
-ret = open_input_file(&ifile, filename);
+ret = open_input_file(&ifile, filename, print_filename);
 if (ret < 0)
 goto end;
 
@@ -3286,6 +3293,12 @@ static int opt_input_file_i(void *optctx, const char 
*opt, const char *arg)
 return 0;
 }
 
+static int opt_print_filename(void *optctx, const char *opt, const char *arg)
+{
+print_input_filename = arg;
+return 0;
+}
+
 void show_help_default(const char *opt, const char *arg)
 {
 av_log_set_callback(log_callback_help);
@@ -3544,6 +3557,7 @@ static const OptionDef real_options[] = {
 { "read_intervals", HAS_ARG, {.func_arg = opt_read_intervals}, "set read 
intervals", "read_intervals" },
 { "default", HAS_ARG | OPT_AUDIO | OPT_VIDEO | OPT_EXPERT, {.func_arg = 
opt_default}, "generic catch all option", "" },
 { "i", HAS_ARG, {.func_arg = opt_input_file_i}, "read specified file", 
"input_file"},
+{ "print_filename", HAS_ARG, {.func_arg = opt_print_filename}, "override 
the printed input filename", "print_file"},
 { "find_stream_info", OPT_BOOL | OPT_INPUT | OPT_EXPERT, { 
&find_stream_info },
 "read and decode the streams to fill missing information with 
heuristics" },
 { NULL, },
@@ -3692,7 +3706,7 @@ int main(int argc, char **argv)
 av_log(NULL, AV_LOG_ERROR, "Use -h to get full help or, even 
better, run 'man %s'.\n", program_name);
 ret = AVERROR(EINVAL);
 } else if (input_filename) {
-ret = probe_file(wctx, input_filename);
+ret = probe_file(wctx, input_filename, print_input_filename);
 if (ret < 0 && do_show_error)
 show_error(wctx, ret);
 }
diff --git a/tests/fate/ffprobe.mak b/tests/fate/ffprobe.mak
index d5fb05cd68..c867bebf41 100644
--- a/tests/fate/ffprobe.mak
+++ b/tests/fate/ffprobe.mak
@@ -1,5 +1,5 @@
 FFPROBE_TEST_FILE=tests/data/ffprobe-test.nut
-FFPROBE_COMMAND=ffprobe$(PROGSSUF)$(EXESUF) -show_streams -show_packets 
-show_format -show_frames -bitexact $(FFPROBE_TEST_FILE)
+FFPROBE_COMMAND=ffprobe$(PROGSSUF)$(EXESUF) -show_streams -show_packets 
-show_format -show_frames -bitexact $(TARGET_PATH)/$(FFPROBE_TEST_FILE) 
-print_filename $(FFPROBE_TE