1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33#include <stdio.h>
34#include <stdlib.h>
35#include <string.h>
36
39#include "common/md5_utils.h"
40#include "common/tools_common.h"
41#include "common/video_reader.h"
42
43static void get_image_md5(
const aom_image_t *img,
unsigned char digest[16]) {
44 int plane, y;
45 MD5Context md5;
46
47 MD5Init(&md5);
48
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;
54
55 for (y = 0; y < h; ++y) {
56 MD5Update(&md5, buf, w);
57 buf += stride;
58 }
59 }
60
61 MD5Final(digest, &md5);
62}
63
64static void print_md5(FILE *stream, unsigned char digest[16]) {
65 int i;
66
67 for (i = 0; i < 16; ++i) fprintf(stream, "%02x", digest[i]);
68}
69
70static const char *exec_name;
71
72void usage_exit(void) {
73 fprintf(stderr, "Usage: %s <infile> <outfile>\n", exec_name);
74 exit(EXIT_FAILURE);
75}
76
77int main(int argc, char **argv) {
78 int frame_cnt = 0;
79 FILE *outfile = NULL;
80 AvxVideoReader *reader = NULL;
81 const AvxVideoInfo *info = NULL;
82
83 exec_name = argv[0];
84
85 if (argc != 3) die("Invalid number of arguments.");
86
87 reader = aom_video_reader_open(argv[1]);
88 if (!reader) die("Failed to open %s for reading.", argv[1]);
89
90 if (!(outfile = fopen(argv[2], "wb")))
91 die("Failed to open %s for writing.", argv[2]);
92
93 info = aom_video_reader_get_info(reader);
94
96 if (!decoder) die("Unknown input codec.");
97
99
102 die("Failed to initialize decoder");
103
104 while (aom_video_reader_read_frame(reader)) {
107 size_t frame_size = 0;
108 const unsigned char *frame =
109 aom_video_reader_get_frame(reader, &frame_size);
111 die_codec(&codec, "Failed to decode frame");
112
114 unsigned char digest[16];
115
116 get_image_md5(img, digest);
117 print_md5(outfile, digest);
118 fprintf(outfile,
" img-%ux%u-%04d.i420\n", img->
d_w, img->
d_h,
119 ++frame_cnt);
120 }
121 }
122
123 printf("Processed %d frames.\n", frame_cnt);
125
126 aom_video_reader_close(reader);
127
128 fclose(outfile);
129 return EXIT_SUCCESS;
130}
Describes the decoder algorithm interface to applications.
struct aom_image aom_image_t
Image Descriptor.
Provides definitions for using AOM or AV1 within the aom Decoder interface.
const char * aom_codec_iface_name(aom_codec_iface_t *iface)
Return the name for a given interface.
struct aom_codec_ctx aom_codec_ctx_t
Codec context structure.
const struct aom_codec_iface aom_codec_iface_t
Codec interface structure.
Definition aom_codec.h:254
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:288
aom_image_t * aom_codec_get_frame(aom_codec_ctx_t *ctx, aom_codec_iter_t *iter)
Decoded frames iterator.
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:129
int stride[3]
Definition aom_image.h:214
unsigned int d_w
Definition aom_image.h:195
unsigned int d_h
Definition aom_image.h:196
unsigned char * planes[3]
Definition aom_image.h:213