Chromium Code Reviews| 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/mp4_stream_parser.h" | 5 #include "media/formats/mp4/mp4_stream_parser.h" |
| 6 | 6 |
| 7 #include "base/callback.h" | 7 #include "base/callback.h" |
| 8 #include "base/callback_helpers.h" | 8 #include "base/callback_helpers.h" |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/time/time.h" | 10 #include "base/time/time.h" |
| (...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 358 subsamples->size() * nalu_size_diff; | 358 subsamples->size() * nalu_size_diff; |
| 359 RCHECK(frame_buf->size() == expected_size); | 359 RCHECK(frame_buf->size() == expected_size); |
| 360 for (size_t i = 0; i < subsamples->size(); i++) | 360 for (size_t i = 0; i < subsamples->size(); i++) |
| 361 (*subsamples)[i].clear_bytes += nalu_size_diff; | 361 (*subsamples)[i].clear_bytes += nalu_size_diff; |
| 362 } | 362 } |
| 363 | 363 |
| 364 if (runs_->is_keyframe()) { | 364 if (runs_->is_keyframe()) { |
| 365 // If this is a keyframe, we (re-)inject SPS and PPS headers at the start of | 365 // If this is a keyframe, we (re-)inject SPS and PPS headers at the start of |
| 366 // a frame. If subsample info is present, we also update the clear byte | 366 // a frame. If subsample info is present, we also update the clear byte |
| 367 // count for that first subsample. | 367 // count for that first subsample. |
| 368 std::vector<uint8> param_sets; | 368 size_t old_size = frame_buf->size(); |
| 369 RCHECK(AVC::ConvertConfigToAnnexB(avc_config, ¶m_sets)); | 369 RCHECK(AVC::InsertParamSetsAnnexB(avc_config, frame_buf)); |
| 370 frame_buf->insert(frame_buf->begin(), | |
| 371 param_sets.begin(), param_sets.end()); | |
| 372 if (!subsamples->empty()) | 370 if (!subsamples->empty()) |
|
damienv1
2014/04/23 00:20:47
Would be nice if InsertParamSetsAnnexB returns the
| |
| 373 (*subsamples)[0].clear_bytes += param_sets.size(); | 371 (*subsamples)[0].clear_bytes += frame_buf->size() - old_size; |
| 374 } | 372 } |
| 373 | |
| 374 DCHECK(AVC::IsValidAnnexB(*frame_buf)); | |
| 375 return true; | 375 return true; |
| 376 } | 376 } |
| 377 | 377 |
| 378 bool MP4StreamParser::PrepareAACBuffer( | 378 bool MP4StreamParser::PrepareAACBuffer( |
| 379 const AAC& aac_config, std::vector<uint8>* frame_buf, | 379 const AAC& aac_config, std::vector<uint8>* frame_buf, |
| 380 std::vector<SubsampleEntry>* subsamples) const { | 380 std::vector<SubsampleEntry>* subsamples) const { |
| 381 // Append an ADTS header to every audio sample. | 381 // Append an ADTS header to every audio sample. |
| 382 RCHECK(aac_config.ConvertEsdsToADTS(frame_buf)); | 382 RCHECK(aac_config.ConvertEsdsToADTS(frame_buf)); |
| 383 | 383 |
| 384 // As above, adjust subsample information to account for the headers. AAC is | 384 // As above, adjust subsample information to account for the headers. AAC is |
| (...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 575 return !err; | 575 return !err; |
| 576 } | 576 } |
| 577 | 577 |
| 578 void MP4StreamParser::ChangeState(State new_state) { | 578 void MP4StreamParser::ChangeState(State new_state) { |
| 579 DVLOG(2) << "Changing state: " << new_state; | 579 DVLOG(2) << "Changing state: " << new_state; |
| 580 state_ = new_state; | 580 state_ = new_state; |
| 581 } | 581 } |
| 582 | 582 |
| 583 } // namespace mp4 | 583 } // namespace mp4 |
| 584 } // namespace media | 584 } // namespace media |
| OLD | NEW |