62#include "common/tools_common.h"
63#include "common/video_reader.h"
65static const char *exec_name;
67void usage_exit(
void) {
68 fprintf(stderr,
"Usage: %s <infile> <outfile> <N-M|N/M>\n", exec_name);
72int main(
int argc,
char **argv) {
75 AvxVideoReader *reader = NULL;
76 const AvxVideoInfo *info = NULL;
84 if (argc != 4) die(
"Invalid number of arguments.");
86 reader = aom_video_reader_open(argv[1]);
87 if (!reader) die(
"Failed to open %s for reading.", argv[1]);
89 if (!(outfile = fopen(argv[2],
"wb")))
90 die(
"Failed to open %s for writing.", argv[2]);
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]);
98 info = aom_video_reader_get_info(reader);
101 if (!decoder) die(
"Unknown input codec.");
106 die(
"Failed to initialize decoder.");
108 while (aom_video_reader_read_frame(reader)) {
111 size_t frame_size = 0;
113 const unsigned char *frame =
114 aom_video_reader_get_frame(reader, &frame_size);
117 skip = (is_range && frame_cnt >= n && frame_cnt <= m) ||
118 (!is_range && m - (frame_cnt - 1) % m <= n);
123 die_codec(&codec,
"Failed to decode frame.");
126 aom_img_write(img, outfile);
134 printf(
"Processed %d frames.\n", frame_cnt);
137 printf(
"Play: ffplay -f rawvideo -pix_fmt yuv420p -s %dx%d %s\n",
138 info->frame_width, info->frame_height, argv[2]);
140 aom_video_reader_close(reader);
Describes the decoder algorithm interface to applications.
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.
const struct aom_codec_iface aom_codec_iface_t
Codec interface structure.
Definition aom_codec.h:271
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:305
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
Codec context structure.
Definition aom_codec.h:315
Image Descriptor.
Definition aom_image.h:182