OSDN Git Service

Merge commit '3dc06b6972cf389269e9c36ff0a4373f80f7149b'
authorMichael Niedermayer <michaelni@gmx.at>
Tue, 16 Oct 2012 12:04:14 +0000 (14:04 +0200)
committerMichael Niedermayer <michaelni@gmx.at>
Tue, 16 Oct 2012 12:04:14 +0000 (14:04 +0200)
* commit '3dc06b6972cf389269e9c36ff0a4373f80f7149b':
  tiny_psnr: check for specified sample size less than 1
  fate: improve md5sum utility selection
  rangecoder-test: Drop timer output that clutters stderr

Conflicts:
tests/tiny_psnr.c

Merged-by: Michael Niedermayer <michaelni@gmx.at>
1  2 
libavcodec/rangecoder.c
tests/md5.sh
tests/tiny_psnr.c

Simple merge
diff --cc tests/md5.sh
Simple merge
@@@ -207,58 -222,5 +207,58 @@@ static int run_psnr(FILE *f[2], int len
             (int)(dev / F), (int)(dev % F),
             (int)(psnr / F), (int)(psnr % F),
             maxdist, size0, size1);
-             if (*end || len > 2) {
 +    return psnr;
 +}
 +
 +int main(int argc, char *argv[])
 +{
 +    FILE *f[2];
 +    int len = 1;
 +    int shift_first= argc < 5 ? 0 : atoi(argv[4]);
 +    int skip_bytes = argc < 6 ? 0 : atoi(argv[5]);
 +    int shift_last = shift_first + (argc < 7 ? 0 : atoi(argv[6]));
 +    int shift;
 +    int max_psnr   = -1;
 +    int max_psnr_shift = 0;
 +
 +    if (argc > 3) {
 +        if (!strcmp(argv[3], "u8")) {
 +            len = 1;
 +        } else if (!strcmp(argv[3], "s16")) {
 +            len = 2;
 +        } else if (!strcmp(argv[3], "f32")) {
 +            len = 4;
 +        } else {
 +            char *end;
 +            len = strtol(argv[3], &end, 0);
++            if (*end || len < 1 || len > 2) {
 +                fprintf(stderr, "Unsupported sample format: %s\n", argv[3]);
 +                return 1;
 +            }
 +        }
 +    }
 +
 +    if (argc < 3) {
 +        printf("tiny_psnr <file1> <file2> [<elem size> [<shift> [<skip bytes> [<shift search range>]]]]\n");
 +        printf("WAV headers are skipped automatically.\n");
 +        return 1;
 +    }
 +
 +    f[0] = fopen(argv[1], "rb");
 +    f[1] = fopen(argv[2], "rb");
 +    if (!f[0] || !f[1]) {
 +        fprintf(stderr, "Could not open input files.\n");
 +        return 1;
 +    }
 +
 +    for (shift = shift_first; shift <= shift_last; shift++) {
 +        int psnr = run_psnr(f, len, shift, skip_bytes);
 +        if (psnr > max_psnr || (shift < 0 && psnr == max_psnr)) {
 +            max_psnr = psnr;
 +            max_psnr_shift = shift;
 +        }
 +    }
 +    if (shift_last > shift_first)
 +        printf("Best PSNR is %3d.%02d for shift %i\n", (int)(max_psnr / F), (int)(max_psnr % F), max_psnr_shift);
      return 0;
  }