18#include "../tools_common.h" 
   19#include "../vp9/encoder/vp9_resize.h" 
   21static const char *exec_name = NULL;
 
   25  printf(
"%s <input_yuv> <width>x<height> <target_width>x<target_height> ",
 
   27  printf(
"<output_yuv> [<frames>]\n");
 
   30void usage_exit(
void) {
 
   35static int parse_dim(
char *v, 
int *width, 
int *height) {
 
   36  char *x = strchr(v, 
'x');
 
   37  if (x == NULL) x = strchr(v, 
'X');
 
   38  if (x == NULL) 
return 0;
 
   40  *height = atoi(&x[1]);
 
   41  if (*width <= 0 || *height <= 0)
 
   47int main(
int argc, 
char *argv[]) {
 
   50  uint8_t *inbuf, *outbuf;
 
   51  uint8_t *inbuf_u, *outbuf_u;
 
   52  uint8_t *inbuf_v, *outbuf_v;
 
   54  int width, height, target_width, target_height;
 
   59    printf(
"Incorrect parameters:\n");
 
   66  if (!parse_dim(argv[2], &width, &height)) {
 
   67    printf(
"Incorrect parameters: %s\n", argv[2]);
 
   71  if (!parse_dim(argv[3], &target_width, &target_height)) {
 
   72    printf(
"Incorrect parameters: %s\n", argv[3]);
 
   77  fpin = fopen(fin, 
"rb");
 
   79    printf(
"Can't open file %s to read\n", fin);
 
   83  fpout = fopen(fout, 
"wb");
 
   85    printf(
"Can't open file %s to write\n", fout);
 
   90    frames = atoi(argv[5]);
 
   94  printf(
"Input size:  %dx%d\n", width, height);
 
   95  printf(
"Target size: %dx%d, Frames: ", target_width, target_height);
 
   96  if (frames == INT_MAX)
 
   99    printf(
"%d\n", frames);
 
  101  inbuf = (uint8_t *)malloc(width * height * 3 / 2);
 
  102  outbuf = (uint8_t *)malloc(target_width * target_height * 3 / 2);
 
  103  inbuf_u = inbuf + width * height;
 
  104  inbuf_v = inbuf_u + width * height / 4;
 
  105  outbuf_u = outbuf + target_width * target_height;
 
  106  outbuf_v = outbuf_u + target_width * target_height / 4;
 
  109    if (fread(inbuf, width * height * 3 / 2, 1, fpin) != 1) 
break;
 
  110    vp9_resize_frame420(inbuf, width, inbuf_u, inbuf_v, width / 2, height,
 
  111                        width, outbuf, target_width, outbuf_u, outbuf_v,
 
  112                        target_width / 2, target_height, target_width);
 
  113    fwrite(outbuf, target_width * target_height * 3 / 2, 1, fpout);
 
  116  printf(
"%d frames processed\n", f);