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