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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56#include <stdio.h>
57#include <stdlib.h>
58#include <string.h>
59
62#include "common/tools_common.h"
63#include "common/video_reader.h"
64
65static const char *exec_name;
66
67void usage_exit(void) {
68 fprintf(stderr, "Usage: %s <infile> <outfile> <N-M|N/M>\n", exec_name);
69 exit(EXIT_FAILURE);
70}
71
72int main(int argc, char **argv) {
73 int frame_cnt = 0;
74 FILE *outfile = NULL;
75 AvxVideoReader *reader = NULL;
76 const AvxVideoInfo *info = NULL;
77 int n = 0;
78 int m = 0;
79 int is_range = 0;
80 char *nptr = NULL;
81
82 exec_name = argv[0];
83
84 if (argc != 4) die("Invalid number of arguments.");
85
86 reader = aom_video_reader_open(argv[1]);
87 if (!reader) die("Failed to open %s for reading.", argv[1]);
88
89 if (!(outfile = fopen(argv[2], "wb")))
90 die("Failed to open %s for writing.", argv[2]);
91
92 n = (int)strtol(argv[3], &nptr, 0);
93 m = (int)strtol(nptr + 1, NULL, 0);
94 is_range = (*nptr == '-');
95 if (!n || !m || (*nptr != '-' && *nptr != '/'))
96 die("Couldn't parse pattern %s.\n", argv[3]);
97
98 info = aom_video_reader_get_info(reader);
99
101 if (!decoder) die("Unknown input codec.");
102
106 die("Failed to initialize decoder.");
107
108 while (aom_video_reader_read_frame(reader)) {
111 size_t frame_size = 0;
112 int skip;
113 const unsigned char *frame =
114 aom_video_reader_get_frame(reader, &frame_size);
115 ++frame_cnt;
116
117 skip = (is_range && frame_cnt >= n && frame_cnt <= m) ||
118 (!is_range && m - (frame_cnt - 1) % m <= n);
119
120 if (!skip) {
121 putc('.', stdout);
123 die_codec(&codec, "Failed to decode frame.");
124
126 aom_img_write(img, outfile);
127 } else {
128 putc('X', stdout);
129 }
130
131 fflush(stdout);
132 }
133
134 printf("Processed %d frames.\n", frame_cnt);
136
137 printf("Play: ffplay -f rawvideo -pix_fmt yuv420p -s %dx%d %s\n",
138 info->frame_width, info->frame_height, argv[2]);
139
140 aom_video_reader_close(reader);
141 fclose(outfile);
142
143 return EXIT_SUCCESS;
144}
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