62 #include "../tools_common.h" 63 #include "../video_reader.h" 64 #include "./vpx_config.h" 66 static const char *exec_name;
68 void usage_exit(
void) {
69 fprintf(stderr,
"Usage: %s <infile> <outfile> <N-M|N/M>\n", exec_name);
73 int main(
int argc,
char **argv) {
77 const VpxInterface *decoder = NULL;
78 VpxVideoReader *reader = NULL;
79 const VpxVideoInfo *info = NULL;
87 if (argc != 4) die(
"Invalid number of arguments.");
89 reader = vpx_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 n = (int)strtol(argv[3], &nptr, 0);
96 m = (int)strtol(nptr + 1, NULL, 0);
97 is_range = (*nptr ==
'-');
98 if (!n || !m || (*nptr !=
'-' && *nptr !=
'/'))
99 die(
"Couldn't parse pattern %s.\n", argv[3]);
101 info = vpx_video_reader_get_info(reader);
103 decoder = get_vpx_decoder_by_fourcc(info->codec_fourcc);
104 if (!decoder) die(
"Unknown input codec.");
109 die_codec(&codec,
"Failed to initialize decoder.");
111 while (vpx_video_reader_read_frame(reader)) {
114 size_t frame_size = 0;
116 const unsigned char *frame =
117 vpx_video_reader_get_frame(reader, &frame_size);
119 die_codec(&codec,
"Failed to decode frame.");
123 skip = (is_range && frame_cnt >= n && frame_cnt <= m) ||
124 (!is_range && m - (frame_cnt - 1) % m <= n);
130 vpx_img_write(img, outfile);
138 printf(
"Processed %d frames.\n", frame_cnt);
141 printf(
"Play: ffplay -f rawvideo -pix_fmt yuv420p -s %dx%d %s\n",
142 info->frame_width, info->frame_height, argv[2]);
144 vpx_video_reader_close(reader);
Image Descriptor.
Definition: vpx_image.h:88
Describes the decoder algorithm interface to applications.
const char * vpx_codec_iface_name(vpx_codec_iface_t *iface)
Return the name for a given interface.
Provides definitions for using VP8 or VP9 within the vpx Decoder interface.
#define vpx_codec_dec_init(ctx, iface, cfg, flags)
Convenience macro for vpx_codec_dec_init_ver()
Definition: vpx_decoder.h:144
vpx_codec_err_t vpx_codec_decode(vpx_codec_ctx_t *ctx, const uint8_t *data, unsigned int data_sz, void *user_priv, long deadline)
Decode data.
vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx)
Destroy a codec instance.
const void * vpx_codec_iter_t
Iterator.
Definition: vpx_codec.h:187
vpx_image_t * vpx_codec_get_frame(vpx_codec_ctx_t *ctx, vpx_codec_iter_t *iter)
Decoded frames iterator.
Codec context structure.
Definition: vpx_codec.h:197