Revision 497559ec tools/probetest.c

View differences:

tools/probetest.c
25 25
#include "libavutil/lfg.h"
26 26

  
27 27
static int score_array[1000]; //this must be larger than the number of formats
28
static int failures=0;
28
static int failures = 0;
29 29

  
30 30
static void probe(AVProbeData *pd, int type, int p, int size)
31 31
{
32 32
    int i = 0;
33 33
    AVInputFormat *fmt;
34 34

  
35
    for(fmt = first_iformat; fmt != NULL; fmt = fmt->next) {
35
    for (fmt = first_iformat; fmt != NULL; fmt = fmt->next) {
36 36
        if (fmt->flags & AVFMT_NOFILE)
37 37
            continue;
38 38
        if (fmt->read_probe) {
39 39
            int score = fmt->read_probe(pd);
40
            if(score > score_array[i] && score > AVPROBE_SCORE_MAX/4){
41
                score_array[i]= score;
42
                fprintf(stderr, "Failure of %s probing code with score=%d type=%d p=%X size=%d\n", fmt->name, score, type, p, size);
40
            if (score > score_array[i] && score > AVPROBE_SCORE_MAX / 4) {
41
                score_array[i] = score;
42
                fprintf(stderr, "Failure of %s probing code with score=%d type=%d p=%X size=%d\n",
43
                        fmt->name, score, type, p, size);
43 44
                failures++;
44 45
            }
45 46
        }
......
59 60

  
60 61
    av_lfg_init(&state, 0xdeadbeef);
61 62

  
62
    pd.buf= NULL;
63
    for(size= 1; size < 65537; size*=2){
64
        pd.buf_size= size;
65
        pd.buf= av_realloc(pd.buf, size + AVPROBE_PADDING_SIZE);
66
        pd.filename= "";
63
    pd.buf = NULL;
64
    for (size = 1; size < 65537; size *= 2) {
65
        pd.buf_size = size;
66
        pd.buf      = av_realloc(pd.buf, size + AVPROBE_PADDING_SIZE);
67
        pd.filename = "";
67 68

  
68 69
        fprintf(stderr, "testing size=%d\n", size);
69 70

  
70
        for(retry=0; retry<4097; retry+= FFMAX(size,32)){
71
            for(type=0; type < 4; type++){
72
                for(p=0; p<4096; p++){
73
                    unsigned hist=0;
71
        for (retry = 0; retry < 4097; retry += FFMAX(size, 32)) {
72
            for (type = 0; type < 4; type++) {
73
                for (p = 0; p < 4096; p++) {
74
                    unsigned hist = 0;
74 75
                    init_put_bits(&pb, pd.buf, size);
75
                    switch(type){
76
                    switch (type) {
76 77
                    case 0:
77
                        for(i=0; i<size*8; i++){
78
                            put_bits(&pb, 1, (av_lfg_get(&state)&0xFFFFFFFF) > p<<20);
78
                        for (i = 0; i < size * 8; i++) {
79
                            put_bits(&pb, 1, (av_lfg_get(&state) & 0xFFFFFFFF) > p << 20);
79 80
                        }
80 81
                        break;
81 82
                    case 1:
82
                        for(i=0; i<size*8; i++){
83
                            unsigned int p2= hist ? p&0x3F : (p>>6);
84
                            unsigned int v= (av_lfg_get(&state)&0xFFFFFFFF) > p2<<26;
83
                        for (i = 0; i < size * 8; i++) {
84
                            unsigned int p2 = hist ? p & 0x3F : (p >> 6);
85
                            unsigned int v  = (av_lfg_get(&state) & 0xFFFFFFFF) > p2 << 26;
85 86
                            put_bits(&pb, 1, v);
86
                            hist= v;
87
                            hist = v;
87 88
                        }
88 89
                        break;
89 90
                    case 2:
90
                        for(i=0; i<size*8; i++){
91
                            unsigned int p2= (p >> (hist*3)) & 7;
92
                            unsigned int v= (av_lfg_get(&state)&0xFFFFFFFF) > p2<<29;
91
                        for (i = 0; i < size * 8; i++) {
92
                            unsigned int p2 = (p >> (hist*3)) & 7;
93
                            unsigned int v  = (av_lfg_get(&state) & 0xFFFFFFFF) > p2 << 29;
93 94
                            put_bits(&pb, 1, v);
94
                            hist= (2*hist + v)&3;
95
                            hist = (2*hist + v) & 3;
95 96
                        }
96 97
                        break;
97 98
                    case 3:
98
                        for(i=0; i<size; i++){
99
                            int c=0;
100
                            while(p&63){
101
                                c= (av_lfg_get(&state)&0xFFFFFFFF)>>24;
102
                                if     (c >= 'a' && c <= 'z' && (p&1)) break;
103
                                else if(c >= 'A' && c <= 'Z' && (p&2)) break;
104
                                else if(c >= '0' && c <= '9' && (p&4)) break;
105
                                else if(c == ' '&& (p&8)) break;
106
                                else if(c == 0 && (p&16)) break;
107
                                else if(c == 1 && (p&32)) break;
99
                        for (i = 0; i < size; i++) {
100
                            int c = 0;
101
                            while (p & 63) {
102
                                c = (av_lfg_get(&state) & 0xFFFFFFFF) >> 24;
103
                                if     (c >= 'a' && c <= 'z' && (p & 1)) break;
104
                                else if(c >= 'A' && c <= 'Z' && (p & 2)) break;
105
                                else if(c >= '0' && c <= '9' && (p & 4)) break;
106
                                else if(c == ' ' && (p &  8)) break;
107
                                else if(c ==  0  && (p & 16)) break;
108
                                else if(c ==  1  && (p & 32)) break;
108 109
                            }
109
                            pd.buf[i]= c;
110
                            pd.buf[i] = c;
110 111
                        }
111 112
                    }
112 113
                    flush_put_bits(&pb);

Also available in: Unified diff