| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2012 The WebRTC 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 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 198 config->output_filename.c_str()); | 198 config->output_filename.c_str()); |
| 199 return 4; | 199 return 4; |
| 200 } | 200 } |
| 201 fclose(test_file); | 201 fclose(test_file); |
| 202 | 202 |
| 203 // Check single core flag. | 203 // Check single core flag. |
| 204 config->use_single_core = FLAGS_use_single_core; | 204 config->use_single_core = FLAGS_use_single_core; |
| 205 | 205 |
| 206 // Get codec specific configuration. | 206 // Get codec specific configuration. |
| 207 webrtc::VideoCodingModule::Codec(webrtc::kVideoCodecVP8, | 207 webrtc::VideoCodingModule::Codec(webrtc::kVideoCodecVP8, |
| 208 config->codec_settings); | 208 &config->codec_settings); |
| 209 | 209 |
| 210 // Check the temporal layers. | 210 // Check the temporal layers. |
| 211 if (FLAGS_temporal_layers < 0 || | 211 if (FLAGS_temporal_layers < 0 || |
| 212 FLAGS_temporal_layers > webrtc::kMaxTemporalStreams) { | 212 FLAGS_temporal_layers > webrtc::kMaxTemporalStreams) { |
| 213 fprintf(stderr, "Temporal layers number must be 0-4, was: %d\n", | 213 fprintf(stderr, "Temporal layers number must be 0-4, was: %d\n", |
| 214 FLAGS_temporal_layers); | 214 FLAGS_temporal_layers); |
| 215 return 13; | 215 return 13; |
| 216 } | 216 } |
| 217 config->codec_settings->VP8()->numberOfTemporalLayers = FLAGS_temporal_layers; | 217 config->codec_settings.VP8()->numberOfTemporalLayers = FLAGS_temporal_layers; |
| 218 | 218 |
| 219 // Check the bit rate. | 219 // Check the bit rate. |
| 220 if (FLAGS_bitrate <= 0) { | 220 if (FLAGS_bitrate <= 0) { |
| 221 fprintf(stderr, "Bit rate must be >0 kbps, was: %d\n", FLAGS_bitrate); | 221 fprintf(stderr, "Bit rate must be >0 kbps, was: %d\n", FLAGS_bitrate); |
| 222 return 5; | 222 return 5; |
| 223 } | 223 } |
| 224 config->codec_settings->startBitrate = FLAGS_bitrate; | 224 config->codec_settings.startBitrate = FLAGS_bitrate; |
| 225 | 225 |
| 226 // Check the keyframe interval. | 226 // Check the keyframe interval. |
| 227 if (FLAGS_keyframe_interval < 0) { | 227 if (FLAGS_keyframe_interval < 0) { |
| 228 fprintf(stderr, "Keyframe interval must be >=0, was: %d\n", | 228 fprintf(stderr, "Keyframe interval must be >=0, was: %d\n", |
| 229 FLAGS_keyframe_interval); | 229 FLAGS_keyframe_interval); |
| 230 return 6; | 230 return 6; |
| 231 } | 231 } |
| 232 config->keyframe_interval = FLAGS_keyframe_interval; | 232 config->keyframe_interval = FLAGS_keyframe_interval; |
| 233 | 233 |
| 234 // Check packet size and max payload size. | 234 // Check packet size and max payload size. |
| (...skipping 11 matching lines...) Expand all Loading... |
| 246 return 8; | 246 return 8; |
| 247 } | 247 } |
| 248 config->networking_config.max_payload_size_in_bytes = | 248 config->networking_config.max_payload_size_in_bytes = |
| 249 static_cast<size_t>(FLAGS_max_payload_size); | 249 static_cast<size_t>(FLAGS_max_payload_size); |
| 250 | 250 |
| 251 // Check the width and height | 251 // Check the width and height |
| 252 if (FLAGS_width <= 0 || FLAGS_height <= 0) { | 252 if (FLAGS_width <= 0 || FLAGS_height <= 0) { |
| 253 fprintf(stderr, "Width and height must be >0."); | 253 fprintf(stderr, "Width and height must be >0."); |
| 254 return 9; | 254 return 9; |
| 255 } | 255 } |
| 256 config->codec_settings->width = FLAGS_width; | 256 config->codec_settings.width = FLAGS_width; |
| 257 config->codec_settings->height = FLAGS_height; | 257 config->codec_settings.height = FLAGS_height; |
| 258 config->codec_settings->maxFramerate = FLAGS_framerate; | 258 config->codec_settings.maxFramerate = FLAGS_framerate; |
| 259 | 259 |
| 260 // Calculate the size of each frame to read (according to YUV spec). | 260 // Calculate the size of each frame to read (according to YUV spec). |
| 261 config->frame_length_in_bytes = | 261 config->frame_length_in_bytes = |
| 262 3 * config->codec_settings->width * config->codec_settings->height / 2; | 262 3 * config->codec_settings.width * config->codec_settings.height / 2; |
| 263 | 263 |
| 264 // Check packet loss settings | 264 // Check packet loss settings |
| 265 if (FLAGS_packet_loss_mode != "uniform" && | 265 if (FLAGS_packet_loss_mode != "uniform" && |
| 266 FLAGS_packet_loss_mode != "burst") { | 266 FLAGS_packet_loss_mode != "burst") { |
| 267 fprintf(stderr, | 267 fprintf(stderr, |
| 268 "Unsupported packet loss mode, must be 'uniform' or " | 268 "Unsupported packet loss mode, must be 'uniform' or " |
| 269 "'burst'\n."); | 269 "'burst'\n."); |
| 270 return 10; | 270 return 10; |
| 271 } | 271 } |
| 272 config->networking_config.packet_loss_mode = webrtc::test::kUniform; | 272 config->networking_config.packet_loss_mode = webrtc::test::kUniform; |
| (...skipping 23 matching lines...) Expand all Loading... |
| 296 FLAGS_packet_loss_burst_length; | 296 FLAGS_packet_loss_burst_length; |
| 297 config->verbose = FLAGS_verbose; | 297 config->verbose = FLAGS_verbose; |
| 298 return 0; | 298 return 0; |
| 299 } | 299 } |
| 300 | 300 |
| 301 void CalculateSsimVideoMetrics(webrtc::test::TestConfig* config, | 301 void CalculateSsimVideoMetrics(webrtc::test::TestConfig* config, |
| 302 webrtc::test::QualityMetricsResult* result) { | 302 webrtc::test::QualityMetricsResult* result) { |
| 303 Log("Calculating SSIM...\n"); | 303 Log("Calculating SSIM...\n"); |
| 304 I420SSIMFromFiles( | 304 I420SSIMFromFiles( |
| 305 config->input_filename.c_str(), config->output_filename.c_str(), | 305 config->input_filename.c_str(), config->output_filename.c_str(), |
| 306 config->codec_settings->width, config->codec_settings->height, result); | 306 config->codec_settings.width, config->codec_settings.height, result); |
| 307 Log(" Average: %3.2f\n", result->average); | 307 Log(" Average: %3.2f\n", result->average); |
| 308 Log(" Min : %3.2f (frame %d)\n", result->min, result->min_frame_number); | 308 Log(" Min : %3.2f (frame %d)\n", result->min, result->min_frame_number); |
| 309 Log(" Max : %3.2f (frame %d)\n", result->max, result->max_frame_number); | 309 Log(" Max : %3.2f (frame %d)\n", result->max, result->max_frame_number); |
| 310 } | 310 } |
| 311 | 311 |
| 312 void CalculatePsnrVideoMetrics(webrtc::test::TestConfig* config, | 312 void CalculatePsnrVideoMetrics(webrtc::test::TestConfig* config, |
| 313 webrtc::test::QualityMetricsResult* result) { | 313 webrtc::test::QualityMetricsResult* result) { |
| 314 Log("Calculating PSNR...\n"); | 314 Log("Calculating PSNR...\n"); |
| 315 I420PSNRFromFiles( | 315 I420PSNRFromFiles( |
| 316 config->input_filename.c_str(), config->output_filename.c_str(), | 316 config->input_filename.c_str(), config->output_filename.c_str(), |
| 317 config->codec_settings->width, config->codec_settings->height, result); | 317 config->codec_settings.width, config->codec_settings.height, result); |
| 318 Log(" Average: %3.2f\n", result->average); | 318 Log(" Average: %3.2f\n", result->average); |
| 319 Log(" Min : %3.2f (frame %d)\n", result->min, result->min_frame_number); | 319 Log(" Min : %3.2f (frame %d)\n", result->min, result->min_frame_number); |
| 320 Log(" Max : %3.2f (frame %d)\n", result->max, result->max_frame_number); | 320 Log(" Max : %3.2f (frame %d)\n", result->max, result->max_frame_number); |
| 321 } | 321 } |
| 322 | 322 |
| 323 void PrintConfigurationSummary(const webrtc::test::TestConfig& config) { | 323 void PrintConfigurationSummary(const webrtc::test::TestConfig& config) { |
| 324 Log("Quality test with parameters:\n"); | 324 Log("Quality test with parameters:\n"); |
| 325 Log(" Test name : %s\n", config.name.c_str()); | 325 Log(" Test name : %s\n", config.name.c_str()); |
| 326 Log(" Description : %s\n", config.description.c_str()); | 326 Log(" Description : %s\n", config.description.c_str()); |
| 327 Log(" Input filename : %s\n", config.input_filename.c_str()); | 327 Log(" Input filename : %s\n", config.input_filename.c_str()); |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 404 config.name.c_str(), config.description.c_str(), config.test_number, | 404 config.name.c_str(), config.description.c_str(), config.test_number, |
| 405 config.input_filename.c_str(), config.output_filename.c_str(), | 405 config.input_filename.c_str(), config.output_filename.c_str(), |
| 406 config.output_dir.c_str(), config.networking_config.packet_size_in_bytes, | 406 config.output_dir.c_str(), config.networking_config.packet_size_in_bytes, |
| 407 config.networking_config.max_payload_size_in_bytes, | 407 config.networking_config.max_payload_size_in_bytes, |
| 408 PacketLossModeToStr(config.networking_config.packet_loss_mode), | 408 PacketLossModeToStr(config.networking_config.packet_loss_mode), |
| 409 config.networking_config.packet_loss_probability, | 409 config.networking_config.packet_loss_probability, |
| 410 config.networking_config.packet_loss_burst_length, | 410 config.networking_config.packet_loss_burst_length, |
| 411 ExcludeFrameTypesToStr(config.exclude_frame_types), | 411 ExcludeFrameTypesToStr(config.exclude_frame_types), |
| 412 config.frame_length_in_bytes, config.use_single_core ? "True " : "False", | 412 config.frame_length_in_bytes, config.use_single_core ? "True " : "False", |
| 413 config.keyframe_interval, | 413 config.keyframe_interval, |
| 414 CodecTypeToPayloadName(config.codec_settings->codecType) | 414 CodecTypeToPayloadName(config.codec_settings.codecType) |
| 415 .value_or("Unknown"), | 415 .value_or("Unknown"), |
| 416 config.codec_settings->width, config.codec_settings->height, | 416 config.codec_settings.width, config.codec_settings.height, |
| 417 config.codec_settings->startBitrate); | 417 config.codec_settings.startBitrate); |
| 418 printf( | 418 printf( |
| 419 "frame_data_types = {" | 419 "frame_data_types = {" |
| 420 "'frame_number': ('number', 'Frame number'),\n" | 420 "'frame_number': ('number', 'Frame number'),\n" |
| 421 "'encoding_successful': ('boolean', 'Encoding successful?'),\n" | 421 "'encoding_successful': ('boolean', 'Encoding successful?'),\n" |
| 422 "'decoding_successful': ('boolean', 'Decoding successful?'),\n" | 422 "'decoding_successful': ('boolean', 'Decoding successful?'),\n" |
| 423 "'encode_time': ('number', 'Encode time (us)'),\n" | 423 "'encode_time': ('number', 'Encode time (us)'),\n" |
| 424 "'decode_time': ('number', 'Decode time (us)'),\n" | 424 "'decode_time': ('number', 'Decode time (us)'),\n" |
| 425 "'encode_return_code': ('number', 'Encode return code'),\n" | 425 "'encode_return_code': ('number', 'Encode return code'),\n" |
| 426 "'decode_return_code': ('number', 'Decode return code'),\n" | 426 "'decode_return_code': ('number', 'Decode return code'),\n" |
| 427 "'bit_rate': ('number', 'Bit rate (kbps)'),\n" | 427 "'bit_rate': ('number', 'Bit rate (kbps)'),\n" |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 466 "Run " + | 466 "Run " + |
| 467 program_name + | 467 program_name + |
| 468 " --helpshort for usage.\n" | 468 " --helpshort for usage.\n" |
| 469 "Example usage:\n" + | 469 "Example usage:\n" + |
| 470 program_name + | 470 program_name + |
| 471 " --input_filename=filename.yuv --width=352 --height=288\n"; | 471 " --input_filename=filename.yuv --width=352 --height=288\n"; |
| 472 google::SetUsageMessage(usage); | 472 google::SetUsageMessage(usage); |
| 473 | 473 |
| 474 google::ParseCommandLineFlags(&argc, &argv, true); | 474 google::ParseCommandLineFlags(&argc, &argv, true); |
| 475 | 475 |
| 476 // Create TestConfig and codec settings struct. | 476 // Create TestConfig. |
| 477 webrtc::test::TestConfig config; | 477 webrtc::test::TestConfig config; |
| 478 webrtc::VideoCodec codec_settings; | |
| 479 config.codec_settings = &codec_settings; | |
| 480 | 478 |
| 481 int return_code = HandleCommandLineFlags(&config); | 479 int return_code = HandleCommandLineFlags(&config); |
| 482 // Exit if an invalid argument is supplied. | 480 // Exit if an invalid argument is supplied. |
| 483 if (return_code != 0) { | 481 if (return_code != 0) { |
| 484 return return_code; | 482 return return_code; |
| 485 } | 483 } |
| 486 | 484 |
| 487 PrintConfigurationSummary(config); | 485 PrintConfigurationSummary(config); |
| 488 | 486 |
| 489 webrtc::VP8Encoder* encoder = webrtc::VP8Encoder::Create(); | 487 webrtc::VP8Encoder* encoder = webrtc::VP8Encoder::Create(); |
| 490 webrtc::VP8Decoder* decoder = webrtc::VP8Decoder::Create(); | 488 webrtc::VP8Decoder* decoder = webrtc::VP8Decoder::Create(); |
| 491 webrtc::test::Stats stats; | 489 webrtc::test::Stats stats; |
| 492 webrtc::test::YuvFrameReaderImpl frame_reader(config.input_filename, | 490 webrtc::test::YuvFrameReaderImpl frame_reader(config.input_filename, |
| 493 config.codec_settings->width, | 491 config.codec_settings.width, |
| 494 config.codec_settings->height); | 492 config.codec_settings.height); |
| 495 webrtc::test::YuvFrameWriterImpl frame_writer(config.output_filename, | 493 webrtc::test::YuvFrameWriterImpl frame_writer(config.output_filename, |
| 496 config.codec_settings->width, | 494 config.codec_settings.width, |
| 497 config.codec_settings->height); | 495 config.codec_settings.height); |
| 498 frame_reader.Init(); | 496 frame_reader.Init(); |
| 499 frame_writer.Init(); | 497 frame_writer.Init(); |
| 500 webrtc::test::PacketReader packet_reader; | 498 webrtc::test::PacketReader packet_reader; |
| 501 | 499 |
| 502 webrtc::test::PacketManipulatorImpl packet_manipulator( | 500 webrtc::test::PacketManipulatorImpl packet_manipulator( |
| 503 &packet_reader, config.networking_config, config.verbose); | 501 &packet_reader, config.networking_config, config.verbose); |
| 504 // By default the packet manipulator is seeded with a fixed random. | 502 // By default the packet manipulator is seeded with a fixed random. |
| 505 // If disabled we must generate a new seed. | 503 // If disabled we must generate a new seed. |
| 506 if (FLAGS_disable_fixed_random_seed) { | 504 if (FLAGS_disable_fixed_random_seed) { |
| 507 packet_manipulator.InitializeRandomSeed(time(NULL)); | 505 packet_manipulator.InitializeRandomSeed(time(NULL)); |
| (...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 546 } | 544 } |
| 547 if (FLAGS_python) { | 545 if (FLAGS_python) { |
| 548 PrintPythonOutput(config, stats, ssim_result, psnr_result); | 546 PrintPythonOutput(config, stats, ssim_result, psnr_result); |
| 549 } | 547 } |
| 550 delete processor; | 548 delete processor; |
| 551 delete encoder; | 549 delete encoder; |
| 552 delete decoder; | 550 delete decoder; |
| 553 Log("Quality test finished!"); | 551 Log("Quality test finished!"); |
| 554 return 0; | 552 return 0; |
| 555 } | 553 } |
| OLD | NEW |