Home | History | Annotate | Download | only in examples
      1 @TEMPLATE decoder_tmpl.c
      2 Frame-by-frame MD5 Checksum
      3 ===========================
      4 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INTRODUCTION
      5 This example builds upon the simple decoder loop to show how checksums
      6 of the decoded output can be generated. These are used for validating
      7 decoder implementations against the reference implementation, for example.
      8 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INTRODUCTION
      9 
     10 MD5 algorithm
     11 -------------
     12 The Message-Digest 5 (MD5) is a well known hash function. We have provided
     13 an implementation derived from the RSA Data Security, Inc. MD5 Message-Digest
     14 Algorithm for your use. Our implmentation only changes the interface of this
     15 reference code. You must include the `md5_utils.h` header for access to these
     16 functions.
     17 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ EXTRA_INCLUDES
     18 #include "md5_utils.h"
     19 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ EXTRA_INCLUDES
     20 
     21 
     22 Processing The Decoded Data
     23 ---------------------------
     24 Each row of the image is passed to the MD5 accumulator. First the Y plane
     25 is processed, then U, then V. It is important to honor the image's `stride`
     26 values.
     27 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PROCESS_DX
     28 unsigned char  md5_sum[16];
     29 MD5Context     md5;
     30 int            i;
     31 
     32 MD5Init(&md5);
     33 
     34 for(plane=0; plane < 3; plane++) {
     35     unsigned char *buf =img->planes[plane];
     36 
     37     for(y=0; y<img->d_h >> (plane?1:0); y++) {
     38         MD5Update(&md5, buf, img->d_w >> (plane?1:0));
     39         buf += img->stride[plane];
     40     }
     41 }
     42 
     43 MD5Final(md5_sum, &md5);
     44 for(i=0; i<16; i++)
     45     fprintf(outfile, "%02x",md5_sum[i]);
     46 fprintf(outfile, "  img-%dx%d-%04d.i420\n", img->d_w, img->d_h,
     47         frame_cnt);
     48 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PROCESS_DX
     49