18 #include "../vp9/encoder/vp9_resize.h"
20 static const char *exec_name = NULL;
24 printf(
"%s <input_yuv> <width>x<height> <target_width>x<target_height> ",
26 printf(
"<output_yuv> [<frames>]\n");
34 static int parse_dim(
char *v,
int *width,
int *height) {
35 char *x = strchr(v,
'x');
41 *height = atoi(&x[1]);
42 if (*width <= 0 || *height <= 0)
48 int main(
int argc,
char *argv[]) {
51 uint8_t *inbuf, *outbuf;
52 uint8_t *inbuf_u, *outbuf_u;
53 uint8_t *inbuf_v, *outbuf_v;
55 int width, height, target_width, target_height;
60 printf(
"Incorrect parameters:\n");
67 if (!parse_dim(argv[2], &width, &height)) {
68 printf(
"Incorrect parameters: %s\n", argv[2]);
72 if (!parse_dim(argv[3], &target_width, &target_height)) {
73 printf(
"Incorrect parameters: %s\n", argv[3]);
78 fpin = fopen(fin,
"rb");
80 printf(
"Can't open file %s to read\n", fin);
84 fpout = fopen(fout,
"wb");
86 printf(
"Can't open file %s to write\n", fout);
91 frames = atoi(argv[5]);
95 printf(
"Input size: %dx%d\n",
97 printf(
"Target size: %dx%d, Frames: ",
98 target_width, target_height);
99 if (frames == INT_MAX)
102 printf(
"%d\n", frames);
104 inbuf = (uint8_t*)malloc(width * height * 3 / 2);
105 outbuf = (uint8_t*)malloc(target_width * target_height * 3 / 2);
106 inbuf_u = inbuf + width * height;
107 inbuf_v = inbuf_u + width * height / 4;
108 outbuf_u = outbuf + target_width * target_height;
109 outbuf_v = outbuf_u + target_width * target_height / 4;
112 if (fread(inbuf, width * height * 3 / 2, 1, fpin) != 1)
114 vp9_resize_frame420(inbuf, width, inbuf_u, inbuf_v, width / 2,
116 outbuf, target_width, outbuf_u, outbuf_v,
118 target_height, target_width);
119 fwrite(outbuf, target_width * target_height * 3 / 2, 1, fpout);
122 printf(
"%d frames processed\n", f);