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) fprintf(stream,
"%02x", digest[i]);
71 static const char *exec_name;
73 void usage_exit(
void) {
74 fprintf(stderr,
"Usage: %s <infile> <outfile>\n", exec_name);
78 int 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);
Image Descriptor.
Definition: vpx_image.h:88
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:99
#define vpx_codec_dec_init(ctx, iface, cfg, flags)
Convenience macro for vpx_codec_dec_init_ver()
Definition: vpx_decoder.h:144
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:117
unsigned char * planes[4]
Definition: vpx_image.h:116
vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx)
Destroy a codec instance.
unsigned int d_h
Definition: vpx_image.h:100
const void * vpx_codec_iter_t
Iterator.
Definition: vpx_codec.h:187
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:197