46 #define VPX_CODEC_DISABLE_COMPAT 1
51 #include "./tools_common.h"
52 #include "./video_reader.h"
53 #include "./vpx_config.h"
55 static const char *exec_name;
58 fprintf(stderr,
"Usage: %s <infile> <outfile>\n", exec_name);
62 int main(
int argc,
char **argv) {
67 VpxVideoReader *reader = NULL;
68 const VpxInterface *decoder = NULL;
69 const VpxVideoInfo *info = NULL;
74 die(
"Invalid number of arguments.");
76 reader = vpx_video_reader_open(argv[1]);
78 die(
"Failed to open %s for reading.", argv[1]);
80 if (!(outfile = fopen(argv[2],
"wb")))
81 die(
"Failed to open %s for writing", argv[2]);
83 info = vpx_video_reader_get_info(reader);
85 decoder = get_vpx_decoder_by_fourcc(info->codec_fourcc);
87 die(
"Unknown input codec.");
94 die_codec(&codec,
"Postproc not supported by this decoder.");
97 die_codec(&codec,
"Failed to initialize decoder.");
99 while (vpx_video_reader_read_frame(reader)) {
102 size_t frame_size = 0;
103 const unsigned char *frame = vpx_video_reader_get_frame(reader,
108 if (frame_cnt % 30 == 1) {
112 die_codec(&codec,
"Failed to turn off postproc.");
113 }
else if (frame_cnt % 30 == 16) {
117 die_codec(&codec,
"Failed to turn on postproc.");
122 die_codec(&codec,
"Failed to decode frame");
125 vpx_img_write(img, outfile);
129 printf(
"Processed %d frames.\n", frame_cnt);
131 die_codec(&codec,
"Failed to destroy codec");
133 printf(
"Play: ffplay -f rawvideo -pix_fmt yuv420p -s %dx%d %s\n",
134 info->frame_width, info->frame_height, argv[2]);
136 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.
#define VPX_CODEC_USE_POSTPROC
Definition: vpx_decoder.h:77
vpx_codec_err_t
Algorithm return codes.
Definition: vpx_codec.h:89
#define vpx_codec_control(ctx, id, data)
vpx_codec_control wrapper macro
Definition: vpx_codec.h:405
vpx_codec_err_t vpx_codec_destroy(vpx_codec_ctx_t *ctx)
Destroy a codec instance.
post process flags
Definition: vp8.h:85
Algorithm does not have required capability.
Definition: vpx_codec.h:103
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