| 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 14 matching lines...) Expand all Loading... |
| 25 | 25 |
| 26 #include "vpx/vpx_encoder.h" | 26 #include "vpx/vpx_encoder.h" |
| 27 #if CONFIG_DECODERS | 27 #if CONFIG_DECODERS |
| 28 #include "vpx/vpx_decoder.h" | 28 #include "vpx/vpx_decoder.h" |
| 29 #endif | 29 #endif |
| 30 | 30 |
| 31 #include "./args.h" | 31 #include "./args.h" |
| 32 #include "./ivfenc.h" | 32 #include "./ivfenc.h" |
| 33 #include "./tools_common.h" | 33 #include "./tools_common.h" |
| 34 | 34 |
| 35 #if CONFIG_VP8_ENCODER || CONFIG_VP9_ENCODER | 35 #if CONFIG_VP8_ENCODER || CONFIG_VP9_ENCODER || CONFIG_VP10_ENCODER |
| 36 #include "vpx/vp8cx.h" | 36 #include "vpx/vp8cx.h" |
| 37 #endif | 37 #endif |
| 38 #if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER | 38 #if CONFIG_VP8_DECODER || CONFIG_VP9_DECODER || CONFIG_VP10_DECODER |
| 39 #include "vpx/vp8dx.h" | 39 #include "vpx/vp8dx.h" |
| 40 #endif | 40 #endif |
| 41 | 41 |
| 42 #include "vpx/vpx_integer.h" | 42 #include "vpx/vpx_integer.h" |
| 43 #include "vpx_ports/mem_ops.h" | 43 #include "vpx_ports/mem_ops.h" |
| 44 #include "vpx_ports/vpx_timer.h" | 44 #include "vpx_ports/vpx_timer.h" |
| 45 #include "./rate_hist.h" | 45 #include "./rate_hist.h" |
| 46 #include "./vpxstats.h" | 46 #include "./vpxstats.h" |
| 47 #include "./warnings.h" | 47 #include "./warnings.h" |
| 48 #if CONFIG_WEBM_IO | 48 #if CONFIG_WEBM_IO |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 194 NULL, "q-hist", 1, "Show quantizer histogram (n-buckets)"); | 194 NULL, "q-hist", 1, "Show quantizer histogram (n-buckets)"); |
| 195 static const arg_def_t rate_hist_n = ARG_DEF( | 195 static const arg_def_t rate_hist_n = ARG_DEF( |
| 196 NULL, "rate-hist", 1, "Show rate histogram (n-buckets)"); | 196 NULL, "rate-hist", 1, "Show rate histogram (n-buckets)"); |
| 197 static const arg_def_t disable_warnings = ARG_DEF( | 197 static const arg_def_t disable_warnings = ARG_DEF( |
| 198 NULL, "disable-warnings", 0, | 198 NULL, "disable-warnings", 0, |
| 199 "Disable warnings about potentially incorrect encode settings."); | 199 "Disable warnings about potentially incorrect encode settings."); |
| 200 static const arg_def_t disable_warning_prompt = ARG_DEF( | 200 static const arg_def_t disable_warning_prompt = ARG_DEF( |
| 201 "y", "disable-warning-prompt", 0, | 201 "y", "disable-warning-prompt", 0, |
| 202 "Display warnings, but do not prompt user to continue."); | 202 "Display warnings, but do not prompt user to continue."); |
| 203 | 203 |
| 204 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 204 #if CONFIG_VP9_HIGHBITDEPTH |
| 205 static const arg_def_t test16bitinternalarg = ARG_DEF( | 205 static const arg_def_t test16bitinternalarg = ARG_DEF( |
| 206 NULL, "test-16bit-internal", 0, "Force use of 16 bit internal buffer"); | 206 NULL, "test-16bit-internal", 0, "Force use of 16 bit internal buffer"); |
| 207 #endif | 207 #endif |
| 208 | 208 |
| 209 static const arg_def_t *main_args[] = { | 209 static const arg_def_t *main_args[] = { |
| 210 &debugmode, | 210 &debugmode, |
| 211 &outputfile, &codecarg, &passes, &pass_arg, &fpf_name, &limit, &skip, | 211 &outputfile, &codecarg, &passes, &pass_arg, &fpf_name, &limit, &skip, |
| 212 &deadline, &best_dl, &good_dl, &rt_dl, | 212 &deadline, &best_dl, &good_dl, &rt_dl, |
| 213 &quietarg, &verbosearg, &psnrarg, &use_webm, &use_ivf, &out_part, &q_hist_n, | 213 &quietarg, &verbosearg, &psnrarg, &use_webm, &use_ivf, &out_part, &q_hist_n, |
| 214 &rate_hist_n, &disable_warnings, &disable_warning_prompt, | 214 &rate_hist_n, &disable_warnings, &disable_warning_prompt, &recontest, |
| 215 NULL | 215 NULL |
| 216 }; | 216 }; |
| 217 | 217 |
| 218 static const arg_def_t usage = ARG_DEF( | 218 static const arg_def_t usage = ARG_DEF( |
| 219 "u", "usage", 1, "Usage profile number to use"); | 219 "u", "usage", 1, "Usage profile number to use"); |
| 220 static const arg_def_t threads = ARG_DEF( | 220 static const arg_def_t threads = ARG_DEF( |
| 221 "t", "threads", 1, "Max number of threads to use"); | 221 "t", "threads", 1, "Max number of threads to use"); |
| 222 static const arg_def_t profile = ARG_DEF( | 222 static const arg_def_t profile = ARG_DEF( |
| 223 NULL, "profile", 1, "Bitstream profile number to use"); | 223 NULL, "profile", 1, "Bitstream profile number to use"); |
| 224 static const arg_def_t width = ARG_DEF("w", "width", 1, "Frame width"); | 224 static const arg_def_t width = ARG_DEF("w", "width", 1, "Frame width"); |
| (...skipping 19 matching lines...) Expand all Loading... |
| 244 | 244 |
| 245 static const arg_def_t *global_args[] = { | 245 static const arg_def_t *global_args[] = { |
| 246 &use_yv12, &use_i420, &use_i422, &use_i444, &use_i440, | 246 &use_yv12, &use_i420, &use_i422, &use_i444, &use_i440, |
| 247 &usage, &threads, &profile, | 247 &usage, &threads, &profile, |
| 248 &width, &height, | 248 &width, &height, |
| 249 #if CONFIG_WEBM_IO | 249 #if CONFIG_WEBM_IO |
| 250 &stereo_mode, | 250 &stereo_mode, |
| 251 #endif | 251 #endif |
| 252 &timebase, &framerate, | 252 &timebase, &framerate, |
| 253 &error_resilient, | 253 &error_resilient, |
| 254 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 254 #if CONFIG_VP9_HIGHBITDEPTH |
| 255 &test16bitinternalarg, | 255 &test16bitinternalarg, |
| 256 #endif | 256 #endif |
| 257 &lag_in_frames, NULL | 257 &lag_in_frames, NULL |
| 258 }; | 258 }; |
| 259 | 259 |
| 260 static const arg_def_t dropframe_thresh = ARG_DEF( | 260 static const arg_def_t dropframe_thresh = ARG_DEF( |
| 261 NULL, "drop-frame", 1, "Temporal resampling threshold (buf %)"); | 261 NULL, "drop-frame", 1, "Temporal resampling threshold (buf %)"); |
| 262 static const arg_def_t resize_allowed = ARG_DEF( | 262 static const arg_def_t resize_allowed = ARG_DEF( |
| 263 NULL, "resize-allowed", 1, "Spatial resampling enabled (bool)"); | 263 NULL, "resize-allowed", 1, "Spatial resampling enabled (bool)"); |
| 264 static const arg_def_t resize_width = ARG_DEF( | 264 static const arg_def_t resize_width = ARG_DEF( |
| (...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 367 VP8E_SET_CPUUSED, VP8E_SET_ENABLEAUTOALTREF, | 367 VP8E_SET_CPUUSED, VP8E_SET_ENABLEAUTOALTREF, |
| 368 VP8E_SET_NOISE_SENSITIVITY, VP8E_SET_SHARPNESS, VP8E_SET_STATIC_THRESHOLD, | 368 VP8E_SET_NOISE_SENSITIVITY, VP8E_SET_SHARPNESS, VP8E_SET_STATIC_THRESHOLD, |
| 369 VP8E_SET_TOKEN_PARTITIONS, | 369 VP8E_SET_TOKEN_PARTITIONS, |
| 370 VP8E_SET_ARNR_MAXFRAMES, VP8E_SET_ARNR_STRENGTH, VP8E_SET_ARNR_TYPE, | 370 VP8E_SET_ARNR_MAXFRAMES, VP8E_SET_ARNR_STRENGTH, VP8E_SET_ARNR_TYPE, |
| 371 VP8E_SET_TUNING, VP8E_SET_CQ_LEVEL, VP8E_SET_MAX_INTRA_BITRATE_PCT, | 371 VP8E_SET_TUNING, VP8E_SET_CQ_LEVEL, VP8E_SET_MAX_INTRA_BITRATE_PCT, |
| 372 VP8E_SET_SCREEN_CONTENT_MODE, | 372 VP8E_SET_SCREEN_CONTENT_MODE, |
| 373 0 | 373 0 |
| 374 }; | 374 }; |
| 375 #endif | 375 #endif |
| 376 | 376 |
| 377 #if CONFIG_VP9_ENCODER | 377 #if CONFIG_VP9_ENCODER || CONFIG_VP10_ENCODER |
| 378 static const arg_def_t cpu_used_vp9 = ARG_DEF( | 378 static const arg_def_t cpu_used_vp9 = ARG_DEF( |
| 379 NULL, "cpu-used", 1, "CPU Used (-8..8)"); | 379 NULL, "cpu-used", 1, "CPU Used (-8..8)"); |
| 380 static const arg_def_t tile_cols = ARG_DEF( | 380 static const arg_def_t tile_cols = ARG_DEF( |
| 381 NULL, "tile-columns", 1, "Number of tile columns to use, log2"); | 381 NULL, "tile-columns", 1, "Number of tile columns to use, log2"); |
| 382 static const arg_def_t tile_rows = ARG_DEF( | 382 static const arg_def_t tile_rows = ARG_DEF( |
| 383 NULL, "tile-rows", 1, "Number of tile rows to use, log2"); | 383 NULL, "tile-rows", 1, "Number of tile rows to use, log2"); |
| 384 static const arg_def_t lossless = ARG_DEF( | 384 static const arg_def_t lossless = ARG_DEF( |
| 385 NULL, "lossless", 1, "Lossless mode"); | 385 NULL, "lossless", 1, "Lossless mode"); |
| 386 static const arg_def_t frame_parallel_decoding = ARG_DEF( | 386 static const arg_def_t frame_parallel_decoding = ARG_DEF( |
| 387 NULL, "frame-parallel", 1, "Enable frame parallel decodability features"); | 387 NULL, "frame-parallel", 1, "Enable frame parallel decodability features"); |
| (...skipping 24 matching lines...) Expand all Loading... |
| 412 { "bt2020", VPX_CS_BT_2020 }, | 412 { "bt2020", VPX_CS_BT_2020 }, |
| 413 { "reserved", VPX_CS_RESERVED }, | 413 { "reserved", VPX_CS_RESERVED }, |
| 414 { "sRGB", VPX_CS_SRGB }, | 414 { "sRGB", VPX_CS_SRGB }, |
| 415 { NULL, 0 } | 415 { NULL, 0 } |
| 416 }; | 416 }; |
| 417 | 417 |
| 418 static const arg_def_t input_color_space = ARG_DEF_ENUM( | 418 static const arg_def_t input_color_space = ARG_DEF_ENUM( |
| 419 NULL, "color-space", 1, | 419 NULL, "color-space", 1, |
| 420 "The color space of input content:", color_space_enum); | 420 "The color space of input content:", color_space_enum); |
| 421 | 421 |
| 422 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 422 #if CONFIG_VP9_HIGHBITDEPTH |
| 423 static const struct arg_enum_list bitdepth_enum[] = { | 423 static const struct arg_enum_list bitdepth_enum[] = { |
| 424 {"8", VPX_BITS_8}, | 424 {"8", VPX_BITS_8}, |
| 425 {"10", VPX_BITS_10}, | 425 {"10", VPX_BITS_10}, |
| 426 {"12", VPX_BITS_12}, | 426 {"12", VPX_BITS_12}, |
| 427 {NULL, 0} | 427 {NULL, 0} |
| 428 }; | 428 }; |
| 429 | 429 |
| 430 static const arg_def_t bitdeptharg = ARG_DEF_ENUM( | 430 static const arg_def_t bitdeptharg = ARG_DEF_ENUM( |
| 431 "b", "bit-depth", 1, | 431 "b", "bit-depth", 1, |
| 432 "Bit depth for codec (8 for version <=1, 10 or 12 for version 2)", | 432 "Bit depth for codec (8 for version <=1, 10 or 12 for version 2)", |
| 433 bitdepth_enum); | 433 bitdepth_enum); |
| 434 static const arg_def_t inbitdeptharg = ARG_DEF( | 434 static const arg_def_t inbitdeptharg = ARG_DEF( |
| 435 NULL, "input-bit-depth", 1, "Bit depth of input"); | 435 NULL, "input-bit-depth", 1, "Bit depth of input"); |
| 436 #endif | 436 #endif |
| 437 | 437 |
| 438 static const struct arg_enum_list tune_content_enum[] = { | 438 static const struct arg_enum_list tune_content_enum[] = { |
| 439 {"default", VP9E_CONTENT_DEFAULT}, | 439 {"default", VP9E_CONTENT_DEFAULT}, |
| 440 {"screen", VP9E_CONTENT_SCREEN}, | 440 {"screen", VP9E_CONTENT_SCREEN}, |
| 441 {NULL, 0} | 441 {NULL, 0} |
| 442 }; | 442 }; |
| 443 | 443 |
| 444 static const arg_def_t tune_content = ARG_DEF_ENUM( | 444 static const arg_def_t tune_content = ARG_DEF_ENUM( |
| 445 NULL, "tune-content", 1, "Tune content type", tune_content_enum); | 445 NULL, "tune-content", 1, "Tune content type", tune_content_enum); |
| 446 #endif |
| 446 | 447 |
| 448 #if CONFIG_VP9_ENCODER |
| 447 static const arg_def_t *vp9_args[] = { | 449 static const arg_def_t *vp9_args[] = { |
| 448 &cpu_used_vp9, &auto_altref, &sharpness, &static_thresh, | 450 &cpu_used_vp9, &auto_altref, &sharpness, &static_thresh, |
| 449 &tile_cols, &tile_rows, &arnr_maxframes, &arnr_strength, &arnr_type, | 451 &tile_cols, &tile_rows, &arnr_maxframes, &arnr_strength, &arnr_type, |
| 450 &tune_ssim, &cq_level, &max_intra_rate_pct, &max_inter_rate_pct, | 452 &tune_ssim, &cq_level, &max_intra_rate_pct, &max_inter_rate_pct, |
| 451 &gf_cbr_boost_pct, &lossless, | 453 &gf_cbr_boost_pct, &lossless, |
| 452 &frame_parallel_decoding, &aq_mode, &frame_periodic_boost, | 454 &frame_parallel_decoding, &aq_mode, &frame_periodic_boost, |
| 453 &noise_sens, &tune_content, &input_color_space, | 455 &noise_sens, &tune_content, &input_color_space, |
| 454 &min_gf_interval, &max_gf_interval, | 456 &min_gf_interval, &max_gf_interval, |
| 455 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | |
| 456 &bitdeptharg, &inbitdeptharg, | |
| 457 #endif | |
| 458 NULL | 457 NULL |
| 459 }; | 458 }; |
| 460 static const int vp9_arg_ctrl_map[] = { | 459 static const int vp9_arg_ctrl_map[] = { |
| 461 VP8E_SET_CPUUSED, VP8E_SET_ENABLEAUTOALTREF, | 460 VP8E_SET_CPUUSED, VP8E_SET_ENABLEAUTOALTREF, |
| 462 VP8E_SET_SHARPNESS, VP8E_SET_STATIC_THRESHOLD, | 461 VP8E_SET_SHARPNESS, VP8E_SET_STATIC_THRESHOLD, |
| 463 VP9E_SET_TILE_COLUMNS, VP9E_SET_TILE_ROWS, | 462 VP9E_SET_TILE_COLUMNS, VP9E_SET_TILE_ROWS, |
| 464 VP8E_SET_ARNR_MAXFRAMES, VP8E_SET_ARNR_STRENGTH, VP8E_SET_ARNR_TYPE, | 463 VP8E_SET_ARNR_MAXFRAMES, VP8E_SET_ARNR_STRENGTH, VP8E_SET_ARNR_TYPE, |
| 465 VP8E_SET_TUNING, VP8E_SET_CQ_LEVEL, VP8E_SET_MAX_INTRA_BITRATE_PCT, | 464 VP8E_SET_TUNING, VP8E_SET_CQ_LEVEL, VP8E_SET_MAX_INTRA_BITRATE_PCT, |
| 466 VP9E_SET_MAX_INTER_BITRATE_PCT, VP9E_SET_GF_CBR_BOOST_PCT, | 465 VP9E_SET_MAX_INTER_BITRATE_PCT, VP9E_SET_GF_CBR_BOOST_PCT, |
| 467 VP9E_SET_LOSSLESS, VP9E_SET_FRAME_PARALLEL_DECODING, VP9E_SET_AQ_MODE, | 466 VP9E_SET_LOSSLESS, VP9E_SET_FRAME_PARALLEL_DECODING, VP9E_SET_AQ_MODE, |
| 468 VP9E_SET_FRAME_PERIODIC_BOOST, VP9E_SET_NOISE_SENSITIVITY, | 467 VP9E_SET_FRAME_PERIODIC_BOOST, VP9E_SET_NOISE_SENSITIVITY, |
| 469 VP9E_SET_TUNE_CONTENT, VP9E_SET_COLOR_SPACE, | 468 VP9E_SET_TUNE_CONTENT, VP9E_SET_COLOR_SPACE, |
| 470 VP9E_SET_MIN_GF_INTERVAL, VP9E_SET_MAX_GF_INTERVAL, | 469 VP9E_SET_MIN_GF_INTERVAL, VP9E_SET_MAX_GF_INTERVAL, |
| 471 0 | 470 0 |
| 472 }; | 471 }; |
| 473 #endif | 472 #endif |
| 474 | 473 |
| 474 #if CONFIG_VP10_ENCODER |
| 475 static const arg_def_t *vp10_args[] = { |
| 476 &cpu_used_vp9, &auto_altref, &sharpness, &static_thresh, |
| 477 &tile_cols, &tile_rows, &arnr_maxframes, &arnr_strength, &arnr_type, |
| 478 &tune_ssim, &cq_level, &max_intra_rate_pct, &max_inter_rate_pct, |
| 479 &gf_cbr_boost_pct, &lossless, |
| 480 &frame_parallel_decoding, &aq_mode, &frame_periodic_boost, |
| 481 &noise_sens, &tune_content, &input_color_space, |
| 482 &min_gf_interval, &max_gf_interval, |
| 483 NULL |
| 484 }; |
| 485 static const int vp10_arg_ctrl_map[] = { |
| 486 VP8E_SET_CPUUSED, VP8E_SET_ENABLEAUTOALTREF, |
| 487 VP8E_SET_SHARPNESS, VP8E_SET_STATIC_THRESHOLD, |
| 488 VP9E_SET_TILE_COLUMNS, VP9E_SET_TILE_ROWS, |
| 489 VP8E_SET_ARNR_MAXFRAMES, VP8E_SET_ARNR_STRENGTH, VP8E_SET_ARNR_TYPE, |
| 490 VP8E_SET_TUNING, VP8E_SET_CQ_LEVEL, VP8E_SET_MAX_INTRA_BITRATE_PCT, |
| 491 VP9E_SET_MAX_INTER_BITRATE_PCT, VP9E_SET_GF_CBR_BOOST_PCT, |
| 492 VP9E_SET_LOSSLESS, VP9E_SET_FRAME_PARALLEL_DECODING, VP9E_SET_AQ_MODE, |
| 493 VP9E_SET_FRAME_PERIODIC_BOOST, VP9E_SET_NOISE_SENSITIVITY, |
| 494 VP9E_SET_TUNE_CONTENT, VP9E_SET_COLOR_SPACE, |
| 495 VP9E_SET_MIN_GF_INTERVAL, VP9E_SET_MAX_GF_INTERVAL, |
| 496 0 |
| 497 }; |
| 498 #endif |
| 499 |
| 475 static const arg_def_t *no_args[] = { NULL }; | 500 static const arg_def_t *no_args[] = { NULL }; |
| 476 | 501 |
| 477 void usage_exit(void) { | 502 void usage_exit(void) { |
| 478 int i; | 503 int i; |
| 479 const int num_encoder = get_vpx_encoder_count(); | 504 const int num_encoder = get_vpx_encoder_count(); |
| 480 | 505 |
| 481 fprintf(stderr, "Usage: %s <options> -o dst_filename src_filename \n", | 506 fprintf(stderr, "Usage: %s <options> -o dst_filename src_filename \n", |
| 482 exec_name); | 507 exec_name); |
| 483 | 508 |
| 484 fprintf(stderr, "\nOptions:\n"); | 509 fprintf(stderr, "\nOptions:\n"); |
| 485 arg_show_usage(stderr, main_args); | 510 arg_show_usage(stderr, main_args); |
| 486 fprintf(stderr, "\nEncoder Global Options:\n"); | 511 fprintf(stderr, "\nEncoder Global Options:\n"); |
| 487 arg_show_usage(stderr, global_args); | 512 arg_show_usage(stderr, global_args); |
| 488 fprintf(stderr, "\nRate Control Options:\n"); | 513 fprintf(stderr, "\nRate Control Options:\n"); |
| 489 arg_show_usage(stderr, rc_args); | 514 arg_show_usage(stderr, rc_args); |
| 490 fprintf(stderr, "\nTwopass Rate Control Options:\n"); | 515 fprintf(stderr, "\nTwopass Rate Control Options:\n"); |
| 491 arg_show_usage(stderr, rc_twopass_args); | 516 arg_show_usage(stderr, rc_twopass_args); |
| 492 fprintf(stderr, "\nKeyframe Placement Options:\n"); | 517 fprintf(stderr, "\nKeyframe Placement Options:\n"); |
| 493 arg_show_usage(stderr, kf_args); | 518 arg_show_usage(stderr, kf_args); |
| 494 #if CONFIG_VP8_ENCODER | 519 #if CONFIG_VP8_ENCODER |
| 495 fprintf(stderr, "\nVP8 Specific Options:\n"); | 520 fprintf(stderr, "\nVP8 Specific Options:\n"); |
| 496 arg_show_usage(stderr, vp8_args); | 521 arg_show_usage(stderr, vp8_args); |
| 497 #endif | 522 #endif |
| 498 #if CONFIG_VP9_ENCODER | 523 #if CONFIG_VP9_ENCODER |
| 499 fprintf(stderr, "\nVP9 Specific Options:\n"); | 524 fprintf(stderr, "\nVP9 Specific Options:\n"); |
| 500 arg_show_usage(stderr, vp9_args); | 525 arg_show_usage(stderr, vp9_args); |
| 501 #endif | 526 #endif |
| 527 #if CONFIG_VP10_ENCODER |
| 528 fprintf(stderr, "\nVP10 Specific Options:\n"); |
| 529 arg_show_usage(stderr, vp10_args); |
| 530 #endif |
| 502 fprintf(stderr, "\nStream timebase (--timebase):\n" | 531 fprintf(stderr, "\nStream timebase (--timebase):\n" |
| 503 " The desired precision of timestamps in the output, expressed\n" | 532 " The desired precision of timestamps in the output, expressed\n" |
| 504 " in fractional seconds. Default is 1/1000.\n"); | 533 " in fractional seconds. Default is 1/1000.\n"); |
| 505 fprintf(stderr, "\nIncluded encoders:\n\n"); | 534 fprintf(stderr, "\nIncluded encoders:\n\n"); |
| 506 | 535 |
| 507 for (i = 0; i < num_encoder; ++i) { | 536 for (i = 0; i < num_encoder; ++i) { |
| 508 const VpxInterface *const encoder = get_vpx_encoder_by_index(i); | 537 const VpxInterface *const encoder = get_vpx_encoder_by_index(i); |
| 509 const char* defstr = (i == (num_encoder - 1)) ? "(default)" : ""; | 538 const char* defstr = (i == (num_encoder - 1)) ? "(default)" : ""; |
| 510 fprintf(stderr, " %-6s - %s %s\n", | 539 fprintf(stderr, " %-6s - %s %s\n", |
| 511 encoder->name, vpx_codec_iface_name(encoder->codec_interface()), | 540 encoder->name, vpx_codec_iface_name(encoder->codec_interface()), |
| 512 defstr); | 541 defstr); |
| 513 } | 542 } |
| 514 fprintf(stderr, "\n "); | 543 fprintf(stderr, "\n "); |
| 515 fprintf(stderr, "Use --codec to switch to a non-default encoder.\n\n"); | 544 fprintf(stderr, "Use --codec to switch to a non-default encoder.\n\n"); |
| 516 | 545 |
| 517 exit(EXIT_FAILURE); | 546 exit(EXIT_FAILURE); |
| 518 } | 547 } |
| 519 | 548 |
| 520 #define mmin(a, b) ((a) < (b) ? (a) : (b)) | 549 #define mmin(a, b) ((a) < (b) ? (a) : (b)) |
| 521 | 550 |
| 522 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 551 #if CONFIG_VP9_HIGHBITDEPTH |
| 523 static void find_mismatch_high(const vpx_image_t *const img1, | 552 static void find_mismatch_high(const vpx_image_t *const img1, |
| 524 const vpx_image_t *const img2, | 553 const vpx_image_t *const img2, |
| 525 int yloc[4], int uloc[4], int vloc[4]) { | 554 int yloc[4], int uloc[4], int vloc[4]) { |
| 526 uint16_t *plane1, *plane2; | 555 uint16_t *plane1, *plane2; |
| 527 uint32_t stride1, stride2; | 556 uint32_t stride1, stride2; |
| 528 const uint32_t bsize = 64; | 557 const uint32_t bsize = 64; |
| 529 const uint32_t bsizey = bsize >> img1->y_chroma_shift; | 558 const uint32_t bsizey = bsize >> img1->y_chroma_shift; |
| 530 const uint32_t bsizex = bsize >> img1->x_chroma_shift; | 559 const uint32_t bsizex = bsize >> img1->x_chroma_shift; |
| 531 const uint32_t c_w = | 560 const uint32_t c_w = |
| 532 (img1->d_w + img1->x_chroma_shift) >> img1->x_chroma_shift; | 561 (img1->d_w + img1->x_chroma_shift) >> img1->x_chroma_shift; |
| (...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 710 uint32_t c_w = | 739 uint32_t c_w = |
| 711 (img1->d_w + img1->x_chroma_shift) >> img1->x_chroma_shift; | 740 (img1->d_w + img1->x_chroma_shift) >> img1->x_chroma_shift; |
| 712 const uint32_t c_h = | 741 const uint32_t c_h = |
| 713 (img1->d_h + img1->y_chroma_shift) >> img1->y_chroma_shift; | 742 (img1->d_h + img1->y_chroma_shift) >> img1->y_chroma_shift; |
| 714 uint32_t i; | 743 uint32_t i; |
| 715 int match = 1; | 744 int match = 1; |
| 716 | 745 |
| 717 match &= (img1->fmt == img2->fmt); | 746 match &= (img1->fmt == img2->fmt); |
| 718 match &= (img1->d_w == img2->d_w); | 747 match &= (img1->d_w == img2->d_w); |
| 719 match &= (img1->d_h == img2->d_h); | 748 match &= (img1->d_h == img2->d_h); |
| 720 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 749 #if CONFIG_VP9_HIGHBITDEPTH |
| 721 if (img1->fmt & VPX_IMG_FMT_HIGHBITDEPTH) { | 750 if (img1->fmt & VPX_IMG_FMT_HIGHBITDEPTH) { |
| 722 l_w *= 2; | 751 l_w *= 2; |
| 723 c_w *= 2; | 752 c_w *= 2; |
| 724 } | 753 } |
| 725 #endif | 754 #endif |
| 726 | 755 |
| 727 for (i = 0; i < img1->d_h; ++i) | 756 for (i = 0; i < img1->d_h; ++i) |
| 728 match &= (memcmp(img1->planes[VPX_PLANE_Y] + i * img1->stride[VPX_PLANE_Y], | 757 match &= (memcmp(img1->planes[VPX_PLANE_Y] + i * img1->stride[VPX_PLANE_Y], |
| 729 img2->planes[VPX_PLANE_Y] + i * img2->stride[VPX_PLANE_Y], | 758 img2->planes[VPX_PLANE_Y] + i * img2->stride[VPX_PLANE_Y], |
| 730 l_w) == 0); | 759 l_w) == 0); |
| 731 | 760 |
| 732 for (i = 0; i < c_h; ++i) | 761 for (i = 0; i < c_h; ++i) |
| 733 match &= (memcmp(img1->planes[VPX_PLANE_U] + i * img1->stride[VPX_PLANE_U], | 762 match &= (memcmp(img1->planes[VPX_PLANE_U] + i * img1->stride[VPX_PLANE_U], |
| 734 img2->planes[VPX_PLANE_U] + i * img2->stride[VPX_PLANE_U], | 763 img2->planes[VPX_PLANE_U] + i * img2->stride[VPX_PLANE_U], |
| 735 c_w) == 0); | 764 c_w) == 0); |
| 736 | 765 |
| 737 for (i = 0; i < c_h; ++i) | 766 for (i = 0; i < c_h; ++i) |
| 738 match &= (memcmp(img1->planes[VPX_PLANE_V] + i * img1->stride[VPX_PLANE_V], | 767 match &= (memcmp(img1->planes[VPX_PLANE_V] + i * img1->stride[VPX_PLANE_V], |
| 739 img2->planes[VPX_PLANE_V] + i * img2->stride[VPX_PLANE_V], | 768 img2->planes[VPX_PLANE_V] + i * img2->stride[VPX_PLANE_V], |
| 740 c_w) == 0); | 769 c_w) == 0); |
| 741 | 770 |
| 742 return match; | 771 return match; |
| 743 } | 772 } |
| 744 | 773 |
| 745 | 774 |
| 746 #define NELEMENTS(x) (sizeof(x)/sizeof(x[0])) | 775 #define NELEMENTS(x) (sizeof(x)/sizeof(x[0])) |
| 747 #define MAX(x,y) ((x)>(y)?(x):(y)) | 776 #if CONFIG_VP10_ENCODER |
| 748 #if CONFIG_VP8_ENCODER && !CONFIG_VP9_ENCODER | 777 #define ARG_CTRL_CNT_MAX NELEMENTS(vp10_arg_ctrl_map) |
| 749 #define ARG_CTRL_CNT_MAX NELEMENTS(vp8_arg_ctrl_map) | 778 #elif CONFIG_VP9_ENCODER |
| 750 #elif !CONFIG_VP8_ENCODER && CONFIG_VP9_ENCODER | |
| 751 #define ARG_CTRL_CNT_MAX NELEMENTS(vp9_arg_ctrl_map) | 779 #define ARG_CTRL_CNT_MAX NELEMENTS(vp9_arg_ctrl_map) |
| 752 #else | 780 #else |
| 753 #define ARG_CTRL_CNT_MAX MAX(NELEMENTS(vp8_arg_ctrl_map), \ | 781 #define ARG_CTRL_CNT_MAX NELEMENTS(vp8_arg_ctrl_map) |
| 754 NELEMENTS(vp9_arg_ctrl_map)) | |
| 755 #endif | 782 #endif |
| 756 | 783 |
| 757 #if !CONFIG_WEBM_IO | 784 #if !CONFIG_WEBM_IO |
| 758 typedef int stereo_format_t; | 785 typedef int stereo_format_t; |
| 759 struct EbmlGlobal { int debug; }; | 786 struct EbmlGlobal { int debug; }; |
| 760 #endif | 787 #endif |
| 761 | 788 |
| 762 /* Per-stream configuration */ | 789 /* Per-stream configuration */ |
| 763 struct stream_config { | 790 struct stream_config { |
| 764 struct vpx_codec_enc_cfg cfg; | 791 struct vpx_codec_enc_cfg cfg; |
| 765 const char *out_fn; | 792 const char *out_fn; |
| 766 const char *stats_fn; | 793 const char *stats_fn; |
| 767 #if CONFIG_FP_MB_STATS | 794 #if CONFIG_FP_MB_STATS |
| 768 const char *fpmb_stats_fn; | 795 const char *fpmb_stats_fn; |
| 769 #endif | 796 #endif |
| 770 stereo_format_t stereo_fmt; | 797 stereo_format_t stereo_fmt; |
| 771 int arg_ctrls[ARG_CTRL_CNT_MAX][2]; | 798 int arg_ctrls[ARG_CTRL_CNT_MAX][2]; |
| 772 int arg_ctrl_cnt; | 799 int arg_ctrl_cnt; |
| 773 int write_webm; | 800 int write_webm; |
| 774 int have_kf_max_dist; | 801 int have_kf_max_dist; |
| 775 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 802 #if CONFIG_VP9_HIGHBITDEPTH |
| 776 // whether to use 16bit internal buffers | 803 // whether to use 16bit internal buffers |
| 777 int use_16bit_internal; | 804 int use_16bit_internal; |
| 778 #endif | 805 #endif |
| 779 }; | 806 }; |
| 780 | 807 |
| 781 | 808 |
| 782 struct stream_state { | 809 struct stream_state { |
| 783 int index; | 810 int index; |
| 784 struct stream_state *next; | 811 struct stream_state *next; |
| 785 struct stream_config config; | 812 struct stream_config config; |
| (...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 909 if (global->pass) { | 936 if (global->pass) { |
| 910 /* DWIM: Assume the user meant passes=2 if pass=2 is specified */ | 937 /* DWIM: Assume the user meant passes=2 if pass=2 is specified */ |
| 911 if (global->pass > global->passes) { | 938 if (global->pass > global->passes) { |
| 912 warn("Assuming --pass=%d implies --passes=%d\n", | 939 warn("Assuming --pass=%d implies --passes=%d\n", |
| 913 global->pass, global->pass); | 940 global->pass, global->pass); |
| 914 global->passes = global->pass; | 941 global->passes = global->pass; |
| 915 } | 942 } |
| 916 } | 943 } |
| 917 /* Validate global config */ | 944 /* Validate global config */ |
| 918 if (global->passes == 0) { | 945 if (global->passes == 0) { |
| 919 #if CONFIG_VP9_ENCODER | 946 #if CONFIG_VP9_ENCODER || CONFIG_VP10_ENCODER |
| 920 // Make default VP9 passes = 2 until there is a better quality 1-pass | 947 // Make default VP9 passes = 2 until there is a better quality 1-pass |
| 921 // encoder | 948 // encoder |
| 922 if (global->codec != NULL && global->codec->name != NULL) | 949 if (global->codec != NULL && global->codec->name != NULL) |
| 923 global->passes = (strcmp(global->codec->name, "vp9") == 0 && | 950 global->passes = (strcmp(global->codec->name, "vp9") == 0 && |
| 924 global->deadline != VPX_DL_REALTIME) ? 2 : 1; | 951 global->deadline != VPX_DL_REALTIME) ? 2 : 1; |
| 925 #else | 952 #else |
| 926 global->passes = 1; | 953 global->passes = 1; |
| 927 #endif | 954 #endif |
| 928 } | 955 } |
| 929 | 956 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1051 | 1078 |
| 1052 static int parse_stream_params(struct VpxEncoderConfig *global, | 1079 static int parse_stream_params(struct VpxEncoderConfig *global, |
| 1053 struct stream_state *stream, | 1080 struct stream_state *stream, |
| 1054 char **argv) { | 1081 char **argv) { |
| 1055 char **argi, **argj; | 1082 char **argi, **argj; |
| 1056 struct arg arg; | 1083 struct arg arg; |
| 1057 static const arg_def_t **ctrl_args = no_args; | 1084 static const arg_def_t **ctrl_args = no_args; |
| 1058 static const int *ctrl_args_map = NULL; | 1085 static const int *ctrl_args_map = NULL; |
| 1059 struct stream_config *config = &stream->config; | 1086 struct stream_config *config = &stream->config; |
| 1060 int eos_mark_found = 0; | 1087 int eos_mark_found = 0; |
| 1061 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 1088 #if CONFIG_VP9_HIGHBITDEPTH |
| 1062 int test_16bit_internal = 0; | 1089 int test_16bit_internal = 0; |
| 1063 #endif | 1090 #endif |
| 1064 | 1091 |
| 1065 // Handle codec specific options | 1092 // Handle codec specific options |
| 1066 if (0) { | 1093 if (0) { |
| 1067 #if CONFIG_VP8_ENCODER | 1094 #if CONFIG_VP8_ENCODER |
| 1068 } else if (strcmp(global->codec->name, "vp8") == 0) { | 1095 } else if (strcmp(global->codec->name, "vp8") == 0) { |
| 1069 ctrl_args = vp8_args; | 1096 ctrl_args = vp8_args; |
| 1070 ctrl_args_map = vp8_arg_ctrl_map; | 1097 ctrl_args_map = vp8_arg_ctrl_map; |
| 1071 #endif | 1098 #endif |
| 1072 #if CONFIG_VP9_ENCODER | 1099 #if CONFIG_VP9_ENCODER |
| 1073 } else if (strcmp(global->codec->name, "vp9") == 0) { | 1100 } else if (strcmp(global->codec->name, "vp9") == 0) { |
| 1074 ctrl_args = vp9_args; | 1101 ctrl_args = vp9_args; |
| 1075 ctrl_args_map = vp9_arg_ctrl_map; | 1102 ctrl_args_map = vp9_arg_ctrl_map; |
| 1076 #endif | 1103 #endif |
| 1104 #if CONFIG_VP10_ENCODER |
| 1105 } else if (strcmp(global->codec->name, "vp10") == 0) { |
| 1106 // TODO(jingning): Reuse VP9 specific encoder configuration parameters. |
| 1107 // Consider to expand this set for VP10 encoder control. |
| 1108 ctrl_args = vp10_args; |
| 1109 ctrl_args_map = vp10_arg_ctrl_map; |
| 1110 #endif |
| 1077 } | 1111 } |
| 1078 | 1112 |
| 1079 for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step) { | 1113 for (argi = argj = argv; (*argj = *argi); argi += arg.argv_step) { |
| 1080 arg.argv_step = 1; | 1114 arg.argv_step = 1; |
| 1081 | 1115 |
| 1082 /* Once we've found an end-of-stream marker (--) we want to continue | 1116 /* Once we've found an end-of-stream marker (--) we want to continue |
| 1083 * shifting arguments but not consuming them. | 1117 * shifting arguments but not consuming them. |
| 1084 */ | 1118 */ |
| 1085 if (eos_mark_found) { | 1119 if (eos_mark_found) { |
| 1086 argj++; | 1120 argj++; |
| (...skipping 20 matching lines...) Expand all Loading... |
| 1107 } else if (arg_match(&arg, &use_ivf, argi)) { | 1141 } else if (arg_match(&arg, &use_ivf, argi)) { |
| 1108 config->write_webm = 0; | 1142 config->write_webm = 0; |
| 1109 } else if (arg_match(&arg, &threads, argi)) { | 1143 } else if (arg_match(&arg, &threads, argi)) { |
| 1110 config->cfg.g_threads = arg_parse_uint(&arg); | 1144 config->cfg.g_threads = arg_parse_uint(&arg); |
| 1111 } else if (arg_match(&arg, &profile, argi)) { | 1145 } else if (arg_match(&arg, &profile, argi)) { |
| 1112 config->cfg.g_profile = arg_parse_uint(&arg); | 1146 config->cfg.g_profile = arg_parse_uint(&arg); |
| 1113 } else if (arg_match(&arg, &width, argi)) { | 1147 } else if (arg_match(&arg, &width, argi)) { |
| 1114 config->cfg.g_w = arg_parse_uint(&arg); | 1148 config->cfg.g_w = arg_parse_uint(&arg); |
| 1115 } else if (arg_match(&arg, &height, argi)) { | 1149 } else if (arg_match(&arg, &height, argi)) { |
| 1116 config->cfg.g_h = arg_parse_uint(&arg); | 1150 config->cfg.g_h = arg_parse_uint(&arg); |
| 1117 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 1151 #if CONFIG_VP9_HIGHBITDEPTH |
| 1118 } else if (arg_match(&arg, &bitdeptharg, argi)) { | 1152 } else if (arg_match(&arg, &bitdeptharg, argi)) { |
| 1119 config->cfg.g_bit_depth = arg_parse_enum_or_int(&arg); | 1153 config->cfg.g_bit_depth = arg_parse_enum_or_int(&arg); |
| 1120 } else if (arg_match(&arg, &inbitdeptharg, argi)) { | 1154 } else if (arg_match(&arg, &inbitdeptharg, argi)) { |
| 1121 config->cfg.g_input_bit_depth = arg_parse_uint(&arg); | 1155 config->cfg.g_input_bit_depth = arg_parse_uint(&arg); |
| 1122 #endif | 1156 #endif |
| 1123 #if CONFIG_WEBM_IO | 1157 #if CONFIG_WEBM_IO |
| 1124 } else if (arg_match(&arg, &stereo_mode, argi)) { | 1158 } else if (arg_match(&arg, &stereo_mode, argi)) { |
| 1125 config->stereo_fmt = arg_parse_enum_or_int(&arg); | 1159 config->stereo_fmt = arg_parse_enum_or_int(&arg); |
| 1126 #endif | 1160 #endif |
| 1127 } else if (arg_match(&arg, &timebase, argi)) { | 1161 } else if (arg_match(&arg, &timebase, argi)) { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1180 | 1214 |
| 1181 if (global->passes < 2) | 1215 if (global->passes < 2) |
| 1182 warn("option %s ignored in one-pass mode.\n", arg.name); | 1216 warn("option %s ignored in one-pass mode.\n", arg.name); |
| 1183 } else if (arg_match(&arg, &kf_min_dist, argi)) { | 1217 } else if (arg_match(&arg, &kf_min_dist, argi)) { |
| 1184 config->cfg.kf_min_dist = arg_parse_uint(&arg); | 1218 config->cfg.kf_min_dist = arg_parse_uint(&arg); |
| 1185 } else if (arg_match(&arg, &kf_max_dist, argi)) { | 1219 } else if (arg_match(&arg, &kf_max_dist, argi)) { |
| 1186 config->cfg.kf_max_dist = arg_parse_uint(&arg); | 1220 config->cfg.kf_max_dist = arg_parse_uint(&arg); |
| 1187 config->have_kf_max_dist = 1; | 1221 config->have_kf_max_dist = 1; |
| 1188 } else if (arg_match(&arg, &kf_disabled, argi)) { | 1222 } else if (arg_match(&arg, &kf_disabled, argi)) { |
| 1189 config->cfg.kf_mode = VPX_KF_DISABLED; | 1223 config->cfg.kf_mode = VPX_KF_DISABLED; |
| 1190 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 1224 #if CONFIG_VP9_HIGHBITDEPTH |
| 1191 } else if (arg_match(&arg, &test16bitinternalarg, argi)) { | 1225 } else if (arg_match(&arg, &test16bitinternalarg, argi)) { |
| 1192 if (strcmp(global->codec->name, "vp9") == 0) { | 1226 if (strcmp(global->codec->name, "vp9") == 0 || |
| 1227 strcmp(global->codec->name, "vp10") == 0) { |
| 1193 test_16bit_internal = 1; | 1228 test_16bit_internal = 1; |
| 1194 } | 1229 } |
| 1195 #endif | 1230 #endif |
| 1196 } else { | 1231 } else { |
| 1197 int i, match = 0; | 1232 int i, match = 0; |
| 1198 for (i = 0; ctrl_args[i]; i++) { | 1233 for (i = 0; ctrl_args[i]; i++) { |
| 1199 if (arg_match(&arg, ctrl_args[i], argi)) { | 1234 if (arg_match(&arg, ctrl_args[i], argi)) { |
| 1200 int j; | 1235 int j; |
| 1201 match = 1; | 1236 match = 1; |
| 1202 | 1237 |
| (...skipping 12 matching lines...) Expand all Loading... |
| 1215 config->arg_ctrls[j][1] = arg_parse_enum_or_int(&arg); | 1250 config->arg_ctrls[j][1] = arg_parse_enum_or_int(&arg); |
| 1216 if (j == config->arg_ctrl_cnt) | 1251 if (j == config->arg_ctrl_cnt) |
| 1217 config->arg_ctrl_cnt++; | 1252 config->arg_ctrl_cnt++; |
| 1218 } | 1253 } |
| 1219 } | 1254 } |
| 1220 } | 1255 } |
| 1221 if (!match) | 1256 if (!match) |
| 1222 argj++; | 1257 argj++; |
| 1223 } | 1258 } |
| 1224 } | 1259 } |
| 1225 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 1260 #if CONFIG_VP9_HIGHBITDEPTH |
| 1226 if (strcmp(global->codec->name, "vp9") == 0) { | 1261 if (strcmp(global->codec->name, "vp9") == 0 || |
| 1262 strcmp(global->codec->name, "vp10") == 0) { |
| 1227 config->use_16bit_internal = test_16bit_internal | | 1263 config->use_16bit_internal = test_16bit_internal | |
| 1228 (config->cfg.g_profile > 1); | 1264 (config->cfg.g_profile > 1); |
| 1229 } | 1265 } |
| 1230 #endif | 1266 #endif |
| 1231 return eos_mark_found; | 1267 return eos_mark_found; |
| 1232 } | 1268 } |
| 1233 | 1269 |
| 1234 | 1270 |
| 1235 #define FOREACH_STREAM(func) \ | 1271 #define FOREACH_STREAM(func) \ |
| 1236 do { \ | 1272 do { \ |
| (...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1500 } | 1536 } |
| 1501 | 1537 |
| 1502 | 1538 |
| 1503 static void initialize_encoder(struct stream_state *stream, | 1539 static void initialize_encoder(struct stream_state *stream, |
| 1504 struct VpxEncoderConfig *global) { | 1540 struct VpxEncoderConfig *global) { |
| 1505 int i; | 1541 int i; |
| 1506 int flags = 0; | 1542 int flags = 0; |
| 1507 | 1543 |
| 1508 flags |= global->show_psnr ? VPX_CODEC_USE_PSNR : 0; | 1544 flags |= global->show_psnr ? VPX_CODEC_USE_PSNR : 0; |
| 1509 flags |= global->out_part ? VPX_CODEC_USE_OUTPUT_PARTITION : 0; | 1545 flags |= global->out_part ? VPX_CODEC_USE_OUTPUT_PARTITION : 0; |
| 1510 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 1546 #if CONFIG_VP9_HIGHBITDEPTH |
| 1511 flags |= stream->config.use_16bit_internal ? VPX_CODEC_USE_HIGHBITDEPTH : 0; | 1547 flags |= stream->config.use_16bit_internal ? VPX_CODEC_USE_HIGHBITDEPTH : 0; |
| 1512 #endif | 1548 #endif |
| 1513 | 1549 |
| 1514 /* Construct Encoder Context */ | 1550 /* Construct Encoder Context */ |
| 1515 vpx_codec_enc_init(&stream->encoder, global->codec->codec_interface(), | 1551 vpx_codec_enc_init(&stream->encoder, global->codec->codec_interface(), |
| 1516 &stream->config.cfg, flags); | 1552 &stream->config.cfg, flags); |
| 1517 ctx_exit_on_error(&stream->encoder, "Failed to initialize encoder"); | 1553 ctx_exit_on_error(&stream->encoder, "Failed to initialize encoder"); |
| 1518 | 1554 |
| 1519 /* Note that we bypass the vpx_codec_control wrapper macro because | 1555 /* Note that we bypass the vpx_codec_control wrapper macro because |
| 1520 * we're being clever to store the control IDs in an array. Real | 1556 * we're being clever to store the control IDs in an array. Real |
| (...skipping 27 matching lines...) Expand all Loading... |
| 1548 struct vpx_usec_timer timer; | 1584 struct vpx_usec_timer timer; |
| 1549 | 1585 |
| 1550 frame_start = (cfg->g_timebase.den * (int64_t)(frames_in - 1) | 1586 frame_start = (cfg->g_timebase.den * (int64_t)(frames_in - 1) |
| 1551 * global->framerate.den) | 1587 * global->framerate.den) |
| 1552 / cfg->g_timebase.num / global->framerate.num; | 1588 / cfg->g_timebase.num / global->framerate.num; |
| 1553 next_frame_start = (cfg->g_timebase.den * (int64_t)(frames_in) | 1589 next_frame_start = (cfg->g_timebase.den * (int64_t)(frames_in) |
| 1554 * global->framerate.den) | 1590 * global->framerate.den) |
| 1555 / cfg->g_timebase.num / global->framerate.num; | 1591 / cfg->g_timebase.num / global->framerate.num; |
| 1556 | 1592 |
| 1557 /* Scale if necessary */ | 1593 /* Scale if necessary */ |
| 1558 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 1594 #if CONFIG_VP9_HIGHBITDEPTH |
| 1559 if (img) { | 1595 if (img) { |
| 1560 if ((img->fmt & VPX_IMG_FMT_HIGHBITDEPTH) && | 1596 if ((img->fmt & VPX_IMG_FMT_HIGHBITDEPTH) && |
| 1561 (img->d_w != cfg->g_w || img->d_h != cfg->g_h)) { | 1597 (img->d_w != cfg->g_w || img->d_h != cfg->g_h)) { |
| 1562 if (img->fmt != VPX_IMG_FMT_I42016) { | 1598 if (img->fmt != VPX_IMG_FMT_I42016) { |
| 1563 fprintf(stderr, "%s can only scale 4:2:0 inputs\n", exec_name); | 1599 fprintf(stderr, "%s can only scale 4:2:0 inputs\n", exec_name); |
| 1564 exit(EXIT_FAILURE); | 1600 exit(EXIT_FAILURE); |
| 1565 } | 1601 } |
| 1566 #if CONFIG_LIBYUV | 1602 #if CONFIG_LIBYUV |
| 1567 if (!stream->img) { | 1603 if (!stream->img) { |
| 1568 stream->img = vpx_img_alloc(NULL, VPX_IMG_FMT_I42016, | 1604 stream->img = vpx_img_alloc(NULL, VPX_IMG_FMT_I42016, |
| (...skipping 230 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1799 vpx_codec_control(&stream->decoder, VP8_COPY_REFERENCE, &ref_dec); | 1835 vpx_codec_control(&stream->decoder, VP8_COPY_REFERENCE, &ref_dec); |
| 1800 } else { | 1836 } else { |
| 1801 struct vp9_ref_frame ref_enc, ref_dec; | 1837 struct vp9_ref_frame ref_enc, ref_dec; |
| 1802 | 1838 |
| 1803 ref_enc.idx = 0; | 1839 ref_enc.idx = 0; |
| 1804 ref_dec.idx = 0; | 1840 ref_dec.idx = 0; |
| 1805 vpx_codec_control(&stream->encoder, VP9_GET_REFERENCE, &ref_enc); | 1841 vpx_codec_control(&stream->encoder, VP9_GET_REFERENCE, &ref_enc); |
| 1806 enc_img = ref_enc.img; | 1842 enc_img = ref_enc.img; |
| 1807 vpx_codec_control(&stream->decoder, VP9_GET_REFERENCE, &ref_dec); | 1843 vpx_codec_control(&stream->decoder, VP9_GET_REFERENCE, &ref_dec); |
| 1808 dec_img = ref_dec.img; | 1844 dec_img = ref_dec.img; |
| 1809 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 1845 #if CONFIG_VP9_HIGHBITDEPTH |
| 1810 if ((enc_img.fmt & VPX_IMG_FMT_HIGHBITDEPTH) != | 1846 if ((enc_img.fmt & VPX_IMG_FMT_HIGHBITDEPTH) != |
| 1811 (dec_img.fmt & VPX_IMG_FMT_HIGHBITDEPTH)) { | 1847 (dec_img.fmt & VPX_IMG_FMT_HIGHBITDEPTH)) { |
| 1812 if (enc_img.fmt & VPX_IMG_FMT_HIGHBITDEPTH) { | 1848 if (enc_img.fmt & VPX_IMG_FMT_HIGHBITDEPTH) { |
| 1813 vpx_img_alloc(&enc_img, enc_img.fmt - VPX_IMG_FMT_HIGHBITDEPTH, | 1849 vpx_img_alloc(&enc_img, enc_img.fmt - VPX_IMG_FMT_HIGHBITDEPTH, |
| 1814 enc_img.d_w, enc_img.d_h, 16); | 1850 enc_img.d_w, enc_img.d_h, 16); |
| 1815 vpx_img_truncate_16_to_8(&enc_img, &ref_enc.img); | 1851 vpx_img_truncate_16_to_8(&enc_img, &ref_enc.img); |
| 1816 } | 1852 } |
| 1817 if (dec_img.fmt & VPX_IMG_FMT_HIGHBITDEPTH) { | 1853 if (dec_img.fmt & VPX_IMG_FMT_HIGHBITDEPTH) { |
| 1818 vpx_img_alloc(&dec_img, dec_img.fmt - VPX_IMG_FMT_HIGHBITDEPTH, | 1854 vpx_img_alloc(&dec_img, dec_img.fmt - VPX_IMG_FMT_HIGHBITDEPTH, |
| 1819 dec_img.d_w, dec_img.d_h, 16); | 1855 dec_img.d_w, dec_img.d_h, 16); |
| 1820 vpx_img_truncate_16_to_8(&dec_img, &ref_dec.img); | 1856 vpx_img_truncate_16_to_8(&dec_img, &ref_dec.img); |
| 1821 } | 1857 } |
| 1822 } | 1858 } |
| 1823 #endif | 1859 #endif |
| 1824 } | 1860 } |
| 1825 ctx_exit_on_error(&stream->encoder, "Failed to get encoder reference frame"); | 1861 ctx_exit_on_error(&stream->encoder, "Failed to get encoder reference frame"); |
| 1826 ctx_exit_on_error(&stream->decoder, "Failed to get decoder reference frame"); | 1862 ctx_exit_on_error(&stream->decoder, "Failed to get decoder reference frame"); |
| 1827 | 1863 |
| 1828 if (!compare_img(&enc_img, &dec_img)) { | 1864 if (!compare_img(&enc_img, &dec_img)) { |
| 1829 int y[4], u[4], v[4]; | 1865 int y[4], u[4], v[4]; |
| 1830 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 1866 #if CONFIG_VP9_HIGHBITDEPTH |
| 1831 if (enc_img.fmt & VPX_IMG_FMT_HIGHBITDEPTH) { | 1867 if (enc_img.fmt & VPX_IMG_FMT_HIGHBITDEPTH) { |
| 1832 find_mismatch_high(&enc_img, &dec_img, y, u, v); | 1868 find_mismatch_high(&enc_img, &dec_img, y, u, v); |
| 1833 } else { | 1869 } else { |
| 1834 find_mismatch(&enc_img, &dec_img, y, u, v); | 1870 find_mismatch(&enc_img, &dec_img, y, u, v); |
| 1835 } | 1871 } |
| 1836 #else | 1872 #else |
| 1837 find_mismatch(&enc_img, &dec_img, y, u, v); | 1873 find_mismatch(&enc_img, &dec_img, y, u, v); |
| 1838 #endif | 1874 #endif |
| 1839 stream->decoder.err = 1; | 1875 stream->decoder.err = 1; |
| 1840 warn_or_exit_on_error(&stream->decoder, fatal == TEST_DECODE_FATAL, | 1876 warn_or_exit_on_error(&stream->decoder, fatal == TEST_DECODE_FATAL, |
| (...skipping 29 matching lines...) Expand all Loading... |
| 1870 label, hours, mins, secs); | 1906 label, hours, mins, secs); |
| 1871 } else { | 1907 } else { |
| 1872 fprintf(stderr, "[%3s unknown] ", label); | 1908 fprintf(stderr, "[%3s unknown] ", label); |
| 1873 } | 1909 } |
| 1874 } | 1910 } |
| 1875 | 1911 |
| 1876 | 1912 |
| 1877 int main(int argc, const char **argv_) { | 1913 int main(int argc, const char **argv_) { |
| 1878 int pass; | 1914 int pass; |
| 1879 vpx_image_t raw; | 1915 vpx_image_t raw; |
| 1880 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 1916 #if CONFIG_VP9_HIGHBITDEPTH |
| 1881 vpx_image_t raw_shift; | 1917 vpx_image_t raw_shift; |
| 1882 int allocated_raw_shift = 0; | 1918 int allocated_raw_shift = 0; |
| 1883 int use_16bit_internal = 0; | 1919 int use_16bit_internal = 0; |
| 1884 int input_shift = 0; | 1920 int input_shift = 0; |
| 1885 #endif | 1921 #endif |
| 1886 int frame_avail, got_data; | 1922 int frame_avail, got_data; |
| 1887 | 1923 |
| 1888 struct VpxInputContext input; | 1924 struct VpxInputContext input; |
| 1889 struct VpxEncoderConfig global; | 1925 struct VpxEncoderConfig global; |
| 1890 struct stream_state *streams = NULL; | 1926 struct stream_state *streams = NULL; |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2056 FOREACH_STREAM(stream->rate_hist = | 2092 FOREACH_STREAM(stream->rate_hist = |
| 2057 init_rate_histogram(&stream->config.cfg, | 2093 init_rate_histogram(&stream->config.cfg, |
| 2058 &global.framerate)); | 2094 &global.framerate)); |
| 2059 } | 2095 } |
| 2060 | 2096 |
| 2061 FOREACH_STREAM(setup_pass(stream, &global, pass)); | 2097 FOREACH_STREAM(setup_pass(stream, &global, pass)); |
| 2062 FOREACH_STREAM(open_output_file(stream, &global, | 2098 FOREACH_STREAM(open_output_file(stream, &global, |
| 2063 &input.pixel_aspect_ratio)); | 2099 &input.pixel_aspect_ratio)); |
| 2064 FOREACH_STREAM(initialize_encoder(stream, &global)); | 2100 FOREACH_STREAM(initialize_encoder(stream, &global)); |
| 2065 | 2101 |
| 2066 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 2102 #if CONFIG_VP9_HIGHBITDEPTH |
| 2067 if (strcmp(global.codec->name, "vp9") == 0) { | 2103 if (strcmp(global.codec->name, "vp9") == 0 || |
| 2104 strcmp(global.codec->name, "vp10") == 0) { |
| 2068 // Check to see if at least one stream uses 16 bit internal. | 2105 // Check to see if at least one stream uses 16 bit internal. |
| 2069 // Currently assume that the bit_depths for all streams using | 2106 // Currently assume that the bit_depths for all streams using |
| 2070 // highbitdepth are the same. | 2107 // highbitdepth are the same. |
| 2071 FOREACH_STREAM({ | 2108 FOREACH_STREAM({ |
| 2072 if (stream->config.use_16bit_internal) { | 2109 if (stream->config.use_16bit_internal) { |
| 2073 use_16bit_internal = 1; | 2110 use_16bit_internal = 1; |
| 2074 } | 2111 } |
| 2075 if (stream->config.cfg.g_profile == 0) { | 2112 if (stream->config.cfg.g_profile == 0) { |
| 2076 input_shift = 0; | 2113 input_shift = 0; |
| 2077 } else { | 2114 } else { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2112 cx_time > 9999999 ? "ms" : "us", | 2149 cx_time > 9999999 ? "ms" : "us", |
| 2113 fps >= 1.0 ? fps : fps * 60, | 2150 fps >= 1.0 ? fps : fps * 60, |
| 2114 fps >= 1.0 ? "fps" : "fpm"); | 2151 fps >= 1.0 ? "fps" : "fpm"); |
| 2115 print_time("ETA", estimated_time_left); | 2152 print_time("ETA", estimated_time_left); |
| 2116 } | 2153 } |
| 2117 | 2154 |
| 2118 } else | 2155 } else |
| 2119 frame_avail = 0; | 2156 frame_avail = 0; |
| 2120 | 2157 |
| 2121 if (frames_in > global.skip_frames) { | 2158 if (frames_in > global.skip_frames) { |
| 2122 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 2159 #if CONFIG_VP9_HIGHBITDEPTH |
| 2123 vpx_image_t *frame_to_encode; | 2160 vpx_image_t *frame_to_encode; |
| 2124 if (input_shift || (use_16bit_internal && input.bit_depth == 8)) { | 2161 if (input_shift || (use_16bit_internal && input.bit_depth == 8)) { |
| 2125 assert(use_16bit_internal); | 2162 assert(use_16bit_internal); |
| 2126 // Input bit depth and stream bit depth do not match, so up | 2163 // Input bit depth and stream bit depth do not match, so up |
| 2127 // shift frame to stream bit depth | 2164 // shift frame to stream bit depth |
| 2128 if (!allocated_raw_shift) { | 2165 if (!allocated_raw_shift) { |
| 2129 vpx_img_alloc(&raw_shift, raw.fmt | VPX_IMG_FMT_HIGHBITDEPTH, | 2166 vpx_img_alloc(&raw_shift, raw.fmt | VPX_IMG_FMT_HIGHBITDEPTH, |
| 2130 input.width, input.height, 32); | 2167 input.width, input.height, 32); |
| 2131 allocated_raw_shift = 1; | 2168 allocated_raw_shift = 1; |
| 2132 } | 2169 } |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2273 if (stream->mismatch_seen) { | 2310 if (stream->mismatch_seen) { |
| 2274 fprintf(f, "First mismatch occurred in frame %d\n", | 2311 fprintf(f, "First mismatch occurred in frame %d\n", |
| 2275 stream->mismatch_seen); | 2312 stream->mismatch_seen); |
| 2276 } else { | 2313 } else { |
| 2277 fprintf(f, "No mismatch detected in recon buffers\n"); | 2314 fprintf(f, "No mismatch detected in recon buffers\n"); |
| 2278 } | 2315 } |
| 2279 fclose(f); | 2316 fclose(f); |
| 2280 }); | 2317 }); |
| 2281 #endif | 2318 #endif |
| 2282 | 2319 |
| 2283 #if CONFIG_VP9 && CONFIG_VP9_HIGHBITDEPTH | 2320 #if CONFIG_VP9_HIGHBITDEPTH |
| 2284 if (allocated_raw_shift) | 2321 if (allocated_raw_shift) |
| 2285 vpx_img_free(&raw_shift); | 2322 vpx_img_free(&raw_shift); |
| 2286 #endif | 2323 #endif |
| 2287 vpx_img_free(&raw); | 2324 vpx_img_free(&raw); |
| 2288 free(argv); | 2325 free(argv); |
| 2289 free(streams); | 2326 free(streams); |
| 2290 return res ? EXIT_FAILURE : EXIT_SUCCESS; | 2327 return res ? EXIT_FAILURE : EXIT_SUCCESS; |
| 2291 } | 2328 } |
| OLD | NEW |