diff options
| author | Tim Redfern <tim@eclectronics.org> | 2013-09-05 17:55:35 +0100 |
|---|---|---|
| committer | Tim Redfern <tim@eclectronics.org> | 2013-09-05 17:55:35 +0100 |
| commit | 741fb4b9e135cfb161a749db88713229038577bb (patch) | |
| tree | 08bc9925659cbcac45162bacf31dc6336d4f60b4 /ffmpeg1/tools/yuvcmp.c | |
| parent | a2e1bf3495b7bfefdaedb8fc737e969ab06df079 (diff) | |
making act segmenter
Diffstat (limited to 'ffmpeg1/tools/yuvcmp.c')
| -rw-r--r-- | ffmpeg1/tools/yuvcmp.c | 182 |
1 files changed, 0 insertions, 182 deletions
diff --git a/ffmpeg1/tools/yuvcmp.c b/ffmpeg1/tools/yuvcmp.c deleted file mode 100644 index 11585f9..0000000 --- a/ffmpeg1/tools/yuvcmp.c +++ /dev/null @@ -1,182 +0,0 @@ -/* - * originally by Andreas Ă–man (andoma) - * some changes by Alexander Strange - */ - -#include <string.h> -#include <stdlib.h> -#include <inttypes.h> -#include <stdio.h> -#include <sys/stat.h> -#include <fcntl.h> -#include <unistd.h> - - -int -main(int argc, char **argv) -{ - int fd[2]; - int print_pixels = 0; - int dump_blocks = 0; - - int width; - int height; - int to_skip = 0; - - if (argc < 6) { - fprintf(stderr, "%s [YUV file 1] [YUV file 2] width height pixelcmp|blockdump (# to skip)\n", argv[0]); - return 1; - } - - width = atoi(argv[3]); - height = atoi(argv[4]); - if (argc > 6) - to_skip = atoi(argv[6]); - - uint8_t *Y[2], *C[2][2]; - int i, v, c, p; - int lsiz = width * height; - int csiz = width * height / 4; - int x, y; - int cwidth = width / 2; - int fr = to_skip; - int mb; - char *mberrors; - int mb_x, mb_y; - uint8_t *a; - uint8_t *b; - int die = 0; - - print_pixels = strstr(argv[5], "pixelcmp") ? 1 : 0; - dump_blocks = strstr(argv[5], "blockdump") ? 1 : 0; - - for(i = 0; i < 2; i++) { - Y[i] = malloc(lsiz); - C[0][i] = malloc(csiz); - C[1][i] = malloc(csiz); - - fd[i] = open(argv[1 + i], O_RDONLY); - if(fd[i] == -1) { - perror("open"); - exit(1); - } - fcntl(fd[i], F_NOCACHE, 1); - - if (to_skip) - lseek(fd[i], to_skip * (lsiz + 2*csiz), SEEK_SET); - } - - mb_x = width / 16; - mb_y = height / 16; - - mberrors = malloc(mb_x * mb_y); - - while(!die) { - memset(mberrors, 0, mb_x * mb_y); - - printf("Loading frame %d\n", ++fr); - - for(i = 0; i < 2; i++) { - v = read(fd[i], Y[i], lsiz); - if(v != lsiz) { - fprintf(stderr, "Unable to read Y from file %d, exiting\n", i + 1); - return 1; - } - } - - - for(c = 0; c < lsiz; c++) { - if(Y[0][c] != Y[1][c]) { - x = c % width; - y = c / width; - - mb = x / 16 + (y / 16) * mb_x; - - if(print_pixels) - printf("Luma diff 0x%02x != 0x%02x at pixel (%4d,%-4d) mb(%d,%d) #%d\n", - Y[0][c], - Y[1][c], - x, y, - x / 16, - y / 16, - mb); - - mberrors[mb] |= 1; - } - } - - /* Chroma planes */ - - for(p = 0; p < 2; p++) { - - for(i = 0; i < 2; i++) { - v = read(fd[i], C[p][i], csiz); - if(v != csiz) { - fprintf(stderr, "Unable to read %c from file %d, exiting\n", - "UV"[p], i + 1); - return 1; - } - } - - for(c = 0; c < csiz; c++) { - if(C[p][0][c] != C[p][1][c]) { - x = c % cwidth; - y = c / cwidth; - - mb = x / 8 + (y / 8) * mb_x; - - mberrors[mb] |= 2 << p; - - if(print_pixels) - - printf("c%c diff 0x%02x != 0x%02x at pixel (%4d,%-4d) " - "mb(%3d,%-3d) #%d\n", - p ? 'r' : 'b', - C[p][0][c], - C[p][1][c], - - x, y, - x / 8, - y / 8, - x / 8 + y / 8 * cwidth / 8); - } - } - } - - for(i = 0; i < mb_x * mb_y; i++) { - x = i % mb_x; - y = i / mb_x; - - if(mberrors[i]) { - die = 1; - - printf("MB (%3d,%-3d) %4d %d %c%c%c damaged\n", - x, y, i, mberrors[i], - mberrors[i] & 1 ? 'Y' : ' ', - mberrors[i] & 2 ? 'U' : ' ', - mberrors[i] & 4 ? 'V' : ' '); - - if(dump_blocks) { - a = Y[0] + x * 16 + y * 16 * width; - b = Y[1] + x * 16 + y * 16 * width; - - for(y = 0; y < 16; y++) { - printf("%c ", "TB"[y&1]); - for(x = 0; x < 16; x++) - printf("%02x%c", a[x + y * width], - a[x + y * width] != b[x + y * width] ? '<' : ' '); - - printf("| "); - for(x = 0; x < 16; x++) - printf("%02x%c", b[x + y * width], - a[x + y * width] != b[x + y * width] ? '<' : ' '); - - printf("\n"); - } - } - } - } - } - - return 0; -} |
