39 #include "../md5_utils.h"
40 #include "../tools_common.h"
41 #include "../video_reader.h"
42 #include "./vpx_config.h"
44 static 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);
65 static void print_md5(FILE *stream,
unsigned char digest[16]) {
68 for (i = 0; i < 16; ++i)
69 fprintf(stream,
"%02x", digest[i]);
72 static const char *exec_name;
74 void usage_exit(
void) {
75 fprintf(stderr,
"Usage: %s <infile> <outfile>\n", exec_name);
79 int main(
int argc,
char **argv) {
83 VpxVideoReader *reader = NULL;
84 const VpxVideoInfo *info = NULL;
85 const VpxInterface *decoder = NULL;
90 die(
"Invalid number of arguments.");
92 reader = vpx_video_reader_open(argv[1]);
94 die(
"Failed to open %s for reading.", argv[1]);
96 if (!(outfile = fopen(argv[2],
"wb")))
97 die(
"Failed to open %s for writing.", argv[2]);
99 info = vpx_video_reader_get_info(reader);
101 decoder = get_vpx_decoder_by_fourcc(info->codec_fourcc);
103 die(
"Unknown input codec.");
108 die_codec(&codec,
"Failed to initialize decoder");
110 while (vpx_video_reader_read_frame(reader)) {
113 size_t frame_size = 0;
114 const unsigned char *frame = vpx_video_reader_get_frame(reader,
117 die_codec(&codec,
"Failed to decode frame");
120 unsigned char digest[16];
122 get_image_md5(img, digest);
123 print_md5(outfile, digest);
124 fprintf(outfile,
" img-%dx%d-%04d.i420\n",
125 img->
d_w, img->
d_h, ++frame_cnt);
129 printf(
"Processed %d frames.\n", frame_cnt);
131 die_codec(&codec,
"Failed to destroy codec.");
133 vpx_video_reader_close(reader);
Image Descriptor.
Definition: vpx_image.h:82
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 VP8 or VP9 within the vpx Decoder interface.
unsigned int d_w
Definition: vpx_image.h:92
#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:106
unsigned char * planes[4]
Definition: vpx_image.h:105
vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx)
Destroy a codec instance.
unsigned int d_h
Definition: vpx_image.h:93
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