Revision c43d77c1 tests/tiny_psnr.c

View differences:

tests/tiny_psnr.c
20 20

  
21 21
#include <stdio.h>
22 22
#include <stdlib.h>
23
#include <string.h>
23 24
#include <inttypes.h>
24 25
#include <assert.h>
25 26

  
......
117 118

  
118 119
    if(argc<3){
119 120
        printf("tiny_psnr <file1> <file2> [<elem size> [<shift> [<skip bytes>]]]\n");
120
        printf("For WAV files use the following:\n");
121
        printf("./tiny_psnr file1.wav file2.wav 2 0 44 to skip the header.\n");
121
        printf("WAV headers are skipped automatically.\n");
122 122
        return -1;
123 123
    }
124 124

  
......
128 128
        fprintf(stderr, "Could not open input files.\n");
129 129
        return -1;
130 130
    }
131
    fseek(f[shift<0], shift < 0 ? -shift : shift, SEEK_SET);
131

  
132
    for (i = 0; i < 2; i++) {
133
        uint8_t *p = buf[i];
134
        fread(p, 1, 12, f[i]);
135
        if (!memcmp(p,   "RIFF", 4) &&
136
            !memcmp(p+8, "WAVE", 4)) {
137
            fread(p, 1, 8, f[i]);
138
            while (memcmp(p, "data", 4)) {
139
                int s = p[4] | p[5]<<8 | p[6]<<16 | p[7]<<24;
140
                fseek(f[i], s, SEEK_CUR);
141
                fread(p, 1, 8, f[i]);
142
            }
143
        } else {
144
            fseek(f[i], -12, SEEK_CUR);
145
        }
146
    }
147

  
148
    fseek(f[shift<0], shift < 0 ? -shift : shift, SEEK_CUR);
132 149

  
133 150
    fseek(f[0],skip_bytes,SEEK_CUR);
134 151
    fseek(f[1],skip_bytes,SEEK_CUR);

Also available in: Unified diff