Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2012-02-02 05:02:18 +0400
committerMichael Niedermayer <michaelni@gmx.at>2012-02-02 05:24:09 +0400
commit4c677df27cc62e5dd8df9da9d0ca9fb7d963bc08 (patch)
tree1453699ac3b21c5c25889aaed590ca4bc0c7a755 /libavcodec/golomb-test.c
parent5cd8afee99c83b62e1474f122d947de7e4ad9ff5 (diff)
parent5ff88020ac4cd285fa00d0c559aa196bbd8526d7 (diff)
Merge remote-tracking branch 'qatar/master'
* qatar/master: (22 commits) frwu: Employ more meaningful return values. fraps: Use av_fast_padded_malloc() instead of av_realloc() mjpegdec: use av_fast_padded_malloc() eatqi: use av_fast_padded_malloc() asv1: use av_fast_padded_malloc() avcodec: Add av_fast_padded_malloc(). swscale: enable dithering in MMX functions. swscale: make rgb24 function macros slightly smaller. avcodec.h: Remove some disabled cruft. swscale: remove obsolete comment. swscale-test: Drop unused argc and argv arguments from main(). zmbv: Employ more meaningful return values. zmbvenc: Employ more meaningful return values. vc1: prevent null pointer dereference on broken files zmbv: check av_realloc() return values and avoid memleaks on ENOMEM truespeech: align buffer ac3: Do not read past the end of ff_ac3_band_start_tab. dv: Fix small stack overread related to CVE-2011-3929 and CVE-2011-3936. dv: Fix null pointer dereference due to ach=0 dv: check stype ... Conflicts: doc/APIchanges libavcodec/asv1.c libavcodec/avcodec.h libavcodec/eatqi.c libavcodec/fraps.c libavcodec/frwu.c libavcodec/zmbv.c libavformat/dv.c libswscale/swscale.c Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/golomb-test.c')
-rw-r--r--libavcodec/golomb-test.c60
1 files changed, 44 insertions, 16 deletions
diff --git a/libavcodec/golomb-test.c b/libavcodec/golomb-test.c
index c13866bbd7..54644ade46 100644
--- a/libavcodec/golomb-test.c
+++ b/libavcodec/golomb-test.c
@@ -21,52 +21,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;
}