[FFmpeg-cvslog] fate-golomb: extend golomb-test to get_ue_golomb_long()

Janne Grunau git at videolan.org
Thu Feb 2 02:46:24 CET 2012


ffmpeg | branch: master | Janne Grunau <janne-libav at jannau.net> | Tue Jan 31 21:39:48 2012 +0100| [e67e3a3f4a43ad08115b4fcebce39fb487728eb3] | committer: Janne Grunau

fate-golomb: extend golomb-test to get_ue_golomb_long()

get_ue_golomb_long() is only tested for values up to 2^15 - 2 since
we can not write larger values.
Silence the test on success and return a non-zero value on error.
Use an heap scratch buffer instead of large stack buffer.
Remove unneeded includes.

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

 libavcodec/golomb-test.c  |   60 +++++++++++++++++++++++++++++++++------------
 tests/fate/libavcodec.mak |    1 +
 tests/ref/fate/golomb     |    2 -
 3 files changed, 45 insertions(+), 18 deletions(-)

diff --git a/libavcodec/golomb-test.c b/libavcodec/golomb-test.c
index 3dbf9d1..bc90f36 100644
--- a/libavcodec/golomb-test.c
+++ b/libavcodec/golomb-test.c
@@ -19,52 +19,80 @@
 #include <stdint.h>
 #include <stdio.h>
 
-#include "avcodec.h"
-#include "dsputil.h"
+#include "libavutil/mem.h"
+
 #include "get_bits.h"
 #include "golomb.h"
 #include "put_bits.h"
 
-#undef printf
-#define COUNT 8000
-#define SIZE (COUNT * 40)
+#undef fprintf
+#define COUNT 8191
+#define SIZE (COUNT * 4)
 
 int main(void)
 {
-    int i;
-    uint8_t temp[SIZE];
+    int i, ret = 0;
+    uint8_t *temp;
     PutBitContext pb;
     GetBitContext gb;
 
+    temp = av_malloc(SIZE);
+    if (!temp)
+        return 2;
+
     init_put_bits(&pb, temp, SIZE);
-    printf("testing unsigned exp golomb\n");
     for (i = 0; i < COUNT; i++)
         set_ue_golomb(&pb, i);
     flush_put_bits(&pb);
 
     init_get_bits(&gb, temp, 8 * SIZE);
     for (i = 0; i < COUNT; i++) {
-        int j, s = show_bits(&gb, 24);
+        int j, s = show_bits(&gb, 25);
 
         j = get_ue_golomb(&gb);
-        if (j != i)
-            printf("mismatch at %d (%d should be %d) bits: %6X\n", i, j, i, s);
+        if (j != i) {
+            fprintf(stderr, "get_ue_golomb: expected %d, got %d. bits: %7x\n",
+                    i, j, s);
+            ret = 1;
+        }
+    }
+
+#define EXTEND(i) (i << 3 | i & 7)
+    init_put_bits(&pb, temp, SIZE);
+    for (i = 0; i < COUNT; i++)
+        set_ue_golomb(&pb, EXTEND(i));
+    flush_put_bits(&pb);
+
+    init_get_bits(&gb, temp, 8 * SIZE);
+    for (i = 0; i < COUNT; i++) {
+        int j, s = show_bits_long(&gb, 32);
+
+        j = get_ue_golomb_long(&gb);
+        if (j != EXTEND(i)) {
+            fprintf(stderr, "get_ue_golomb_long: expected %d, got %d. "
+                    "bits: %8x\n", EXTEND(i), j, s);
+            ret = 1;
+        }
     }
 
     init_put_bits(&pb, temp, SIZE);
-    printf("testing signed exp golomb\n");
     for (i = 0; i < COUNT; i++)
         set_se_golomb(&pb, i - COUNT / 2);
     flush_put_bits(&pb);
 
     init_get_bits(&gb, temp, 8 * SIZE);
     for (i = 0; i < COUNT; i++) {
-        int j, s = show_bits(&gb, 24);
+        int j, s = show_bits(&gb, 25);
 
         j = get_se_golomb(&gb);
-        if (j != i - COUNT / 2)
-            printf("mismatch at %d (%d should be %d) bits: %6X\n", i, j, i, s);
+        if (j != i - COUNT / 2) {
+            fprintf(stderr, "get_se_golomb: expected %d, got %d. bits: %7x\n",
+                    i - COUNT / 2, j, s);
+            ret = 1;
+        }
     }
 
-    return 0;
+    av_free(temp);
+
+    return ret;
 }
diff --git a/tests/fate/libavcodec.mak b/tests/fate/libavcodec.mak
index 90c8178..ec4012e 100644
--- a/tests/fate/libavcodec.mak
+++ b/tests/fate/libavcodec.mak
@@ -1,6 +1,7 @@
 FATE_TESTS += fate-golomb
 fate-golomb: libavcodec/golomb-test$(EXESUF)
 fate-golomb: CMD = run libavcodec/golomb-test
+fate-golomb: REF = /dev/null
 
 FATE_TESTS += fate-iirfilter
 fate-iirfilter: libavcodec/iirfilter-test$(EXESUF)
diff --git a/tests/ref/fate/golomb b/tests/ref/fate/golomb
deleted file mode 100644
index 652e97b..0000000
--- a/tests/ref/fate/golomb
+++ /dev/null
@@ -1,2 +0,0 @@
-testing unsigned exp golomb
-testing signed exp golomb



More information about the ffmpeg-cvslog mailing list