1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42#include <stdio.h>
43#include <stdlib.h>
44#include <string.h>
45
48
49#include "../tools_common.h"
50#include "../video_reader.h"
51#include "./vpx_config.h"
52
53static const char *exec_name;
54
55void usage_exit(void) {
56 fprintf(stderr, "Usage: %s <infile> <outfile>\n", exec_name);
57 exit(EXIT_FAILURE);
58}
59
60int main(int argc, char **argv) {
61 int frame_cnt = 0;
62 FILE *outfile = NULL;
65 VpxVideoReader *reader = NULL;
66 const VpxInterface *decoder = NULL;
67 const VpxVideoInfo *info = NULL;
68
69 exec_name = argv[0];
70
71 if (argc != 3) die("Invalid number of arguments.");
72
73 reader = vpx_video_reader_open(argv[1]);
74 if (!reader) die("Failed to open %s for reading.", argv[1]);
75
76 if (!(outfile = fopen(argv[2], "wb")))
77 die("Failed to open %s for writing", argv[2]);
78
79 info = vpx_video_reader_get_info(reader);
80
81 decoder = get_vpx_decoder_by_fourcc(info->codec_fourcc);
82 if (!decoder) die("Unknown input codec.");
83
85
89 die("Postproc not supported by this decoder.");
90
91 if (res) die("Failed to initialize decoder.");
92
93 while (vpx_video_reader_read_frame(reader)) {
96 size_t frame_size = 0;
97 const unsigned char *frame =
98 vpx_video_reader_get_frame(reader, &frame_size);
99
100 ++frame_cnt;
101
102 if (frame_cnt % 30 == 1) {
104
106 die_codec(&codec, "Failed to turn off postproc.");
107 } else if (frame_cnt % 30 == 16) {
109 0 };
111 die_codec(&codec, "Failed to turn on postproc.");
112 }
113
114
116 die_codec(&codec, "Failed to decode frame");
117
119 vpx_img_write(img, outfile);
120 }
121 }
122
123 printf("Processed %d frames.\n", frame_cnt);
125
126 printf("Play: ffplay -f rawvideo -pix_fmt yuv420p -s %dx%d %s\n",
127 info->frame_width, info->frame_height, argv[2]);
128
129 vpx_video_reader_close(reader);
130
131 fclose(outfile);
132 return EXIT_SUCCESS;
133}
struct vpx_codec_ctx vpx_codec_ctx_t
Codec context structure.
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:190
const char * vpx_codec_iface_name(vpx_codec_iface_t *iface)
Return the name for a given interface.
#define vpx_codec_control(ctx, id, data)
vpx_codec_control wrapper macro
Definition vpx_codec.h:408
vpx_codec_err_t
Algorithm return codes.
Definition vpx_codec.h:93
@ VPX_CODEC_INCAPABLE
Algorithm does not have required capability.
Definition vpx_codec.h:107
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
Initialization-time Feature Enabling.
Definition vpx_decoder.h:73
#define vpx_codec_dec_init(ctx, iface, cfg, flags)
Convenience macro for vpx_codec_dec_init_ver()
Definition vpx_decoder.h:143
vpx_image_t * vpx_codec_get_frame(vpx_codec_ctx_t *ctx, vpx_codec_iter_t *iter)
Decoded frames iterator.
struct vp8_postproc_cfg vp8_postproc_cfg_t
post process flags
@ VP8_SET_POSTPROC
Definition vp8.h:49
Provides definitions for using VP8 or VP9 within the vpx Decoder interface.
Describes the decoder algorithm interface to applications.
struct vpx_image vpx_image_t
Image Descriptor.