00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #include <stdlib.h>
00022
00023 #include "libavformat/avformat.h"
00024 #include "libavcodec/put_bits.h"
00025 #include "libavutil/lfg.h"
00026
00027 static int score_array[1000];
00028 static int failures = 0;
00029
00030 static void probe(AVProbeData *pd, int type, int p, int size)
00031 {
00032 int i = 0;
00033 AVInputFormat *fmt = NULL;
00034
00035 while ((fmt = av_iformat_next(fmt))) {
00036 if (fmt->flags & AVFMT_NOFILE)
00037 continue;
00038 if (fmt->read_probe) {
00039 int score = fmt->read_probe(pd);
00040 if (score > score_array[i] && score > AVPROBE_SCORE_MAX / 4) {
00041 score_array[i] = score;
00042 fprintf(stderr, "Failure of %s probing code with score=%d type=%d p=%X size=%d\n",
00043 fmt->name, score, type, p, size);
00044 failures++;
00045 }
00046 }
00047 i++;
00048 }
00049 }
00050
00051 int main(void)
00052 {
00053 unsigned int p, i, type, size, retry;
00054 AVProbeData pd;
00055 AVLFG state;
00056 PutBitContext pb;
00057
00058 avcodec_register_all();
00059 av_register_all();
00060
00061 av_lfg_init(&state, 0xdeadbeef);
00062
00063 pd.buf = NULL;
00064 for (size = 1; size < 65537; size *= 2) {
00065 pd.buf_size = size;
00066 pd.buf = av_realloc(pd.buf, size + AVPROBE_PADDING_SIZE);
00067 pd.filename = "";
00068
00069 fprintf(stderr, "testing size=%d\n", size);
00070
00071 for (retry = 0; retry < 4097; retry += FFMAX(size, 32)) {
00072 for (type = 0; type < 4; type++) {
00073 for (p = 0; p < 4096; p++) {
00074 unsigned hist = 0;
00075 init_put_bits(&pb, pd.buf, size);
00076 switch (type) {
00077 case 0:
00078 for (i = 0; i < size * 8; i++) {
00079 put_bits(&pb, 1, (av_lfg_get(&state) & 0xFFFFFFFF) > p << 20);
00080 }
00081 break;
00082 case 1:
00083 for (i = 0; i < size * 8; i++) {
00084 unsigned int p2 = hist ? p & 0x3F : (p >> 6);
00085 unsigned int v = (av_lfg_get(&state) & 0xFFFFFFFF) > p2 << 26;
00086 put_bits(&pb, 1, v);
00087 hist = v;
00088 }
00089 break;
00090 case 2:
00091 for (i = 0; i < size * 8; i++) {
00092 unsigned int p2 = (p >> (hist*3)) & 7;
00093 unsigned int v = (av_lfg_get(&state) & 0xFFFFFFFF) > p2 << 29;
00094 put_bits(&pb, 1, v);
00095 hist = (2*hist + v) & 3;
00096 }
00097 break;
00098 case 3:
00099 for (i = 0; i < size; i++) {
00100 int c = 0;
00101 while (p & 63) {
00102 c = (av_lfg_get(&state) & 0xFFFFFFFF) >> 24;
00103 if (c >= 'a' && c <= 'z' && (p & 1)) break;
00104 else if(c >= 'A' && c <= 'Z' && (p & 2)) break;
00105 else if(c >= '0' && c <= '9' && (p & 4)) break;
00106 else if(c == ' ' && (p & 8)) break;
00107 else if(c == 0 && (p & 16)) break;
00108 else if(c == 1 && (p & 32)) break;
00109 }
00110 pd.buf[i] = c;
00111 }
00112 }
00113 flush_put_bits(&pb);
00114 probe(&pd, type, p, size);
00115 }
00116 }
00117 }
00118 }
00119 return failures;
00120 }