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

Side by Side Diff: webrtc/modules/video_coding/codecs/test/videoprocessor.h

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

Powered by Google App Engine
This is Rietveld 408576698