18 #include "../tools_common.h" 19 #include "../vp9/encoder/vp9_resize.h" 21 static const char *exec_name = NULL;
25 printf(
"%s <input_yuv> <width>x<height> <target_width>x<target_height> ",
27 printf(
"<output_yuv> [<frames>]\n");
30 void usage_exit(
void) {
35 static int parse_dim(
char *v,
int *width,
int *height) {
36 char *x = strchr(v,
'x');
42 *height = atoi(&x[1]);
43 if (*width <= 0 || *height <= 0)
49 int main(
int argc,
char *argv[]) {
52 uint8_t *inbuf, *outbuf;
53 uint8_t *inbuf_u, *outbuf_u;
54 uint8_t *inbuf_v, *outbuf_v;
56 int width, height, target_width, target_height;
61 printf(
"Incorrect parameters:\n");
68 if (!parse_dim(argv[2], &width, &height)) {
69 printf(
"Incorrect parameters: %s\n", argv[2]);
73 if (!parse_dim(argv[3], &target_width, &target_height)) {
74 printf(
"Incorrect parameters: %s\n", argv[3]);
79 fpin = fopen(fin,
"rb");
81 printf(
"Can't open file %s to read\n", fin);
85 fpout = fopen(fout,
"wb");
87 printf(
"Can't open file %s to write\n", fout);
92 frames = atoi(argv[5]);
96 printf(
"Input size: %dx%d\n",
98 printf(
"Target size: %dx%d, Frames: ",
99 target_width, target_height);
100 if (frames == INT_MAX)
103 printf(
"%d\n", frames);
105 inbuf = (uint8_t*)malloc(width * height * 3 / 2);
106 outbuf = (uint8_t*)malloc(target_width * target_height * 3 / 2);
107 inbuf_u = inbuf + width * height;
108 inbuf_v = inbuf_u + width * height / 4;
109 outbuf_u = outbuf + target_width * target_height;
110 outbuf_v = outbuf_u + target_width * target_height / 4;
113 if (fread(inbuf, width * height * 3 / 2, 1, fpin) != 1)
115 vp9_resize_frame420(inbuf, width, inbuf_u, inbuf_v, width / 2,
117 outbuf, target_width, outbuf_u, outbuf_v,
119 target_height, target_width);
120 fwrite(outbuf, target_width * target_height * 3 / 2, 1, fpout);
123 printf(
"%d frames processed\n", f);