| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "media/formats/mp4/track_run_iterator.h" | 5 #include "media/formats/mp4/track_run_iterator.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iomanip> | 8 #include <iomanip> |
| 9 #include <limits> | 9 #include <limits> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 MEDIA_LOG(ERROR, media_log) << "Reserved value used in sample dependency" | 162 MEDIA_LOG(ERROR, media_log) << "Reserved value used in sample dependency" |
| 163 " info."; | 163 " info."; |
| 164 return false; | 164 return false; |
| 165 } | 165 } |
| 166 | 166 |
| 167 // Per spec (ISO 14496-12:2012), the definition for a "sync sample" is | 167 // Per spec (ISO 14496-12:2012), the definition for a "sync sample" is |
| 168 // equivalent to the downstream code's "is keyframe" concept. But media exists | 168 // equivalent to the downstream code's "is keyframe" concept. But media exists |
| 169 // that marks non-key video frames as sync samples (http://crbug.com/507916 | 169 // that marks non-key video frames as sync samples (http://crbug.com/507916 |
| 170 // and http://crbug.com/310712). Hence, for video we additionally check that | 170 // and http://crbug.com/310712). Hence, for video we additionally check that |
| 171 // the sample does not depend on others (FFmpeg does too, see mov_read_trun). | 171 // the sample does not depend on others (FFmpeg does too, see mov_read_trun). |
| 172 // Sample dependency is not ignored for audio because encoded audio samples | 172 // Sample dependency is ignored for audio because encoded audio samples can |
| 173 // can depend on other samples and still be used for random access. Generally | 173 // depend on other samples and still be used for random access. Generally all |
| 174 // all audio samples are expected to be sync samples, but we prefer to check | 174 // audio samples are expected to be sync samples, but we prefer to check the |
| 175 // the flags to catch badly muxed audio (for now anyway ;P). History of | 175 // flags to catch badly muxed audio (for now anyway ;P). History of attempts |
| 176 // attempts to get this right discussed in http://crrev.com/1319813002 | 176 // to get this right discussed in http://crrev.com/1319813002 |
| 177 bool sample_is_sync_sample = !(flags & kSampleIsNonSyncSample); | 177 bool sample_is_sync_sample = !(flags & kSampleIsNonSyncSample); |
| 178 bool sample_depends_on_others = sample_depends_on == kSampleDependsOnOthers; | 178 bool sample_depends_on_others = sample_depends_on == kSampleDependsOnOthers; |
| 179 sample_info->is_keyframe = sample_is_sync_sample && | 179 sample_info->is_keyframe = sample_is_sync_sample && |
| 180 (!sample_depends_on_others || is_audio); | 180 (!sample_depends_on_others || is_audio); |
| 181 | 181 |
| 182 DVLOG(4) << __func__ << " is_kf:" << sample_info->is_keyframe | 182 DVLOG(4) << __func__ << " is_kf:" << sample_info->is_keyframe |
| 183 << " is_sync:" << sample_is_sync_sample | 183 << " is_sync:" << sample_is_sync_sample |
| 184 << " deps:" << sample_depends_on_others << " audio:" << is_audio; | 184 << " deps:" << sample_depends_on_others << " audio:" << is_audio; |
| 185 | 185 |
| 186 return true; | 186 return true; |
| (...skipping 524 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 711 index == 0 ? track_encryption().default_constant_iv | 711 index == 0 ? track_encryption().default_constant_iv |
| 712 : GetSampleEncryptionInfoEntry(*run_itr_, index)->constant_iv; | 712 : GetSampleEncryptionInfoEntry(*run_itr_, index)->constant_iv; |
| 713 RCHECK(constant_iv != nullptr); | 713 RCHECK(constant_iv != nullptr); |
| 714 memcpy(entry->initialization_vector, constant_iv, kInitializationVectorSize); | 714 memcpy(entry->initialization_vector, constant_iv, kInitializationVectorSize); |
| 715 return true; | 715 return true; |
| 716 } | 716 } |
| 717 #endif | 717 #endif |
| 718 | 718 |
| 719 } // namespace mp4 | 719 } // namespace mp4 |
| 720 } // namespace media | 720 } // namespace media |
| OLD | NEW |