shithub: libvpx

ref: 3225b893e80627aa95e924ec789468db6c38f82c
dir: /examples/decode_to_md5.txt/

View raw version
@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