Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Unified Diff: webrtc/modules/video_coding/codecs/test/videoprocessor.h

Issue 2741953002: Step #4: Run VideoProcessor integration test batch mode on task queue. (Closed)
Patch Set: tommi comments 1: Add thread safety annotations. Created 3 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webrtc/modules/video_coding/codecs/test/videoprocessor.h
diff --git a/webrtc/modules/video_coding/codecs/test/videoprocessor.h b/webrtc/modules/video_coding/codecs/test/videoprocessor.h
index 242844387a77b6eada4d42d9ca5838acd0b5e483..cd4482aeff75dadcc7f7ee8a193bc0d7fbefdd49 100644
--- a/webrtc/modules/video_coding/codecs/test/videoprocessor.h
+++ b/webrtc/modules/video_coding/codecs/test/videoprocessor.h
@@ -18,6 +18,7 @@
#include "webrtc/api/video/video_frame.h"
#include "webrtc/base/buffer.h"
#include "webrtc/base/checks.h"
+#include "webrtc/base/sequenced_task_checker.h"
#include "webrtc/common_video/libyuv/include/webrtc_libyuv.h"
#include "webrtc/modules/video_coding/include/video_codec_interface.h"
#include "webrtc/modules/video_coding/codecs/test/packet_manipulator.h"
@@ -128,16 +129,17 @@ struct TestConfig {
// Video Engine, where signaling would request a retransmit of the lost packets,
// since they're so important.
//
-// Note this class is not thread safe in any way and is meant for simple testing
-// purposes.
+// This class should be run on a single thread, or a single task queue.
class VideoProcessor {
public:
- virtual ~VideoProcessor() {}
+ virtual ~VideoProcessor() = default;
// Performs initial calculations about frame size, sets up callbacks etc.
// Returns false if an error has occurred, in addition to printing to stderr.
virtual bool Init() = 0;
+ virtual void DeregisterCallbacks() = 0;
+
// Processes a single frame. Returns true as long as there's more frames
// available in the source clip.
// Frame number must be an integer >= 0.
@@ -172,8 +174,9 @@ class VideoProcessorImpl : public VideoProcessor {
FrameWriter* source_frame_writer,
IvfFileWriter* encoded_frame_writer,
FrameWriter* decoded_frame_writer);
- virtual ~VideoProcessorImpl();
+ ~VideoProcessorImpl() override;
bool Init() override;
+ void DeregisterCallbacks() override;
bool ProcessFrame(int frame_number) override;
private:
@@ -271,21 +274,22 @@ class VideoProcessorImpl : public VideoProcessor {
// Return the number of spatial resizes.
int NumberSpatialResizes() override;
- webrtc::VideoEncoder* const encoder_;
- webrtc::VideoDecoder* const decoder_;
- const std::unique_ptr<VideoBitrateAllocator> bitrate_allocator_;
+ webrtc::VideoEncoder* const encoder_ PT_GUARDED_BY(task_checker_);
+ webrtc::VideoDecoder* const decoder_ PT_GUARDED_BY(task_checker_);
+ const std::unique_ptr<VideoBitrateAllocator> bitrate_allocator_
+ PT_GUARDED_BY(task_checker_);
// Adapters for the codec callbacks.
const std::unique_ptr<EncodedImageCallback> encode_callback_;
const std::unique_ptr<DecodedImageCallback> decode_callback_;
- PacketManipulator* const packet_manipulator_;
+ PacketManipulator* const packet_manipulator_ PT_GUARDED_BY(task_checker_);
const TestConfig& config_;
// These (mandatory) file manipulators are used for, e.g., objective PSNR and
// SSIM calculations at the end of a test run.
- FrameReader* const analysis_frame_reader_;
- FrameWriter* const analysis_frame_writer_;
+ FrameReader* const analysis_frame_reader_ PT_GUARDED_BY(task_checker_);
+ FrameWriter* const analysis_frame_writer_ PT_GUARDED_BY(task_checker_);
const int num_frames_;
// These (optional) file writers are used for persistently storing the output
@@ -294,31 +298,34 @@ class VideoProcessorImpl : public VideoProcessor {
// experimenter an option to subjectively evaluate the quality of the
// encoding, given the test settings. Each frame writer is enabled by being
// non-null.
- FrameWriter* const source_frame_writer_;
- IvfFileWriter* const encoded_frame_writer_;
- FrameWriter* const decoded_frame_writer_;
+ FrameWriter* const source_frame_writer_ PT_GUARDED_BY(task_checker_);
+ IvfFileWriter* const encoded_frame_writer_ PT_GUARDED_BY(task_checker_);
+ FrameWriter* const decoded_frame_writer_ PT_GUARDED_BY(task_checker_);
- bool initialized_;
+ bool initialized_ GUARDED_BY(task_checker_);
// Frame metadata for all frames that have been added through a call to
// ProcessFrames(). We need to store this metadata over the course of the
// test run, to support pipelining HW codecs.
- std::vector<FrameInfo> frame_infos_;
- int last_encoded_frame_num_;
- int last_decoded_frame_num_;
+ std::vector<FrameInfo> frame_infos_ GUARDED_BY(task_checker_);
+ int last_encoded_frame_num_ GUARDED_BY(task_checker_);
+ int last_decoded_frame_num_ GUARDED_BY(task_checker_);
// Keep track of if we have excluded the first key frame from packet loss.
- bool first_key_frame_has_been_excluded_;
+ bool first_key_frame_has_been_excluded_ GUARDED_BY(task_checker_);
// Keep track of the last successfully decoded frame, since we write that
// frame to disk when decoding fails.
- rtc::Buffer last_decoded_frame_buffer_;
+ rtc::Buffer last_decoded_frame_buffer_ GUARDED_BY(task_checker_);
// Statistics.
- Stats* stats_;
- int num_dropped_frames_;
- int num_spatial_resizes_;
- double bit_rate_factor_; // Multiply frame length with this to get bit rate.
+ Stats* stats_ PT_GUARDED_BY(task_checker_);
+ int num_dropped_frames_ GUARDED_BY(task_checker_);
+ int num_spatial_resizes_ GUARDED_BY(task_checker_);
+ // Multiply frame length with this to get bit rate.
+ double bit_rate_factor_ GUARDED_BY(task_checker_);
+
+ rtc::SequencedTaskChecker task_checker_;
};
} // namespace test

Powered by Google App Engine
This is Rietveld 408576698