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

Side by Side Diff: media/formats/webm/opus_packet_builder.cc

Issue 2893953002: Revert of Remove ScopedVector from all other codes in media/ (Closed)
Patch Set: Created 3 years, 7 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
OLDNEW
1 // Copyright (c) 2015 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2015 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 "base/logging.h"
5 #include "media/formats/webm/opus_packet_builder.h" 6 #include "media/formats/webm/opus_packet_builder.h"
6
7 #include "base/logging.h"
8 #include "base/memory/ptr_util.h"
9 #include "media/formats/webm/webm_cluster_parser.h" 7 #include "media/formats/webm/webm_cluster_parser.h"
10 8
11 namespace media { 9 namespace media {
12 10
13 OpusPacket::OpusPacket(uint8_t config, uint8_t frame_count, bool is_VBR) { 11 OpusPacket::OpusPacket(uint8_t config, uint8_t frame_count, bool is_VBR) {
14 DCHECK_GE(config, 0); 12 DCHECK_GE(config, 0);
15 DCHECK_LT(config, kNumPossibleOpusConfigs); 13 DCHECK_LT(config, kNumPossibleOpusConfigs);
16 DCHECK_GE(frame_count, kMinOpusPacketFrameCount); 14 DCHECK_GE(frame_count, kMinOpusPacketFrameCount);
17 DCHECK_LE(frame_count, kMaxOpusPacketFrameCount); 15 DCHECK_LE(frame_count, kMaxOpusPacketFrameCount);
18 16
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 } 55 }
58 56
59 int OpusPacket::size() const { 57 int OpusPacket::size() const {
60 return data_.size(); 58 return data_.size();
61 } 59 }
62 60
63 double OpusPacket::duration_ms() const { 61 double OpusPacket::duration_ms() const {
64 return duration_ms_; 62 return duration_ms_;
65 } 63 }
66 64
67 std::vector<std::unique_ptr<OpusPacket>> BuildAllOpusPackets() { 65 ScopedVector<OpusPacket> BuildAllOpusPackets() {
68 std::vector<std::unique_ptr<OpusPacket>> opus_packets; 66 ScopedVector<OpusPacket> opus_packets;
69 67
70 for (int frame_count = kMinOpusPacketFrameCount; 68 for (int frame_count = kMinOpusPacketFrameCount;
71 frame_count <= kMaxOpusPacketFrameCount; frame_count++) { 69 frame_count <= kMaxOpusPacketFrameCount; frame_count++) {
72 for (int opus_config_num = 0; opus_config_num < kNumPossibleOpusConfigs; 70 for (int opus_config_num = 0; opus_config_num < kNumPossibleOpusConfigs;
73 opus_config_num++) { 71 opus_config_num++) {
74 bool is_VBR = false; 72 bool is_VBR = false;
75 opus_packets.push_back( 73 opus_packets.push_back(
76 base::MakeUnique<OpusPacket>(opus_config_num, frame_count, is_VBR)); 74 new OpusPacket(opus_config_num, frame_count, is_VBR));
77 75
78 if (frame_count >= 2) { 76 if (frame_count >= 2) {
79 // Add another packet with VBR flag toggled. For frame counts >= 2, 77 // Add another packet with VBR flag toggled. For frame counts >= 2,
80 // VBR triggers changes to packet framing. 78 // VBR triggers changes to packet framing.
81 is_VBR = true; 79 is_VBR = true;
82 opus_packets.push_back( 80 opus_packets.push_back(
83 base::MakeUnique<OpusPacket>(opus_config_num, frame_count, is_VBR)); 81 new OpusPacket(opus_config_num, frame_count, is_VBR));
84 } 82 }
85 } 83 }
86 } 84 }
87 85
88 return opus_packets; 86 return opus_packets;
89 } 87 }
90 88
91 } // namespace media 89 } // namespace media
OLDNEW
« no previous file with comments | « media/formats/webm/opus_packet_builder.h ('k') | media/formats/webm/webm_cluster_parser_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698