36 #define VPX_CODEC_DISABLE_COMPAT 1
41 #include "./md5_utils.h"
42 #include "./tools_common.h"
43 #include "./video_reader.h"
44 #include "./vpx_config.h"
46 static void get_image_md5(
const vpx_image_t *img,
unsigned char digest[16]) {
52 for (plane = 0; plane < 3; ++plane) {
53 const unsigned char *buf = img->
planes[plane];
54 const int stride = img->
stride[plane];
55 const int w = plane ? (img->
d_w + 1) >> 1 : img->
d_w;
56 const int h = plane ? (img->
d_h + 1) >> 1 : img->
d_h;
58 for (y = 0; y < h; ++y) {
59 MD5Update(&md5, buf, w);
64 MD5Final(digest, &md5);
67 static void print_md5(FILE *stream,
unsigned char digest[16]) {
70 for (i = 0; i < 16; ++i)
71 fprintf(stream,
"%02x", digest[i]);
74 static const char *exec_name;
77 fprintf(stderr,
"Usage: %s <infile> <outfile>\n", exec_name);
81 int main(
int argc,
char **argv) {
85 VpxVideoReader *reader = NULL;
86 const VpxVideoInfo *info = NULL;
87 const VpxInterface *decoder = NULL;
92 die(
"Invalid number of arguments.");
94 reader = vpx_video_reader_open(argv[1]);
96 die(
"Failed to open %s for reading.", argv[1]);
98 if (!(outfile = fopen(argv[2],
"wb")))
99 die(
"Failed to open %s for writing.", argv[2]);
101 info = vpx_video_reader_get_info(reader);
103 decoder = get_vpx_decoder_by_fourcc(info->codec_fourcc);
105 die(
"Unknown input codec.");
110 die_codec(&codec,
"Failed to initialize decoder");
112 while (vpx_video_reader_read_frame(reader)) {
115 size_t frame_size = 0;
116 const unsigned char *frame = vpx_video_reader_get_frame(reader,
119 die_codec(&codec,
"Failed to decode frame");
122 unsigned char digest[16];
124 get_image_md5(img, digest);
125 print_md5(outfile, digest);
126 fprintf(outfile,
" img-%dx%d-%04d.i420\n",
127 img->
d_w, img->
d_h, ++frame_cnt);
131 printf(
"Processed %d frames.\n", frame_cnt);
133 die_codec(&codec,
"Failed to destroy codec.");
135 vpx_video_reader_close(reader);
Image Descriptor.
Definition: vpx_image.h:102
Describes the decoder algorithm interface to applications.
const char * vpx_codec_iface_name(vpx_codec_iface_t *iface)
Return the name for a given interface.
Provides definitions for using the VP8 algorithm within the vpx Decoder interface.
unsigned int d_w
Definition: vpx_image.h:111
#define vpx_codec_dec_init(ctx, iface, cfg, flags)
Convenience macro for vpx_codec_dec_init_ver()
Definition: vpx_decoder.h:154
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.
int stride[4]
Definition: vpx_image.h:132
unsigned char * planes[4]
Definition: vpx_image.h:131
vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx)
Destroy a codec instance.
unsigned int d_h
Definition: vpx_image.h:112
const void * vpx_codec_iter_t
Iterator.
Definition: vpx_codec.h:188
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:199