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

Side by Side Diff: media/formats/mp4/mp4_stream_parser.cc

Issue 246853005: Fix SPS/PPS insertion logic in MP4StreamParser. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address CR comments. Created 6 years, 8 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 | Annotate | Revision Log
OLDNEW
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
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 RCHECK(AVC::InsertParamSetsAnnexB(avc_config, frame_buf, subsamples));
369 RCHECK(AVC::ConvertConfigToAnnexB(avc_config, &param_sets));
370 frame_buf->insert(frame_buf->begin(),
371 param_sets.begin(), param_sets.end());
372 if (!subsamples->empty())
373 (*subsamples)[0].clear_bytes += param_sets.size();
374 } 369 }
370
371 DCHECK(AVC::IsValidAnnexB(*frame_buf));
375 return true; 372 return true;
376 } 373 }
377 374
378 bool MP4StreamParser::PrepareAACBuffer( 375 bool MP4StreamParser::PrepareAACBuffer(
379 const AAC& aac_config, std::vector<uint8>* frame_buf, 376 const AAC& aac_config, std::vector<uint8>* frame_buf,
380 std::vector<SubsampleEntry>* subsamples) const { 377 std::vector<SubsampleEntry>* subsamples) const {
381 // Append an ADTS header to every audio sample. 378 // Append an ADTS header to every audio sample.
382 RCHECK(aac_config.ConvertEsdsToADTS(frame_buf)); 379 RCHECK(aac_config.ConvertEsdsToADTS(frame_buf));
383 380
384 // As above, adjust subsample information to account for the headers. AAC is 381 // As above, adjust subsample information to account for the headers. AAC is
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
575 return !err; 572 return !err;
576 } 573 }
577 574
578 void MP4StreamParser::ChangeState(State new_state) { 575 void MP4StreamParser::ChangeState(State new_state) {
579 DVLOG(2) << "Changing state: " << new_state; 576 DVLOG(2) << "Changing state: " << new_state;
580 state_ = new_state; 577 state_ = new_state;
581 } 578 }
582 579
583 } // namespace mp4 580 } // namespace mp4
584 } // namespace media 581 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698