| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (c) 2011 The WebRTC project authors. All Rights Reserved. | 2 * Copyright (c) 2011 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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 48 | 48 |
| 49 uint32_t VCMDecodingState::time_stamp() const { | 49 uint32_t VCMDecodingState::time_stamp() const { |
| 50 return time_stamp_; | 50 return time_stamp_; |
| 51 } | 51 } |
| 52 | 52 |
| 53 uint16_t VCMDecodingState::sequence_num() const { | 53 uint16_t VCMDecodingState::sequence_num() const { |
| 54 return sequence_num_; | 54 return sequence_num_; |
| 55 } | 55 } |
| 56 | 56 |
| 57 bool VCMDecodingState::IsOldFrame(const VCMFrameBuffer* frame) const { | 57 bool VCMDecodingState::IsOldFrame(const VCMFrameBuffer* frame) const { |
| 58 assert(frame != NULL); | 58 assert(frame != nullptr); |
| 59 if (in_initial_state_) | 59 if (in_initial_state_) |
| 60 return false; | 60 return false; |
| 61 return !IsNewerTimestamp(frame->TimeStamp(), time_stamp_); | 61 return !IsNewerTimestamp(frame->TimeStamp(), time_stamp_); |
| 62 } | 62 } |
| 63 | 63 |
| 64 bool VCMDecodingState::IsOldPacket(const VCMPacket* packet) const { | 64 bool VCMDecodingState::IsOldPacket(const VCMPacket* packet) const { |
| 65 assert(packet != NULL); | 65 assert(packet != nullptr); |
| 66 if (in_initial_state_) | 66 if (in_initial_state_) |
| 67 return false; | 67 return false; |
| 68 return !IsNewerTimestamp(packet->timestamp, time_stamp_); | 68 return !IsNewerTimestamp(packet->timestamp, time_stamp_); |
| 69 } | 69 } |
| 70 | 70 |
| 71 void VCMDecodingState::SetState(const VCMFrameBuffer* frame) { | 71 void VCMDecodingState::SetState(const VCMFrameBuffer* frame) { |
| 72 assert(frame != NULL && frame->GetHighSeqNum() >= 0); | 72 assert(frame != nullptr && frame->GetHighSeqNum() >= 0); |
| 73 if (!UsingFlexibleMode(frame)) | 73 if (!UsingFlexibleMode(frame)) |
| 74 UpdateSyncState(frame); | 74 UpdateSyncState(frame); |
| 75 sequence_num_ = static_cast<uint16_t>(frame->GetHighSeqNum()); | 75 sequence_num_ = static_cast<uint16_t>(frame->GetHighSeqNum()); |
| 76 time_stamp_ = frame->TimeStamp(); | 76 time_stamp_ = frame->TimeStamp(); |
| 77 picture_id_ = frame->PictureId(); | 77 picture_id_ = frame->PictureId(); |
| 78 temporal_id_ = frame->TemporalId(); | 78 temporal_id_ = frame->TemporalId(); |
| 79 tl0_pic_id_ = frame->Tl0PicId(); | 79 tl0_pic_id_ = frame->Tl0PicId(); |
| 80 | 80 |
| 81 for (const NaluInfo& nalu : frame->GetNaluInfos()) { | 81 for (const NaluInfo& nalu : frame->GetNaluInfos()) { |
| 82 if (nalu.type == H264::NaluType::kPps) { | 82 if (nalu.type == H264::NaluType::kPps) { |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 // Continuous empty packets or continuous frames can be dropped if we | 143 // Continuous empty packets or continuous frames can be dropped if we |
| 144 // advance the sequence number. | 144 // advance the sequence number. |
| 145 sequence_num_ = frame->GetHighSeqNum(); | 145 sequence_num_ = frame->GetHighSeqNum(); |
| 146 time_stamp_ = frame->TimeStamp(); | 146 time_stamp_ = frame->TimeStamp(); |
| 147 return true; | 147 return true; |
| 148 } | 148 } |
| 149 return false; | 149 return false; |
| 150 } | 150 } |
| 151 | 151 |
| 152 void VCMDecodingState::UpdateOldPacket(const VCMPacket* packet) { | 152 void VCMDecodingState::UpdateOldPacket(const VCMPacket* packet) { |
| 153 assert(packet != NULL); | 153 assert(packet != nullptr); |
| 154 if (packet->timestamp == time_stamp_) { | 154 if (packet->timestamp == time_stamp_) { |
| 155 // Late packet belonging to the last decoded frame - make sure we update the | 155 // Late packet belonging to the last decoded frame - make sure we update the |
| 156 // last decoded sequence number. | 156 // last decoded sequence number. |
| 157 sequence_num_ = LatestSequenceNumber(packet->seqNum, sequence_num_); | 157 sequence_num_ = LatestSequenceNumber(packet->seqNum, sequence_num_); |
| 158 } | 158 } |
| 159 } | 159 } |
| 160 | 160 |
| 161 void VCMDecodingState::SetSeqNum(uint16_t new_seq_num) { | 161 void VCMDecodingState::SetSeqNum(uint16_t new_seq_num) { |
| 162 sequence_num_ = new_seq_num; | 162 sequence_num_ = new_seq_num; |
| 163 } | 163 } |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 196 } | 196 } |
| 197 } | 197 } |
| 198 | 198 |
| 199 bool VCMDecodingState::ContinuousFrame(const VCMFrameBuffer* frame) const { | 199 bool VCMDecodingState::ContinuousFrame(const VCMFrameBuffer* frame) const { |
| 200 // Check continuity based on the following hierarchy: | 200 // Check continuity based on the following hierarchy: |
| 201 // - Temporal layers (stop here if out of sync). | 201 // - Temporal layers (stop here if out of sync). |
| 202 // - Picture Id when available. | 202 // - Picture Id when available. |
| 203 // - Sequence numbers. | 203 // - Sequence numbers. |
| 204 // Return true when in initial state. | 204 // Return true when in initial state. |
| 205 // Note that when a method is not applicable it will return false. | 205 // Note that when a method is not applicable it will return false. |
| 206 assert(frame != NULL); | 206 assert(frame != nullptr); |
| 207 // A key frame is always considered continuous as it doesn't refer to any | 207 // A key frame is always considered continuous as it doesn't refer to any |
| 208 // frames and therefore won't introduce any errors even if prior frames are | 208 // frames and therefore won't introduce any errors even if prior frames are |
| 209 // missing. | 209 // missing. |
| 210 if (frame->FrameType() == kVideoFrameKey && | 210 if (frame->FrameType() == kVideoFrameKey && |
| 211 HaveSpsAndPps(frame->GetNaluInfos())) { | 211 HaveSpsAndPps(frame->GetNaluInfos())) { |
| 212 return true; | 212 return true; |
| 213 } | 213 } |
| 214 // When in the initial state we always require a key frame to start decoding. | 214 // When in the initial state we always require a key frame to start decoding. |
| 215 if (in_initial_state_) | 215 if (in_initial_state_) |
| 216 return false; | 216 return false; |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 357 return false; | 357 return false; |
| 358 } | 358 } |
| 359 break; | 359 break; |
| 360 } | 360 } |
| 361 } | 361 } |
| 362 } | 362 } |
| 363 return true; | 363 return true; |
| 364 } | 364 } |
| 365 | 365 |
| 366 } // namespace webrtc | 366 } // namespace webrtc |
| OLD | NEW |