OLD | NEW |
1 /* | 1 /* |
2 * Copyright (c) 2010 The WebM project authors. All Rights Reserved. | 2 * Copyright (c) 2010 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 |
(...skipping 110 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
121 return 0; | 121 return 0; |
122 } | 122 } |
123 | 123 |
124 int fourcc_is_ivf(const char detect[4]) { | 124 int fourcc_is_ivf(const char detect[4]) { |
125 if (memcmp(detect, "DKIF", 4) == 0) { | 125 if (memcmp(detect, "DKIF", 4) == 0) { |
126 return 1; | 126 return 1; |
127 } | 127 } |
128 return 0; | 128 return 0; |
129 } | 129 } |
130 | 130 |
131 static const arg_def_t debugmode = ARG_DEF("D", "debug", 0, | 131 static const arg_def_t debugmode = ARG_DEF( |
132 "Debug mode (makes output determinist
ic)"); | 132 "D", "debug", 0, "Debug mode (makes output deterministic)"); |
133 static const arg_def_t outputfile = ARG_DEF("o", "output", 1, | 133 static const arg_def_t outputfile = ARG_DEF( |
134 "Output filename"); | 134 "o", "output", 1, "Output filename"); |
135 static const arg_def_t use_yv12 = ARG_DEF(NULL, "yv12", 0, | 135 static const arg_def_t use_yv12 = ARG_DEF( |
136 "Input file is YV12 "); | 136 NULL, "yv12", 0, "Input file is YV12 "); |
137 static const arg_def_t use_i420 = ARG_DEF(NULL, "i420", 0, | 137 static const arg_def_t use_i420 = ARG_DEF( |
138 "Input file is I420 (default)"); | 138 NULL, "i420", 0, "Input file is I420 (default)"); |
139 static const arg_def_t use_i422 = ARG_DEF(NULL, "i422", 0, | 139 static const arg_def_t use_i422 = ARG_DEF( |
140 "Input file is I422"); | 140 NULL, "i422", 0, "Input file is I422"); |
141 static const arg_def_t use_i444 = ARG_DEF(NULL, "i444", 0, | 141 static const arg_def_t use_i444 = ARG_DEF( |
142 "Input file is I444"); | 142 NULL, "i444", 0, "Input file is I444"); |
143 static const arg_def_t codecarg = ARG_DEF(NULL, "codec", 1, | 143 static const arg_def_t use_i440 = ARG_DEF( |
144 "Codec to use"); | 144 NULL, "i440", 0, "Input file is I440"); |
145 static const arg_def_t passes = ARG_DEF("p", "passes", 1, | 145 static const arg_def_t codecarg = ARG_DEF( |
146 "Number of passes (1/2)"); | 146 NULL, "codec", 1, "Codec to use"); |
147 static const arg_def_t pass_arg = ARG_DEF(NULL, "pass", 1, | 147 static const arg_def_t passes = ARG_DEF( |
148 "Pass to execute (1/2)"); | 148 "p", "passes", 1, "Number of passes (1/2)"); |
149 static const arg_def_t fpf_name = ARG_DEF(NULL, "fpf", 1, | 149 static const arg_def_t pass_arg = ARG_DEF( |
150 "First pass statistics file na
me"); | 150 NULL, "pass", 1, "Pass to execute (1/2)"); |
| 151 static const arg_def_t fpf_name = ARG_DEF( |
| 152 NULL, "fpf", 1, "First pass statistics file name"); |
151 #if CONFIG_FP_MB_STATS | 153 #if CONFIG_FP_MB_STATS |
152 static const arg_def_t fpmbf_name = ARG_DEF(NULL, "fpmbf", 1, | 154 static const arg_def_t fpmbf_name = ARG_DEF( |
153 "First pass block statistics file name"); | 155 NULL, "fpmbf", 1, "First pass block statistics file name"); |
154 #endif | 156 #endif |
155 static const arg_def_t limit = ARG_DEF(NULL, "limit", 1, | 157 static const arg_def_t limit = ARG_DEF( |
156 "Stop encoding after n input frames"); | 158 NULL, "limit", 1, "Stop encoding after n input frames"); |
157 static const arg_def_t skip = ARG_DEF(NULL, "skip", 1, | 159 static const arg_def_t skip = ARG_DEF( |
158 "Skip the first n input frames"); | 160 NULL, "skip", 1, "Skip the first n input frames"); |
159 static const arg_def_t deadline = ARG_DEF("d", "deadline", 1, | 161 static const arg_def_t deadline = ARG_DEF( |
160 "Deadline per frame (usec)"); | 162 "d", "deadline", 1, "Deadline per frame (usec)"); |
161 static const arg_def_t best_dl = ARG_DEF(NULL, "best", 0, | 163 static const arg_def_t best_dl = ARG_DEF( |
162 "Use Best Quality Deadline"); | 164 NULL, "best", 0, "Use Best Quality Deadline"); |
163 static const arg_def_t good_dl = ARG_DEF(NULL, "good", 0, | 165 static const arg_def_t good_dl = ARG_DEF( |
164 "Use Good Quality Deadline"); | 166 NULL, "good", 0, "Use Good Quality Deadline"); |
165 static const arg_def_t rt_dl = ARG_DEF(NULL, "rt", 0, | 167 static const arg_def_t rt_dl = ARG_DEF( |
166 "Use Realtime Quality Deadline
"); | 168 NULL, "rt", 0, "Use Realtime Quality Deadline"); |
167 static const arg_def_t quietarg = ARG_DEF("q", "quiet", 0, | 169 static const arg_def_t quietarg = ARG_DEF( |
168 "Do not print encode progress"
); | 170 "q", "quiet", 0, "Do not print encode progress"); |
169 static const arg_def_t verbosearg = ARG_DEF("v", "verbose", 0, | 171 static const arg_def_t verbosearg = ARG_DEF( |
170 "Show encoder parameters"); | 172 "v", "verbose", 0, "Show encoder parameters"); |
171 static const arg_def_t psnrarg = ARG_DEF(NULL, "psnr", 0, | 173 static const arg_def_t psnrarg = ARG_DEF( |
172 "Show PSNR in status line"); | 174 NULL, "psnr", 0, "Show PSNR in status line"); |
173 | 175 |
174 static const struct arg_enum_list test_decode_enum[] = { | 176 static const struct arg_enum_list test_decode_enum[] = { |
175 {"off", TEST_DECODE_OFF}, | 177 {"off", TEST_DECODE_OFF}, |
176 {"fatal", TEST_DECODE_FATAL}, | 178 {"fatal", TEST_DECODE_FATAL}, |
177 {"warn", TEST_DECODE_WARN}, | 179 {"warn", TEST_DECODE_WARN}, |
178 {NULL, 0} | 180 {NULL, 0} |
179 }; | 181 }; |
180 static const arg_def_t recontest = ARG_DEF_ENUM(NULL, "test-decode", 1, | 182 static const arg_def_t recontest = ARG_DEF_ENUM( |
181 "Test encode/decode mismatch", | 183 NULL, "test-decode", 1, "Test encode/decode mismatch", test_decode_enum); |
182 test_decode_enum); | 184 static const arg_def_t framerate = ARG_DEF( |
183 static const arg_def_t framerate = ARG_DEF(NULL, "fps", 1, | 185 NULL, "fps", 1, "Stream frame rate (rate/scale)"); |
184 "Stream frame rate (rate/scale
)"); | 186 static const arg_def_t use_ivf = ARG_DEF( |
185 static const arg_def_t use_ivf = ARG_DEF(NULL, "ivf", 0, | 187 NULL, "ivf", 0, "Output IVF (default is WebM if WebM IO is enabled)"); |
186 "Output IVF (default is WebM i
f WebM IO is enabled)"); | 188 static const arg_def_t out_part = ARG_DEF( |
187 static const arg_def_t out_part = ARG_DEF("P", "output-partitions", 0, | 189 "P", "output-partitions", 0, |
188 "Makes encoder output partitions. Requ
ires IVF output!"); | 190 "Makes encoder output partitions. Requires IVF output!"); |
189 static const arg_def_t q_hist_n = ARG_DEF(NULL, "q-hist", 1, | 191 static const arg_def_t q_hist_n = ARG_DEF( |
190 "Show quantizer histogram (n-b
uckets)"); | 192 NULL, "q-hist", 1, "Show quantizer histogram (n-buckets)"); |
191 static const arg_def_t rate_hist_n = ARG_DEF(NULL, "rate-hist", 1, | 193 static const arg_def_t rate_hist_n = ARG_DEF( |
192 "Show rate histogram (n-buc
kets)"); | 194 NULL, "rate-hist", 1, "Show rate histogram (n-buckets)"); |
193 static const arg_def_t disable_warnings = | 195 static const arg_def_t disable_warnings = ARG_DEF( |
194 ARG_DEF(NULL, "disable-warnings", 0, | 196 NULL, "disable-warnings", 0, |
195 "Disable warnings about potentially incorrect encode settings."); | 197 "Disable warnings about potentially incorrect encode settings."); |
196 static const arg_def_t disable_warning_prompt = | 198 static const arg_def_t disable_warning_prompt = ARG_DEF( |
197 ARG_DEF("y", "disable-warning-prompt", 0, | 199 "y", "disable-warning-prompt", 0, |
198 "Display warnings, but do not prompt user to continue."); | 200 "Display warnings, but do not prompt user to continue."); |
199 static const arg_def_t experimental_bitstream = | |
200 ARG_DEF(NULL, "experimental-bitstream", 0, | |
201 "Allow experimental bitstream features."); | |
202 | 201 |
203 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 202 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH |
204 static const arg_def_t test16bitinternalarg = ARG_DEF( | 203 static const arg_def_t test16bitinternalarg = ARG_DEF( |
205 NULL, "test-16bit-internal", 0, "Force use of 16 bit internal buffer"); | 204 NULL, "test-16bit-internal", 0, "Force use of 16 bit internal buffer"); |
206 #endif | 205 #endif |
207 | 206 |
208 static const arg_def_t *main_args[] = { | 207 static const arg_def_t *main_args[] = { |
209 &debugmode, | 208 &debugmode, |
210 &outputfile, &codecarg, &passes, &pass_arg, &fpf_name, &limit, &skip, | 209 &outputfile, &codecarg, &passes, &pass_arg, &fpf_name, &limit, &skip, |
211 &deadline, &best_dl, &good_dl, &rt_dl, | 210 &deadline, &best_dl, &good_dl, &rt_dl, |
212 &quietarg, &verbosearg, &psnrarg, &use_ivf, &out_part, &q_hist_n, | 211 &quietarg, &verbosearg, &psnrarg, &use_ivf, &out_part, &q_hist_n, |
213 &rate_hist_n, &disable_warnings, &disable_warning_prompt, | 212 &rate_hist_n, &disable_warnings, &disable_warning_prompt, |
214 NULL | 213 NULL |
215 }; | 214 }; |
216 | 215 |
217 static const arg_def_t usage = ARG_DEF("u", "usage", 1, | 216 static const arg_def_t usage = ARG_DEF( |
218 "Usage profile number to use")
; | 217 "u", "usage", 1, "Usage profile number to use"); |
219 static const arg_def_t threads = ARG_DEF("t", "threads", 1, | 218 static const arg_def_t threads = ARG_DEF( |
220 "Max number of threads to use"
); | 219 "t", "threads", 1, "Max number of threads to use"); |
221 static const arg_def_t profile = ARG_DEF(NULL, "profile", 1, | 220 static const arg_def_t profile = ARG_DEF( |
222 "Bitstream profile number to u
se"); | 221 NULL, "profile", 1, "Bitstream profile number to use"); |
223 static const arg_def_t width = ARG_DEF("w", "width", 1, | 222 static const arg_def_t width = ARG_DEF("w", "width", 1, "Frame width"); |
224 "Frame width"); | 223 static const arg_def_t height = ARG_DEF("h", "height", 1, "Frame height"); |
225 static const arg_def_t height = ARG_DEF("h", "height", 1, | |
226 "Frame height"); | |
227 #if CONFIG_WEBM_IO | 224 #if CONFIG_WEBM_IO |
228 static const struct arg_enum_list stereo_mode_enum[] = { | 225 static const struct arg_enum_list stereo_mode_enum[] = { |
229 {"mono", STEREO_FORMAT_MONO}, | 226 {"mono", STEREO_FORMAT_MONO}, |
230 {"left-right", STEREO_FORMAT_LEFT_RIGHT}, | 227 {"left-right", STEREO_FORMAT_LEFT_RIGHT}, |
231 {"bottom-top", STEREO_FORMAT_BOTTOM_TOP}, | 228 {"bottom-top", STEREO_FORMAT_BOTTOM_TOP}, |
232 {"top-bottom", STEREO_FORMAT_TOP_BOTTOM}, | 229 {"top-bottom", STEREO_FORMAT_TOP_BOTTOM}, |
233 {"right-left", STEREO_FORMAT_RIGHT_LEFT}, | 230 {"right-left", STEREO_FORMAT_RIGHT_LEFT}, |
234 {NULL, 0} | 231 {NULL, 0} |
235 }; | 232 }; |
236 static const arg_def_t stereo_mode = ARG_DEF_ENUM(NULL, "stereo-mode", 1, | 233 static const arg_def_t stereo_mode = ARG_DEF_ENUM( |
237 "Stereo 3D video format",
stereo_mode_enum); | 234 NULL, "stereo-mode", 1, "Stereo 3D video format", stereo_mode_enum); |
238 #endif | 235 #endif |
239 static const arg_def_t timebase = ARG_DEF(NULL, "timebase", 1, | 236 static const arg_def_t timebase = ARG_DEF( |
240 "Output timestamp precision (f
ractional seconds)"); | 237 NULL, "timebase", 1, "Output timestamp precision (fractional seconds)"); |
241 static const arg_def_t error_resilient = ARG_DEF(NULL, "error-resilient", 1, | 238 static const arg_def_t error_resilient = ARG_DEF( |
242 "Enable error resiliency featu
res"); | 239 NULL, "error-resilient", 1, "Enable error resiliency features"); |
243 static const arg_def_t lag_in_frames = ARG_DEF(NULL, "lag-in-frames", 1, | 240 static const arg_def_t lag_in_frames = ARG_DEF( |
244 "Max number of frames to lag")
; | 241 NULL, "lag-in-frames", 1, "Max number of frames to lag"); |
245 | 242 |
246 static const arg_def_t *global_args[] = { | 243 static const arg_def_t *global_args[] = { |
247 &use_yv12, &use_i420, &use_i422, &use_i444, | 244 &use_yv12, &use_i420, &use_i422, &use_i444, &use_i440, |
248 &usage, &threads, &profile, | 245 &usage, &threads, &profile, |
249 &width, &height, | 246 &width, &height, |
250 #if CONFIG_WEBM_IO | 247 #if CONFIG_WEBM_IO |
251 &stereo_mode, | 248 &stereo_mode, |
252 #endif | 249 #endif |
253 &timebase, &framerate, | 250 &timebase, &framerate, |
254 &error_resilient, | 251 &error_resilient, |
255 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 252 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH |
256 &test16bitinternalarg, | 253 &test16bitinternalarg, |
257 #endif | 254 #endif |
258 &lag_in_frames, NULL | 255 &lag_in_frames, NULL |
259 }; | 256 }; |
260 | 257 |
261 static const arg_def_t dropframe_thresh = ARG_DEF(NULL, "drop-frame", 1, | 258 static const arg_def_t dropframe_thresh = ARG_DEF( |
262 "Temporal resampling thresho
ld (buf %)"); | 259 NULL, "drop-frame", 1, "Temporal resampling threshold (buf %)"); |
263 static const arg_def_t resize_allowed = ARG_DEF(NULL, "resize-allowed", 1, | 260 static const arg_def_t resize_allowed = ARG_DEF( |
264 "Spatial resampling enabled
(bool)"); | 261 NULL, "resize-allowed", 1, "Spatial resampling enabled (bool)"); |
265 static const arg_def_t resize_width = ARG_DEF(NULL, "resize-width", 1, | 262 static const arg_def_t resize_width = ARG_DEF( |
266 "Width of encoded frame"); | 263 NULL, "resize-width", 1, "Width of encoded frame"); |
267 static const arg_def_t resize_height = ARG_DEF(NULL, "resize-height", 1, | 264 static const arg_def_t resize_height = ARG_DEF( |
268 "Height of encoded frame"); | 265 NULL, "resize-height", 1, "Height of encoded frame"); |
269 static const arg_def_t resize_up_thresh = ARG_DEF(NULL, "resize-up", 1, | 266 static const arg_def_t resize_up_thresh = ARG_DEF( |
270 "Upscale threshold (buf %)")
; | 267 NULL, "resize-up", 1, "Upscale threshold (buf %)"); |
271 static const arg_def_t resize_down_thresh = ARG_DEF(NULL, "resize-down", 1, | 268 static const arg_def_t resize_down_thresh = ARG_DEF( |
272 "Downscale threshold (buf %)
"); | 269 NULL, "resize-down", 1, "Downscale threshold (buf %)"); |
273 static const struct arg_enum_list end_usage_enum[] = { | 270 static const struct arg_enum_list end_usage_enum[] = { |
274 {"vbr", VPX_VBR}, | 271 {"vbr", VPX_VBR}, |
275 {"cbr", VPX_CBR}, | 272 {"cbr", VPX_CBR}, |
276 {"cq", VPX_CQ}, | 273 {"cq", VPX_CQ}, |
277 {"q", VPX_Q}, | 274 {"q", VPX_Q}, |
278 {NULL, 0} | 275 {NULL, 0} |
279 }; | 276 }; |
280 static const arg_def_t end_usage = ARG_DEF_ENUM(NULL, "end-usage", 1, | 277 static const arg_def_t end_usage = ARG_DEF_ENUM( |
281 "Rate control mode", en
d_usage_enum); | 278 NULL, "end-usage", 1, "Rate control mode", end_usage_enum); |
282 static const arg_def_t target_bitrate = ARG_DEF(NULL, "target-bitrate", 1, | 279 static const arg_def_t target_bitrate = ARG_DEF( |
283 "Bitrate (kbps)"); | 280 NULL, "target-bitrate", 1, "Bitrate (kbps)"); |
284 static const arg_def_t min_quantizer = ARG_DEF(NULL, "min-q", 1, | 281 static const arg_def_t min_quantizer = ARG_DEF( |
285 "Minimum (best) quantizer"); | 282 NULL, "min-q", 1, "Minimum (best) quantizer"); |
286 static const arg_def_t max_quantizer = ARG_DEF(NULL, "max-q", 1, | 283 static const arg_def_t max_quantizer = ARG_DEF( |
287 "Maximum (worst) quantizer")
; | 284 NULL, "max-q", 1, "Maximum (worst) quantizer"); |
288 static const arg_def_t undershoot_pct = ARG_DEF(NULL, "undershoot-pct", 1, | 285 static const arg_def_t undershoot_pct = ARG_DEF( |
289 "Datarate undershoot (min) t
arget (%)"); | 286 NULL, "undershoot-pct", 1, "Datarate undershoot (min) target (%)"); |
290 static const arg_def_t overshoot_pct = ARG_DEF(NULL, "overshoot-pct", 1, | 287 static const arg_def_t overshoot_pct = ARG_DEF( |
291 "Datarate overshoot (max) ta
rget (%)"); | 288 NULL, "overshoot-pct", 1, "Datarate overshoot (max) target (%)"); |
292 static const arg_def_t buf_sz = ARG_DEF(NULL, "buf-sz", 1, | 289 static const arg_def_t buf_sz = ARG_DEF( |
293 "Client buffer size (ms)"); | 290 NULL, "buf-sz", 1, "Client buffer size (ms)"); |
294 static const arg_def_t buf_initial_sz = ARG_DEF(NULL, "buf-initial-sz", 1, | 291 static const arg_def_t buf_initial_sz = ARG_DEF( |
295 "Client initial buffer size
(ms)"); | 292 NULL, "buf-initial-sz", 1, "Client initial buffer size (ms)"); |
296 static const arg_def_t buf_optimal_sz = ARG_DEF(NULL, "buf-optimal-sz", 1, | 293 static const arg_def_t buf_optimal_sz = ARG_DEF( |
297 "Client optimal buffer size
(ms)"); | 294 NULL, "buf-optimal-sz", 1, "Client optimal buffer size (ms)"); |
298 static const arg_def_t *rc_args[] = { | 295 static const arg_def_t *rc_args[] = { |
299 &dropframe_thresh, &resize_allowed, &resize_width, &resize_height, | 296 &dropframe_thresh, &resize_allowed, &resize_width, &resize_height, |
300 &resize_up_thresh, &resize_down_thresh, &end_usage, &target_bitrate, | 297 &resize_up_thresh, &resize_down_thresh, &end_usage, &target_bitrate, |
301 &min_quantizer, &max_quantizer, &undershoot_pct, &overshoot_pct, &buf_sz, | 298 &min_quantizer, &max_quantizer, &undershoot_pct, &overshoot_pct, &buf_sz, |
302 &buf_initial_sz, &buf_optimal_sz, NULL | 299 &buf_initial_sz, &buf_optimal_sz, NULL |
303 }; | 300 }; |
304 | 301 |
305 | 302 |
306 static const arg_def_t bias_pct = ARG_DEF(NULL, "bias-pct", 1, | 303 static const arg_def_t bias_pct = ARG_DEF( |
307 "CBR/VBR bias (0=CBR, 100=VBR)"); | 304 NULL, "bias-pct", 1, "CBR/VBR bias (0=CBR, 100=VBR)"); |
308 static const arg_def_t minsection_pct = ARG_DEF(NULL, "minsection-pct", 1, | 305 static const arg_def_t minsection_pct = ARG_DEF( |
309 "GOP min bitrate (% of target)")
; | 306 NULL, "minsection-pct", 1, "GOP min bitrate (% of target)"); |
310 static const arg_def_t maxsection_pct = ARG_DEF(NULL, "maxsection-pct", 1, | 307 static const arg_def_t maxsection_pct = ARG_DEF( |
311 "GOP max bitrate (% of target)")
; | 308 NULL, "maxsection-pct", 1, "GOP max bitrate (% of target)"); |
312 static const arg_def_t *rc_twopass_args[] = { | 309 static const arg_def_t *rc_twopass_args[] = { |
313 &bias_pct, &minsection_pct, &maxsection_pct, NULL | 310 &bias_pct, &minsection_pct, &maxsection_pct, NULL |
314 }; | 311 }; |
315 | 312 |
316 | 313 |
317 static const arg_def_t kf_min_dist = ARG_DEF(NULL, "kf-min-dist", 1, | 314 static const arg_def_t kf_min_dist = ARG_DEF( |
318 "Minimum keyframe interval (frames)
"); | 315 NULL, "kf-min-dist", 1, "Minimum keyframe interval (frames)"); |
319 static const arg_def_t kf_max_dist = ARG_DEF(NULL, "kf-max-dist", 1, | 316 static const arg_def_t kf_max_dist = ARG_DEF( |
320 "Maximum keyframe interval (frames)
"); | 317 NULL, "kf-max-dist", 1, "Maximum keyframe interval (frames)"); |
321 static const arg_def_t kf_disabled = ARG_DEF(NULL, "disable-kf", 0, | 318 static const arg_def_t kf_disabled = ARG_DEF( |
322 "Disable keyframe placement"); | 319 NULL, "disable-kf", 0, "Disable keyframe placement"); |
323 static const arg_def_t *kf_args[] = { | 320 static const arg_def_t *kf_args[] = { |
324 &kf_min_dist, &kf_max_dist, &kf_disabled, NULL | 321 &kf_min_dist, &kf_max_dist, &kf_disabled, NULL |
325 }; | 322 }; |
326 | 323 |
327 | 324 |
328 static const arg_def_t noise_sens = ARG_DEF(NULL, "noise-sensitivity", 1, | 325 static const arg_def_t noise_sens = ARG_DEF( |
329 "Noise sensitivity (frames to blur)"
); | 326 NULL, "noise-sensitivity", 1, "Noise sensitivity (frames to blur)"); |
330 static const arg_def_t sharpness = ARG_DEF(NULL, "sharpness", 1, | 327 static const arg_def_t sharpness = ARG_DEF( |
331 "Loop filter sharpness (0..7)"); | 328 NULL, "sharpness", 1, "Loop filter sharpness (0..7)"); |
332 static const arg_def_t static_thresh = ARG_DEF(NULL, "static-thresh", 1, | 329 static const arg_def_t static_thresh = ARG_DEF( |
333 "Motion detection threshold"); | 330 NULL, "static-thresh", 1, "Motion detection threshold"); |
334 static const arg_def_t cpu_used = ARG_DEF(NULL, "cpu-used", 1, | 331 static const arg_def_t cpu_used = ARG_DEF( |
335 "CPU Used (-16..16)"); | 332 NULL, "cpu-used", 1, "CPU Used (-16..16)"); |
336 static const arg_def_t auto_altref = ARG_DEF(NULL, "auto-alt-ref", 1, | 333 static const arg_def_t auto_altref = ARG_DEF( |
337 "Enable automatic alt reference fra
mes"); | 334 NULL, "auto-alt-ref", 1, "Enable automatic alt reference frames"); |
338 static const arg_def_t arnr_maxframes = ARG_DEF(NULL, "arnr-maxframes", 1, | 335 static const arg_def_t arnr_maxframes = ARG_DEF( |
339 "AltRef max frames (0..15)"); | 336 NULL, "arnr-maxframes", 1, "AltRef max frames (0..15)"); |
340 static const arg_def_t arnr_strength = ARG_DEF(NULL, "arnr-strength", 1, | 337 static const arg_def_t arnr_strength = ARG_DEF( |
341 "AltRef filter strength (0..6)"); | 338 NULL, "arnr-strength", 1, "AltRef filter strength (0..6)"); |
342 static const arg_def_t arnr_type = ARG_DEF(NULL, "arnr-type", 1, | 339 static const arg_def_t arnr_type = ARG_DEF( |
343 "AltRef type"); | 340 NULL, "arnr-type", 1, "AltRef type"); |
344 static const struct arg_enum_list tuning_enum[] = { | 341 static const struct arg_enum_list tuning_enum[] = { |
345 {"psnr", VP8_TUNE_PSNR}, | 342 {"psnr", VP8_TUNE_PSNR}, |
346 {"ssim", VP8_TUNE_SSIM}, | 343 {"ssim", VP8_TUNE_SSIM}, |
347 {NULL, 0} | 344 {NULL, 0} |
348 }; | 345 }; |
349 static const arg_def_t tune_ssim = ARG_DEF_ENUM(NULL, "tune", 1, | 346 static const arg_def_t tune_ssim = ARG_DEF_ENUM( |
350 "Material to favor", tuning_enum
); | 347 NULL, "tune", 1, "Material to favor", tuning_enum); |
351 static const arg_def_t cq_level = ARG_DEF(NULL, "cq-level", 1, | 348 static const arg_def_t cq_level = ARG_DEF( |
352 "Constant/Constrained Quality level"); | 349 NULL, "cq-level", 1, "Constant/Constrained Quality level"); |
353 static const arg_def_t max_intra_rate_pct = ARG_DEF(NULL, "max-intra-rate", 1, | 350 static const arg_def_t max_intra_rate_pct = ARG_DEF( |
354 "Max I-frame bitrate (pct)")
; | 351 NULL, "max-intra-rate", 1, "Max I-frame bitrate (pct)"); |
355 | 352 |
356 #if CONFIG_VP8_ENCODER | 353 #if CONFIG_VP8_ENCODER |
357 static const arg_def_t token_parts = | 354 static const arg_def_t token_parts = ARG_DEF( |
358 ARG_DEF(NULL, "token-parts", 1, "Number of token partitions to use, log2"); | 355 NULL, "token-parts", 1, "Number of token partitions to use, log2"); |
359 static const arg_def_t *vp8_args[] = { | 356 static const arg_def_t *vp8_args[] = { |
360 &cpu_used, &auto_altref, &noise_sens, &sharpness, &static_thresh, | 357 &cpu_used, &auto_altref, &noise_sens, &sharpness, &static_thresh, |
361 &token_parts, &arnr_maxframes, &arnr_strength, &arnr_type, | 358 &token_parts, &arnr_maxframes, &arnr_strength, &arnr_type, |
362 &tune_ssim, &cq_level, &max_intra_rate_pct, | 359 &tune_ssim, &cq_level, &max_intra_rate_pct, |
363 NULL | 360 NULL |
364 }; | 361 }; |
365 static const int vp8_arg_ctrl_map[] = { | 362 static const int vp8_arg_ctrl_map[] = { |
366 VP8E_SET_CPUUSED, VP8E_SET_ENABLEAUTOALTREF, | 363 VP8E_SET_CPUUSED, VP8E_SET_ENABLEAUTOALTREF, |
367 VP8E_SET_NOISE_SENSITIVITY, VP8E_SET_SHARPNESS, VP8E_SET_STATIC_THRESHOLD, | 364 VP8E_SET_NOISE_SENSITIVITY, VP8E_SET_SHARPNESS, VP8E_SET_STATIC_THRESHOLD, |
368 VP8E_SET_TOKEN_PARTITIONS, | 365 VP8E_SET_TOKEN_PARTITIONS, |
369 VP8E_SET_ARNR_MAXFRAMES, VP8E_SET_ARNR_STRENGTH, VP8E_SET_ARNR_TYPE, | 366 VP8E_SET_ARNR_MAXFRAMES, VP8E_SET_ARNR_STRENGTH, VP8E_SET_ARNR_TYPE, |
370 VP8E_SET_TUNING, VP8E_SET_CQ_LEVEL, VP8E_SET_MAX_INTRA_BITRATE_PCT, | 367 VP8E_SET_TUNING, VP8E_SET_CQ_LEVEL, VP8E_SET_MAX_INTRA_BITRATE_PCT, |
371 0 | 368 0 |
372 }; | 369 }; |
373 #endif | 370 #endif |
374 | 371 |
375 #if CONFIG_VP9_ENCODER | 372 #if CONFIG_VP9_ENCODER |
376 static const arg_def_t tile_cols = | 373 static const arg_def_t tile_cols = ARG_DEF( |
377 ARG_DEF(NULL, "tile-columns", 1, "Number of tile columns to use, log2"); | 374 NULL, "tile-columns", 1, "Number of tile columns to use, log2"); |
378 static const arg_def_t tile_rows = | 375 static const arg_def_t tile_rows = ARG_DEF( |
379 ARG_DEF(NULL, "tile-rows", 1, "Number of tile rows to use, log2"); | 376 NULL, "tile-rows", 1, "Number of tile rows to use, log2"); |
380 static const arg_def_t lossless = ARG_DEF(NULL, "lossless", 1, "Lossless mode"); | 377 static const arg_def_t lossless = ARG_DEF( |
| 378 NULL, "lossless", 1, "Lossless mode"); |
381 static const arg_def_t frame_parallel_decoding = ARG_DEF( | 379 static const arg_def_t frame_parallel_decoding = ARG_DEF( |
382 NULL, "frame-parallel", 1, "Enable frame parallel decodability features"); | 380 NULL, "frame-parallel", 1, "Enable frame parallel decodability features"); |
383 static const arg_def_t aq_mode = ARG_DEF( | 381 static const arg_def_t aq_mode = ARG_DEF( |
384 NULL, "aq-mode", 1, | 382 NULL, "aq-mode", 1, |
385 "Adaptive quantization mode (0: off (default), 1: variance 2: complexity, " | 383 "Adaptive quantization mode (0: off (default), 1: variance 2: complexity, " |
386 "3: cyclic refresh)"); | 384 "3: cyclic refresh)"); |
387 static const arg_def_t frame_periodic_boost = ARG_DEF( | 385 static const arg_def_t frame_periodic_boost = ARG_DEF( |
388 NULL, "frame-boost", 1, | 386 NULL, "frame-boost", 1, |
389 "Enable frame periodic boost (0: off (default), 1: on)"); | 387 "Enable frame periodic boost (0: off (default), 1: on)"); |
390 | 388 |
391 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 389 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH |
392 static const struct arg_enum_list bitdepth_enum[] = { | 390 static const struct arg_enum_list bitdepth_enum[] = { |
393 {"8", VPX_BITS_8}, | 391 {"8", VPX_BITS_8}, |
394 {"10", VPX_BITS_10}, | 392 {"10", VPX_BITS_10}, |
395 {"12", VPX_BITS_12}, | 393 {"12", VPX_BITS_12}, |
396 {NULL, 0} | 394 {NULL, 0} |
397 }; | 395 }; |
398 | 396 |
399 static const arg_def_t bitdeptharg = ARG_DEF_ENUM("b", "bit-depth", 1, | 397 static const arg_def_t bitdeptharg = ARG_DEF_ENUM( |
400 "Bit depth for codec " | 398 "b", "bit-depth", 1, |
401 "(8 for version <=1, " | 399 "Bit depth for codec (8 for version <=1, 10 or 12 for version 2)", |
402 "10 or 12 for version 2)", | 400 bitdepth_enum); |
403 bitdepth_enum); | 401 static const arg_def_t inbitdeptharg = ARG_DEF( |
404 static const arg_def_t inbitdeptharg = ARG_DEF(NULL, "input-bit-depth", 1, | 402 NULL, "input-bit-depth", 1, "Bit depth of input"); |
405 "Bit depth of input"); | |
406 #endif | 403 #endif |
407 | 404 |
408 static const struct arg_enum_list tune_content_enum[] = { | 405 static const struct arg_enum_list tune_content_enum[] = { |
409 {"default", VP9E_CONTENT_DEFAULT}, | 406 {"default", VP9E_CONTENT_DEFAULT}, |
410 {"screen", VP9E_CONTENT_SCREEN}, | 407 {"screen", VP9E_CONTENT_SCREEN}, |
411 {NULL, 0} | 408 {NULL, 0} |
412 }; | 409 }; |
413 | 410 |
414 static const arg_def_t tune_content = ARG_DEF_ENUM( | 411 static const arg_def_t tune_content = ARG_DEF_ENUM( |
415 NULL, "tune-content", 1, "Tune content type", tune_content_enum); | 412 NULL, "tune-content", 1, "Tune content type", tune_content_enum); |
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 else if (arg_match(&arg, &rt_dl, argi)) | 819 else if (arg_match(&arg, &rt_dl, argi)) |
823 global->deadline = VPX_DL_REALTIME; | 820 global->deadline = VPX_DL_REALTIME; |
824 else if (arg_match(&arg, &use_yv12, argi)) | 821 else if (arg_match(&arg, &use_yv12, argi)) |
825 global->color_type = YV12; | 822 global->color_type = YV12; |
826 else if (arg_match(&arg, &use_i420, argi)) | 823 else if (arg_match(&arg, &use_i420, argi)) |
827 global->color_type = I420; | 824 global->color_type = I420; |
828 else if (arg_match(&arg, &use_i422, argi)) | 825 else if (arg_match(&arg, &use_i422, argi)) |
829 global->color_type = I422; | 826 global->color_type = I422; |
830 else if (arg_match(&arg, &use_i444, argi)) | 827 else if (arg_match(&arg, &use_i444, argi)) |
831 global->color_type = I444; | 828 global->color_type = I444; |
| 829 else if (arg_match(&arg, &use_i440, argi)) |
| 830 global->color_type = I440; |
832 else if (arg_match(&arg, &quietarg, argi)) | 831 else if (arg_match(&arg, &quietarg, argi)) |
833 global->quiet = 1; | 832 global->quiet = 1; |
834 else if (arg_match(&arg, &verbosearg, argi)) | 833 else if (arg_match(&arg, &verbosearg, argi)) |
835 global->verbose = 1; | 834 global->verbose = 1; |
836 else if (arg_match(&arg, &limit, argi)) | 835 else if (arg_match(&arg, &limit, argi)) |
837 global->limit = arg_parse_uint(&arg); | 836 global->limit = arg_parse_uint(&arg); |
838 else if (arg_match(&arg, &skip, argi)) | 837 else if (arg_match(&arg, &skip, argi)) |
839 global->skip_frames = arg_parse_uint(&arg); | 838 global->skip_frames = arg_parse_uint(&arg); |
840 else if (arg_match(&arg, &psnrarg, argi)) | 839 else if (arg_match(&arg, &psnrarg, argi)) |
841 global->show_psnr = 1; | 840 global->show_psnr = 1; |
842 else if (arg_match(&arg, &recontest, argi)) | 841 else if (arg_match(&arg, &recontest, argi)) |
843 global->test_decode = arg_parse_enum_or_int(&arg); | 842 global->test_decode = arg_parse_enum_or_int(&arg); |
844 else if (arg_match(&arg, &framerate, argi)) { | 843 else if (arg_match(&arg, &framerate, argi)) { |
845 global->framerate = arg_parse_rational(&arg); | 844 global->framerate = arg_parse_rational(&arg); |
846 validate_positive_rational(arg.name, &global->framerate); | 845 validate_positive_rational(arg.name, &global->framerate); |
847 global->have_framerate = 1; | 846 global->have_framerate = 1; |
848 } else if (arg_match(&arg, &out_part, argi)) | 847 } else if (arg_match(&arg, &out_part, argi)) |
849 global->out_part = 1; | 848 global->out_part = 1; |
850 else if (arg_match(&arg, &debugmode, argi)) | 849 else if (arg_match(&arg, &debugmode, argi)) |
851 global->debug = 1; | 850 global->debug = 1; |
852 else if (arg_match(&arg, &q_hist_n, argi)) | 851 else if (arg_match(&arg, &q_hist_n, argi)) |
853 global->show_q_hist_buckets = arg_parse_uint(&arg); | 852 global->show_q_hist_buckets = arg_parse_uint(&arg); |
854 else if (arg_match(&arg, &rate_hist_n, argi)) | 853 else if (arg_match(&arg, &rate_hist_n, argi)) |
855 global->show_rate_hist_buckets = arg_parse_uint(&arg); | 854 global->show_rate_hist_buckets = arg_parse_uint(&arg); |
856 else if (arg_match(&arg, &disable_warnings, argi)) | 855 else if (arg_match(&arg, &disable_warnings, argi)) |
857 global->disable_warnings = 1; | 856 global->disable_warnings = 1; |
858 else if (arg_match(&arg, &disable_warning_prompt, argi)) | 857 else if (arg_match(&arg, &disable_warning_prompt, argi)) |
859 global->disable_warning_prompt = 1; | 858 global->disable_warning_prompt = 1; |
860 else if (arg_match(&arg, &experimental_bitstream, argi)) | |
861 global->experimental_bitstream = 1; | |
862 else | 859 else |
863 argj++; | 860 argj++; |
864 } | 861 } |
865 | 862 |
866 if (global->pass) { | 863 if (global->pass) { |
867 /* DWIM: Assume the user meant passes=2 if pass=2 is specified */ | 864 /* DWIM: Assume the user meant passes=2 if pass=2 is specified */ |
868 if (global->pass > global->passes) { | 865 if (global->pass > global->passes) { |
869 warn("Assuming --pass=%d implies --passes=%d\n", | 866 warn("Assuming --pass=%d implies --passes=%d\n", |
870 global->pass, global->pass); | 867 global->pass, global->pass); |
871 global->passes = global->pass; | 868 global->passes = global->pass; |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1155 break; | 1152 break; |
1156 | 1153 |
1157 /* Update/insert */ | 1154 /* Update/insert */ |
1158 assert(j < (int)ARG_CTRL_CNT_MAX); | 1155 assert(j < (int)ARG_CTRL_CNT_MAX); |
1159 if (ctrl_args_map != NULL && j < (int)ARG_CTRL_CNT_MAX) { | 1156 if (ctrl_args_map != NULL && j < (int)ARG_CTRL_CNT_MAX) { |
1160 config->arg_ctrls[j][0] = ctrl_args_map[i]; | 1157 config->arg_ctrls[j][0] = ctrl_args_map[i]; |
1161 config->arg_ctrls[j][1] = arg_parse_enum_or_int(&arg); | 1158 config->arg_ctrls[j][1] = arg_parse_enum_or_int(&arg); |
1162 if (j == config->arg_ctrl_cnt) | 1159 if (j == config->arg_ctrl_cnt) |
1163 config->arg_ctrl_cnt++; | 1160 config->arg_ctrl_cnt++; |
1164 } | 1161 } |
1165 | |
1166 } | 1162 } |
1167 } | 1163 } |
1168 if (!match) | 1164 if (!match) |
1169 argj++; | 1165 argj++; |
1170 } | 1166 } |
1171 } | 1167 } |
1172 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 1168 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH |
1173 if (strcmp(global->codec->name, "vp9") == 0) { | 1169 if (strcmp(global->codec->name, "vp9") == 0) { |
1174 config->use_16bit_internal = test_16bit_internal | | 1170 config->use_16bit_internal = test_16bit_internal | |
1175 (config->cfg.g_profile > 1); | 1171 (config->cfg.g_profile > 1); |
(...skipping 13 matching lines...) Expand all Loading... |
1189 | 1185 |
1190 | 1186 |
1191 static void validate_stream_config(const struct stream_state *stream, | 1187 static void validate_stream_config(const struct stream_state *stream, |
1192 const struct VpxEncoderConfig *global) { | 1188 const struct VpxEncoderConfig *global) { |
1193 const struct stream_state *streami; | 1189 const struct stream_state *streami; |
1194 | 1190 |
1195 if (!stream->config.cfg.g_w || !stream->config.cfg.g_h) | 1191 if (!stream->config.cfg.g_w || !stream->config.cfg.g_h) |
1196 fatal("Stream %d: Specify stream dimensions with --width (-w) " | 1192 fatal("Stream %d: Specify stream dimensions with --width (-w) " |
1197 " and --height (-h)", stream->index); | 1193 " and --height (-h)", stream->index); |
1198 | 1194 |
1199 if (stream->config.cfg.g_profile != 0 && !global->experimental_bitstream) { | |
1200 fatal("Stream %d: profile %d is experimental and requires the --%s flag", | |
1201 stream->index, stream->config.cfg.g_profile, | |
1202 experimental_bitstream.long_name); | |
1203 } | |
1204 | |
1205 // Check that the codec bit depth is greater than the input bit depth. | 1195 // Check that the codec bit depth is greater than the input bit depth. |
1206 if (stream->config.cfg.g_input_bit_depth > | 1196 if (stream->config.cfg.g_input_bit_depth > |
1207 (unsigned int)stream->config.cfg.g_bit_depth) { | 1197 (unsigned int)stream->config.cfg.g_bit_depth) { |
1208 fatal("Stream %d: codec bit depth (%d) less than input bit depth (%d)", | 1198 fatal("Stream %d: codec bit depth (%d) less than input bit depth (%d)", |
1209 stream->index, (int)stream->config.cfg.g_bit_depth, | 1199 stream->index, (int)stream->config.cfg.g_bit_depth, |
1210 stream->config.cfg.g_input_bit_depth); | 1200 stream->config.cfg.g_input_bit_depth); |
1211 } | 1201 } |
1212 | 1202 |
1213 for (streami = stream; streami; streami = streami->next) { | 1203 for (streami = stream; streami; streami = streami->next) { |
1214 /* All streams require output files */ | 1204 /* All streams require output files */ |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1281 case FILE_TYPE_Y4M: return "Y4M"; | 1271 case FILE_TYPE_Y4M: return "Y4M"; |
1282 default: return "Other"; | 1272 default: return "Other"; |
1283 } | 1273 } |
1284 } | 1274 } |
1285 | 1275 |
1286 static const char* image_format_to_string(vpx_img_fmt_t f) { | 1276 static const char* image_format_to_string(vpx_img_fmt_t f) { |
1287 switch (f) { | 1277 switch (f) { |
1288 case VPX_IMG_FMT_I420: return "I420"; | 1278 case VPX_IMG_FMT_I420: return "I420"; |
1289 case VPX_IMG_FMT_I422: return "I422"; | 1279 case VPX_IMG_FMT_I422: return "I422"; |
1290 case VPX_IMG_FMT_I444: return "I444"; | 1280 case VPX_IMG_FMT_I444: return "I444"; |
| 1281 case VPX_IMG_FMT_I440: return "I440"; |
1291 case VPX_IMG_FMT_YV12: return "YV12"; | 1282 case VPX_IMG_FMT_YV12: return "YV12"; |
| 1283 case VPX_IMG_FMT_I42016: return "I42016"; |
| 1284 case VPX_IMG_FMT_I42216: return "I42216"; |
| 1285 case VPX_IMG_FMT_I44416: return "I44416"; |
| 1286 case VPX_IMG_FMT_I44016: return "I44016"; |
1292 default: return "Other"; | 1287 default: return "Other"; |
1293 } | 1288 } |
1294 } | 1289 } |
1295 | 1290 |
1296 static void show_stream_config(struct stream_state *stream, | 1291 static void show_stream_config(struct stream_state *stream, |
1297 struct VpxEncoderConfig *global, | 1292 struct VpxEncoderConfig *global, |
1298 struct VpxInputContext *input) { | 1293 struct VpxInputContext *input) { |
1299 | 1294 |
1300 #define SHOW(field) \ | 1295 #define SHOW(field) \ |
1301 fprintf(stderr, " %-28s = %d\n", #field, stream->config.cfg.field) | 1296 fprintf(stderr, " %-28s = %d\n", #field, stream->config.cfg.field) |
(...skipping 386 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1688 } | 1683 } |
1689 | 1684 |
1690 break; | 1685 break; |
1691 default: | 1686 default: |
1692 break; | 1687 break; |
1693 } | 1688 } |
1694 } | 1689 } |
1695 } | 1690 } |
1696 | 1691 |
1697 | 1692 |
1698 static void show_psnr(struct stream_state *stream) { | 1693 static void show_psnr(struct stream_state *stream, double peak) { |
1699 int i; | 1694 int i; |
1700 double ovpsnr; | 1695 double ovpsnr; |
1701 | 1696 |
1702 if (!stream->psnr_count) | 1697 if (!stream->psnr_count) |
1703 return; | 1698 return; |
1704 | 1699 |
1705 fprintf(stderr, "Stream %d PSNR (Overall/Avg/Y/U/V)", stream->index); | 1700 fprintf(stderr, "Stream %d PSNR (Overall/Avg/Y/U/V)", stream->index); |
1706 ovpsnr = sse_to_psnr((double)stream->psnr_samples_total, 255.0, | 1701 ovpsnr = sse_to_psnr((double)stream->psnr_samples_total, peak, |
1707 (double)stream->psnr_sse_total); | 1702 (double)stream->psnr_sse_total); |
1708 fprintf(stderr, " %.3f", ovpsnr); | 1703 fprintf(stderr, " %.3f", ovpsnr); |
1709 | 1704 |
1710 for (i = 0; i < 4; i++) { | 1705 for (i = 0; i < 4; i++) { |
1711 fprintf(stderr, " %.3f", stream->psnr_totals[i] / stream->psnr_count); | 1706 fprintf(stderr, " %.3f", stream->psnr_totals[i] / stream->psnr_count); |
1712 } | 1707 } |
1713 fprintf(stderr, "\n"); | 1708 fprintf(stderr, "\n"); |
1714 } | 1709 } |
1715 | 1710 |
1716 | 1711 |
1717 static float usec_to_fps(uint64_t usec, unsigned int frames) { | 1712 static float usec_to_fps(uint64_t usec, unsigned int frames) { |
1718 return (float)(usec > 0 ? frames * 1000000.0 / (float)usec : 0); | 1713 return (float)(usec > 0 ? frames * 1000000.0 / (float)usec : 0); |
1719 } | 1714 } |
1720 | 1715 |
1721 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | |
1722 static void high_img_upshift(vpx_image_t *dst, vpx_image_t *src, | |
1723 int input_shift) { | |
1724 // Note the offset is 1 less than half | |
1725 const int offset = input_shift > 0 ? (1 << (input_shift - 1)) - 1 : 0; | |
1726 int plane; | |
1727 if (dst->w != src->w || dst->h != src->h || | |
1728 dst->x_chroma_shift != src->x_chroma_shift || | |
1729 dst->y_chroma_shift != src->y_chroma_shift || | |
1730 dst->fmt != src->fmt || input_shift < 0) { | |
1731 fatal("Unsupported image conversion"); | |
1732 } | |
1733 switch (src->fmt) { | |
1734 case VPX_IMG_FMT_I42016: | |
1735 case VPX_IMG_FMT_I42216: | |
1736 case VPX_IMG_FMT_I44416: | |
1737 break; | |
1738 default: | |
1739 fatal("Unsupported image conversion"); | |
1740 break; | |
1741 } | |
1742 for (plane = 0; plane < 3; plane++) { | |
1743 int w = src->w; | |
1744 int h = src->h; | |
1745 int x, y; | |
1746 if (plane) { | |
1747 w >>= src->x_chroma_shift; | |
1748 h >>= src->y_chroma_shift; | |
1749 } | |
1750 for (y = 0; y < h; y++) { | |
1751 uint16_t *p_src = (uint16_t *)(src->planes[plane] + | |
1752 y * src->stride[plane]); | |
1753 uint16_t *p_dst = (uint16_t *)(dst->planes[plane] + | |
1754 y * dst->stride[plane]); | |
1755 for (x = 0; x < w; x++) | |
1756 *p_dst++ = (*p_src++ << input_shift) + offset; | |
1757 } | |
1758 } | |
1759 } | |
1760 | |
1761 static void low_img_upshift(vpx_image_t *dst, vpx_image_t *src, | |
1762 int input_shift) { | |
1763 // Note the offset is 1 less than half | |
1764 const int offset = input_shift > 0 ? (1 << (input_shift - 1)) - 1 : 0; | |
1765 int plane; | |
1766 if (dst->w != src->w || dst->h != src->h || | |
1767 dst->x_chroma_shift != src->x_chroma_shift || | |
1768 dst->y_chroma_shift != src->y_chroma_shift || | |
1769 dst->fmt != src->fmt + VPX_IMG_FMT_HIGHBITDEPTH || | |
1770 input_shift < 0) { | |
1771 fatal("Unsupported image conversion"); | |
1772 } | |
1773 switch (src->fmt) { | |
1774 case VPX_IMG_FMT_I420: | |
1775 case VPX_IMG_FMT_I422: | |
1776 case VPX_IMG_FMT_I444: | |
1777 break; | |
1778 default: | |
1779 fatal("Unsupported image conversion"); | |
1780 break; | |
1781 } | |
1782 for (plane = 0; plane < 3; plane++) { | |
1783 int w = src->w; | |
1784 int h = src->h; | |
1785 int x, y; | |
1786 if (plane) { | |
1787 w >>= src->x_chroma_shift; | |
1788 h >>= src->y_chroma_shift; | |
1789 } | |
1790 for (y = 0; y < h; y++) { | |
1791 uint8_t *p_src = src->planes[plane] + y * src->stride[plane]; | |
1792 uint16_t *p_dst = (uint16_t *)(dst->planes[plane] + | |
1793 y * dst->stride[plane]); | |
1794 for (x = 0; x < w; x++) { | |
1795 *p_dst++ = (*p_src++ << input_shift) + offset; | |
1796 } | |
1797 } | |
1798 } | |
1799 } | |
1800 | |
1801 static void img_upshift(vpx_image_t *dst, vpx_image_t *src, | |
1802 int input_shift) { | |
1803 if (src->fmt & VPX_IMG_FMT_HIGHBITDEPTH) { | |
1804 high_img_upshift(dst, src, input_shift); | |
1805 } else { | |
1806 low_img_upshift(dst, src, input_shift); | |
1807 } | |
1808 } | |
1809 | |
1810 static void img_cast_16_to_8(vpx_image_t *dst, vpx_image_t *src) { | |
1811 int plane; | |
1812 if (dst->fmt + VPX_IMG_FMT_HIGHBITDEPTH != src->fmt || | |
1813 dst->d_w != src->d_w || dst->d_h != src->d_h || | |
1814 dst->x_chroma_shift != src->x_chroma_shift || | |
1815 dst->y_chroma_shift != src->y_chroma_shift) { | |
1816 fatal("Unsupported image conversion"); | |
1817 } | |
1818 switch (dst->fmt) { | |
1819 case VPX_IMG_FMT_I420: | |
1820 case VPX_IMG_FMT_I422: | |
1821 case VPX_IMG_FMT_I444: | |
1822 break; | |
1823 default: | |
1824 fatal("Unsupported image conversion"); | |
1825 break; | |
1826 } | |
1827 for (plane = 0; plane < 3; plane++) { | |
1828 int w = src->d_w; | |
1829 int h = src->d_h; | |
1830 int x, y; | |
1831 if (plane) { | |
1832 w >>= src->x_chroma_shift; | |
1833 h >>= src->y_chroma_shift; | |
1834 } | |
1835 for (y = 0; y < h; y++) { | |
1836 uint16_t *p_src = (uint16_t *)(src->planes[plane] + | |
1837 y * src->stride[plane]); | |
1838 uint8_t *p_dst = dst->planes[plane] + y * dst->stride[plane]; | |
1839 for (x = 0; x < w; x++) { | |
1840 *p_dst++ = *p_src++; | |
1841 } | |
1842 } | |
1843 } | |
1844 } | |
1845 #endif | |
1846 | |
1847 static void test_decode(struct stream_state *stream, | 1716 static void test_decode(struct stream_state *stream, |
1848 enum TestDecodeFatality fatal, | 1717 enum TestDecodeFatality fatal, |
1849 const VpxInterface *codec) { | 1718 const VpxInterface *codec) { |
1850 vpx_image_t enc_img, dec_img; | 1719 vpx_image_t enc_img, dec_img; |
1851 | 1720 |
1852 if (stream->mismatch_seen) | 1721 if (stream->mismatch_seen) |
1853 return; | 1722 return; |
1854 | 1723 |
1855 /* Get the internal reference frame */ | 1724 /* Get the internal reference frame */ |
1856 if (strcmp(codec->name, "vp8") == 0) { | 1725 if (strcmp(codec->name, "vp8") == 0) { |
(...skipping 19 matching lines...) Expand all Loading... |
1876 vpx_codec_control(&stream->encoder, VP9_GET_REFERENCE, &ref_enc); | 1745 vpx_codec_control(&stream->encoder, VP9_GET_REFERENCE, &ref_enc); |
1877 enc_img = ref_enc.img; | 1746 enc_img = ref_enc.img; |
1878 vpx_codec_control(&stream->decoder, VP9_GET_REFERENCE, &ref_dec); | 1747 vpx_codec_control(&stream->decoder, VP9_GET_REFERENCE, &ref_dec); |
1879 dec_img = ref_dec.img; | 1748 dec_img = ref_dec.img; |
1880 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 1749 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH |
1881 if ((enc_img.fmt & VPX_IMG_FMT_HIGHBITDEPTH) != | 1750 if ((enc_img.fmt & VPX_IMG_FMT_HIGHBITDEPTH) != |
1882 (dec_img.fmt & VPX_IMG_FMT_HIGHBITDEPTH)) { | 1751 (dec_img.fmt & VPX_IMG_FMT_HIGHBITDEPTH)) { |
1883 if (enc_img.fmt & VPX_IMG_FMT_HIGHBITDEPTH) { | 1752 if (enc_img.fmt & VPX_IMG_FMT_HIGHBITDEPTH) { |
1884 vpx_img_alloc(&enc_img, enc_img.fmt - VPX_IMG_FMT_HIGHBITDEPTH, | 1753 vpx_img_alloc(&enc_img, enc_img.fmt - VPX_IMG_FMT_HIGHBITDEPTH, |
1885 enc_img.d_w, enc_img.d_h, 16); | 1754 enc_img.d_w, enc_img.d_h, 16); |
1886 img_cast_16_to_8(&enc_img, &ref_enc.img); | 1755 vpx_img_truncate_16_to_8(&enc_img, &ref_enc.img); |
1887 } | 1756 } |
1888 if (dec_img.fmt & VPX_IMG_FMT_HIGHBITDEPTH) { | 1757 if (dec_img.fmt & VPX_IMG_FMT_HIGHBITDEPTH) { |
1889 vpx_img_alloc(&dec_img, dec_img.fmt - VPX_IMG_FMT_HIGHBITDEPTH, | 1758 vpx_img_alloc(&dec_img, dec_img.fmt - VPX_IMG_FMT_HIGHBITDEPTH, |
1890 dec_img.d_w, dec_img.d_h, 16); | 1759 dec_img.d_w, dec_img.d_h, 16); |
1891 img_cast_16_to_8(&dec_img, &ref_dec.img); | 1760 vpx_img_truncate_16_to_8(&dec_img, &ref_dec.img); |
1892 } | 1761 } |
1893 } | 1762 } |
1894 #endif | 1763 #endif |
1895 } | 1764 } |
1896 ctx_exit_on_error(&stream->encoder, "Failed to get encoder reference frame"); | 1765 ctx_exit_on_error(&stream->encoder, "Failed to get encoder reference frame"); |
1897 ctx_exit_on_error(&stream->decoder, "Failed to get decoder reference frame"); | 1766 ctx_exit_on_error(&stream->decoder, "Failed to get decoder reference frame"); |
1898 | 1767 |
1899 if (!compare_img(&enc_img, &dec_img)) { | 1768 if (!compare_img(&enc_img, &dec_img)) { |
1900 int y[4], u[4], v[4]; | 1769 int y[4], u[4], v[4]; |
1901 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 1770 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH |
(...skipping 84 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1986 switch (global.color_type) { | 1855 switch (global.color_type) { |
1987 case I420: | 1856 case I420: |
1988 input.fmt = VPX_IMG_FMT_I420; | 1857 input.fmt = VPX_IMG_FMT_I420; |
1989 break; | 1858 break; |
1990 case I422: | 1859 case I422: |
1991 input.fmt = VPX_IMG_FMT_I422; | 1860 input.fmt = VPX_IMG_FMT_I422; |
1992 break; | 1861 break; |
1993 case I444: | 1862 case I444: |
1994 input.fmt = VPX_IMG_FMT_I444; | 1863 input.fmt = VPX_IMG_FMT_I444; |
1995 break; | 1864 break; |
| 1865 case I440: |
| 1866 input.fmt = VPX_IMG_FMT_I440; |
| 1867 break; |
1996 case YV12: | 1868 case YV12: |
1997 input.fmt = VPX_IMG_FMT_YV12; | 1869 input.fmt = VPX_IMG_FMT_YV12; |
1998 break; | 1870 break; |
1999 } | 1871 } |
2000 | 1872 |
2001 { | 1873 { |
2002 /* Now parse each stream's parameters. Using a local scope here | 1874 /* Now parse each stream's parameters. Using a local scope here |
2003 * due to the use of 'stream' as loop variable in FOREACH_STREAM | 1875 * due to the use of 'stream' as loop variable in FOREACH_STREAM |
2004 * loops | 1876 * loops |
2005 */ | 1877 */ |
(...skipping 29 matching lines...) Expand all Loading... |
2035 int frames_in = 0, seen_frames = 0; | 1907 int frames_in = 0, seen_frames = 0; |
2036 int64_t estimated_time_left = -1; | 1908 int64_t estimated_time_left = -1; |
2037 int64_t average_rate = -1; | 1909 int64_t average_rate = -1; |
2038 int64_t lagged_count = 0; | 1910 int64_t lagged_count = 0; |
2039 | 1911 |
2040 open_input_file(&input); | 1912 open_input_file(&input); |
2041 | 1913 |
2042 /* If the input file doesn't specify its w/h (raw files), try to get | 1914 /* If the input file doesn't specify its w/h (raw files), try to get |
2043 * the data from the first stream's configuration. | 1915 * the data from the first stream's configuration. |
2044 */ | 1916 */ |
2045 if (!input.width || !input.height) | 1917 if (!input.width || !input.height) { |
2046 FOREACH_STREAM( { | 1918 FOREACH_STREAM({ |
2047 if (stream->config.cfg.g_w && stream->config.cfg.g_h) { | 1919 if (stream->config.cfg.g_w && stream->config.cfg.g_h) { |
2048 input.width = stream->config.cfg.g_w; | 1920 input.width = stream->config.cfg.g_w; |
2049 input.height = stream->config.cfg.g_h; | 1921 input.height = stream->config.cfg.g_h; |
2050 break; | 1922 break; |
2051 } | 1923 } |
2052 }); | 1924 }); |
| 1925 } |
2053 | 1926 |
2054 /* Update stream configurations from the input file's parameters */ | 1927 /* Update stream configurations from the input file's parameters */ |
2055 if (!input.width || !input.height) | 1928 if (!input.width || !input.height) |
2056 fatal("Specify stream dimensions with --width (-w) " | 1929 fatal("Specify stream dimensions with --width (-w) " |
2057 " and --height (-h)"); | 1930 " and --height (-h)"); |
2058 | 1931 |
2059 /* If input file does not specify bit-depth but input-bit-depth parameter | 1932 /* If input file does not specify bit-depth but input-bit-depth parameter |
2060 * exists, assume that to be the input bit-depth. However, if the | 1933 * exists, assume that to be the input bit-depth. However, if the |
2061 * input-bit-depth paramter does not exist, assume the input bit-depth | 1934 * input-bit-depth paramter does not exist, assume the input bit-depth |
2062 * to be the same as the codec bit-depth. | 1935 * to be the same as the codec bit-depth. |
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2189 vpx_image_t *frame_to_encode; | 2062 vpx_image_t *frame_to_encode; |
2190 if (input_shift || (use_16bit_internal && input.bit_depth == 8)) { | 2063 if (input_shift || (use_16bit_internal && input.bit_depth == 8)) { |
2191 assert(use_16bit_internal); | 2064 assert(use_16bit_internal); |
2192 // Input bit depth and stream bit depth do not match, so up | 2065 // Input bit depth and stream bit depth do not match, so up |
2193 // shift frame to stream bit depth | 2066 // shift frame to stream bit depth |
2194 if (!allocated_raw_shift) { | 2067 if (!allocated_raw_shift) { |
2195 vpx_img_alloc(&raw_shift, raw.fmt | VPX_IMG_FMT_HIGHBITDEPTH, | 2068 vpx_img_alloc(&raw_shift, raw.fmt | VPX_IMG_FMT_HIGHBITDEPTH, |
2196 input.width, input.height, 32); | 2069 input.width, input.height, 32); |
2197 allocated_raw_shift = 1; | 2070 allocated_raw_shift = 1; |
2198 } | 2071 } |
2199 img_upshift(&raw_shift, &raw, input_shift); | 2072 vpx_img_upshift(&raw_shift, &raw, input_shift); |
2200 frame_to_encode = &raw_shift; | 2073 frame_to_encode = &raw_shift; |
2201 } else { | 2074 } else { |
2202 frame_to_encode = &raw; | 2075 frame_to_encode = &raw; |
2203 } | 2076 } |
2204 vpx_usec_timer_start(&timer); | 2077 vpx_usec_timer_start(&timer); |
2205 if (use_16bit_internal) { | 2078 if (use_16bit_internal) { |
2206 assert(frame_to_encode->fmt & VPX_IMG_FMT_HIGHBITDEPTH); | 2079 assert(frame_to_encode->fmt & VPX_IMG_FMT_HIGHBITDEPTH); |
2207 FOREACH_STREAM({ | 2080 FOREACH_STREAM({ |
2208 if (stream->config.use_16bit_internal) | 2081 if (stream->config.use_16bit_internal) |
2209 encode_frame(stream, &global, | 2082 encode_frame(stream, &global, |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2265 } | 2138 } |
2266 | 2139 |
2267 fflush(stdout); | 2140 fflush(stdout); |
2268 if (!global.quiet) | 2141 if (!global.quiet) |
2269 fprintf(stderr, "\033[K"); | 2142 fprintf(stderr, "\033[K"); |
2270 } | 2143 } |
2271 | 2144 |
2272 if (stream_cnt > 1) | 2145 if (stream_cnt > 1) |
2273 fprintf(stderr, "\n"); | 2146 fprintf(stderr, "\n"); |
2274 | 2147 |
2275 if (!global.quiet) | 2148 if (!global.quiet) { |
2276 FOREACH_STREAM(fprintf( | 2149 FOREACH_STREAM(fprintf(stderr, |
2277 stderr, | 2150 "\rPass %d/%d frame %4d/%-4d %7"PRId64"B %7"PRId64"b/f %7"PRId64"b/s" |
2278 "\rPass %d/%d frame %4d/%-4d %7"PRId64"B %7lub/f %7"PRId6
4"b/s" | 2151 " %7"PRId64" %s (%.2f fps)\033[K\n", |
2279 " %7"PRId64" %s (%.2f fps)\033[K\n", pass + 1, | 2152 pass + 1, |
2280 global.passes, frames_in, stream->frames_out, (int64_t)st
ream->nbytes, | 2153 global.passes, frames_in, stream->frames_out, (int64_t)stream->nbytes, |
2281 seen_frames ? (unsigned long)(stream->nbytes * 8 / seen_f
rames) : 0, | 2154 seen_frames ? (int64_t)(stream->nbytes * 8 / seen_frames) : 0, |
2282 seen_frames ? (int64_t)stream->nbytes * 8 | 2155 seen_frames ? (int64_t)stream->nbytes * 8 * |
2283 * (int64_t)global.framerate.num / global.framerate.den | 2156 (int64_t)global.framerate.num / global.framerate.den / |
2284 / seen_frames | 2157 seen_frames : 0, |
2285 : 0, | 2158 stream->cx_time > 9999999 ? stream->cx_time / 1000 : stream->cx_time, |
2286 stream->cx_time > 9999999 ? stream->cx_time / 1000 : stre
am->cx_time, | 2159 stream->cx_time > 9999999 ? "ms" : "us", |
2287 stream->cx_time > 9999999 ? "ms" : "us", | 2160 usec_to_fps(stream->cx_time, seen_frames))); |
2288 usec_to_fps(stream->cx_time, seen_frames)); | 2161 } |
2289 ); | |
2290 | 2162 |
2291 if (global.show_psnr) | 2163 if (global.show_psnr) { |
2292 FOREACH_STREAM(show_psnr(stream)); | 2164 if (global.codec->fourcc == VP9_FOURCC) { |
| 2165 FOREACH_STREAM( |
| 2166 show_psnr(stream, (1 << stream->config.cfg.g_input_bit_depth) - 1)); |
| 2167 } else { |
| 2168 FOREACH_STREAM(show_psnr(stream, 255.0)); |
| 2169 } |
| 2170 } |
2293 | 2171 |
2294 FOREACH_STREAM(vpx_codec_destroy(&stream->encoder)); | 2172 FOREACH_STREAM(vpx_codec_destroy(&stream->encoder)); |
2295 | 2173 |
2296 if (global.test_decode != TEST_DECODE_OFF) { | 2174 if (global.test_decode != TEST_DECODE_OFF) { |
2297 FOREACH_STREAM(vpx_codec_destroy(&stream->decoder)); | 2175 FOREACH_STREAM(vpx_codec_destroy(&stream->decoder)); |
2298 } | 2176 } |
2299 | 2177 |
2300 close_input_file(&input); | 2178 close_input_file(&input); |
2301 | 2179 |
2302 if (global.test_decode == TEST_DECODE_FATAL) { | 2180 if (global.test_decode == TEST_DECODE_FATAL) { |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2343 | 2221 |
2344 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 2222 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH |
2345 if (allocated_raw_shift) | 2223 if (allocated_raw_shift) |
2346 vpx_img_free(&raw_shift); | 2224 vpx_img_free(&raw_shift); |
2347 #endif | 2225 #endif |
2348 vpx_img_free(&raw); | 2226 vpx_img_free(&raw); |
2349 free(argv); | 2227 free(argv); |
2350 free(streams); | 2228 free(streams); |
2351 return res ? EXIT_FAILURE : EXIT_SUCCESS; | 2229 return res ? EXIT_FAILURE : EXIT_SUCCESS; |
2352 } | 2230 } |
OLD | NEW |