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

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: Rebase 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
« no previous file with comments | « media/formats/mp4/avc_unittest.cc ('k') | media/formats/mp4/mp4_stream_parser_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 345 matching lines...) Expand 10 before | Expand all | Expand 10 after
356 subsamples->size() * nalu_size_diff; 356 subsamples->size() * nalu_size_diff;
357 RCHECK(frame_buf->size() == expected_size); 357 RCHECK(frame_buf->size() == expected_size);
358 for (size_t i = 0; i < subsamples->size(); i++) 358 for (size_t i = 0; i < subsamples->size(); i++)
359 (*subsamples)[i].clear_bytes += nalu_size_diff; 359 (*subsamples)[i].clear_bytes += nalu_size_diff;
360 } 360 }
361 361
362 if (runs_->is_keyframe()) { 362 if (runs_->is_keyframe()) {
363 // If this is a keyframe, we (re-)inject SPS and PPS headers at the start of 363 // If this is a keyframe, we (re-)inject SPS and PPS headers at the start of
364 // a frame. If subsample info is present, we also update the clear byte 364 // a frame. If subsample info is present, we also update the clear byte
365 // count for that first subsample. 365 // count for that first subsample.
366 std::vector<uint8> param_sets; 366 RCHECK(AVC::InsertParamSetsAnnexB(avc_config, frame_buf, subsamples));
367 RCHECK(AVC::ConvertConfigToAnnexB(avc_config, &param_sets));
368 frame_buf->insert(frame_buf->begin(),
369 param_sets.begin(), param_sets.end());
370 if (!subsamples->empty())
371 (*subsamples)[0].clear_bytes += param_sets.size();
372 } 367 }
368
369 DCHECK(AVC::IsValidAnnexB(*frame_buf));
373 return true; 370 return true;
374 } 371 }
375 372
376 bool MP4StreamParser::PrepareAACBuffer( 373 bool MP4StreamParser::PrepareAACBuffer(
377 const AAC& aac_config, std::vector<uint8>* frame_buf, 374 const AAC& aac_config, std::vector<uint8>* frame_buf,
378 std::vector<SubsampleEntry>* subsamples) const { 375 std::vector<SubsampleEntry>* subsamples) const {
379 // Append an ADTS header to every audio sample. 376 // Append an ADTS header to every audio sample.
380 RCHECK(aac_config.ConvertEsdsToADTS(frame_buf)); 377 RCHECK(aac_config.ConvertEsdsToADTS(frame_buf));
381 378
382 // As above, adjust subsample information to account for the headers. AAC is 379 // As above, adjust subsample information to account for the headers. AAC is
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
573 return !err; 570 return !err;
574 } 571 }
575 572
576 void MP4StreamParser::ChangeState(State new_state) { 573 void MP4StreamParser::ChangeState(State new_state) {
577 DVLOG(2) << "Changing state: " << new_state; 574 DVLOG(2) << "Changing state: " << new_state;
578 state_ = new_state; 575 state_ = new_state;
579 } 576 }
580 577
581 } // namespace mp4 578 } // namespace mp4
582 } // namespace media 579 } // namespace media
OLDNEW
« no previous file with comments | « media/formats/mp4/avc_unittest.cc ('k') | media/formats/mp4/mp4_stream_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698