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

Side by Side Diff: media/formats/mp4/avc.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 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/avc.h" 5 #include "media/formats/mp4/avc.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory>
8 #include <utility> 9 #include <utility>
9 10
10 #include "base/logging.h" 11 #include "base/logging.h"
11 #include "media/base/decrypt_config.h" 12 #include "media/base/decrypt_config.h"
12 #include "media/filters/h264_parser.h" 13 #include "media/filters/h264_parser.h"
13 #include "media/formats/mp4/box_definitions.h" 14 #include "media/formats/mp4/box_definitions.h"
14 #include "media/formats/mp4/box_reader.h" 15 #include "media/formats/mp4/box_reader.h"
15 16
16 namespace media { 17 namespace media {
17 namespace mp4 { 18 namespace mp4 {
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 } 100 }
100 return pos == temp.size(); 101 return pos == temp.size();
101 } 102 }
102 103
103 // static 104 // static
104 bool AVC::InsertParamSetsAnnexB(const AVCDecoderConfigurationRecord& avc_config, 105 bool AVC::InsertParamSetsAnnexB(const AVCDecoderConfigurationRecord& avc_config,
105 std::vector<uint8_t>* buffer, 106 std::vector<uint8_t>* buffer,
106 std::vector<SubsampleEntry>* subsamples) { 107 std::vector<SubsampleEntry>* subsamples) {
107 DCHECK(AVC::IsValidAnnexB(*buffer, *subsamples)); 108 DCHECK(AVC::IsValidAnnexB(*buffer, *subsamples));
108 109
109 scoped_ptr<H264Parser> parser(new H264Parser()); 110 std::unique_ptr<H264Parser> parser(new H264Parser());
110 const uint8_t* start = &(*buffer)[0]; 111 const uint8_t* start = &(*buffer)[0];
111 parser->SetEncryptedStream(start, buffer->size(), *subsamples); 112 parser->SetEncryptedStream(start, buffer->size(), *subsamples);
112 113
113 H264NALU nalu; 114 H264NALU nalu;
114 if (parser->AdvanceToNextNALU(&nalu) != H264Parser::kOk) 115 if (parser->AdvanceToNextNALU(&nalu) != H264Parser::kOk)
115 return false; 116 return false;
116 117
117 std::vector<uint8_t>::iterator config_insert_point = buffer->begin(); 118 std::vector<uint8_t>::iterator config_insert_point = buffer->begin();
118 119
119 if (nalu.nal_unit_type == H264NALU::kAUD) { 120 if (nalu.nal_unit_type == H264NALU::kAUD) {
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after
304 305
305 case H264Parser::kEOStream: 306 case H264Parser::kEOStream:
306 done = true; 307 done = true;
307 } 308 }
308 } 309 }
309 310
310 return order_state >= kAfterFirstVCL; 311 return order_state >= kAfterFirstVCL;
311 } 312 }
312 313
313 AVCBitstreamConverter::AVCBitstreamConverter( 314 AVCBitstreamConverter::AVCBitstreamConverter(
314 scoped_ptr<AVCDecoderConfigurationRecord> avc_config) 315 std::unique_ptr<AVCDecoderConfigurationRecord> avc_config)
315 : avc_config_(std::move(avc_config)) { 316 : avc_config_(std::move(avc_config)) {
316 DCHECK(avc_config_); 317 DCHECK(avc_config_);
317 } 318 }
318 319
319 AVCBitstreamConverter::~AVCBitstreamConverter() { 320 AVCBitstreamConverter::~AVCBitstreamConverter() {
320 } 321 }
321 322
322 bool AVCBitstreamConverter::ConvertFrame( 323 bool AVCBitstreamConverter::ConvertFrame(
323 std::vector<uint8_t>* frame_buf, 324 std::vector<uint8_t>* frame_buf,
324 bool is_keyframe, 325 bool is_keyframe,
325 std::vector<SubsampleEntry>* subsamples) const { 326 std::vector<SubsampleEntry>* subsamples) const {
326 // Convert the AVC NALU length fields to Annex B headers, as expected by 327 // Convert the AVC NALU length fields to Annex B headers, as expected by
(...skipping 10 matching lines...) Expand all
337 // count for that first subsample. 338 // count for that first subsample.
338 RCHECK(AVC::InsertParamSetsAnnexB(*avc_config_, frame_buf, subsamples)); 339 RCHECK(AVC::InsertParamSetsAnnexB(*avc_config_, frame_buf, subsamples));
339 } 340 }
340 341
341 DCHECK(AVC::IsValidAnnexB(*frame_buf, *subsamples)); 342 DCHECK(AVC::IsValidAnnexB(*frame_buf, *subsamples));
342 return true; 343 return true;
343 } 344 }
344 345
345 } // namespace mp4 346 } // namespace mp4
346 } // namespace media 347 } // namespace media
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698