1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

tiny_psnr: support unseekable raw files.

If either one of the files if not seekable,
do not try to read headers.

It allows to use it with pipes on whole rawvideo data.
This commit is contained in:
Nicolas George 2012-04-15 14:20:42 +02:00
parent 93927eb334
commit e6f7e22d18

View File

@ -114,10 +114,13 @@ static int run_psnr(FILE *f[2], int len, int shift, int skip_bytes)
int size0 = 0; int size0 = 0;
int size1 = 0; int size1 = 0;
int maxdist = 0; int maxdist = 0;
int noseek;
rewind(f[0]); noseek = fseek(f[0], 0, SEEK_SET) ||
rewind(f[1]); fseek(f[1], 0, SEEK_SET);
if (!noseek) {
/* TODO reindent */
for (i = 0; i < 2; i++) { for (i = 0; i < 2; i++) {
uint8_t *p = buf[i]; uint8_t *p = buf[i];
if (fread(p, 1, 12, f[i]) != 12) if (fread(p, 1, 12, f[i]) != 12)
@ -141,6 +144,7 @@ static int run_psnr(FILE *f[2], int len, int shift, int skip_bytes)
fseek(f[0], skip_bytes, SEEK_CUR); fseek(f[0], skip_bytes, SEEK_CUR);
fseek(f[1], skip_bytes, SEEK_CUR); fseek(f[1], skip_bytes, SEEK_CUR);
}
for (;;) { for (;;) {
int s0 = fread(buf[0], 1, SIZE, f[0]); int s0 = fread(buf[0], 1, SIZE, f[0]);