18 main(
int argc,
char **argv)
29 fprintf(stderr,
"%s [YUV file 1] [YUV file 2] width height pixelcmp|blockdump (# to skip)\n", argv[0]);
33 width = atoi(argv[3]);
34 height = atoi(argv[4]);
36 to_skip = atoi(argv[6]);
41 int csiz = width * height / 4;
43 int cwidth = width / 2;
52 print_pixels = strstr(argv[5],
"pixelcmp") ? 1 : 0;
53 dump_blocks = strstr(argv[5],
"blockdump") ? 1 : 0;
55 for(i = 0; i < 2; i++) {
57 C[0][
i] = malloc(csiz);
58 C[1][
i] = malloc(csiz);
60 fd[
i] = open(argv[1 + i], O_RDONLY);
65 fcntl(fd[i], F_NOCACHE, 1);
68 lseek(fd[i], to_skip * (lsiz + 2*csiz), SEEK_SET);
74 mberrors = malloc(mb_x * mb_y);
77 memset(mberrors, 0, mb_x * mb_y);
79 printf(
"Loading frame %d\n", ++fr);
81 for(i = 0; i < 2; i++) {
82 v = read(fd[i], Y[i], lsiz);
84 fprintf(stderr,
"Unable to read Y from file %d, exiting\n", i + 1);
90 for(c = 0; c < lsiz; c++) {
91 if(Y[0][c] != Y[1][c]) {
95 mb = x / 16 + (y / 16) * mb_x;
98 printf(
"Luma diff 0x%02x != 0x%02x at pixel (%4d,%-4d) mb(%d,%d) #%d\n",
112 for(p = 0; p < 2; p++) {
114 for(i = 0; i < 2; i++) {
115 v = read(fd[i], C[p][i], csiz);
117 fprintf(stderr,
"Unable to read %c from file %d, exiting\n",
123 for(c = 0; c < csiz; c++) {
124 if(C[p][0][c] != C[p][1][c]) {
128 mb = x / 8 + (y / 8) * mb_x;
130 mberrors[
mb] |= 2 << p;
134 printf(
"c%c diff 0x%02x != 0x%02x at pixel (%4d,%-4d) " 135 "mb(%3d,%-3d) #%d\n",
143 x / 8 + y / 8 * cwidth / 8);
148 for(i = 0; i < mb_x * mb_y; i++) {
155 printf(
"MB (%3d,%-3d) %4d %d %c%c%c damaged\n",
156 x, y, i, mberrors[i],
157 mberrors[i] & 1 ?
'Y' :
' ',
158 mberrors[i] & 2 ?
'U' :
' ',
159 mberrors[i] & 4 ?
'V' :
' ');
162 a = Y[0] + x * 16 + y * 16 *
width;
163 b = Y[1] + x * 16 + y * 16 *
width;
165 for(y = 0; y < 16; y++) {
167 for(x = 0; x < 16; x++)
168 printf(
"%02x%c", a[x + y * width],
169 a[x + y * width] != b[x + y * width] ?
'<' :
' ');
172 for(x = 0; x < 16; x++)
173 printf(
"%02x%c", b[x + y * width],
174 a[x + y * width] != b[x + y * width] ?
'<' :
' ');
The reader does not expect b to be semantically here and if the code is changed by maybe adding a a division or other the signedness will almost certainly be mistaken To avoid this confusion a new type was SUINT is the C unsigned type but it holds a signed int to use the same example SUINT a
Undefined Behavior In the C some operations are like signed integer dereferencing freed accessing outside allocated Undefined Behavior must not occur in a C it is not safe even if the output of undefined operations is unused The unsafety may seem nit picking but Optimizing compilers have in fact optimized code on the assumption that no undefined Behavior occurs Optimizing code based on wrong assumptions can and has in some cases lead to effects beyond the output of computations The signed integer overflow problem in speed critical code Code which is highly optimized and works with signed integers sometimes has the problem that often the output of the computation does not c
s EdgeDetect Foobar g libavfilter vf_edgedetect c libavfilter vf_foobar c edit libavfilter and add an entry for foobar following the pattern of the other filters edit libavfilter allfilters and add an entry for foobar following the pattern of the other filters configure make j< whatever > ffmpeg ffmpeg i you should get a foobar png with Lena edge detected That s your new playground is ready Some little details about what s going which in turn will define variables for the build system and the C
int main(int argc, char **argv)
printf("static const uint8_t my_array[100] = {\n")