39 #include "common/md5_utils.h" 40 #include "common/tools_common.h" 41 #include "common/video_reader.h" 43 static void get_image_md5(
const aom_image_t *img,
unsigned char digest[16]) {
49 for (plane = 0; plane < 3; ++plane) {
50 const unsigned char *buf = img->
planes[plane];
51 const int stride = img->
stride[plane];
52 const int w = plane ? (img->
d_w + 1) >> 1 : img->
d_w;
53 const int h = plane ? (img->
d_h + 1) >> 1 : img->
d_h;
55 for (y = 0; y < h; ++y) {
56 MD5Update(&md5, buf, w);
61 MD5Final(digest, &md5);
64 static void print_md5(FILE *stream,
unsigned char digest[16]) {
67 for (i = 0; i < 16; ++i) fprintf(stream,
"%02x", digest[i]);
70 static const char *exec_name;
72 void usage_exit(
void) {
73 fprintf(stderr,
"Usage: %s <infile> <outfile>\n", exec_name);
77 int main(
int argc,
char **argv) {
81 AvxVideoReader *reader = NULL;
82 const AvxVideoInfo *info = NULL;
83 const AvxInterface *decoder = NULL;
87 if (argc != 3) die(
"Invalid number of arguments.");
89 reader = aom_video_reader_open(argv[1]);
90 if (!reader) die(
"Failed to open %s for reading.", argv[1]);
92 if (!(outfile = fopen(argv[2],
"wb")))
93 die(
"Failed to open %s for writing.", argv[2]);
95 info = aom_video_reader_get_info(reader);
97 decoder = get_aom_decoder_by_fourcc(info->codec_fourcc);
98 if (!decoder) die(
"Unknown input codec.");
103 die_codec(&codec,
"Failed to initialize decoder");
105 while (aom_video_reader_read_frame(reader)) {
108 size_t frame_size = 0;
109 const unsigned char *frame =
110 aom_video_reader_get_frame(reader, &frame_size);
112 die_codec(&codec,
"Failed to decode frame");
115 unsigned char digest[16];
117 get_image_md5(img, digest);
118 print_md5(outfile, digest);
119 fprintf(outfile,
" img-%dx%d-%04d.i420\n", img->
d_w, img->
d_h,
124 printf(
"Processed %d frames.\n", frame_cnt);
127 aom_video_reader_close(reader);
unsigned int d_h
Definition: aom_image.h:157
aom_image_t * aom_codec_get_frame(aom_codec_ctx_t *ctx, aom_codec_iter_t *iter)
Decoded frames iterator.
Codec context structure.
Definition: aom_codec.h:204
int stride[4]
Definition: aom_image.h:174
Describes the decoder algorithm interface to applications.
Image Descriptor.
Definition: aom_image.h:141
aom_codec_err_t aom_codec_decode(aom_codec_ctx_t *ctx, const uint8_t *data, size_t data_sz, void *user_priv)
Decode data.
#define aom_codec_dec_init(ctx, iface, cfg, flags)
Convenience macro for aom_codec_dec_init_ver()
Definition: aom_decoder.h:142
const char * aom_codec_iface_name(aom_codec_iface_t *iface)
Return the name for a given interface.
aom_codec_err_t aom_codec_destroy(aom_codec_ctx_t *ctx)
Destroy a codec instance.
const void * aom_codec_iter_t
Iterator.
Definition: aom_codec.h:194
Provides definitions for using AOM or AV1 within the aom Decoder interface.
unsigned char * planes[4]
Definition: aom_image.h:173
unsigned int d_w
Definition: aom_image.h:156