62 #include "common/tools_common.h"
63 #include "common/video_reader.h"
65 static const char *exec_name;
67 void usage_exit(
void) {
68 fprintf(stderr,
"Usage: %s <infile> <outfile> <N-M|N/M>\n", exec_name);
72 int main(
int argc,
char **argv) {
76 const AvxInterface *decoder = NULL;
77 AvxVideoReader *reader = NULL;
78 const AvxVideoInfo *info = NULL;
86 if (argc != 4) die(
"Invalid number of arguments.");
88 reader = aom_video_reader_open(argv[1]);
89 if (!reader) die(
"Failed to open %s for reading.", argv[1]);
91 if (!(outfile = fopen(argv[2],
"wb")))
92 die(
"Failed to open %s for writing.", argv[2]);
94 n = (int)strtol(argv[3], &nptr, 0);
95 m = (int)strtol(nptr + 1, NULL, 0);
96 is_range = (*nptr ==
'-');
97 if (!n || !m || (*nptr !=
'-' && *nptr !=
'/'))
98 die(
"Couldn't parse pattern %s.\n", argv[3]);
100 info = aom_video_reader_get_info(reader);
102 decoder = get_aom_decoder_by_fourcc(info->codec_fourcc);
103 if (!decoder) die(
"Unknown input codec.");
108 die_codec(&codec,
"Failed to initialize decoder.");
110 while (aom_video_reader_read_frame(reader)) {
113 size_t frame_size = 0;
115 const unsigned char *frame =
116 aom_video_reader_get_frame(reader, &frame_size);
119 skip = (is_range && frame_cnt >= n && frame_cnt <= m) ||
120 (!is_range && m - (frame_cnt - 1) % m <= n);
125 die_codec(&codec,
"Failed to decode frame.");
128 aom_img_write(img, outfile);
136 printf(
"Processed %d frames.\n", frame_cnt);
139 printf(
"Play: ffplay -f rawvideo -pix_fmt yuv420p -s %dx%d %s\n",
140 info->frame_width, info->frame_height, argv[2]);
142 aom_video_reader_close(reader);
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
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.