| 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 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 139 // Frame number must be an integer >=0. | 139 // Frame number must be an integer >=0. |
| 140 virtual bool ProcessFrame(int frame_number) = 0; | 140 virtual bool ProcessFrame(int frame_number) = 0; |
| 141 | 141 |
| 142 // Updates the encoder with the target bit rate and the frame rate. | 142 // Updates the encoder with the target bit rate and the frame rate. |
| 143 virtual void SetRates(int bit_rate, int frame_rate) = 0; | 143 virtual void SetRates(int bit_rate, int frame_rate) = 0; |
| 144 | 144 |
| 145 // Return the size of the encoded frame in bytes. Dropped frames by the | 145 // Return the size of the encoded frame in bytes. Dropped frames by the |
| 146 // encoder are regarded as zero size. | 146 // encoder are regarded as zero size. |
| 147 virtual size_t EncodedFrameSize() = 0; | 147 virtual size_t EncodedFrameSize() = 0; |
| 148 | 148 |
| 149 // Return the encoded frame type (key or delta). |
| 150 virtual VideoFrameType EncodedFrameType() = 0; |
| 151 |
| 149 // Return the number of dropped frames. | 152 // Return the number of dropped frames. |
| 150 virtual int NumberDroppedFrames() = 0; | 153 virtual int NumberDroppedFrames() = 0; |
| 151 | 154 |
| 152 // Return the number of spatial resizes. | 155 // Return the number of spatial resizes. |
| 153 virtual int NumberSpatialResizes() = 0; | 156 virtual int NumberSpatialResizes() = 0; |
| 154 }; | 157 }; |
| 155 | 158 |
| 156 class VideoProcessorImpl : public VideoProcessor { | 159 class VideoProcessorImpl : public VideoProcessor { |
| 157 public: | 160 public: |
| 158 VideoProcessorImpl(webrtc::VideoEncoder* encoder, | 161 VideoProcessorImpl(webrtc::VideoEncoder* encoder, |
| (...skipping 13 matching lines...) Expand all Loading... |
| 172 // Invoked by the callback when a frame has completed decoding. | 175 // Invoked by the callback when a frame has completed decoding. |
| 173 void FrameDecoded(const webrtc::VideoFrame& image); | 176 void FrameDecoded(const webrtc::VideoFrame& image); |
| 174 // Used for getting a 32-bit integer representing time | 177 // Used for getting a 32-bit integer representing time |
| 175 // (checks the size is within signed 32-bit bounds before casting it) | 178 // (checks the size is within signed 32-bit bounds before casting it) |
| 176 int GetElapsedTimeMicroseconds(const webrtc::TickTime& start, | 179 int GetElapsedTimeMicroseconds(const webrtc::TickTime& start, |
| 177 const webrtc::TickTime& stop); | 180 const webrtc::TickTime& stop); |
| 178 // Updates the encoder with the target bit rate and the frame rate. | 181 // Updates the encoder with the target bit rate and the frame rate. |
| 179 void SetRates(int bit_rate, int frame_rate) override; | 182 void SetRates(int bit_rate, int frame_rate) override; |
| 180 // Return the size of the encoded frame in bytes. | 183 // Return the size of the encoded frame in bytes. |
| 181 size_t EncodedFrameSize() override; | 184 size_t EncodedFrameSize() override; |
| 185 // Return the encoded frame type (key or delta). |
| 186 VideoFrameType EncodedFrameType() override; |
| 182 // Return the number of dropped frames. | 187 // Return the number of dropped frames. |
| 183 int NumberDroppedFrames() override; | 188 int NumberDroppedFrames() override; |
| 184 // Return the number of spatial resizes. | 189 // Return the number of spatial resizes. |
| 185 int NumberSpatialResizes() override; | 190 int NumberSpatialResizes() override; |
| 186 | 191 |
| 187 webrtc::VideoEncoder* encoder_; | 192 webrtc::VideoEncoder* encoder_; |
| 188 webrtc::VideoDecoder* decoder_; | 193 webrtc::VideoDecoder* decoder_; |
| 189 FrameReader* frame_reader_; | 194 FrameReader* frame_reader_; |
| 190 FrameWriter* frame_writer_; | 195 FrameWriter* frame_writer_; |
| 191 PacketManipulator* packet_manipulator_; | 196 PacketManipulator* packet_manipulator_; |
| 192 const TestConfig& config_; | 197 const TestConfig& config_; |
| 193 Stats* stats_; | 198 Stats* stats_; |
| 194 | 199 |
| 195 EncodedImageCallback* encode_callback_; | 200 EncodedImageCallback* encode_callback_; |
| 196 DecodedImageCallback* decode_callback_; | 201 DecodedImageCallback* decode_callback_; |
| 197 // Buffer used for reading the source video file: | 202 // Buffer used for reading the source video file: |
| 198 uint8_t* source_buffer_; | 203 uint8_t* source_buffer_; |
| 199 // Keep track of the last successful frame, since we need to write that | 204 // Keep track of the last successful frame, since we need to write that |
| 200 // when decoding fails: | 205 // when decoding fails: |
| 201 uint8_t* last_successful_frame_buffer_; | 206 uint8_t* last_successful_frame_buffer_; |
| 202 webrtc::VideoFrame source_frame_; | 207 webrtc::VideoFrame source_frame_; |
| 203 // To keep track of if we have excluded the first key frame from packet loss: | 208 // To keep track of if we have excluded the first key frame from packet loss: |
| 204 bool first_key_frame_has_been_excluded_; | 209 bool first_key_frame_has_been_excluded_; |
| 205 // To tell the decoder previous frame have been dropped due to packet loss: | 210 // To tell the decoder previous frame have been dropped due to packet loss: |
| 206 bool last_frame_missing_; | 211 bool last_frame_missing_; |
| 207 // If Init() has executed successfully. | 212 // If Init() has executed successfully. |
| 208 bool initialized_; | 213 bool initialized_; |
| 209 size_t encoded_frame_size_; | 214 size_t encoded_frame_size_; |
| 215 VideoFrameType encoded_frame_type_; |
| 210 int prev_time_stamp_; | 216 int prev_time_stamp_; |
| 211 int num_dropped_frames_; | 217 int num_dropped_frames_; |
| 212 int num_spatial_resizes_; | 218 int num_spatial_resizes_; |
| 213 int last_encoder_frame_width_; | 219 int last_encoder_frame_width_; |
| 214 int last_encoder_frame_height_; | 220 int last_encoder_frame_height_; |
| 215 Scaler scaler_; | 221 Scaler scaler_; |
| 216 | 222 |
| 217 // Statistics | 223 // Statistics |
| 218 double bit_rate_factor_; // multiply frame length with this to get bit rate | 224 double bit_rate_factor_; // multiply frame length with this to get bit rate |
| 219 webrtc::TickTime encode_start_; | 225 webrtc::TickTime encode_start_; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 245 | 251 |
| 246 private: | 252 private: |
| 247 VideoProcessorImpl* video_processor_; | 253 VideoProcessorImpl* video_processor_; |
| 248 }; | 254 }; |
| 249 }; | 255 }; |
| 250 | 256 |
| 251 } // namespace test | 257 } // namespace test |
| 252 } // namespace webrtc | 258 } // namespace webrtc |
| 253 | 259 |
| 254 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ | 260 #endif // WEBRTC_MODULES_VIDEO_CODING_CODECS_TEST_VIDEOPROCESSOR_H_ |
| OLD | NEW |