diff options
author | Janne Grunau <janne-libav@jannau.net> | 2012-01-31 21:39:48 +0100 |
---|---|---|
committer | Janne Grunau <janne-libav@jannau.net> | 2012-02-01 01:18:55 +0100 |
commit | e67e3a3f4a43ad08115b4fcebce39fb487728eb3 (patch) | |
tree | 606e367096b19ed67c18ebd2d417571e5827cd17 | |
parent | c0bc7bd1e785c3cfe1ce988b04108694b95b5c9d (diff) | |
download | ffmpeg-e67e3a3f4a43ad08115b4fcebce39fb487728eb3.tar.gz |
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.
-rw-r--r-- | libavcodec/golomb-test.c | 60 | ||||
-rw-r--r-- | tests/fate/libavcodec.mak | 1 | ||||
-rw-r--r-- | 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 3dbf9d14cb..bc90f36baf 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 90c817812f..ec4012ebb6 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 652e97b305..0000000000 --- a/tests/ref/fate/golomb +++ /dev/null @@ -1,2 +0,0 @@ -testing unsigned exp golomb -testing signed exp golomb |