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

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

Issue 1874413003: Convert media/formats to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 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/mp4/hevc.h" 5 #include "media/formats/mp4/hevc.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory>
8 #include <utility> 9 #include <utility>
9 #include <vector> 10 #include <vector>
10 11
11 #include "base/logging.h" 12 #include "base/logging.h"
12 #include "media/base/decrypt_config.h" 13 #include "media/base/decrypt_config.h"
13 #include "media/filters/h265_parser.h" 14 #include "media/filters/h265_parser.h"
14 #include "media/formats/mp4/avc.h" 15 #include "media/formats/mp4/avc.h"
15 #include "media/formats/mp4/box_definitions.h" 16 #include "media/formats/mp4/box_definitions.h"
16 #include "media/formats/mp4/box_reader.h" 17 #include "media/formats/mp4/box_reader.h"
17 18
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
125 126
126 static const uint8_t kAnnexBStartCode[] = {0, 0, 0, 1}; 127 static const uint8_t kAnnexBStartCode[] = {0, 0, 0, 1};
127 static const int kAnnexBStartCodeSize = 4; 128 static const int kAnnexBStartCodeSize = 4;
128 129
129 bool HEVC::InsertParamSetsAnnexB( 130 bool HEVC::InsertParamSetsAnnexB(
130 const HEVCDecoderConfigurationRecord& hevc_config, 131 const HEVCDecoderConfigurationRecord& hevc_config,
131 std::vector<uint8_t>* buffer, 132 std::vector<uint8_t>* buffer,
132 std::vector<SubsampleEntry>* subsamples) { 133 std::vector<SubsampleEntry>* subsamples) {
133 DCHECK(HEVC::IsValidAnnexB(*buffer, *subsamples)); 134 DCHECK(HEVC::IsValidAnnexB(*buffer, *subsamples));
134 135
135 scoped_ptr<H265Parser> parser(new H265Parser()); 136 std::unique_ptr<H265Parser> parser(new H265Parser());
136 const uint8_t* start = &(*buffer)[0]; 137 const uint8_t* start = &(*buffer)[0];
137 parser->SetEncryptedStream(start, buffer->size(), *subsamples); 138 parser->SetEncryptedStream(start, buffer->size(), *subsamples);
138 139
139 H265NALU nalu; 140 H265NALU nalu;
140 if (parser->AdvanceToNextNALU(&nalu) != H265Parser::kOk) 141 if (parser->AdvanceToNextNALU(&nalu) != H265Parser::kOk)
141 return false; 142 return false;
142 143
143 std::vector<uint8_t>::iterator config_insert_point = buffer->begin(); 144 std::vector<uint8_t>::iterator config_insert_point = buffer->begin();
144 145
145 if (nalu.nal_unit_type == H265NALU::AUD_NUT) { 146 if (nalu.nal_unit_type == H265NALU::AUD_NUT) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
205 DCHECK(buffer); 206 DCHECK(buffer);
206 207
207 if (size == 0) 208 if (size == 0)
208 return true; 209 return true;
209 210
210 // TODO(servolk): Implement this, see crbug.com/527595 211 // TODO(servolk): Implement this, see crbug.com/527595
211 return true; 212 return true;
212 } 213 }
213 214
214 HEVCBitstreamConverter::HEVCBitstreamConverter( 215 HEVCBitstreamConverter::HEVCBitstreamConverter(
215 scoped_ptr<HEVCDecoderConfigurationRecord> hevc_config) 216 std::unique_ptr<HEVCDecoderConfigurationRecord> hevc_config)
216 : hevc_config_(std::move(hevc_config)) { 217 : hevc_config_(std::move(hevc_config)) {
217 DCHECK(hevc_config_); 218 DCHECK(hevc_config_);
218 } 219 }
219 220
220 HEVCBitstreamConverter::~HEVCBitstreamConverter() { 221 HEVCBitstreamConverter::~HEVCBitstreamConverter() {
221 } 222 }
222 223
223 bool HEVCBitstreamConverter::ConvertFrame( 224 bool HEVCBitstreamConverter::ConvertFrame(
224 std::vector<uint8_t>* frame_buf, 225 std::vector<uint8_t>* frame_buf,
225 bool is_keyframe, 226 bool is_keyframe,
226 std::vector<SubsampleEntry>* subsamples) const { 227 std::vector<SubsampleEntry>* subsamples) const {
227 RCHECK(AVC::ConvertFrameToAnnexB(hevc_config_->lengthSizeMinusOne + 1, 228 RCHECK(AVC::ConvertFrameToAnnexB(hevc_config_->lengthSizeMinusOne + 1,
228 frame_buf, subsamples)); 229 frame_buf, subsamples));
229 230
230 if (is_keyframe) { 231 if (is_keyframe) {
231 // If this is a keyframe, we (re-)inject HEVC params headers at the start of 232 // If this is a keyframe, we (re-)inject HEVC params headers at the start of
232 // a frame. If subsample info is present, we also update the clear byte 233 // a frame. If subsample info is present, we also update the clear byte
233 // count for that first subsample. 234 // count for that first subsample.
234 RCHECK(HEVC::InsertParamSetsAnnexB(*hevc_config_, frame_buf, subsamples)); 235 RCHECK(HEVC::InsertParamSetsAnnexB(*hevc_config_, frame_buf, subsamples));
235 } 236 }
236 237
237 DCHECK(HEVC::IsValidAnnexB(*frame_buf, *subsamples)); 238 DCHECK(HEVC::IsValidAnnexB(*frame_buf, *subsamples));
238 return true; 239 return true;
239 } 240 }
240 241
241 } // namespace mp4 242 } // namespace mp4
242 } // namespace media 243 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698