Chromium Code Reviews| Index: webrtc/modules/video_coding/codecs/vp8/vp8_sequence_coder.cc |
| diff --git a/webrtc/modules/video_coding/codecs/vp8/vp8_sequence_coder.cc b/webrtc/modules/video_coding/codecs/vp8/vp8_sequence_coder.cc |
| index d2d317773a3018b3f40e81ce3e2496a2a0a1c542..5846dee399f61842f50e344ed8e5c94da5e0973a 100644 |
| --- a/webrtc/modules/video_coding/codecs/vp8/vp8_sequence_coder.cc |
| +++ b/webrtc/modules/video_coding/codecs/vp8/vp8_sequence_coder.cc |
| @@ -1,12 +1,12 @@ |
| - /* |
| - * Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| - * |
| - * Use of this source code is governed by a BSD-style license |
| - * that can be found in the LICENSE file in the root of the source |
| - * tree. An additional intellectual property rights grant can be found |
| - * in the file PATENTS. All contributing project authors may |
| - * be found in the AUTHORS file in the root of the source tree. |
| - */ |
| +/* |
|
mflodman
2015/12/17 13:05:39
Move back line 2 - 9 one step to the right.
philipel
2015/12/18 12:23:16
Done.
|
| +* Copyright (c) 2012 The WebRTC project authors. All Rights Reserved. |
| +* |
| +* Use of this source code is governed by a BSD-style license |
| +* that can be found in the LICENSE file in the root of the source |
| +* tree. An additional intellectual property rights grant can be found |
| +* in the file PATENTS. All contributing project authors may |
| +* be found in the AUTHORS file in the root of the source tree. |
| +*/ |
| #include "testing/gtest/include/gtest/gtest.h" |
| #include "webrtc/base/checks.h" |
| @@ -23,8 +23,7 @@ |
| class Vp8SequenceCoderEncodeCallback : public webrtc::EncodedImageCallback { |
| public: |
| explicit Vp8SequenceCoderEncodeCallback(FILE* encoded_file) |
| - : encoded_file_(encoded_file), |
| - encoded_bytes_(0) {} |
| + : encoded_file_(encoded_file), encoded_bytes_(0) {} |
| ~Vp8SequenceCoderEncodeCallback(); |
| int Encoded(const webrtc::EncodedImage& encoded_image, |
| const webrtc::CodecSpecificInfo* codecSpecificInfo, |
| @@ -32,6 +31,7 @@ class Vp8SequenceCoderEncodeCallback : public webrtc::EncodedImageCallback { |
| // Returns the encoded image. |
| webrtc::EncodedImage encoded_image() { return encoded_image_; } |
| size_t encoded_bytes() { return encoded_bytes_; } |
| + |
| private: |
| webrtc::EncodedImage encoded_image_; |
| FILE* encoded_file_; |
| @@ -39,7 +39,7 @@ class Vp8SequenceCoderEncodeCallback : public webrtc::EncodedImageCallback { |
| }; |
| Vp8SequenceCoderEncodeCallback::~Vp8SequenceCoderEncodeCallback() { |
| - delete [] encoded_image_._buffer; |
| + delete[] encoded_image_._buffer; |
| encoded_image_._buffer = NULL; |
| } |
| int Vp8SequenceCoderEncodeCallback::Encoded( |
| @@ -47,7 +47,7 @@ int Vp8SequenceCoderEncodeCallback::Encoded( |
| const webrtc::CodecSpecificInfo* codecSpecificInfo, |
| const webrtc::RTPFragmentationHeader* fragmentation) { |
| if (encoded_image_._size < encoded_image._size) { |
| - delete [] encoded_image_._buffer; |
| + delete[] encoded_image_._buffer; |
| encoded_image_._buffer = NULL; |
| encoded_image_._buffer = new uint8_t[encoded_image._size]; |
| encoded_image_._size = encoded_image._size; |
| @@ -72,7 +72,7 @@ class Vp8SequenceCoderDecodeCallback : public webrtc::DecodedImageCallback { |
| int32_t Decoded(webrtc::VideoFrame& frame) override; |
| int32_t Decoded(webrtc::VideoFrame& frame, int64_t decode_time_ms) override { |
| RTC_NOTREACHED(); |
| - return -1;; |
| + return -1; |
| } |
| bool DecodeComplete(); |
| @@ -85,16 +85,16 @@ int Vp8SequenceCoderDecodeCallback::Decoded(webrtc::VideoFrame& image) { |
| return 0; |
| } |
| -int SequenceCoder(webrtc::test::CommandLineParser& parser) { |
| - int width = strtol((parser.GetFlag("w")).c_str(), NULL, 10); |
| - int height = strtol((parser.GetFlag("h")).c_str(), NULL, 10); |
| - int framerate = strtol((parser.GetFlag("f")).c_str(), NULL, 10); |
| +int SequenceCoder(webrtc::test::CommandLineParser* parser) { |
| + int width = strtol((parser->GetFlag("w")).c_str(), NULL, 10); |
| + int height = strtol((parser->GetFlag("h")).c_str(), NULL, 10); |
| + int framerate = strtol((parser->GetFlag("f")).c_str(), NULL, 10); |
| if (width <= 0 || height <= 0 || framerate <= 0) { |
| fprintf(stderr, "Error: Resolution cannot be <= 0!\n"); |
| return -1; |
| } |
| - int target_bitrate = strtol((parser.GetFlag("b")).c_str(), NULL, 10); |
| + int target_bitrate = strtol((parser->GetFlag("b")).c_str(), NULL, 10); |
| if (target_bitrate <= 0) { |
| fprintf(stderr, "Error: Bit-rate cannot be <= 0!\n"); |
| return -1; |
| @@ -102,20 +102,20 @@ int SequenceCoder(webrtc::test::CommandLineParser& parser) { |
| // SetUp |
| // Open input file. |
| - std::string encoded_file_name = parser.GetFlag("encoded_file"); |
| + std::string encoded_file_name = parser->GetFlag("encoded_file"); |
| FILE* encoded_file = fopen(encoded_file_name.c_str(), "wb"); |
| if (encoded_file == NULL) { |
| fprintf(stderr, "Error: Cannot open encoded file\n"); |
| return -1; |
| } |
| - std::string input_file_name = parser.GetFlag("input_file"); |
| + std::string input_file_name = parser->GetFlag("input_file"); |
| FILE* input_file = fopen(input_file_name.c_str(), "rb"); |
| if (input_file == NULL) { |
| fprintf(stderr, "Error: Cannot open input file\n"); |
| return -1; |
| } |
| // Open output file. |
| - std::string output_file_name = parser.GetFlag("output_file"); |
| + std::string output_file_name = parser->GetFlag("output_file"); |
| FILE* output_file = fopen(output_file_name.c_str(), "wb"); |
| if (output_file == NULL) { |
| fprintf(stderr, "Error: Cannot open output file\n"); |
| @@ -123,8 +123,8 @@ int SequenceCoder(webrtc::test::CommandLineParser& parser) { |
| } |
| // Get range of frames: will encode num_frames following start_frame). |
| - int start_frame = strtol((parser.GetFlag("start_frame")).c_str(), NULL, 10); |
| - int num_frames = strtol((parser.GetFlag("num_frames")).c_str(), NULL, 10); |
| + int start_frame = strtol((parser->GetFlag("start_frame")).c_str(), NULL, 10); |
| + int num_frames = strtol((parser->GetFlag("num_frames")).c_str(), NULL, 10); |
| // Codec SetUp. |
| webrtc::VideoCodec inst; |
| @@ -162,8 +162,8 @@ int SequenceCoder(webrtc::test::CommandLineParser& parser) { |
| int frames_processed = 0; |
| input_frame.CreateEmptyFrame(width, height, width, half_width, half_width); |
| while (!feof(input_file) && |
| - (num_frames == -1 || frames_processed < num_frames)) { |
| - if (fread(frame_buffer.get(), 1, length, input_file) != length) |
| + (num_frames == -1 || frames_processed < num_frames)) { |
| + if (fread(frame_buffer.get(), 1, length, input_file) != length) |
| continue; |
| if (frame_cnt >= start_frame) { |
| webrtc::ConvertToI420(webrtc::kI420, frame_buffer.get(), 0, 0, width, |
| @@ -184,33 +184,35 @@ int SequenceCoder(webrtc::test::CommandLineParser& parser) { |
| printf("Actual bitrate: %f kbps\n", actual_bit_rate / 1000); |
| webrtc::test::QualityMetricsResult psnr_result, ssim_result; |
| EXPECT_EQ(0, webrtc::test::I420MetricsFromFiles( |
| - input_file_name.c_str(), output_file_name.c_str(), |
| - inst.width, inst.height, |
| - &psnr_result, &ssim_result)); |
| + input_file_name.c_str(), output_file_name.c_str(), |
| + inst.width, inst.height, &psnr_result, &ssim_result)); |
| printf("PSNR avg: %f[dB], min: %f[dB]\nSSIM avg: %f, min: %f\n", |
| - psnr_result.average, psnr_result.min, |
| - ssim_result.average, ssim_result.min); |
| + psnr_result.average, psnr_result.min, ssim_result.average, |
| + ssim_result.min); |
| return frame_cnt; |
| } |
| int main(int argc, char** argv) { |
| std::string program_name = argv[0]; |
| - std::string usage = "Encode and decodes a video sequence, and writes" |
| - "results to a file.\n" |
| - "Example usage:\n" + program_name + " functionality" |
| - " --w=352 --h=288 --input_file=input.yuv --output_file=output.yuv " |
| - " Command line flags:\n" |
| - " - width(int): The width of the input file. Default: 352\n" |
| - " - height(int): The height of the input file. Default: 288\n" |
| - " - input_file(string): The YUV file to encode." |
| - " Default: foreman.yuv\n" |
| - " - encoded_file(string): The vp8 encoded file (encoder output)." |
| - " Default: vp8_encoded.vp8\n" |
| - " - output_file(string): The yuv decoded file (decoder output)." |
| - " Default: vp8_decoded.yuv\n." |
| - " - start_frame - frame number in which encoding will begin. Default: 0" |
| - " - num_frames - Number of frames to be processed. " |
| - " Default: -1 (entire sequence)."; |
| + std::string usage = |
| + "Encode and decodes a video sequence, and writes" |
| + "results to a file.\n" |
| + "Example usage:\n" + |
| + program_name + |
| + " functionality" |
| + " --w=352 --h=288 --input_file=input.yuv --output_file=output.yuv " |
| + " Command line flags:\n" |
| + " - width(int): The width of the input file. Default: 352\n" |
| + " - height(int): The height of the input file. Default: 288\n" |
| + " - input_file(string): The YUV file to encode." |
| + " Default: foreman.yuv\n" |
| + " - encoded_file(string): The vp8 encoded file (encoder output)." |
| + " Default: vp8_encoded.vp8\n" |
| + " - output_file(string): The yuv decoded file (decoder output)." |
| + " Default: vp8_decoded.yuv\n." |
| + " - start_frame - frame number in which encoding will begin. Default: 0" |
| + " - num_frames - Number of frames to be processed. " |
| + " Default: -1 (entire sequence)."; |
| webrtc::test::CommandLineParser parser; |
| @@ -228,8 +230,8 @@ int main(int argc, char** argv) { |
| parser.SetFlag("output_file", webrtc::test::OutputPath() + "vp8_decoded.yuv"); |
| parser.SetFlag("encoded_file", |
| webrtc::test::OutputPath() + "vp8_encoded.vp8"); |
| - parser.SetFlag("input_file", webrtc::test::ResourcePath("foreman_cif", |
| - "yuv")); |
| + parser.SetFlag("input_file", |
| + webrtc::test::ResourcePath("foreman_cif", "yuv")); |
| parser.SetFlag("help", "false"); |
| parser.ProcessFlags(); |
| @@ -239,5 +241,5 @@ int main(int argc, char** argv) { |
| } |
| parser.PrintEnteredFlags(); |
| - return SequenceCoder(parser); |
| + return SequenceCoder(&parser); |
| } |