39#include "../md5_utils.h" 
   40#include "../tools_common.h" 
   41#include "../video_reader.h" 
   42#include "./vpx_config.h" 
   44static void get_image_md5(
const vpx_image_t *img, 
unsigned char digest[16]) {
 
   50  for (plane = 0; plane < 3; ++plane) {
 
   51    const unsigned char *buf = img->
planes[plane];
 
   52    const int stride = img->
stride[plane];
 
   53    const int w = plane ? (img->
d_w + 1) >> 1 : img->d_w;
 
   54    const int h = plane ? (img->
d_h + 1) >> 1 : img->d_h;
 
   56    for (y = 0; y < h; ++y) {
 
   57      MD5Update(&md5, buf, w);
 
   62  MD5Final(digest, &md5);
 
   65static void print_md5(FILE *stream, 
unsigned char digest[16]) {
 
   68  for (i = 0; i < 16; ++i) fprintf(stream, 
"%02x", digest[i]);
 
   71static const char *exec_name;
 
   73void usage_exit(
void) {
 
   74  fprintf(stderr, 
"Usage: %s <infile> <outfile>\n", exec_name);
 
   78int main(
int argc, 
char **argv) {
 
   82  VpxVideoReader *reader = NULL;
 
   83  const VpxVideoInfo *info = NULL;
 
   84  const VpxInterface *decoder = NULL;
 
   88  if (argc != 3) die(
"Invalid number of arguments.");
 
   90  reader = vpx_video_reader_open(argv[1]);
 
   91  if (!reader) die(
"Failed to open %s for reading.", argv[1]);
 
   93  if (!(outfile = fopen(argv[2], 
"wb")))
 
   94    die(
"Failed to open %s for writing.", argv[2]);
 
   96  info = vpx_video_reader_get_info(reader);
 
   98  decoder = get_vpx_decoder_by_fourcc(info->codec_fourcc);
 
   99  if (!decoder) die(
"Unknown input codec.");
 
  104    die_codec(&codec, 
"Failed to initialize decoder");
 
  106  while (vpx_video_reader_read_frame(reader)) {
 
  109    size_t frame_size = 0;
 
  110    const unsigned char *frame =
 
  111        vpx_video_reader_get_frame(reader, &frame_size);
 
  113      die_codec(&codec, 
"Failed to decode frame");
 
  116      unsigned char digest[16];
 
  118      get_image_md5(img, digest);
 
  119      print_md5(outfile, digest);
 
  120      fprintf(outfile, 
"  img-%dx%d-%04d.i420\n", img->
d_w, img->
d_h,
 
  125  printf(
"Processed %d frames.\n", frame_cnt);
 
  128  vpx_video_reader_close(reader);
 
vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx)
Destroy a codec instance.
const void * vpx_codec_iter_t
Iterator.
Definition vpx_codec.h:190
const char * vpx_codec_iface_name(vpx_codec_iface_t *iface)
Return the name for a given interface.
vpx_codec_err_t vpx_codec_decode(vpx_codec_ctx_t *ctx, const uint8_t *data, unsigned int data_sz, void *user_priv, long deadline)
Decode data.
#define vpx_codec_dec_init(ctx, iface, cfg, flags)
Convenience macro for vpx_codec_dec_init_ver()
Definition vpx_decoder.h:143
vpx_image_t * vpx_codec_get_frame(vpx_codec_ctx_t *ctx, vpx_codec_iter_t *iter)
Decoded frames iterator.
Codec context structure.
Definition vpx_codec.h:200
Image Descriptor.
Definition vpx_image.h:72
unsigned int d_h
Definition vpx_image.h:84
unsigned int d_w
Definition vpx_image.h:83
unsigned char * planes[4]
Definition vpx_image.h:100
int stride[4]
Definition vpx_image.h:101
Provides definitions for using VP8 or VP9 within the vpx Decoder interface.
Describes the decoder algorithm interface to applications.