Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 /* | |
| 2 * Copyright (c) 2016 The WebRTC project authors. All Rights Reserved. | |
| 3 * | |
| 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 | |
| 6 * tree. An additional intellectual property rights grant can be found | |
| 7 * in the file PATENTS. All contributing project authors may | |
| 8 * be found in the AUTHORS file in the root of the source tree. | |
| 9 */ | |
| 10 | |
| 11 #ifndef WEBRTC_MODULES_VIDEO_CODING_FRAME_BUFFER2_H_ | |
| 12 #define WEBRTC_MODULES_VIDEO_CODING_FRAME_BUFFER2_H_ | |
| 13 | |
| 14 #include <array> | |
| 15 #include <map> | |
| 16 #include <memory> | |
| 17 #include <utility> | |
| 18 | |
| 19 #include "webrtc/base/criticalsection.h" | |
| 20 #include "webrtc/base/event.h" | |
| 21 #include "webrtc/base/thread_annotations.h" | |
| 22 #include "webrtc/modules/video_coding/frame_object.h" | |
| 23 #include "webrtc/modules/video_coding/jitter_estimator.h" | |
| 24 #include "webrtc/modules/video_coding/sequence_number_util.h" | |
| 25 #include "webrtc/modules/video_coding/timing.h" | |
| 26 #include "webrtc/system_wrappers/include/clock.h" | |
| 27 | |
| 28 namespace webrtc { | |
| 29 namespace video_coding { | |
| 30 | |
| 31 class FrameBuffer { | |
| 32 public: | |
| 33 FrameBuffer(Clock* clock, | |
| 34 VCMJitterEstimator* jitter_estimator, | |
| 35 VCMTiming* timing); | |
| 36 | |
| 37 // Insert a frame into the frame buffer. | |
| 38 void InsertFrame(std::unique_ptr<FrameObject> frame); | |
| 39 | |
| 40 // Get the next frame for decoding. Will return at latest after | |
| 41 // |max_wait_time|, with either a managed FrameObject or an empty | |
| 42 // unique ptr if there is no available frame for decoding. | |
| 43 std::unique_ptr<FrameObject> NextFrame(int64_t max_wait_time); | |
|
danilchap
2016/05/13 15:33:56
max_wait_time_ms
philipel
2016/05/17 09:16:41
Done.
| |
| 44 | |
| 45 private: | |
| 46 // The maximum age of a frame stored in the frame buffer, compared to | |
| 47 // |newest_picture_id_|. | |
| 48 static const int kMaxFrameAge = 4096; | |
| 49 | |
| 50 // The maximum number of frames stored in the frame buffer. | |
| 51 static const int kMaxStoredFrames = 256; | |
| 52 | |
| 53 // The maximum number of spatial layers. | |
| 54 static const int kMaxSpatialLayers = 5; | |
| 55 | |
| 56 // Determines whether a frame is continuous. | |
| 57 bool IsContinuous(const FrameObject& frame) const | |
| 58 EXCLUSIVE_LOCKS_REQUIRED(crit_); | |
| 59 | |
| 60 // For every picture id, keep information whether a frame has been decoded | |
| 61 // for a given spatial layer. | |
| 62 std::map<uint16_t, | |
| 63 std::array<bool, kMaxSpatialLayers>, | |
| 64 DescendingSeqNumComp<uint16_t>> decoded_frames_ GUARDED_BY(crit_); | |
| 65 | |
| 66 // Comparator used to sort frames, first on their picture id, and second | |
| 67 // on their spatial layer. | |
| 68 struct FrameComp { | |
| 69 bool operator()(const std::pair<uint16_t, uint8_t>& f1, | |
|
danilchap
2016/05/13 15:33:56
probably better make this static if you want to ke
philipel
2016/05/17 09:16:41
I don't really understand...
danilchap
2016/05/17 12:35:02
i.e. static bool operator()(<same as before>) cons
philipel
2016/05/17 14:57:04
Acknowledged.
| |
| 70 const std::pair<uint16_t, uint8_t>& f2) const { | |
| 71 // first = picture id | |
| 72 // second = spatial layer | |
| 73 if (f1.first == f2.first) | |
| 74 return f1.second < f2.second; | |
| 75 return AheadOf(f2.first, f1.first); | |
| 76 } | |
| 77 }; | |
| 78 | |
| 79 // The actual buffer that holds the FrameObjects, the key being the | |
| 80 // tuple (picture id, spatial layer). | |
| 81 std::map<std::pair<uint16_t, uint8_t>, | |
|
danilchap
2016/05/13 15:33:56
may be instead of using pair as key and creating s
philipel
2016/05/17 09:16:41
Acknowledged.
| |
| 82 std::unique_ptr<FrameObject>, | |
| 83 FrameComp> frames_ GUARDED_BY(crit_); | |
| 84 | |
| 85 rtc::CriticalSection crit_; | |
| 86 Clock* clock_; | |
|
danilchap
2016/05/13 15:33:56
Clock* const clock_;
philipel
2016/05/17 09:16:41
Done.
| |
| 87 rtc::Event frame_inserted_event_; | |
| 88 VCMJitterEstimator* jitter_estimator_; | |
|
danilchap
2016/05/13 15:33:57
VCMJitterEstimator* const jitter_estimator_;
philipel
2016/05/17 09:16:41
Done.
| |
| 89 VCMTiming* timing_; | |
|
danilchap
2016/05/13 15:33:56
const VCMTiming* const timing_;
philipel
2016/05/17 09:16:41
Done.
| |
| 90 int newest_picture_id_ GUARDED_BY(crit_); | |
| 91 }; | |
| 92 | |
| 93 | |
| 94 } // namespace video_coding | |
| 95 } // namespace webrtc | |
| 96 | |
| 97 #endif // WEBRTC_MODULES_VIDEO_CODING_FRAME_BUFFER2_H_ | |
| OLD | NEW |