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

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

Issue 2891683002: 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 "media/formats/webm/opus_packet_builder.h"
xhwang 2017/05/17 16:39:45 nit: add an empty line here
xiaofengzhang 2017/05/18 05:43:26 Done.
5 #include "base/logging.h" 6 #include "base/logging.h"
6 #include "media/formats/webm/opus_packet_builder.h" 7 #include "base/memory/ptr_util.h"
7 #include "media/formats/webm/webm_cluster_parser.h" 8 #include "media/formats/webm/webm_cluster_parser.h"
8 9
9 namespace media { 10 namespace media {
10 11
11 OpusPacket::OpusPacket(uint8_t config, uint8_t frame_count, bool is_VBR) { 12 OpusPacket::OpusPacket(uint8_t config, uint8_t frame_count, bool is_VBR) {
12 DCHECK_GE(config, 0); 13 DCHECK_GE(config, 0);
13 DCHECK_LT(config, kNumPossibleOpusConfigs); 14 DCHECK_LT(config, kNumPossibleOpusConfigs);
14 DCHECK_GE(frame_count, kMinOpusPacketFrameCount); 15 DCHECK_GE(frame_count, kMinOpusPacketFrameCount);
15 DCHECK_LE(frame_count, kMaxOpusPacketFrameCount); 16 DCHECK_LE(frame_count, kMaxOpusPacketFrameCount);
16 17
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 } 56 }
56 57
57 int OpusPacket::size() const { 58 int OpusPacket::size() const {
58 return data_.size(); 59 return data_.size();
59 } 60 }
60 61
61 double OpusPacket::duration_ms() const { 62 double OpusPacket::duration_ms() const {
62 return duration_ms_; 63 return duration_ms_;
63 } 64 }
64 65
65 ScopedVector<OpusPacket> BuildAllOpusPackets() { 66 std::vector<std::unique_ptr<OpusPacket>> BuildAllOpusPackets() {
66 ScopedVector<OpusPacket> opus_packets; 67 std::vector<std::unique_ptr<OpusPacket>> opus_packets;
67 68
68 for (int frame_count = kMinOpusPacketFrameCount; 69 for (int frame_count = kMinOpusPacketFrameCount;
69 frame_count <= kMaxOpusPacketFrameCount; frame_count++) { 70 frame_count <= kMaxOpusPacketFrameCount; frame_count++) {
70 for (int opus_config_num = 0; opus_config_num < kNumPossibleOpusConfigs; 71 for (int opus_config_num = 0; opus_config_num < kNumPossibleOpusConfigs;
71 opus_config_num++) { 72 opus_config_num++) {
72 bool is_VBR = false; 73 bool is_VBR = false;
73 opus_packets.push_back( 74 opus_packets.push_back(
74 new OpusPacket(opus_config_num, frame_count, is_VBR)); 75 base::MakeUnique<OpusPacket>(opus_config_num, frame_count, is_VBR));
75 76
76 if (frame_count >= 2) { 77 if (frame_count >= 2) {
77 // Add another packet with VBR flag toggled. For frame counts >= 2, 78 // Add another packet with VBR flag toggled. For frame counts >= 2,
78 // VBR triggers changes to packet framing. 79 // VBR triggers changes to packet framing.
79 is_VBR = true; 80 is_VBR = true;
80 opus_packets.push_back( 81 opus_packets.push_back(
81 new OpusPacket(opus_config_num, frame_count, is_VBR)); 82 base::MakeUnique<OpusPacket>(opus_config_num, frame_count, is_VBR));
82 } 83 }
83 } 84 }
84 } 85 }
85 86
86 return opus_packets; 87 return opus_packets;
87 } 88 }
88 89
89 } // namespace media 90 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698