decode_to_md5.txt 1.77 KB
Newer Older
John Koleszar's avatar
John Koleszar committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
@TEMPLATE decoder_tmpl.c
Frame-by-frame MD5 Checksum
===========================
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INTRODUCTION
This example builds upon the simple decoder loop to show how checksums
of the decoded output can be generated. These are used for validating
decoder implementations against the reference implementation, for example.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ INTRODUCTION

MD5 algorithm
-------------
The Message-Digest 5 (MD5) is a well known hash function. We have provided
an implementation derived from the RSA Data Security, Inc. MD5 Message-Digest
Algorithm for your use. Our implmentation only changes the interface of this
reference code. You must include the `md5_utils.h` header for access to these
functions.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ EXTRA_INCLUDES
#include "md5_utils.h"
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ EXTRA_INCLUDES


Processing The Decoded Data
---------------------------
Each row of the image is passed to the MD5 accumulator. First the Y plane
is processed, then U, then V. It is important to honor the image's `stride`
values.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PROCESS_DX
unsigned char  md5_sum[16];
md5_ctx_t      md5;
int            i;

md5_init(&md5);

for(plane=0; plane < 3; plane++) {
    unsigned char *buf =img->planes[plane];

    for(y=0; y<img->d_h >> (plane?1:0); y++) {
        md5_update(&md5, buf, img->d_w >> (plane?1:0));
        buf += img->stride[plane];
    }
}

md5_finalize(&md5, md5_sum);
for(i=0; i<16; i++)
    fprintf(outfile, "%02x",md5_sum[i]);
fprintf(outfile, "  img-%dx%d-%04d.i420\n", img->d_w, img->d_h,
        frame_cnt);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ PROCESS_DX