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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
42 // Exclude all keyframes from packet loss, no matter where in the video | 42 // Exclude all keyframes from packet loss, no matter where in the video |
43 // sequence they occur. | 43 // sequence they occur. |
44 kExcludeAllKeyFrames | 44 kExcludeAllKeyFrames |
45 }; | 45 }; |
46 | 46 |
47 // Returns a string representation of the enum value. | 47 // Returns a string representation of the enum value. |
48 const char* ExcludeFrameTypesToStr(ExcludeFrameTypes e); | 48 const char* ExcludeFrameTypesToStr(ExcludeFrameTypes e); |
49 | 49 |
50 // Test configuration for a test run. | 50 // Test configuration for a test run. |
51 struct TestConfig { | 51 struct TestConfig { |
52 TestConfig(); | 52 // Name of the test. This is purely metadata and does not affect the test. |
53 ~TestConfig(); | |
54 | |
55 // Name of the test. This is purely metadata and does not affect | |
56 // the test in any way. | |
57 std::string name; | 53 std::string name; |
58 | 54 |
59 // More detailed description of the test. This is purely metadata and does | 55 // More detailed description of the test. This is purely metadata and does |
60 // not affect the test in any way. | 56 // not affect the test. |
61 std::string description; | 57 std::string description; |
62 | 58 |
63 // Number of this test. Useful if multiple runs of the same test with | 59 // Number of this test. Useful if multiple runs of the same test with |
64 // different configurations shall be managed. | 60 // different configurations shall be managed. |
65 int test_number; | 61 int test_number = 0; |
66 | 62 |
67 // File to process for the test. This must be a video file in the YUV format. | 63 // File to process. This must be a video file in the YUV format. |
68 std::string input_filename; | 64 std::string input_filename; |
69 | 65 |
70 // File to write to during processing for the test. Will be a video file | 66 // File to write to during processing for the test. Will be a video file |
71 // in the YUV format. | 67 // in the YUV format. |
72 std::string output_filename; | 68 std::string output_filename; |
73 | 69 |
74 // Path to the directory where encoded files will be put | 70 // Path to the directory where encoded files will be put |
75 // (absolute or relative to the executable). Default: "out". | 71 // (absolute or relative to the executable). |
76 std::string output_dir; | 72 std::string output_dir = "out"; |
77 | 73 |
78 // Configurations related to networking. | 74 // Configurations related to networking. |
79 NetworkingConfig networking_config; | 75 NetworkingConfig networking_config; |
80 | 76 |
81 // Decides how the packet loss simulations shall exclude certain frames | 77 // Decides how the packet loss simulations shall exclude certain frames |
82 // from packet loss. Default: kExcludeOnlyFirstKeyFrame. | 78 // from packet loss. |
83 ExcludeFrameTypes exclude_frame_types; | 79 ExcludeFrameTypes exclude_frame_types = kExcludeOnlyFirstKeyFrame; |
84 | 80 |
85 // The length of a single frame of the input video file. This value is | 81 // The length of a single frame of the input video file. This value is |
86 // calculated out of the width and height according to the video format | 82 // calculated out of the width and height according to the video format |
87 // specification. Must be set before processing. | 83 // specification. Must be set before processing. |
88 size_t frame_length_in_bytes; | 84 size_t frame_length_in_bytes = 0; |
89 | 85 |
90 // Force the encoder and decoder to use a single core for processing. | 86 // Force the encoder and decoder to use a single core for processing. |
91 // Using a single core is necessary to get a deterministic behavior for the | 87 // Using a single core is necessary to get a deterministic behavior for the |
92 // encoded frames - using multiple cores will produce different encoded frames | 88 // encoded frames - using multiple cores will produce different encoded frames |
93 // since multiple cores are competing to consume the byte budget for each | 89 // since multiple cores are competing to consume the byte budget for each |
94 // frame in parallel. | 90 // frame in parallel. |
95 // If set to false, the maximum number of available cores will be used. | 91 // If set to false, the maximum number of available cores will be used. |
96 // Default: false. | 92 bool use_single_core = false; |
97 bool use_single_core; | |
98 | 93 |
99 // If set to a value >0 this setting forces the encoder to create a keyframe | 94 // If set to a value >0 this setting forces the encoder to create a keyframe |
100 // every Nth frame. Note that the encoder may create a keyframe in other | 95 // every Nth frame. Note that the encoder may create a keyframe in other |
101 // locations in addition to the interval that is set using this parameter. | 96 // locations in addition to the interval that is set using this parameter. |
102 // Forcing key frames may also affect encoder planning optimizations in | 97 // Forcing key frames may also affect encoder planning optimizations in |
103 // a negative way, since it will suddenly be forced to produce an expensive | 98 // a negative way, since it will suddenly be forced to produce an expensive |
104 // key frame. | 99 // key frame. |
105 // Default: 0. | 100 int keyframe_interval = 0; |
106 int keyframe_interval; | |
107 | 101 |
108 // The codec settings to use for the test (target bitrate, video size, | 102 // The codec settings to use for the test (target bitrate, video size, |
109 // framerate and so on). This struct must be created and filled in using | 103 // framerate and so on). This struct must be created and filled in using |
110 // the VideoCodingModule::Codec() method. | 104 // the VideoCodingModule::Codec() method. |
111 webrtc::VideoCodec* codec_settings; | 105 webrtc::VideoCodec* codec_settings = nullptr; |
112 | 106 |
113 // If printing of information to stdout shall be performed during processing. | 107 // If printing of information to stdout shall be performed during processing. |
114 bool verbose; | 108 bool verbose = true; |
115 }; | 109 }; |
116 | 110 |
117 // Handles encoding/decoding of video using the VideoEncoder/VideoDecoder | 111 // Handles encoding/decoding of video using the VideoEncoder/VideoDecoder |
118 // interfaces. This is done in a sequential manner in order to be able to | 112 // interfaces. This is done in a sequential manner in order to be able to |
119 // measure times properly. | 113 // measure times properly. |
120 // The class processes a frame at the time for the configured input file. | 114 // The class processes a frame at the time for the configured input file. |
121 // It maintains state of where in the source input file the processing is at. | 115 // It maintains state of where in the source input file the processing is at. |
122 // | 116 // |
123 // Regarding packet loss: Note that keyframes are excluded (first or all | 117 // Regarding packet loss: Note that keyframes are excluded (first or all |
124 // depending on the ExcludeFrameTypes setting). This is because if key frames | 118 // depending on the ExcludeFrameTypes setting). This is because if key frames |
125 // would be altered, all the following delta frames would be pretty much | 119 // would be altered, all the following delta frames would be pretty much |
126 // worthless. VP8 has an error-resilience feature that makes it able to handle | 120 // worthless. VP8 has an error-resilience feature that makes it able to handle |
127 // packet loss in key non-first keyframes, which is why only the first is | 121 // packet loss in key non-first keyframes, which is why only the first is |
128 // excluded by default. | 122 // excluded by default. |
129 // Packet loss in such important frames is handled on a higher level in the | 123 // Packet loss in such important frames is handled on a higher level in the |
130 // Video Engine, where signaling would request a retransmit of the lost packets, | 124 // Video Engine, where signaling would request a retransmit of the lost packets, |
131 // since they're so important. | 125 // since they're so important. |
132 // | 126 // |
133 // Note this class is not thread safe in any way and is meant for simple testing | 127 // Note this class is not thread safe in any way and is meant for simple testing |
134 // purposes. | 128 // purposes. |
135 class VideoProcessor { | 129 class VideoProcessor { |
136 public: | 130 public: |
137 virtual ~VideoProcessor() {} | 131 virtual ~VideoProcessor() {} |
138 | 132 |
139 // Sets up callbacks and initializes the encoder and decoder. | 133 // Sets up callbacks and initializes the encoder and decoder. |
140 virtual void Init() = 0; | 134 virtual void Init() = 0; |
141 | 135 |
142 // Processes a single frame. Returns true as long as there's more frames | 136 // Processes a single frame. Returns true as long as there's more frames |
143 // available in the source clip. | 137 // available in the source clip. |
144 // Frame number must be an integer >= 0. | 138 // |frame_number| must be an integer >= 0. |
145 virtual bool ProcessFrame(int frame_number) = 0; | 139 virtual bool ProcessFrame(int frame_number) = 0; |
146 | 140 |
147 // Updates the encoder with the target bit rate and the frame rate. | 141 // Updates the encoder with the target |bit_rate| and the |frame_rate|. |
148 virtual void SetRates(int bit_rate, int frame_rate) = 0; | 142 virtual void SetRates(int bit_rate, int frame_rate) = 0; |
149 | 143 |
150 // Return the size of the encoded frame in bytes. Dropped frames by the | 144 // Return the size of the encoded frame in bytes. Dropped frames by the |
151 // encoder are regarded as zero size. | 145 // encoder are regarded as zero size. |
152 virtual size_t EncodedFrameSize(int frame_number) = 0; | 146 virtual size_t EncodedFrameSize(int frame_number) = 0; |
153 | 147 |
154 // Return the encoded frame type (key or delta). | 148 // Return the encoded frame type (key or delta). |
155 virtual FrameType EncodedFrameType(int frame_number) = 0; | 149 virtual FrameType EncodedFrameType(int frame_number) = 0; |
156 | 150 |
157 // Return the qp used by encoder. | 151 // Return the qp used by encoder. |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 // Statistics. | 327 // Statistics. |
334 Stats* stats_; | 328 Stats* stats_; |
335 int num_dropped_frames_; | 329 int num_dropped_frames_; |
336 int num_spatial_resizes_; | 330 int num_spatial_resizes_; |
337 }; | 331 }; |
338 | 332 |
339 } // namespace test | 333 } // namespace test |
340 } // namespace webrtc | 334 } // namespace webrtc |
341 | 335 |
342 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ | 336 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ |
OLD | NEW |