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

Side by Side Diff: media/mp4/aac.cc

Issue 10886022: Fix encrypted AAC in BMFF by adding subsample info. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Use constant in ConvertEsdsToADTS Created 8 years, 3 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/mp4/aac.h ('k') | media/mp4/mp4_stream_parser.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/mp4/aac.h" 5 #include "media/mp4/aac.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "media/base/bit_reader.h" 10 #include "media/base/bit_reader.h"
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after
149 // TODO(acolwell) : Extend sample rate cap to 96kHz for Level 5 content. 149 // TODO(acolwell) : Extend sample rate cap to 96kHz for Level 5 content.
150 DCHECK_GT(frequency_, 0); 150 DCHECK_GT(frequency_, 0);
151 return std::min(2 * frequency_, 48000); 151 return std::min(2 * frequency_, 48000);
152 } 152 }
153 153
154 ChannelLayout AAC::channel_layout() const { 154 ChannelLayout AAC::channel_layout() const {
155 return channel_layout_; 155 return channel_layout_;
156 } 156 }
157 157
158 bool AAC::ConvertEsdsToADTS(std::vector<uint8>* buffer) const { 158 bool AAC::ConvertEsdsToADTS(std::vector<uint8>* buffer) const {
159 size_t size = buffer->size() + 7; 159 size_t size = buffer->size() + kADTSHeaderSize;
160 160
161 DCHECK(profile_ >= 1 && profile_ <= 4 && frequency_index_ != 0xf && 161 DCHECK(profile_ >= 1 && profile_ <= 4 && frequency_index_ != 0xf &&
162 channel_config_ <= 7); 162 channel_config_ <= 7);
163 163
164 // ADTS header uses 13 bits for packet size. 164 // ADTS header uses 13 bits for packet size.
165 if (size >= (1 << 13)) 165 if (size >= (1 << 13))
166 return false; 166 return false;
167 167
168 std::vector<uint8>& adts = *buffer; 168 std::vector<uint8>& adts = *buffer;
169 169
170 adts.insert(buffer->begin(), 7, 0); 170 adts.insert(buffer->begin(), kADTSHeaderSize, 0);
171 adts[0] = 0xff; 171 adts[0] = 0xff;
172 adts[1] = 0xf1; 172 adts[1] = 0xf1;
173 adts[2] = ((profile_ - 1) << 6) + (frequency_index_ << 2) + 173 adts[2] = ((profile_ - 1) << 6) + (frequency_index_ << 2) +
174 (channel_config_ >> 2); 174 (channel_config_ >> 2);
175 adts[3] = ((channel_config_ & 0x3) << 6) + (size >> 11); 175 adts[3] = ((channel_config_ & 0x3) << 6) + (size >> 11);
176 adts[4] = (size & 0x7ff) >> 3; 176 adts[4] = (size & 0x7ff) >> 3;
177 adts[5] = ((size & 7) << 5) + 0x1f; 177 adts[5] = ((size & 7) << 5) + 0x1f;
178 adts[6] = 0xfc; 178 adts[6] = 0xfc;
179 179
180 return true; 180 return true;
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
254 254
255 RCHECK(bit_reader->ReadBits(1, &dummy)); // extensionFlag3 255 RCHECK(bit_reader->ReadBits(1, &dummy)); // extensionFlag3
256 } 256 }
257 257
258 return true; 258 return true;
259 } 259 }
260 260
261 } // namespace mp4 261 } // namespace mp4
262 262
263 } // namespace media 263 } // namespace media
OLDNEW
« no previous file with comments | « media/mp4/aac.h ('k') | media/mp4/mp4_stream_parser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698