Home | History | Annotate | Download | only in yuv420sp2rgb
      1 #include <debug.h>
      2 #include <stdio.h>
      3 #include <ctype.h>
      4 
      5 #define NUM_COLS  (32)
      6 
      7 int dump_hex_buffer(FILE *s, void *b, size_t len, size_t elsize) {
      8     int num_nonprintable = 0;
      9     int i, last;
     10     char *pchr = (char *)b;
     11     fputc('\n', s);
     12     fprintf(s, "%p: ", b);
     13     for (i = last = 0; i < len; i++) {
     14         if (!elsize) {
     15             if (i && !(i % 4)) fprintf(s, " ");
     16             if (i && !(i % 8)) fprintf(s, " ");
     17         } else {
     18             if (i && !(i % elsize)) fprintf(s, " ");
     19         }
     20 
     21         if (i && !(i % NUM_COLS)) {
     22             while (last < i) {
     23                 if (isprint(pchr[last]))
     24                     fputc(pchr[last], s);
     25                 else {
     26                     fputc('.', s);
     27                     num_nonprintable++;
     28                 }
     29                 last++;
     30             }
     31             fprintf(s, " (%d)\n%p: ", i, b);
     32         }
     33         fprintf(s, "%02x", (unsigned char)pchr[i]);
     34     }
     35     if (i && (i % NUM_COLS)) fputs("\n", s);
     36     return num_nonprintable;
     37 }
     38 
     39