59 #define VPX_CODEC_DISABLE_COMPAT 1
64 #include "./tools_common.h"
65 #include "./video_reader.h"
66 #include "./vpx_config.h"
68 static const char *exec_name;
71 fprintf(stderr,
"Usage: %s <infile> <outfile> <N-M|N/M>\n", exec_name);
75 int main(
int argc,
char **argv) {
79 const VpxInterface *decoder = NULL;
80 VpxVideoReader *reader = NULL;
81 const VpxVideoInfo *info = NULL;
90 die(
"Invalid number of arguments.");
92 reader = vpx_video_reader_open(argv[1]);
94 die(
"Failed to open %s for reading.", argv[1]);
96 if (!(outfile = fopen(argv[2],
"wb")))
97 die(
"Failed to open %s for writing.", argv[2]);
99 n = strtol(argv[3], &nptr, 0);
100 m = strtol(nptr + 1, NULL, 0);
101 is_range = (*nptr ==
'-');
102 if (!n || !m || (*nptr !=
'-' && *nptr !=
'/'))
103 die(
"Couldn't parse pattern %s.\n", argv[3]);
105 info = vpx_video_reader_get_info(reader);
107 decoder = get_vpx_decoder_by_fourcc(info->codec_fourcc);
109 die(
"Unknown input codec.");
114 die_codec(&codec,
"Failed to initialize decoder.");
116 while (vpx_video_reader_read_frame(reader)) {
119 size_t frame_size = 0;
121 const unsigned char *frame = vpx_video_reader_get_frame(reader,
124 die_codec(&codec,
"Failed to decode frame.");
128 skip = (is_range && frame_cnt >= n && frame_cnt <= m) ||
129 (!is_range && m - (frame_cnt - 1) % m <= n);
135 vpx_img_write(img, outfile);
143 printf(
"Processed %d frames.\n", frame_cnt);
145 die_codec(&codec,
"Failed to destroy codec.");
147 printf(
"Play: ffplay -f rawvideo -pix_fmt yuv420p -s %dx%d %s\n",
148 info->frame_width, info->frame_height, argv[2]);
150 vpx_video_reader_close(reader);
Image Descriptor.
Definition: vpx_image.h:102
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 the VP8 algorithm 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:154
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:188
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:199