Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: source/libvpx/examples/resize_util.c

Issue 958693004: libvpx: Pull from upstream (Closed) Base URL: https://chromium.googlesource.com/chromium/deps/libvpx.git@master
Patch Set: Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « source/libvpx/examples/postproc.c ('k') | source/libvpx/examples/set_maps.c » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved. 2 * Copyright (c) 2014 The WebM project authors. All Rights Reserved.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license 4 * Use of this source code is governed by a BSD-style license
5 * that can be found in the LICENSE file in the root of the source 5 * that can be found in the LICENSE file in the root of the source
6 * tree. An additional intellectual property rights grant can be found 6 * tree. An additional intellectual property rights grant can be found
7 * in the file PATENTS. All contributing project authors may 7 * in the file PATENTS. All contributing project authors may
8 * be found in the AUTHORS file in the root of the source tree. 8 * be found in the AUTHORS file in the root of the source tree.
9 */ 9 */
10 10
11 #include <assert.h> 11 #include <assert.h>
12 #include <limits.h> 12 #include <limits.h>
13 #include <math.h> 13 #include <math.h>
14 #include <stdio.h> 14 #include <stdio.h>
15 #include <stdlib.h> 15 #include <stdlib.h>
16 #include <string.h> 16 #include <string.h>
17 17
18 #include "./vp9/encoder/vp9_resize.h" 18 #include "../vp9/encoder/vp9_resize.h"
19 19
20 static void usage(char *progname) { 20 static const char *exec_name = NULL;
21
22 static void usage() {
21 printf("Usage:\n"); 23 printf("Usage:\n");
22 printf("%s <input_yuv> <width>x<height> <target_width>x<target_height> ", 24 printf("%s <input_yuv> <width>x<height> <target_width>x<target_height> ",
23 progname); 25 exec_name);
24 printf("<output_yuv> [<frames>]\n"); 26 printf("<output_yuv> [<frames>]\n");
25 } 27 }
26 28
29 void usage_exit() {
30 usage();
31 exit(EXIT_FAILURE);
32 }
33
27 static int parse_dim(char *v, int *width, int *height) { 34 static int parse_dim(char *v, int *width, int *height) {
28 char *x = strchr(v, 'x'); 35 char *x = strchr(v, 'x');
29 if (x == NULL) 36 if (x == NULL)
30 x = strchr(v, 'X'); 37 x = strchr(v, 'X');
31 if (x == NULL) 38 if (x == NULL)
32 return 0; 39 return 0;
33 *width = atoi(v); 40 *width = atoi(v);
34 *height = atoi(&x[1]); 41 *height = atoi(&x[1]);
35 if (*width <= 0 || *height <= 0) 42 if (*width <= 0 || *height <= 0)
36 return 0; 43 return 0;
37 else 44 else
38 return 1; 45 return 1;
39 } 46 }
40 47
41 int main(int argc, char *argv[]) { 48 int main(int argc, char *argv[]) {
42 char *fin, *fout; 49 char *fin, *fout;
43 FILE *fpin, *fpout; 50 FILE *fpin, *fpout;
44 uint8_t *inbuf, *outbuf; 51 uint8_t *inbuf, *outbuf;
45 uint8_t *inbuf_u, *outbuf_u; 52 uint8_t *inbuf_u, *outbuf_u;
46 uint8_t *inbuf_v, *outbuf_v; 53 uint8_t *inbuf_v, *outbuf_v;
47 int f, frames; 54 int f, frames;
48 int width, height, target_width, target_height; 55 int width, height, target_width, target_height;
49 56
57 exec_name = argv[0];
58
50 if (argc < 5) { 59 if (argc < 5) {
51 printf("Incorrect parameters:\n"); 60 printf("Incorrect parameters:\n");
52 usage(argv[0]); 61 usage();
53 return 1; 62 return 1;
54 } 63 }
55 64
56 fin = argv[1]; 65 fin = argv[1];
57 fout = argv[4]; 66 fout = argv[4];
58 if (!parse_dim(argv[2], &width, &height)) { 67 if (!parse_dim(argv[2], &width, &height)) {
59 printf("Incorrect parameters: %s\n", argv[2]); 68 printf("Incorrect parameters: %s\n", argv[2]);
60 usage(argv[0]); 69 usage();
61 return 1; 70 return 1;
62 } 71 }
63 if (!parse_dim(argv[3], &target_width, &target_height)) { 72 if (!parse_dim(argv[3], &target_width, &target_height)) {
64 printf("Incorrect parameters: %s\n", argv[3]); 73 printf("Incorrect parameters: %s\n", argv[3]);
65 usage(argv[0]); 74 usage();
66 return 1; 75 return 1;
67 } 76 }
68 77
69 fpin = fopen(fin, "rb"); 78 fpin = fopen(fin, "rb");
70 if (fpin == NULL) { 79 if (fpin == NULL) {
71 printf("Can't open file %s to read\n", fin); 80 printf("Can't open file %s to read\n", fin);
72 usage(argv[0]); 81 usage();
73 return 1; 82 return 1;
74 } 83 }
75 fpout = fopen(fout, "wb"); 84 fpout = fopen(fout, "wb");
76 if (fpout == NULL) { 85 if (fpout == NULL) {
77 printf("Can't open file %s to write\n", fout); 86 printf("Can't open file %s to write\n", fout);
78 usage(argv[0]); 87 usage();
79 return 1; 88 return 1;
80 } 89 }
81 if (argc >= 6) 90 if (argc >= 6)
82 frames = atoi(argv[5]); 91 frames = atoi(argv[5]);
83 else 92 else
84 frames = INT_MAX; 93 frames = INT_MAX;
85 94
86 printf("Input size: %dx%d\n", 95 printf("Input size: %dx%d\n",
87 width, height); 96 width, height);
88 printf("Target size: %dx%d, Frames: ", 97 printf("Target size: %dx%d, Frames: ",
(...skipping 22 matching lines...) Expand all
111 f++; 120 f++;
112 } 121 }
113 printf("%d frames processed\n", f); 122 printf("%d frames processed\n", f);
114 fclose(fpin); 123 fclose(fpin);
115 fclose(fpout); 124 fclose(fpout);
116 125
117 free(inbuf); 126 free(inbuf);
118 free(outbuf); 127 free(outbuf);
119 return 0; 128 return 0;
120 } 129 }
OLDNEW
« no previous file with comments | « source/libvpx/examples/postproc.c ('k') | source/libvpx/examples/set_maps.c » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698